コード例 #1
0
ファイル: MainWindow.cs プロジェクト: nikimar1/cloneofg4g2019
        int TryOpenProject(UserSelectedProjectSettings Project, int ReplaceTabIdx, OpenProjectOptions Options = OpenProjectOptions.None)
        {
            Log.WriteLine("Detecting settings for {0}", Project);
            using (DetectProjectSettingsTask DetectProjectSettings = new DetectProjectSettingsTask(Project, DataFolder, CacheFolder, new PrefixedTextWriter("  ", Log)))
            {
                string ErrorMessage;

                ModalTaskResult Result;
                if ((Options & OpenProjectOptions.Quiet) != 0)
                {
                    Result = ModalTask.Execute(this, DetectProjectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage);
                }
                else
                {
                    Result = PerforceModalTask.Execute(this, Project.LocalPath, Project.ServerAndPort, Project.UserName, DetectProjectSettings, "Opening Project", "Opening project, please wait...", Log, out ErrorMessage);
                }

                if (Result != ModalTaskResult.Succeeded)
                {
                    CreateErrorPanel(ReplaceTabIdx, Project, ErrorMessage);
                    return(-1);
                }
                return(TryOpenProject(DetectProjectSettings, ReplaceTabIdx, Options));
            }
        }
コード例 #2
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            UserSelectedProjectSettings SelectedProject;

            if (TryGetSelectedProject(out SelectedProject))
            {
                DetectProjectSettingsTask NewDetectedProjectSettings = new DetectProjectSettingsTask(SelectedProject, DataFolder, CacheFolder, Log);
                try
                {
                    string ErrorMessage;
                    if (PerforceModalTask.Execute(this, Perforce, NewDetectedProjectSettings, "Opening Project", "Opening project, please wait...", Log, out ErrorMessage) != ModalTaskResult.Succeeded)
                    {
                        if (!String.IsNullOrEmpty(ErrorMessage))
                        {
                            MessageBox.Show(ErrorMessage);
                        }
                        return;
                    }

                    DetectedProjectSettings    = NewDetectedProjectSettings;
                    NewDetectedProjectSettings = null;
                    DialogResult = DialogResult.OK;
                    Close();
                }
                finally
                {
                    if (NewDetectedProjectSettings != null)
                    {
                        NewDetectedProjectSettings.Dispose();
                        NewDetectedProjectSettings = null;
                    }
                }
            }
        }
コード例 #3
0
 public void Dispose()
 {
     if (Task != null)
     {
         Task.Dispose();
         Task = null;
     }
 }
コード例 #4
0
        private OpenProjectWindow(UserSelectedProjectSettings Project, UserSettings Settings, string DataFolder, string CacheFolder, PerforceConnection DefaultConnection, TextWriter Log)
        {
            InitializeComponent();

            this.Settings = Settings;
            this.DetectedProjectSettings = null;
            this.DataFolder        = DataFolder;
            this.CacheFolder       = CacheFolder;
            this.DefaultConnection = DefaultConnection;
            this.Log = Log;

            if (Project == null)
            {
                LocalFileRadioBtn.Checked = true;
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(Project.ServerAndPort))
                {
                    ServerAndPortOverride = Project.ServerAndPort;
                }
                if (!String.IsNullOrWhiteSpace(Project.UserName))
                {
                    UserNameOverride = Project.UserName;
                }

                if (Project.ClientPath != null && Project.ClientPath.StartsWith("//"))
                {
                    int SlashIdx = Project.ClientPath.IndexOf('/', 2);
                    if (SlashIdx != -1)
                    {
                        WorkspaceNameTextBox.Text = Project.ClientPath.Substring(2, SlashIdx - 2);
                        WorkspacePathTextBox.Text = Project.ClientPath.Substring(SlashIdx);
                    }
                }

                if (Project.LocalPath != null)
                {
                    LocalFileTextBox.Text = Project.LocalPath;
                }

                if (Project.Type == UserSelectedProjectType.Client)
                {
                    WorkspaceRadioBtn.Checked = true;
                }
                else
                {
                    LocalFileRadioBtn.Checked = true;
                }
            }

            UpdateEnabledControls();
            UpdateServerLabel();
            UpdateWorkspacePathBrowseButton();
            UpdateOkButton();
        }
コード例 #5
0
        void RunTask(int Idx)
        {
            DetectProjectSettingsTask Task = Tasks[Idx];

            UserSelectedProjectSettings Project  = Task.SelectedProject;
            PerforceConnection          Perforce = Utility.OverridePerforceSettings(DefaultConnection, Project.ServerAndPort, Project.UserName);

            string TaskErrorMessage;
            bool   bTaskSucceeded = Tasks[Idx].Run(Perforce, out TaskErrorMessage);

            Results[Idx] = new DetectProjectSettingsResult(Tasks[Idx], bTaskSucceeded, TaskErrorMessage);
            Tasks[Idx]   = null;
        }
