private void NotifyIcon_MouseDown(object sender, MouseEventArgs e) { // Have to set up this stuff here, because the menu is laid out before Opening() is called on it after mouse-up. if (CurrentWorkspace != null) { bool bCanSyncNow = CurrentWorkspace.CanSyncNow(); bool bCanLaunchEditor = CurrentWorkspace.CanLaunchEditor(); NotifyMenu_SyncNow.Visible = CurrentWorkspace.CanSyncNow(); NotifyMenu_LaunchEditor.Visible = CurrentWorkspace.CanLaunchEditor(); NotifyMenu_ExitSeparator.Visible = bCanSyncNow || bCanLaunchEditor; } }
AutomationRequestOutput StartAutomatedSync(AutomationRequest Request, bool bForceSync) { ShowAndActivate(); BinaryReader Reader = new BinaryReader(new MemoryStream(Request.Input.Data)); string StreamName = Reader.ReadString(); string ProjectPath = Reader.ReadString(); AutomatedSyncWindow.WorkspaceInfo WorkspaceInfo; if (!AutomatedSyncWindow.ShowModal(this, StreamName, ProjectPath, out WorkspaceInfo, Log)) { return(new AutomationRequestOutput(AutomationRequestResult.Canceled)); } if (WorkspaceInfo.bRequiresStreamSwitch) { // Close any tab containing this window for (int ExistingTabIdx = 0; ExistingTabIdx < TabControl.GetTabCount(); ExistingTabIdx++) { WorkspaceControl ExistingWorkspace = TabControl.GetTabData(ExistingTabIdx) as WorkspaceControl; if (ExistingWorkspace != null && ExistingWorkspace.ClientName.Equals(WorkspaceInfo.WorkspaceName)) { TabControl.RemoveTab(ExistingTabIdx); break; } } // Switch the stream PerforceConnection Perforce = new PerforceConnection(WorkspaceInfo.UserName, WorkspaceInfo.WorkspaceName, WorkspaceInfo.ServerAndPort); if (!Perforce.SwitchStream(StreamName, Log)) { Log.WriteLine("Unable to switch stream"); return(new AutomationRequestOutput(AutomationRequestResult.Error)); } } UserSelectedProjectSettings SelectedProject = new UserSelectedProjectSettings(WorkspaceInfo.ServerAndPort, WorkspaceInfo.UserName, UserSelectedProjectType.Client, String.Format("//{0}{1}", WorkspaceInfo.WorkspaceName, ProjectPath), null); int TabIdx = TryOpenProject(SelectedProject, -1, OpenProjectOptions.None); if (TabIdx == -1) { Log.WriteLine("Unable to open project"); return(new AutomationRequestOutput(AutomationRequestResult.Error)); } WorkspaceControl Workspace = TabControl.GetTabData(TabIdx) as WorkspaceControl; if (Workspace == null) { Log.WriteLine("Workspace was unable to open"); return(new AutomationRequestOutput(AutomationRequestResult.Error)); } if (!bForceSync && Workspace.CanLaunchEditor()) { return(new AutomationRequestOutput(AutomationRequestResult.Ok, Encoding.UTF8.GetBytes(Workspace.SelectedFileName))); } Workspace.AddStartupCallback((Control, bCancel) => StartAutomatedSyncAfterStartup(Control, bCancel, Request)); return(null); }