Esempio n. 1
0
        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, 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);
            }
        }
        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);
            }
        }
Esempio n. 4
0
        private void FetchMoreResults()
        {
            int             NewMaxResults = MaxResults + 100;
            QueryIssuesTask Task          = new QueryIssuesTask(IssueMonitor.ApiUrl, NewMaxResults);

            // Execute the task
            string          ErrorMessage;
            ModalTaskResult Result = ModalTask.Execute(this, Task, "Querying issues", "Fetching data, please wait...", out ErrorMessage);

            if (Result != ModalTaskResult.Succeeded)
            {
                if (Result != ModalTaskResult.Aborted)
                {
                    StatusLabel.Text = "Unable to fetch issues.";
                    MessageBox.Show(ErrorMessage);
                }
                return;
            }

            // Update the list of project names
            Issues       = Task.Issues;
            ProjectNames = Task.Issues.Select(x => x.Project).Distinct().OrderBy(x => x).ToList();

            // Populate the list control
            UpdateIssueList();
            MaxResults = NewMaxResults;
        }
Esempio n. 5
0
        private void ConnectBtn_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 = null;
            }

            Program.SaveSettings(ServerAndPort, UserName, DepotPath);

            // Create the task for connecting to this server
            StringWriter           Log             = new StringWriter();
            SyncAndRunPerforceTask SyncApplication = new SyncAndRunPerforceTask((Perforce, LogWriter) => SyncAndRun(Perforce, DepotPath, UseUnstableBuildCheckBox.Checked, LogWriter));

            // Attempt to sync through a modal dialog
            string          ErrorMessage;
            ModalTaskResult Result = PerforceModalTask.Execute(this, null, ServerAndPort, UserName, SyncApplication, "Updating", "Checking for updates, please wait...", Log, out ErrorMessage);

            if (Result == ModalTaskResult.Succeeded)
            {
                Program.SaveSettings(ServerAndPort, UserName, DepotPath);
                DialogResult = DialogResult.OK;
                Close();
            }

            if (ErrorMessage != null)
            {
                PromptLabel.Text = ErrorMessage;
            }

            LogText            = Log.ToString();
            ViewLogBtn.Visible = true;
        }
Esempio n. 6
0
        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);
                }
            }
        }
Esempio n. 7
0
        public static bool ExecuteAndShowError(IWin32Window Owner, IModalTask Task, string InTitle, string InMessage)
        {
            string          ErrorMessage;
            ModalTaskResult Result = Execute(Owner, Task, InTitle, InMessage, out ErrorMessage);

            if (Result != ModalTaskResult.Succeeded)
            {
                if (!String.IsNullOrEmpty(ErrorMessage))
                {
                    MessageBox.Show(ErrorMessage);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 8
0
        public static bool ExecuteAndShowError(IWin32Window Owner, PerforceConnection Perforce, IPerforceModalTask Task, string Title, string Message, TextWriter Log)
        {
            string          ErrorMessage;
            ModalTaskResult Result = Execute(Owner, Perforce, Task, Title, Message, Log, out ErrorMessage);

            if (Result != ModalTaskResult.Succeeded)
            {
                if (!String.IsNullOrEmpty(ErrorMessage))
                {
                    MessageBox.Show(ErrorMessage);
                }
                return(false);
            }
            return(true);
        }
        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);
        }
Esempio n. 10
0
        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();
            }
        }
Esempio n. 11
0
        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();
        }