// // Copyright 2014 Perforce Software Inc. // using Perforce.Helper; using Perforce.ViewModel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Technewlogic.WpfDialogManagement; namespace Perforce.View { /// /// Interaction logic for MenuBar.xaml /// public partial class MenuBar : UserControl { private MenuBarViewModel _model; public MenuBar() { InitializeComponent(); _model = new MenuBarViewModel(); this.DataContext = _model; } public MenuBarViewModel Model { get { return _model; } set { _model = value; } } public void Refresh() { Log.TraceFunction(); _model.Refresh(); } private void Menu_ChangeConnection(object sender, RoutedEventArgs e) { Log.TraceFunction(); var helper = Utility.GetPerforceHelper(); helper.Logout(); Utility.RestartApplication(); } private void Menu_GatherChanges(object sender, RoutedEventArgs e) { Log.TraceFunction(); try { var helper = Utility.GetPerforceHelper(); if (helper.ClientEnabled) { var main = App.Current.MainWindow as MainWindow; var dialog = main.DialogManager.CreateWaitDialog("Gathering files...", DialogMode.Ok); dialog.VerticalDialogAlignment = System.Windows.VerticalAlignment.Top; dialog.CanOk = false; dialog.Show(() => { var results = helper.GatherOpenFilesInCurrentChangelist(); dialog.CanOk = true; int num = (results != null) ? results.Count : 0; dialog.Message = string.Format("{0} files gathered in pending changelist", num); }); } } catch (Exception ex) { Log.Exception(ex); } } private void Menu_GoToPath(object sender, RoutedEventArgs e) { Log.TraceFunction(); var form = new GoToPathForm(); MainWindow main = App.Current.MainWindow as MainWindow; var pathDialog = main.DialogManager.CreateCustomContentDialog(form, null, DialogMode.OkCancel); form.ParentDialog = pathDialog; pathDialog.VerticalDialogAlignment = System.Windows.VerticalAlignment.Top; pathDialog.OkText = "Go"; pathDialog.CanOk = false; pathDialog.Ok = () => { OnPathChoice(form); }; pathDialog.Cancel = OnPathChoiceCancel; pathDialog.Show(); } private void OnPathChoice(GoToPathForm form) { UIHelper.GoToPath(form.GoToField.Text.Trim()); } private void OnPathChoiceCancel() { // cancelled path choice } private void Menu_SelectWorkspace(object sender, RoutedEventArgs e) { Log.TraceFunction(); MainWindow main = App.Current.MainWindow as MainWindow; main.ShowWorkspaceDialog(); } private void Menu_SetSyncInterval(object sender, RoutedEventArgs e) { Log.TraceFunction(); UIHelper.SetSyncInterval(); } private void Menu_ManualSync(object sender, RoutedEventArgs e) { Log.TraceFunction(); } private void Menu_ToggleSync(object sender, RoutedEventArgs e) { Log.TraceFunction(); _model.ToggleSync(); } private void Menu_Logout(object sender, RoutedEventArgs e) { Log.TraceFunction(); var helper = Utility.GetPerforceHelper(); if (helper != null) { helper.Logout(); App.Current.MainWindow.Close(); } } private void Menu_HelperApps(object sender, RoutedEventArgs e) { Log.TraceFunction(); var dialog = new HelperApplicationUtility(); dialog.ShowDialog(); } private void Menu_Exit(object sender, RoutedEventArgs e) { Log.TraceFunction(); Utility.ShutdownApplication(0); } private void Menu_OpenLog(object sender, RoutedEventArgs e) { Log.TraceFunction(); var _lw = Utility.GetLogWindow(); if (!_lw.IsOpen) { _lw.Show(); } else { _lw.Focus(); } _lw.BringIntoView(); } private void Menu_Contact(object sender, RoutedEventArgs e) { Log.TraceFunction(); System.Diagnostics.Process.Start("http://deheremap8058.emea.adsint.biz:8080/DesignHelp/"); } private void Menu_About(object sender, RoutedEventArgs e) { Log.TraceFunction(); MainWindow main = App.Current.MainWindow as MainWindow; var about = new Perforce.View.About(); var dialog = main.DialogManager.CreateCustomContentDialog(about, "About DESI", DialogMode.Ok); dialog.VerticalDialogAlignment = System.Windows.VerticalAlignment.Top; dialog.Show(); } } }