private void MainWindow_FormClosing(object Sender, FormClosingEventArgs EventArgs) { if (!bAllowClose && Settings.bKeepInTray) { Hide(); EventArgs.Cancel = true; } else { for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { IMainWindowTabPanel TabPanel = (IMainWindowTabPanel)TabControl.GetTabData(Idx); if (!TabPanel.CanClose()) { EventArgs.Cancel = true; return; } } StopScheduleTimer(); } Settings.bWindowVisible = Visible; Settings.WindowState = WindowState; if (WindowState == FormWindowState.Normal) { Settings.WindowBounds = new Rectangle(Location, Size); } else { Settings.WindowBounds = RestoreBounds; } Settings.Save(); }
private void MainWindow_FormClosing(object Sender, FormClosingEventArgs EventArgs) { if (!bAllowClose && Settings.bKeepInTray) { Hide(); EventArgs.Cancel = true; } else { for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { IMainWindowTabPanel TabPanel = (IMainWindowTabPanel)TabControl.GetTabData(Idx); if (!TabPanel.CanClose()) { EventArgs.Cancel = true; return; } } StopScheduleTimer(); Settings.bWindowVisible = Visible; Settings.Save(); } }
private void MainWindow_FormClosing(object Sender, FormClosingEventArgs EventArgs) { if (!bAllowClose && Settings.bKeepInTray) { Hide(); EventArgs.Cancel = true; } else { for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { WorkspaceControl Workspace = (WorkspaceControl)TabControl.GetTabData(Idx); if (!Workspace.CanClose()) { EventArgs.Cancel = true; return; } } ActivationListener.OnActivate -= OnActivationListenerAsyncCallback; ActivationListener.Stop(); UpdateMonitor.OnUpdateAvailable -= OnUpdateAvailable; UpdateMonitor.Close(); // prevent race condition StopScheduleTimer(); Rectangle SaveBounds = (WindowState == FormWindowState.Normal)? Bounds : RestoreBounds; Settings.WindowRectangle = SaveBounds; Settings.bWindowVisible = Visible; Settings.Save(); } }
private void LocalFileBrowseBtn_Click(object sender, EventArgs e) { LocalFileRadioBtn.Checked = true; OpenFileDialog Dialog = new OpenFileDialog(); Dialog.Filter = "Project files (*.uproject)|*.uproject|Project directory lists (*.uprojectdirs)|*.uprojectdirs|All supported files (*.uproject;*.uprojectdirs)|*.uproject;*.uprojectdirs|All files (*.*)|*.*"; Dialog.FilterIndex = Settings.FilterIndex; if (!String.IsNullOrEmpty(LocalFileTextBox.Text)) { try { Dialog.InitialDirectory = Path.GetDirectoryName(LocalFileTextBox.Text); } catch { } } if (Dialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string FullName = Path.GetFullPath(Dialog.FileName); Settings.FilterIndex = Dialog.FilterIndex; Settings.Save(); LocalFileTextBox.Text = FullName; UpdateOkButton(); } }
private void OkButton_Click(object sender, EventArgs e) { int NewNumRetries = 0; if (NumRetriesTextBox.Text.Length > 0 && !int.TryParse(NumRetriesTextBox.Text, out NewNumRetries)) { MessageBox.Show("Invalid value for number of retries"); return; } int NewTcpBufferSize = 0; if (TcpBufferSizeText.Text.Length > 0 && !int.TryParse(TcpBufferSizeText.Text, out NewTcpBufferSize)) { MessageBox.Show("Invalid value for TCP buffer size"); return; } Settings.SyncOptions.NumRetries = NewNumRetries; Settings.SyncOptions.TcpBufferSize = NewTcpBufferSize; Settings.Save(); DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
private void OkBtn_Click(object sender, EventArgs e) { int NewNotifyUnresolvedMinutes = -1; if (NotifyUnresolvedCheckBox.Checked) { ushort NewNotifyUnresolvedMinutesValue; if (!ushort.TryParse(NotifyUnresolvedTextBox.Text, out NewNotifyUnresolvedMinutesValue)) { MessageBox.Show("Invalid time"); return; } NewNotifyUnresolvedMinutes = NewNotifyUnresolvedMinutesValue; } int NewNotifyUnassignedMinutes = -1; if (NotifyUnassignedCheckBox.Checked) { ushort NewNotifyUnassignedMinutesValue; if (!ushort.TryParse(NotifyUnassignedTextBox.Text, out NewNotifyUnassignedMinutesValue)) { MessageBox.Show("Invalid time"); return; } NewNotifyUnassignedMinutes = NewNotifyUnassignedMinutesValue; } Settings.NotifyUnresolvedMinutes = NewNotifyUnresolvedMinutes; Settings.NotifyUnassignedMinutes = NewNotifyUnassignedMinutes; Settings.Save(); DialogResult = DialogResult.Cancel; Close(); }
private void OkBtn_Click(object sender, EventArgs e) { List <string> NewNotifyProjects = new List <string>(); if (NotifyProjectsCheckBox.Checked) { NewNotifyProjects.AddRange(NotifyProjectsTextBox.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); } int NewNotifyUnresolvedMinutes = -1; if (NotifyUnresolvedCheckBox.Checked) { ushort NewNotifyUnresolvedMinutesValue; if (!ushort.TryParse(NotifyUnresolvedTextBox.Text, out NewNotifyUnresolvedMinutesValue)) { MessageBox.Show("Invalid time"); return; } NewNotifyUnresolvedMinutes = NewNotifyUnresolvedMinutesValue; } int NewNotifyUnacknowledgedMinutes = -1; if (NotifyUnacknowledgedCheckBox.Checked) { ushort NewNotifyUnacknowledgedMinutesValue; if (!ushort.TryParse(NotifyUnacknowledgedTextBox.Text, out NewNotifyUnacknowledgedMinutesValue)) { MessageBox.Show("Invalid time"); return; } NewNotifyUnacknowledgedMinutes = NewNotifyUnacknowledgedMinutesValue; } int NewNotifyUnassignedMinutes = -1; if (NotifyUnassignedCheckBox.Checked) { ushort NewNotifyUnassignedMinutesValue; if (!ushort.TryParse(NotifyUnassignedTextBox.Text, out NewNotifyUnassignedMinutesValue)) { MessageBox.Show("Invalid time"); return; } NewNotifyUnassignedMinutes = NewNotifyUnassignedMinutesValue; } Settings.NotifyProjects = NewNotifyProjects; Settings.NotifyUnresolvedMinutes = NewNotifyUnresolvedMinutes; Settings.NotifyUnacknowledgedMinutes = NewNotifyUnacknowledgedMinutes; Settings.NotifyUnassignedMinutes = NewNotifyUnassignedMinutes; Settings.Save(); DialogResult = DialogResult.OK; Close(); }
public ProgramApplicationContext(PerforceConnection DefaultConnection, UpdateMonitor UpdateMonitor, string ApiUrl, string DataFolder, EventWaitHandle ActivateEvent, bool bRestoreState, string UpdateSpawn, string ProjectFileName, bool bUnstable, TimestampLogWriter Log) { this.DefaultConnection = DefaultConnection; this.UpdateMonitor = UpdateMonitor; this.ApiUrl = ApiUrl; this.DataFolder = DataFolder; this.CacheFolder = Path.Combine(DataFolder, "Cache"); this.bRestoreState = bRestoreState; this.UpdateSpawn = UpdateSpawn; this.bUnstable = bUnstable; this.Log = Log; // Create the directories Directory.CreateDirectory(DataFolder); Directory.CreateDirectory(CacheFolder); // Make sure a synchronization context is set. We spawn a bunch of threads (eg. UpdateMonitor) at startup, and need to make sure we can post messages // back to the main thread at any time. if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext()); } // Capture the main thread's synchronization context for callbacks MainThreadSynchronizationContext = WindowsFormsSynchronizationContext.Current; // Read the user's settings Settings = new UserSettings(Path.Combine(DataFolder, "UnrealGameSync.ini")); if (!String.IsNullOrEmpty(ProjectFileName)) { string FullProjectFileName = Path.GetFullPath(ProjectFileName); if (!Settings.OpenProjects.Any(x => x.LocalPath != null && String.Compare(x.LocalPath, FullProjectFileName, StringComparison.InvariantCultureIgnoreCase) == 0)) { Settings.OpenProjects.Add(new UserSelectedProjectSettings(null, null, UserSelectedProjectType.Local, null, FullProjectFileName)); } } // Update the settings to the latest version if (Settings.Version < UserSettingsVersion.Latest) { // Clear out the server settings for anything using the default server if (Settings.Version < UserSettingsVersion.DefaultServerSettings) { for (int Idx = 0; Idx < Settings.OpenProjects.Count; Idx++) { Settings.OpenProjects[Idx] = UpgradeSelectedProjectSettings(Settings.OpenProjects[Idx]); } for (int Idx = 0; Idx < Settings.RecentProjects.Count; Idx++) { Settings.RecentProjects[Idx] = UpgradeSelectedProjectSettings(Settings.RecentProjects[Idx]); } } // Save the new settings Settings.Version = UserSettingsVersion.Latest; Settings.Save(); } // Register the update listener UpdateMonitor.OnUpdateAvailable += OnUpdateAvailableCallback; // Create the activation listener ActivationListener = new ActivationListener(ActivateEvent); ActivationListener.Start(); ActivationListener.OnActivate += OnActivationListenerAsyncCallback; // Create the notification menu items NotifyMenu_OpenUnrealGameSync = new ToolStripMenuItem(); NotifyMenu_OpenUnrealGameSync.Name = nameof(NotifyMenu_OpenUnrealGameSync); NotifyMenu_OpenUnrealGameSync.Size = new Size(196, 22); NotifyMenu_OpenUnrealGameSync.Text = "Open UnrealGameSync"; NotifyMenu_OpenUnrealGameSync.Click += new EventHandler(NotifyMenu_OpenUnrealGameSync_Click); NotifyMenu_OpenUnrealGameSync.Font = new Font(NotifyMenu_OpenUnrealGameSync.Font, FontStyle.Bold); NotifyMenu_OpenUnrealGameSync_Separator = new ToolStripSeparator(); NotifyMenu_OpenUnrealGameSync_Separator.Name = nameof(NotifyMenu_OpenUnrealGameSync_Separator); NotifyMenu_OpenUnrealGameSync_Separator.Size = new Size(193, 6); NotifyMenu_SyncNow = new ToolStripMenuItem(); NotifyMenu_SyncNow.Name = nameof(NotifyMenu_SyncNow); NotifyMenu_SyncNow.Size = new Size(196, 22); NotifyMenu_SyncNow.Text = "Sync Now"; NotifyMenu_SyncNow.Click += new EventHandler(NotifyMenu_SyncNow_Click); NotifyMenu_LaunchEditor = new ToolStripMenuItem(); NotifyMenu_LaunchEditor.Name = nameof(NotifyMenu_LaunchEditor); NotifyMenu_LaunchEditor.Size = new Size(196, 22); NotifyMenu_LaunchEditor.Text = "Launch Editor"; NotifyMenu_LaunchEditor.Click += new EventHandler(NotifyMenu_LaunchEditor_Click); NotifyMenu_ExitSeparator = new ToolStripSeparator(); NotifyMenu_ExitSeparator.Name = nameof(NotifyMenu_ExitSeparator); NotifyMenu_ExitSeparator.Size = new Size(193, 6); NotifyMenu_Exit = new ToolStripMenuItem(); NotifyMenu_Exit.Name = nameof(NotifyMenu_Exit); NotifyMenu_Exit.Size = new Size(196, 22); NotifyMenu_Exit.Text = "Exit"; NotifyMenu_Exit.Click += new EventHandler(NotifyMenu_Exit_Click); // Create the notification menu NotifyMenu = new ContextMenuStrip(Components); NotifyMenu.Name = nameof(NotifyMenu); NotifyMenu.Size = new System.Drawing.Size(197, 104); NotifyMenu.SuspendLayout(); NotifyMenu.Items.Add(NotifyMenu_OpenUnrealGameSync); NotifyMenu.Items.Add(NotifyMenu_OpenUnrealGameSync_Separator); NotifyMenu.Items.Add(NotifyMenu_SyncNow); NotifyMenu.Items.Add(NotifyMenu_LaunchEditor); NotifyMenu.Items.Add(NotifyMenu_ExitSeparator); NotifyMenu.Items.Add(NotifyMenu_Exit); NotifyMenu.ResumeLayout(false); // Create the notification icon NotifyIcon = new NotifyIcon(Components); NotifyIcon.ContextMenuStrip = NotifyMenu; NotifyIcon.Icon = Properties.Resources.Icon; NotifyIcon.Text = "UnrealGameSync"; NotifyIcon.Visible = true; NotifyIcon.DoubleClick += new EventHandler(NotifyIcon_DoubleClick); NotifyIcon.MouseDown += new MouseEventHandler(NotifyIcon_MouseDown); // Find the initial list of projects to attempt to reopen List <DetectProjectSettingsTask> Tasks = new List <DetectProjectSettingsTask>(); foreach (UserSelectedProjectSettings OpenProject in Settings.OpenProjects) { BufferedTextWriter StartupLog = new BufferedTextWriter(); StartupLog.WriteLine("Detecting settings for {0}", OpenProject); StartupLogs.Add(StartupLog); Tasks.Add(new DetectProjectSettingsTask(OpenProject, DataFolder, CacheFolder, new TimestampLogWriter(new PrefixedTextWriter(" ", StartupLog)))); } // Detect settings for the project we want to open DetectStartupProjectSettingsTask = new DetectMultipleProjectSettingsTask(DefaultConnection, Tasks); DetectStartupProjectSettingsWindow = new ModalTaskWindow(DetectStartupProjectSettingsTask, "Opening Projects", "Opening projects, please wait...", FormStartPosition.CenterScreen); if (bRestoreState) { if (Settings.bWindowVisible) { DetectStartupProjectSettingsWindow.Show(); } } else { DetectStartupProjectSettingsWindow.Show(); DetectStartupProjectSettingsWindow.Activate(); } DetectStartupProjectSettingsWindow.Complete += OnDetectStartupProjectsComplete; }
private void OkBtn_Click(object sender, EventArgs e) { // Update the settings string ServerAndPort = ServerTextBox.Text.Trim(); if (ServerAndPort.Length == 0) { ServerAndPort = null; } string UserName = UserNameTextBox.Text.Trim(); if (UserName.Length == 0) { UserName = null; } string DepotPath = DepotPathTextBox.Text.Trim(); if (DepotPath.Length == 0 || DepotPath == DeploymentSettings.DefaultDepotPath) { DepotPath = null; } bool bUnstable = UseUnstableBuildCheckBox.Checked; if (ServerAndPort != InitialServerAndPort || UserName != InitialUserName || DepotPath != InitialDepotPath || bUnstable != bInitialUnstable) { // Try to log in to the new server, and check the application is there if (ServerAndPort != InitialServerAndPort || UserName != InitialUserName || DepotPath != InitialDepotPath) { string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(this, null, ServerAndPort, UserName, new PerforceTestConnectionTask(DepotPath), "Connecting", "Checking connection, please wait...", Log, out ErrorMessage); if (Result != ModalTaskResult.Succeeded) { if (Result == ModalTaskResult.Failed) { MessageBox.Show(ErrorMessage, "Unable to connect"); } return; } } if (MessageBox.Show("UnrealGameSync must be restarted to apply these settings.\n\nWould you like to restart now?", "Restart Required", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } bRestartUnstable = UseUnstableBuildCheckBox.Checked; Utility.SaveGlobalPerforceSettings(ServerAndPort, UserName, DepotPath); } RegistryKey Key = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); if (IsAutomaticallyRunAtStartup()) { Key.DeleteValue("UnrealGameSync", false); } else { Key.SetValue("UnrealGameSync", String.Format("\"{0}\" -RestoreState", OriginalExecutableFileName)); } if (Settings.bKeepInTray != KeepInTrayCheckBox.Checked) { Settings.bKeepInTray = KeepInTrayCheckBox.Checked; Settings.Save(); } DialogResult = DialogResult.OK; Close(); }