コード例 #6
0
 int TryOpenProject(UserSelectedProjectSettings Project, int ReplaceTabIdx, OpenProjectOptions Options = OpenProjectOptions.None)
 {
     using (DetectProjectSettingsTask DetectProjectSettings = new DetectProjectSettingsTask(Project, DataFolder, Log))
     {
         string ErrorMessage;
         if (ModalTask.Execute(this, DetectProjectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage) != ModalTaskResult.Succeeded)
         {
             if (!String.IsNullOrEmpty(ErrorMessage) && (Options & OpenProjectOptions.Quiet) == 0)
             {
                 CreateErrorPanel(ReplaceTabIdx, Project, ErrorMessage);
             }
             return(-1);
         }
         return(TryOpenProject(DetectProjectSettings, ReplaceTabIdx, Options));
     }
 }
コード例 #7
0
 public QuietDetectProjectSettingsTask(PerforceConnection Perforce, DetectProjectSettingsTask Inner, TextWriter Log)
 {
     this.Perforce = Perforce;
     this.Inner    = Inner;
     this.Log      = Log;
 }
コード例 #8
0
 public DetectProjectSettingsResult(DetectProjectSettingsTask Task, bool bSucceeded, string ErrorMessage)
 {
     this.Task         = Task;
     this.bSucceeded   = bSucceeded;
     this.ErrorMessage = ErrorMessage;
 }
