public static bool ShowModal(IWin32Window Owner, PerforceConnection Perforce, TextWriter Log, out string SelectedUserName) { EnumerateUsersTask Task = new EnumerateUsersTask(); string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(Owner, Perforce, Task, "Finding users", "Finding users, please wait...", Log, out ErrorMessage); if (Result != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(Owner, ErrorMessage); } SelectedUserName = null; return(false); } SelectUserWindow SelectUser = new SelectUserWindow(Task.Users, 0); if (SelectUser.ShowDialog(Owner) == DialogResult.OK) { SelectedUserName = Task.Users[SelectUser.SelectedUserIndex].Name; return(true); } else { SelectedUserName = null; return(false); } }
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; } } } }
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)); } }
public static bool ShowModal(IWin32Window Owner, PerforceConnection Perforce, string ForceStreamName, string CurrentWorkspaceName, TextWriter Log, out string WorkspaceName) { FindWorkspaceSettingsTask FindSettings = new FindWorkspaceSettingsTask(CurrentWorkspaceName); string ErrorMessage; if (PerforceModalTask.Execute(Owner, Perforce, FindSettings, "Checking settings", "Checking settings, please wait...", Log, out ErrorMessage) != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(ErrorMessage); } WorkspaceName = null; return(false); } NewWorkspaceWindow Window = new NewWorkspaceWindow(Perforce, ForceStreamName, FindSettings.CurrentStream, FindSettings.Info, FindSettings.Clients, Log); if (Window.ShowDialog(Owner) == DialogResult.OK) { WorkspaceName = Window.Settings.Name; return(true); } else { WorkspaceName = null; return(false); } }
private void OkBtn_Click(object sender, EventArgs e) { if (TryGetWorkspaceSettings(out Settings)) { DirectoryInfo RootDir = new DirectoryInfo(Settings.RootDir); if (RootDir.Exists && RootDir.EnumerateFileSystemInfos().Any(x => x.Name != "." && x.Name != "..")) { if (MessageBox.Show(this, String.Format("The directory '{0}' is not empty. Are you sure you want to create a workspace there?", RootDir.FullName), "Directory not empty", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } NewWorkspaceTask NewWorkspace = new NewWorkspaceTask(Settings, Info.UserName, Info.HostName); string ErrorMessage; if (PerforceModalTask.Execute(Owner, Perforce, NewWorkspace, "Creating workspace", "Creating workspace, please wait...", Log, out ErrorMessage) != ModalTaskResult.Succeeded) { MessageBox.Show(ErrorMessage); return; } DialogResult = DialogResult.OK; Close(); } }
public static bool ShowModal(IWin32Window Owner, string ServerAndPort, string UserName, string WorkspaceName, TextWriter Log, out string NewWorkspaceName) { EnumerateWorkspacesTask EnumerateWorkspaces = new EnumerateWorkspacesTask(); string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(Owner, null, ServerAndPort, UserName, EnumerateWorkspaces, "Finding workspaces", "Finding workspaces, please wait...", Log, out ErrorMessage); if (Result != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(Owner, ErrorMessage); } NewWorkspaceName = null; return(false); } SelectWorkspaceWindow SelectWorkspace = new SelectWorkspaceWindow(EnumerateWorkspaces.Info, EnumerateWorkspaces.Clients, WorkspaceName); if (SelectWorkspace.ShowDialog(Owner) == DialogResult.OK) { NewWorkspaceName = SelectWorkspace.WorkspaceName; return(true); } else { NewWorkspaceName = null; return(false); } }
public static bool ShowModal(IWin32Window Owner, string ServerAndPort, string UserName, string WorkspaceName, string WorkspacePath, TextWriter Log, out string NewWorkspacePath) { EnumerateWorkspaceProjectsTask EnumerateProjectsTask = new EnumerateWorkspaceProjectsTask(WorkspaceName); string ErrorMessage; if (PerforceModalTask.Execute(Owner, null, ServerAndPort, UserName, EnumerateProjectsTask, "Finding Projects", "Finding projects, please wait...", Log, out ErrorMessage) != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(Owner, ErrorMessage); } NewWorkspacePath = null; return(false); } SelectProjectFromWorkspaceWindow SelectProjectWindow = new SelectProjectFromWorkspaceWindow(WorkspaceName, EnumerateProjectsTask.Paths, WorkspacePath); if (SelectProjectWindow.ShowDialog() == DialogResult.OK && !String.IsNullOrEmpty(SelectProjectWindow.SelectedProjectFile)) { NewWorkspacePath = SelectProjectWindow.SelectedProjectFile; return(true); } else { NewWorkspacePath = null; return(false); } }
public static bool ShowModal(IWin32Window Owner, string ServerAndPort, string UserName, string StreamName, TextWriter Log, out string NewStreamName) { EnumerateStreamsTask Task = new EnumerateStreamsTask(); string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(Owner, null, ServerAndPort, UserName, Task, "Finding streams", "Finding streams, please wait...", Log, out ErrorMessage); if (Result != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(Owner, ErrorMessage); } NewStreamName = null; return(false); } SelectStreamWindow SelectStream = new SelectStreamWindow(Task.Streams, StreamName); if (SelectStream.ShowDialog(Owner) == DialogResult.OK) { NewStreamName = SelectStream.SelectedStream; return(true); } else { NewStreamName = null; return(false); } }
public bool Run(out string ErrorMessage) { // Get the server settings string ServerAndPort = SelectedProject.ServerAndPort; string UserName = SelectedProject.UserName; string ProjectFileName = null; if (SelectedProject.Type == UserSelectedProjectType.Local) { ProjectFileName = SelectedProject.LocalPath; } if (!PerforceModalTask.TryGetServerSettings(ProjectFileName, ref ServerAndPort, ref UserName, Log)) { ErrorMessage = "Unable to get Perforce server settings."; return(false); } // Create the connection and make sure we're logged in PerforceConnection Perforce = new PerforceConnection(UserName, null, ServerAndPort); if (!Perforce.IsLoggedIn(Log)) { ErrorMessage = "User is not logged in to Perforce."; return(false); } // Execute like a regular task return(Run(Perforce, Log, out ErrorMessage)); }
public static string FindDefaultWorkspace(IWin32Window Owner, PerforceConnection DefaultConnection, string StreamName, TextWriter Log) { FindDefaultWorkspaceTask FindWorkspace = new FindDefaultWorkspaceTask(StreamName); string ErrorMessage; PerforceModalTask.Execute(Owner, DefaultConnection, FindWorkspace, "Finding workspace", "Finding default workspace, please wait...", Log, out ErrorMessage); return(FindWorkspace.WorkspaceName); }
public bool Run(out string ErrorMessage) { if (PerforceModalTask.TryGetServerSettings(null, ref ServerAndPort, ref UserName, Log)) { ErrorMessage = null; return(true); } else { ErrorMessage = "Unable to query server settings"; return(false); } }
public static ModalTaskResult Execute(IWin32Window Owner, string ProjectFileName, string ServerAndPort, string UserName, IPerforceModalTask PerforceTask, string Title, string Message, TextWriter Log, out string ErrorMessage) { PerforceModalTask Task = new PerforceModalTask(ProjectFileName, ServerAndPort, UserName, PerforceTask, Log); for (;;) { string TaskErrorMessage; ModalTaskResult TaskResult = ModalTask.Execute(Owner, Task, Title, Message, out TaskErrorMessage); if (Task.LoginResult == LoginResult.Succeded) { ErrorMessage = TaskErrorMessage; return(TaskResult); } else if (Task.LoginResult == LoginResult.MissingPassword) { PasswordWindow PasswordWindow = new PasswordWindow(String.Format("Enter the password for user '{0}' on server '{1}'.", Task.UserName, Task.ServerAndPort), Task.Password); if (Owner == null) { PasswordWindow.StartPosition = FormStartPosition.CenterScreen; } if (PasswordWindow.ShowDialog() != DialogResult.OK) { ErrorMessage = null; return(ModalTaskResult.Aborted); } Task.Password = PasswordWindow.Password; } else if (Task.LoginResult == LoginResult.IncorrectPassword) { PasswordWindow PasswordWindow = new PasswordWindow(String.Format("Authentication failed. Enter the password for user '{0}' on server '{1}'.", Task.UserName, Task.ServerAndPort), Task.Password); if (Owner == null) { PasswordWindow.StartPosition = FormStartPosition.CenterScreen; } if (PasswordWindow.ShowDialog() != DialogResult.OK) { ErrorMessage = null; return(ModalTaskResult.Aborted); } Task.Password = PasswordWindow.Password; } else { ErrorMessage = TaskErrorMessage; return(ModalTaskResult.Failed); } } }
public static bool ValidateWorkspace(IWin32Window Owner, PerforceConnection Perforce, string WorkspaceName, string StreamName, TextWriter Log, out WorkspaceInfo SelectedWorkspaceInfo) { ValidateWorkspaceTask ValidateWorkspace = new ValidateWorkspaceTask(WorkspaceName, StreamName); string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(Owner, Perforce, ValidateWorkspace, "Checking workspace", "Checking workspace, please wait...", Log, out ErrorMessage); if (Result == ModalTaskResult.Failed) { MessageBox.Show(ErrorMessage); } else if (Result == ModalTaskResult.Succeeded) { if (ValidateWorkspace.bRequiresStreamSwitch) { string Message; if (ValidateWorkspace.bHasOpenFiles) { Message = String.Format("You have files open for edit in this workspace. If you switch this workspace to {0}, you will not be able to submit them until you switch back.\n\nContinue switching streams?", StreamName); } else { Message = String.Format("Switch this workspace to {0}?", StreamName); } if (MessageBox.Show(Message, "Switch Streams", MessageBoxButtons.YesNo) != DialogResult.Yes) { SelectedWorkspaceInfo = null; return(false); } } SelectedWorkspaceInfo = new WorkspaceInfo() { ServerAndPort = ValidateWorkspace.ServerAndPort, UserName = ValidateWorkspace.UserName, WorkspaceName = ValidateWorkspace.WorkspaceName, bRequiresStreamSwitch = ValidateWorkspace.bRequiresStreamSwitch }; return(true); } SelectedWorkspaceInfo = null; return(false); }
public static bool ShowModal(IWin32Window Owner, PerforceConnection DefaultConnection, string StreamName, string ProjectPath, out WorkspaceInfo WorkspaceInfo, TextWriter Log) { FindDefaultWorkspaceTask FindWorkspace = new FindDefaultWorkspaceTask(StreamName); string ErrorMessage; PerforceModalTask.Execute(Owner, DefaultConnection, FindWorkspace, "Finding workspace", "Finding default workspace, please wait...", Log, out ErrorMessage); AutomatedSyncWindow Window = new AutomatedSyncWindow(StreamName, ProjectPath, FindWorkspace.WorkspaceName, DefaultConnection, Log); if (Window.ShowDialog() == DialogResult.OK) { WorkspaceInfo = Window.SelectedWorkspaceInfo; return(true); } else { WorkspaceInfo = null; return(false); } }
private void OkBtn_Click(object sender, EventArgs e) { ValidateWorkspaceTask ValidateWorkspace = new ValidateWorkspaceTask(WorkspaceNameTextBox.Text, StreamName); string ErrorMessage; ModalTaskResult Result = PerforceModalTask.Execute(Owner, Perforce, ValidateWorkspace, "Checking workspace", "Checking workspace, please wait...", Log, out ErrorMessage); if (Result == ModalTaskResult.Failed) { MessageBox.Show(ErrorMessage); } else if (Result == ModalTaskResult.Succeeded) { if (ValidateWorkspace.bRequiresStreamSwitch) { string Message; if (ValidateWorkspace.bHasOpenFiles) { Message = String.Format("You have files open for edit in this workspace. If you switch this workspace to {0}, you will not be able to submit them until you switch back.\n\nContinue switching streams?", StreamName); } else { Message = String.Format("Switch this workspace to {0}?", StreamName); } if (MessageBox.Show(Message, "Switch Streams", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } SelectedWorkspaceInfo = new WorkspaceInfo() { ServerAndPort = ValidateWorkspace.ServerAndPort, UserName = ValidateWorkspace.UserName, WorkspaceName = ValidateWorkspace.WorkspaceName, bRequiresStreamSwitch = ValidateWorkspace.bRequiresStreamSwitch }; DialogResult = DialogResult.OK; Close(); } }
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(); }