Esempio n. 1
0
        public void Done(bool isSuccess)
        {
            try
            {
                AppendMessageCrossThread("Done");
                ProgressBar.Visible = false;
                Ok.Enabled          = true;
                Ok.Focus();
                AcceptButton  = Ok;
                Abort.Enabled = false;
                TaskbarProgress.SetProgress(
                    isSuccess
                        ? TaskbarProgressBarState.Normal
                        : TaskbarProgressBarState.Error,
                    100,
                    100);

                picBoxSuccessFail.Image = isSuccess
                    ? Images.StatusBadgeSuccess
                    : Images.StatusBadgeError;

                _errorOccurred = !isSuccess;

                if (isSuccess && !_showOnError && (_useDialogSettings && AppSettings.CloseProcessDialog))
                {
                    Close();
                }
            }
            finally
            {
                _modalController?.EndModal(isSuccess);
            }
        }
Esempio n. 2
0
        private protected void Done(bool isSuccess)
        {
            try
            {
                AppendMessage("Done");
                ProgressBar.Visible = false;
                Ok.Enabled          = true;
                Ok.Focus();
                AcceptButton  = Ok;
                Abort.Enabled = false;
                TaskbarProgress.SetProgress(isSuccess ? TaskbarProgressBarState.Normal : TaskbarProgressBarState.Error, 100, 100);

                Bitmap image = isSuccess ? Images.StatusBadgeSuccess : Images.StatusBadgeError;
                SetIcon(image);

                _errorOccurred = !isSuccess;

                if (isSuccess && (_useDialogSettings && AppSettings.CloseProcessDialog))
                {
                    Close();
                }
            }
            catch (ConEmu.WinForms.GuiMacroExecutor.GuiMacroException)
            {
                // Do nothing
            }
        }