コード例 #9
0
ファイル: MainWindow.cs プロジェクト: nicklinesla/4.21-arcore
        int TryOpenProject(string ProjectFileName, int ReplaceTabIdx = -1)
        {
            Log.WriteLine("Trying to open project {0}", ProjectFileName);

            // Normalize the filename
            ProjectFileName = Path.GetFullPath(ProjectFileName).Replace('/', Path.DirectorySeparatorChar);

            // Make sure the project exists
            if (!File.Exists(ProjectFileName))
            {
                ShowErrorDialog("{0} does not exist.", ProjectFileName);
                return(-1);
            }

            // Check that none of the other tabs already have it open
            for (int TabIdx = 0; TabIdx < TabControl.GetTabCount(); TabIdx++)
            {
                if (ReplaceTabIdx != TabIdx)
                {
                    WorkspaceControl Workspace = (WorkspaceControl)TabControl.GetTabData(TabIdx);
                    if (Workspace.SelectedFileName.Equals(ProjectFileName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        TabControl.SelectTab(TabIdx);
                        return(TabIdx);
                    }
                    else if (ProjectFileName.StartsWith(Workspace.BranchDirectoryName + Path.DirectorySeparatorChar, StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (MessageBox.Show(String.Format("{0} is already open under {1}.\n\nWould you like to close it?", Path.GetFileNameWithoutExtension(Workspace.SelectedFileName), Workspace.BranchDirectoryName, Path.GetFileNameWithoutExtension(ProjectFileName)), "Branch already open", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                        {
                            TabControl.RemoveTab(TabIdx);
                        }
                        else
                        {
                            return(-1);
                        }
                    }
                }
            }

            // Make sure the path case is correct. This can cause UBT intermediates to be out of date if the case mismatches.
            ProjectFileName = Utility.GetPathWithCorrectCase(new FileInfo(ProjectFileName));

            // Detect the project settings in a background thread
            using (DetectProjectSettingsTask DetectSettings = new DetectProjectSettingsTask(ProjectFileName, Log))
            {
                string ErrorMessage;
                if (!ModalTaskWindow.Execute(this, DetectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage))
                {
                    if (!String.IsNullOrEmpty(ErrorMessage))
                    {
                        ShowErrorDialog("{0}", ErrorMessage);
                    }
                    return(-1);
                }

                // Hide the default control if it's visible
                DefaultControl.Hide();

                // Now that we have the project settings, we can construct the tab
                WorkspaceControl Workspace = new WorkspaceControl(this, SqlConnectionString, DataFolder, bRestoreStateOnLoad, OriginalExecutableFileName, ProjectFileName, bUnstable, DetectSettings, Log, Settings);
                Workspace.Parent   = TabPanel;
                Workspace.Location = new Point(0, 0);
                Workspace.Size     = new Size(TabPanel.Width, TabPanel.Height);
                Workspace.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
                Workspace.Hide();

                // Add the tab
                string NewTabName = GetTabName(Workspace);
                if (ReplaceTabIdx == -1)
                {
                    int NewTabIdx = TabControl.InsertTab(-1, NewTabName, Workspace);
                    return(NewTabIdx);
                }
                else
                {
                    TabControl.InsertTab(ReplaceTabIdx + 1, NewTabName, Workspace);
                    TabControl.RemoveTab(ReplaceTabIdx);
                    return(ReplaceTabIdx);
                }
            }
        }
コード例 #10
0
ファイル: MainWindow.cs プロジェクト: nikimar1/cloneofg4g2019
        int TryOpenProject(DetectProjectSettingsTask ProjectSettings, int ReplaceTabIdx, OpenProjectOptions Options)
        {
            Log.WriteLine("Trying to open project {0}", ProjectSettings.SelectedProject.ToString());

            // Check that none of the other tabs already have it open
            for (int TabIdx = 0; TabIdx < TabControl.GetTabCount(); TabIdx++)
            {
                if (ReplaceTabIdx != TabIdx)
                {
                    WorkspaceControl Workspace = TabControl.GetTabData(TabIdx) as WorkspaceControl;
                    if (Workspace != null)
                    {
                        if (Workspace.SelectedFileName.Equals(ProjectSettings.NewSelectedFileName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Log.WriteLine("  Already open in tab {0}", TabIdx);
                            if ((Options & OpenProjectOptions.Quiet) == 0)
                            {
                                TabControl.SelectTab(TabIdx);
                            }
                            return(TabIdx);
                        }
                        else if (ProjectSettings.NewSelectedFileName.StartsWith(Workspace.BranchDirectoryName + Path.DirectorySeparatorChar, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if ((Options & OpenProjectOptions.Quiet) == 0 && MessageBox.Show(String.Format("{0} is already open under {1}.\n\nWould you like to close it?", Path.GetFileNameWithoutExtension(Workspace.SelectedFileName), Workspace.BranchDirectoryName, Path.GetFileNameWithoutExtension(ProjectSettings.NewSelectedFileName)), "Branch already open", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                            {
                                Log.WriteLine("  Another project already open in this workspace, tab {0}. Replacing.", TabIdx);
                                TabControl.RemoveTab(TabIdx);
                            }
                            else
                            {
                                Log.WriteLine("  Another project already open in this workspace, tab {0}. Aborting.", TabIdx);
                                return(-1);
                            }
                        }
                    }
                }
            }

            // Hide the default control if it's visible
            DefaultControl.Hide();

            // Remove the current tab. We need to ensure the workspace has been shut down before creating a new one with the same log files, etc...
            if (ReplaceTabIdx != -1)
            {
                WorkspaceControl OldWorkspace = TabControl.GetTabData(ReplaceTabIdx) as WorkspaceControl;
                if (OldWorkspace != null)
                {
                    OldWorkspace.Hide();
                    TabControl.SetTabData(ReplaceTabIdx, new ErrorPanel(ProjectSettings.SelectedProject));
                    OldWorkspace.Dispose();
                }
            }

            // Now that we have the project settings, we can construct the tab
            WorkspaceControl NewWorkspace = new WorkspaceControl(this, ApiUrl, OriginalExecutableFileName, bUnstable, ProjectSettings, Log, Settings);

            NewWorkspace.Parent = TabPanel;
            NewWorkspace.Dock   = DockStyle.Fill;
            NewWorkspace.Hide();

            // Add the tab
            string NewTabName = GetTabName(NewWorkspace);

            if (ReplaceTabIdx == -1)
            {
                int NewTabIdx = TabControl.InsertTab(-1, NewTabName, NewWorkspace);
                Log.WriteLine("  Inserted tab {0}", NewTabIdx);
                return(NewTabIdx);
            }
            else
            {
                Log.WriteLine("  Replacing tab {0}", ReplaceTabIdx);
                TabControl.InsertTab(ReplaceTabIdx + 1, NewTabName, NewWorkspace);
                TabControl.RemoveTab(ReplaceTabIdx);
                return(ReplaceTabIdx);
            }
        }
コード例 #11
0
        public static bool ShowModal(IWin32Window Owner, UserSelectedProjectSettings Project, out DetectProjectSettingsTask NewDetectedProjectSettings, UserSettings Settings, string DataFolder, string CacheFolder, PerforceConnection DefaultConnection, TextWriter Log)
        {
            OpenProjectWindow Window = new OpenProjectWindow(Project, Settings, DataFolder, CacheFolder, DefaultConnection, Log);

            if (Window.ShowDialog(Owner) == DialogResult.OK)
            {
                NewDetectedProjectSettings = Window.DetectedProjectSettings;
                return(true);
            }
            else
            {
                NewDetectedProjectSettings = null;
                return(false);
            }
        }
コード例 #12
0
		private bool OpenProject(string NewSelectedFileName)
		{
			if(String.IsNullOrWhiteSpace(NewSelectedFileName))
			{
				Log.WriteLine("Trying to open empty project path - closing instead");
				return TryCloseProject();
			}

			Log.WriteLine("Trying to open project {0}", NewSelectedFileName);
			if(!File.Exists(NewSelectedFileName))
			{
				ShowErrorDialog("{0} does not exist.", NewSelectedFileName);
				return false;
			}

			// Detect the project settings in a background thread
			using(DetectProjectSettingsTask DetectSettings = new DetectProjectSettingsTask(NewSelectedFileName, Log))
			{
				string ErrorMessage;
				if(!ModalTaskWindow.Execute(DetectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage))
				{
					if(!String.IsNullOrEmpty(ErrorMessage))
					{
						ShowErrorDialog("{0}", ErrorMessage);
					}
					return false;
				}

				// Now that we've done everything that can fail, perform the final switch over
				if(!TryCloseProject())
				{
					return false;
				}

				// Set the project logo on the status panel and notification window
				NotificationWindow = new NotificationWindow(Properties.Resources.DefaultNotificationLogo);
				StatusPanel.SetProjectLogo(DetectSettings.ProjectLogo);
				DetectSettings.ProjectLogo = null;

				// Update the user settings for the new project
				Settings.OpenProject(DetectSettings.BranchClientPath, DetectSettings.NewSelectedClientFileName);

				// Commit all the new project info
				PerforceConnection PerforceClient = DetectSettings.PerforceClient;
				SelectedFileName = NewSelectedFileName;
				SelectedProjectIdentifier = DetectSettings.NewSelectedProjectIdentifier;
				EditorTargetName = DetectSettings.NewProjectEditorTarget;
				BranchDirectoryName = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(DetectSettings.BaseEditorTargetPath), "..", ".."));
				StreamName = DetectSettings.StreamName;
				ServerTimeZone = DetectSettings.ServerTimeZone;

				// Check if we've the project we've got open in this workspace is the one we're actually synced to
				int CurrentChangeNumber = -1;
				if(String.Compare(Settings.CurrentWorkspace.CurrentProjectIdentifier, SelectedProjectIdentifier, true) == 0)
				{
					CurrentChangeNumber = Settings.CurrentWorkspace.CurrentChangeNumber;
				}

				string ProjectLogBaseName = Path.Combine(DataFolder, String.Format("{0}@{1}", PerforceClient.ClientName, DetectSettings.BranchClientPath.Replace("//" + PerforceClient.ClientName + "/", "").Trim('/').Replace("/", "$")));

				string TelemetryProjectIdentifier = PerforceUtils.GetClientOrDepotDirectoryName(DetectSettings.NewSelectedProjectIdentifier);

				Workspace = new Workspace(PerforceClient, BranchDirectoryName, SelectedFileName, DetectSettings.BranchClientPath, DetectSettings.NewSelectedClientFileName, CurrentChangeNumber, Settings.CurrentWorkspace.LastBuiltChangeNumber, TelemetryProjectIdentifier, new LogControlTextWriter(SyncLog));
				Workspace.OnUpdateComplete += UpdateCompleteCallback;

				PerforceMonitor = new PerforceMonitor(PerforceClient, DetectSettings.BranchClientPath, DetectSettings.NewSelectedClientFileName, SelectedProjectIdentifier, ProjectLogBaseName + ".p4.log");
				PerforceMonitor.OnUpdate += UpdateBuildListCallback;
				PerforceMonitor.OnUpdateMetadata += UpdateBuildMetadataCallback;
				PerforceMonitor.OnStreamChange += StreamChangedCallbackAsync;

				EventMonitor = new EventMonitor(SqlConnectionString, PerforceUtils.GetClientOrDepotDirectoryName(SelectedProjectIdentifier), DetectSettings.PerforceClient.UserName, ProjectLogBaseName + ".review.log");
				EventMonitor.OnUpdatesReady += UpdateReviewsCallback;

				string LogFileName = Path.Combine(DataFolder, ProjectLogBaseName + ".sync.log");
				SyncLog.OpenFile(LogFileName);

				ProjectList.Text = NewSelectedFileName;
				UpdateProjectList();

				Settings.LastProjectFileName = SelectedFileName;
				Settings.Save();

				BuildList.Items.Clear();
				UpdateBuildList();
				UpdateBuildSteps();
				UpdateSyncActionCheckboxes();
				UpdateStatusPanel();

				if(CurrentChangeNumber != -1)
				{
					SelectChange(CurrentChangeNumber);
				}
			}
			return true;
		}