Esempio n. 3
0
        private void OkClick(object sender, EventArgs e)
        {
            // Ok button set as the "AcceptButton" for the form
            // if the user hits [Enter] at any point, we need to trigger BranchNameTextBox Leave event
            Ok.Focus();

            var newName = BranchNameTextBox.Text;

            if (newName == _oldName)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }

            try
            {
                var renameBranchResult = Module.RenameBranch(_oldName, newName);

                if (!string.IsNullOrEmpty(renameBranchResult))
                {
                    MessageBox.Show(this, _branchRenameFailed.Text + Environment.NewLine + renameBranchResult, Text,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

            DialogResult = DialogResult.OK;
        }
Esempio n. 4
0
        private void OkClick(object sender, EventArgs e)
        {
            // Ok button set as the "AcceptButton" for the form
            // if the user hits [Enter] at any point, we need to trigger BranchNameTextBox Leave event
            Ok.Focus();

            var objectId = commitPickerSmallControl1.SelectedObjectId;

            if (objectId == null)
            {
                MessageBox.Show(this, _noRevisionSelected.Text, Text);
                DialogResult = DialogResult.None;
                return;
            }

            var branchName = BranchNameTextBox.Text.Trim();

            if (branchName.IsNullOrWhiteSpace())
            {
                MessageBox.Show(_branchNameIsEmpty.Text, Text);
                DialogResult = DialogResult.None;
                return;
            }

            if (!Module.CheckBranchFormat(branchName))
            {
                MessageBox.Show(string.Format(_branchNameIsNotValid.Text, branchName), Text);
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                var originalHash = Module.GetCurrentCheckout();

                var cmd = Orphan.Checked
                    ? GitCommandHelpers.CreateOrphanCmd(branchName, objectId)
                    : GitCommandHelpers.BranchCmd(branchName, objectId.ToString(), chkbxCheckoutAfterCreate.Checked);

                bool wasSuccessful = FormProcess.ShowDialog(this, cmd);
                if (Orphan.Checked && wasSuccessful && ClearOrphan.Checked)
                {
                    // orphan AND orphan creation success AND clear
                    cmd = GitCommandHelpers.RemoveCmd();
                    FormProcess.ShowDialog(this, cmd);
                }

                if (wasSuccessful && chkbxCheckoutAfterCreate.Checked && objectId != originalHash)
                {
                    UICommands.UpdateSubmodules(this);
                }

                DialogResult = wasSuccessful ? DialogResult.OK : DialogResult.None;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 5
0
 // Constructor
 //  We set the application name, version, and dialog title.
 public AboutDlg()
 {
     Logger.record("[AboutDlg]: Starting About Dialog. Initializing component.", "AboutDlg", "info");
     InitializeComponent();
     this.Title           = System.Windows.Forms.Application.ProductName + " - Help";
     this.appName.Content = System.Windows.Forms.Application.ProductName;
     this.appVers.Content = System.Windows.Forms.Application.ProductVersion;
     Ok.Focus();
 }
Esempio n. 6
0
        public void Done(bool isSuccess)
        {
            if (outpuTimer != null)
            {
                outpuTimer.Stop(true);
            }
            AppendMessage("Done");
            ProgressBar.Visible = false;
            Ok.Enabled          = true;
            Ok.Focus();
            AcceptButton  = Ok;
            Abort.Enabled = false;
#if !__MonoCS__
            if (GitCommands.Settings.RunningOnWindows() && TaskbarManager.IsPlatformSupported)
            {
                try
                {
                    TaskbarManager.Instance.SetProgressState(isSuccess
                                                                 ? TaskbarProgressBarState.Normal
                                                                 : TaskbarProgressBarState.Error);

                    TaskbarManager.Instance.SetProgressValue(100, 100);
                }
                catch (InvalidOperationException) { }
            }
#endif

            if (isSuccess)
            {
                picBoxSuccessFail.Image = GitUI.Properties.Resources.success;
            }
            else
            {
                picBoxSuccessFail.Image = GitUI.Properties.Resources.error;
            }
            splitContainer1.Panel2Collapsed = false;

            errorOccurred = !isSuccess;

            if (showOnError && !isSuccess)
            {
                // For some reason setting the state to normal interferes with
                // proper parent centering...
                WindowState = FormWindowState.Normal;
                CenterToParent();
                Visible = true;
            }

            if (isSuccess && (showOnError || (UseDialogSettings && GitCommands.Settings.CloseProcessDialog)))
            {
                Close();
            }
        }
Esempio n. 7
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     Ok.Focus();
     _links = this.FindDescendants <RichTextBox>().SelectMany(b => b.Document.GetElementsOfType <Hyperlink>()).ToList();
     _links.ForEach(l =>
     {
         l.RequestNavigate += OnHyperlinkRequestNavigate;
     });
     _modPlayer = new MikMod();
     _modPlayer.Init <NaudioDriver>("");
     _modPlayer.Play(new MemoryStream(_resourceManager.GetContentByteArray("/Resources/Sounds/credits.xm")));
 }
Esempio n. 8
0
        public void Done(bool isSuccess)
        {
            try
            {
                AppendMessageCrossThread("Done");
                ProgressBar.Visible = false;
                Ok.Enabled          = true;
                Ok.Focus();
                AcceptButton  = Ok;
                Abort.Enabled = false;
#if !__MonoCS__
                if (GitCommands.Utils.EnvUtils.RunningOnWindows() && TaskbarManager.IsPlatformSupported)
                {
                    try
                    {
                        TaskbarManager.Instance.SetProgressState(isSuccess
                                                                     ? TaskbarProgressBarState.Normal
                                                                     : TaskbarProgressBarState.Error);

                        TaskbarManager.Instance.SetProgressValue(100, 100);
                    }
                    catch (InvalidOperationException) { }
                }
#endif

                if (isSuccess)
                {
                    picBoxSuccessFail.Image = GitUI.Properties.Resources.success;
                }
                else
                {
                    picBoxSuccessFail.Image = GitUI.Properties.Resources.error;
                }

                errorOccurred = !isSuccess;

                if (isSuccess && !showOnError && (UseDialogSettings && AppSettings.CloseProcessDialog))
                {
                    Close();
                }
            }
            finally
            {
                if (ModalControler != null)
                {
                    ModalControler.EndModal(isSuccess);
                }
            }
        }
Esempio n. 9
0
        public void Done(bool isSuccess)
        {
            ProcessOutputTimer.Stop();
            AddOutput("Done");
            ProgressBar.Visible = false;
            Ok.Enabled          = true;
            Ok.Focus();
            AcceptButton  = Ok;
            Abort.Enabled = false;
#if !__MonoCS__
            if (TaskbarManager.IsPlatformSupported)
            {
                try
                {
                    TaskbarManager.Instance.SetProgressState(isSuccess
                                                                 ? TaskbarProgressBarState.Normal
                                                                 : TaskbarProgressBarState.Error);

                    TaskbarManager.Instance.SetProgressValue(100, 100);
                }
                catch (InvalidOperationException) { }
            }
#endif

            SuccessImage.Visible            = isSuccess;
            ErrorImage.Visible              = !isSuccess;
            errorOccurred                   = !isSuccess;
            splitContainer5.Panel2Collapsed = false;

            if (showOnError && !isSuccess)
            {
                // For some reason setting the state to normal interferes with
                // proper parent centering...
                WindowState = FormWindowState.Normal;
                CenterToParent();
                Visible = true;
            }

            if (isSuccess && (showOnError || (UseDialogSettings && GitCommands.Settings.CloseProcessDialog)))
            {
                Close();
            }
        }
Esempio n. 10
0
        private void CreateAuthenticatorButtons()
        {
            var af  = new AuthenticatorFactory();
            var aus = af.CreateInteractiveAuthenticators();

            for (int i = 0; i < aus.Length; i++)
            {
                var b = new ImageButton()
                {
                    CausesValidation = false,
                    AlternateText    = aus[i].DisplayName,
                    ToolTip          = String.Format("Log on using {0}.", aus[i].DisplayName),
                    CommandArgument  = String.Format("{0}|{1}", aus[i].Protocol, aus[i].AuthorityUri)
                };

                b.Click += new ImageClickEventHandler(AuthenticatorButton_Click);

                Authenticators.Controls.Add(b);
            }

            // Focus on the 'sign in' button
            Ok.Focus();
        }
Esempio n. 11
0
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     Ok.Focus();
 }
Esempio n. 12
0
        private DialogResult OkClick()
        {
            // Ok button set as the "AcceptButton" for the form
            // if the user hits [Enter] at any point, we need to trigger txtCustomBranchName Leave event
            Ok.Focus();

            GitCheckoutBranchCmd cmd = new GitCheckoutBranchCmd(Branches.Text.Trim(), Remotebranch.Checked);

            if (Remotebranch.Checked)
            {
                if (rbCreateBranchWithCustomName.Checked)
                {
                    cmd.NewBranchName   = txtCustomBranchName.Text.Trim();
                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Create;
                    if (cmd.NewBranchName.IsNullOrWhiteSpace())
                    {
                        MessageBox.Show(_customBranchNameIsEmpty.Text, Text);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }

                    if (!Module.CheckBranchFormat(cmd.NewBranchName))
                    {
                        MessageBox.Show(string.Format(_customBranchNameIsNotValid.Text, cmd.NewBranchName), Text);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }
                }
                else if (rbResetBranch.Checked)
                {
                    IGitRef localBranchRef  = GetLocalBranchRef(_localBranchName);
                    IGitRef remoteBranchRef = GetRemoteBranchRef(cmd.BranchName);
                    if (localBranchRef != null && remoteBranchRef != null)
                    {
                        string mergeBaseGuid      = Module.GetMergeBase(localBranchRef.Guid, remoteBranchRef.Guid);
                        bool   isResetFastForward = localBranchRef.Guid.Equals(mergeBaseGuid);
                        if (!isResetFastForward)
                        {
                            string mergeBaseText = mergeBaseGuid.IsNullOrWhiteSpace()
                                ? "merge base"
                                : GitRevision.ToShortSha(mergeBaseGuid);

                            string warningMessage = string.Format(_resetNonFastForwardBranch.Text, _localBranchName, mergeBaseText);
                            if (MessageBox.Show(this, warningMessage, _resetCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                            {
                                DialogResult = DialogResult.None;
                                return(DialogResult.None);
                            }
                        }
                    }

                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.Reset;
                    cmd.NewBranchName   = _localBranchName;
                }
                else
                {
                    cmd.NewBranchAction = GitCheckoutBranchCmd.NewBranch.DontCreate;
                    cmd.NewBranchName   = null;
                }
            }

            LocalChangesAction changes = ChangesMode;

            if (changes != LocalChangesAction.Reset &&
                chkSetLocalChangesActionAsDefault.Checked)
            {
                AppSettings.CheckoutBranchAction = changes;
            }

            if ((Visible || AppSettings.UseDefaultCheckoutBranchAction) && HasUncommittedChanges)
            {
                cmd.LocalChanges = changes;
            }
            else
            {
                cmd.LocalChanges = LocalChangesAction.DontChange;
            }

            IWin32Window owner = Visible ? this : Owner;

            bool stash = false;

            if (changes == LocalChangesAction.Stash)
            {
                if (_isDirtyDir == null && Visible)
                {
                    _isDirtyDir = Module.IsDirtyDir();
                }

                stash = _isDirtyDir == true;
                if (stash)
                {
                    UICommands.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash);
                }
            }

            var originalHash = Module.GetCurrentCheckout();

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforeCheckout);

            if (UICommands.StartCommandLineProcessDialog(cmd, owner))
            {
                if (stash)
                {
                    bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch;
                    if (messageBoxResult == null)
                    {
                        DialogResult res = cTaskDialog.MessageBox(
                            this,
                            _applyShashedItemsAgainCaption.Text,
                            "",
                            _applyShashedItemsAgain.Text,
                            "",
                            "",
                            _dontShowAgain.Text,
                            eTaskDialogButtons.YesNo,
                            eSysIcons.Question,
                            eSysIcons.Question);
                        messageBoxResult = res == DialogResult.Yes;
                        if (cTaskDialog.VerificationChecked)
                        {
                            AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult;
                        }
                    }

                    if (messageBoxResult ?? false)
                    {
                        UICommands.StashPop(this);
                    }
                }

                var currentHash = Module.GetCurrentCheckout();
                if (!string.Equals(originalHash, currentHash, StringComparison.OrdinalIgnoreCase))
                {
                    UICommands.UpdateSubmodules(this);
                }

                ScriptManager.RunEventScripts(this, ScriptEvent.AfterCheckout);

                return(DialogResult.OK);
            }

            return(DialogResult.None);
        }
Esempio n. 13
0
        private DialogResult OkClick()
        {
            // Ok button set as the "AcceptButton" for the form
            // if the user hits [Enter] at any point, we need to trigger txtCustomBranchName Leave event
            Ok.Focus();

            var branchName    = Branches.Text.Trim();
            var isRemote      = Remotebranch.Checked;
            var newBranchName = (string)null;
            var newBranchMode = CheckoutNewBranchMode.DontCreate;

            if (isRemote)
            {
                if (rbCreateBranchWithCustomName.Checked)
                {
                    newBranchName = txtCustomBranchName.Text.Trim();
                    newBranchMode = CheckoutNewBranchMode.Create;
                    if (string.IsNullOrWhiteSpace(newBranchName))
                    {
                        MessageBox.Show(_customBranchNameIsEmpty.Text, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }

                    if (!Module.CheckBranchFormat(newBranchName))
                    {
                        MessageBox.Show(string.Format(_customBranchNameIsNotValid.Text, newBranchName), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        DialogResult = DialogResult.None;
                        return(DialogResult.None);
                    }
                }
                else if (rbResetBranch.Checked)
                {
                    IGitRef localBranchRef  = GetLocalBranchRef(_localBranchName);
                    IGitRef remoteBranchRef = GetRemoteBranchRef(branchName);
                    if (localBranchRef != null && remoteBranchRef != null)
                    {
                        var mergeBaseGuid      = Module.GetMergeBase(localBranchRef.ObjectId, remoteBranchRef.ObjectId);
                        var isResetFastForward = localBranchRef.ObjectId == mergeBaseGuid;

                        if (!isResetFastForward)
                        {
                            string mergeBaseText = mergeBaseGuid == null
                                ? "merge base"
                                : mergeBaseGuid.ToShortString();

                            string warningMessage = string.Format(_resetNonFastForwardBranch.Text, _localBranchName, mergeBaseText);

                            if (MessageBox.Show(this, warningMessage, _resetCaption.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                            {
                                DialogResult = DialogResult.None;
                                return(DialogResult.None);
                            }
                        }
                    }

                    newBranchMode = CheckoutNewBranchMode.Reset;
                    newBranchName = _localBranchName;
                }
                else
                {
                    newBranchMode = CheckoutNewBranchMode.DontCreate;
                }
            }

            var localChanges = ChangesMode;

            if (localChanges != LocalChangesAction.Reset && chkSetLocalChangesActionAsDefault.Checked)
            {
                AppSettings.CheckoutBranchAction = localChanges;
            }

            if ((!Visible && !AppSettings.UseDefaultCheckoutBranchAction) || !HasUncommittedChanges)
            {
                localChanges = LocalChangesAction.DontChange;
            }

            IWin32Window owner = Visible ? this : Owner;

            bool stash = false;

            if (localChanges == LocalChangesAction.Stash)
            {
                if (_isDirtyDir == null && Visible)
                {
                    _isDirtyDir = Module.IsDirtyDir();
                }

                stash = _isDirtyDir == true;
                if (stash)
                {
                    UICommands.StashSave(owner, AppSettings.IncludeUntrackedFilesInAutoStash);
                }
            }

            var originalId = Module.GetCurrentCheckout();

            Debug.Assert(originalId != null, "originalId != null");

            ScriptManager.RunEventScripts(this, ScriptEvent.BeforeCheckout);

            if (UICommands.StartCommandLineProcessDialog(owner, new GitCheckoutBranchCmd(branchName, isRemote, localChanges, newBranchMode, newBranchName)))
            {
                if (stash)
                {
                    bool?messageBoxResult = AppSettings.AutoPopStashAfterCheckoutBranch;
                    if (messageBoxResult == null)
                    {
                        using var dialog = new TaskDialog
                              {
                                  OwnerWindowHandle = Handle,
                                  Text               = _applyStashedItemsAgain.Text,
                                  Caption            = _applyStashedItemsAgainCaption.Text,
                                  Icon               = TaskDialogStandardIcon.Information,
                                  StandardButtons    = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No,
                                  FooterCheckBoxText = _dontShowAgain.Text,
                                  FooterIcon         = TaskDialogStandardIcon.Information,
                                  StartupLocation    = TaskDialogStartupLocation.CenterOwner
                              };

                        messageBoxResult = dialog.Show() == TaskDialogResult.Yes;

                        if (dialog.FooterCheckBoxChecked == true)
                        {
                            AppSettings.AutoPopStashAfterCheckoutBranch = messageBoxResult;
                        }
                    }

                    if (messageBoxResult ?? false)
                    {
                        UICommands.StashPop(this);
                    }
                }

                var currentId = Module.GetCurrentCheckout();

                if (originalId != currentId)
                {
                    UICommands.UpdateSubmodules(this);
                }

                ScriptManager.RunEventScripts(this, ScriptEvent.AfterCheckout);

                return(DialogResult.OK);
            }

            return(DialogResult.None);

            IGitRef GetLocalBranchRef(string name)
            {
                return(GetLocalBranches().FirstOrDefault(head => head.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
            }

            IGitRef GetRemoteBranchRef(string name)
            {
                return(GetRemoteBranches().FirstOrDefault(head => head.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
            }
        }
Esempio n. 14
0
 public Landing()
 {
     InitializeComponent();
     Ok.Focus();
     this.ControlBox = false;
 }
Esempio n. 15
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Logger.record("[Window_Loaded]: loading dialog....", "AboutDlg", "info");
     Ok.Focus();
 }
Esempio n. 16
0
 // Loaded and Unloaded event
 // When we load the window, we focus the Ok button (to close the dialog quickly).
 // When we unload the window, we delete the help text, to leave it blank for the next time.
 //  Everytime the dialog overwrites the text, but by cleaning it we protect ourselves from a possible ugly bug of showing the wrong text.
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     Logger.record("[Window_Loaded]: Loading help window", "HelpDlg", "info");
     Ok.Focus();
 }