public void HasChanges_updated_correctly()
        {
            string filePath = Path.Combine(_referenceRepository.Module.WorkingDir, Path.GetRandomFileName());

            try
            {
                File.WriteAllText(filePath, "Hello↔world", _commands.Module.FilesEncoding);

                UITest.RunForm <FormEditor>(
                    () =>
                {
                    using var formEditor = new FormEditor(_commands, filePath, showWarning: false);
                    formEditor.ShowDialog();
                },
                    form =>
                {
                    Assert.False(form.GetTestAccessor().HasChanges);

                    var fileViewerInternal = form.GetTestAccessor().FileViewer.GetTestAccessor().FileViewerInternal;
                    fileViewerInternal.SetText(fileViewerInternal.GetText() + "!", openWithDifftool: null, isDiff: false);

                    Assert.True(form.GetTestAccessor().HasChanges);

                    form.GetTestAccessor().SaveChanges();

                    Assert.False(form.GetTestAccessor().HasChanges);

                    return(Task.CompletedTask);
                });
            }
            finally
            {
                File.Delete(filePath);
            }
        }
        private void Should_preserve_encoding(Encoding encoding)
        {
            Assert.AreEqual(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), _commands.Module.FilesEncoding);

            string filePath = Path.Combine(_referenceRepository.Module.WorkingDir, Path.GetRandomFileName());

            try
            {
                File.WriteAllText(filePath, "Hello↔world", encoding);

                UITest.RunForm <FormEditor>(
                    () =>
                {
                    using (var formEditor = new FormEditor(_commands, filePath, showWarning: false))
                    {
                        formEditor.ShowDialog();
                    }
                },
                    form =>
                {
                    var fileViewerInternal = form.GetTestAccessor().FileViewer.GetTestAccessor().FileViewerInternal;
                    fileViewerInternal.SetText(fileViewerInternal.GetText() + "!", openWithDifftool: null, isDiff: false);
                    form.GetTestAccessor().SaveChanges();
                    return(Task.CompletedTask);
                });

                Assert.That(File.ReadAllBytes(filePath), Is.EquivalentTo(encoding.GetPreamble().Concat(encoding.GetBytes("Hello↔world!"))));
            }
            finally
            {
                File.Delete(filePath);
            }
        }
Beispiel #3
0
 private static void RunFileEditorCommand(string[] args)
 {
     using (var formEditor = new FormEditor(args[2]))
     {
         if (formEditor.ShowDialog() == DialogResult.Cancel)
         {
             System.Environment.ExitCode = -1;
         }
     }
 }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            EmployeeInSchoolYear eisy = (EmployeeInSchoolYear)bindingSourceEmployeeInSchoolYear.Current;

            if (eisy != null)
            {
                File.WriteAllText("Employee.txt",
                                  eisy.GetEmployeeInfo(myDatabase.CourseInWork.ToList <CourseInWork>()),
                                  Encoding.Default);
                // MessageBox.Show(eisy.GetEmployeeInfo());
                FormEditor fe = new FormEditor(eisy.GetEmployeeInfo(myDatabase.CourseInWork.ToList <CourseInWork>()));
                fe.ShowDialog();
            }
        }
Beispiel #5
0
 public bool StartFileEditorDialog(string filename, bool showWarning = false)
 {
     using (var formEditor = new FormEditor(this, filename, showWarning))
         return formEditor.ShowDialog() != DialogResult.Cancel;
 }
Beispiel #6
0
        private static void RunCommand(string[] args)
        {
            if (args.Length > 1)
            {
                switch (args[1])
                {
                case "mergeconflicts":
                    GitUICommands.Instance.StartResolveConflictsDialog();
                    return;

                case "gitbash":
                    GitCommandHelpers.RunBash();
                    return;

                case "gitignore":
                    GitUICommands.Instance.StartEditGitIgnoreDialog();
                    return;

                case "remotes":
                    GitUICommands.Instance.StartRemotesDialog();
                    return;

                case "blame":
                    if (args.Length > 2)
                    {
                        // Remove working dir from filename. This is to prevent filenames that are too
                        // long while there is room left when the workingdir was not in the path.
                        string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                        GitUICommands.Instance.StartBlameDialog(fileName);
                    }
                    else
                    {
                        MessageBox.Show("Cannot open blame, there is no file selected.", "Blame");
                    }
                    return;

                case "browse":
                    GitUICommands.Instance.StartBrowseDialog(GetParameterOrEmptyStringAsDefault(args, "-filter"));
                    return;

                case "add":
                case "addfiles":
                    GitUICommands.Instance.StartAddFilesDialog();
                    return;

                case "apply":
                case "applypatch":
                    GitUICommands.Instance.StartApplyPatchDialog();
                    return;

                case "branch":
                    GitUICommands.Instance.StartCreateBranchDialog();
                    return;

                case "checkout":
                case "checkoutbranch":
                    GitUICommands.Instance.StartCheckoutBranchDialog();
                    return;

                case "checkoutrevision":
                    GitUICommands.Instance.StartCheckoutRevisionDialog();
                    return;

                case "init":
                    if (args.Length > 2)
                    {
                        GitUICommands.Instance.StartInitializeDialog(args[2]);
                    }
                    else
                    {
                        GitUICommands.Instance.StartInitializeDialog();
                    }
                    return;

                case "clone":
                    GitUICommands.Instance.StartCloneDialog();
                    return;

                case "commit":
                    GitUICommands.Instance.StartCommitDialog();
                    return;

                case "filehistory":
                    if (args.Length > 2)
                    {
                        //Remove working dir from filename. This is to prevent filenames that are too
                        //long while there is room left when the workingdir was not in the path.
                        string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                        GitUICommands.Instance.StartFileHistoryDialog(fileName);
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file history, there is no file selected.", "File history");
                    }
                    return;

                case "fileeditor":
                    if (args.Length > 2)
                    {
                        using (var formEditor = new FormEditor(args[2]))
                        {
                            if (formEditor.ShowDialog() == DialogResult.Cancel)
                            {
                                System.Environment.ExitCode = -1;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file editor, there is no file selected.", "File editor");
                    }
                    return;

                case "formatpatch":
                    GitUICommands.Instance.StartFormatPatchDialog();
                    return;

                case "pull":
                    GitUICommands.Instance.StartPullDialog();
                    return;

                case "push":
                    GitUICommands.Instance.StartPushDialog();
                    return;

                case "settings":
                    GitUICommands.Instance.StartSettingsDialog();
                    return;

                case "viewdiff":
                    GitUICommands.Instance.StartCompareRevisionsDialog();
                    return;

                case "rebase":
                    GitUICommands.Instance.StartRebaseDialog(null);
                    return;

                case "merge":
                    GitUICommands.Instance.StartMergeBranchDialog(null);
                    return;

                case "cherry":
                    GitUICommands.Instance.StartCherryPickDialog();
                    return;

                case "revert":
                    Application.Run(new FormRevert(args[2]));
                    return;

                case "tag":
                    GitUICommands.Instance.StartCreateTagDialog();
                    return;

                case "about":
                    Application.Run(new AboutBox());
                    return;

                case "stash":
                    GitUICommands.Instance.StartStashDialog();
                    return;

                default:
                    Application.Run(new FormCommandlineHelp());
                    return;
                }
            }
        }
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            string returnString = "Фамилия".PadRight(30) + "|" +
                                  "Должность".PadRight(20) + "|" +
                                  "Форм. нагрузка".PadRight(15) + "|" +
                                  "Перегрузка".PadRight(10) + "|" +
                                  "Недогрузка".PadRight(10) + "|" +
                                  "Форм. нагр. по часам".PadRight(20) + "|" +
                                  "Форм. ставка".PadRight(12) + "|" +
                                  "Факт. нагрузка".PadRight(14) + "|" +
                                  "Факт. ставка".PadRight(12) + "|" + "\n";

            decimal workloadForm    = 0;
            decimal overload        = 0;
            decimal underload       = 0;
            decimal rateFormByHours = 0;
            decimal rateForm        = 0;
            decimal workloadFact    = 0;
            decimal rateFact        = 0;

            var q = from eisy in this.bindingSourceEmployeeInSchoolYear.OfType <EmployeeInSchoolYear>()
                    orderby eisy.Post.Id descending
                    select eisy;

            foreach (EmployeeInSchoolYear eisy in q)
            {
                if (eisy.WorkloadForm != 0 ||
                    eisy.Overload != 0 ||
                    eisy.Underload != 0 ||
                    (decimal)eisy.RateFormByHours != 0 ||
                    eisy.RateForm != 0 ||
                    eisy.WorkloadFact != 0 ||
                    (decimal)eisy.RateFact != 0)
                {
                    returnString += eisy.Fio.PadRight(30) + "|" +
                                    eisy.Post.ToString().PadRight(20) + "|" +
                                    eisy.WorkloadForm.ToString().PadLeft(15) + "|" +
                                    eisy.Overload.ToString().PadLeft(10) + "|" +
                                    eisy.Underload.ToString().PadLeft(10) + "|" +
                                    eisy.RateFormByHours.ToString().PadLeft(20) + "|" +
                                    eisy.RateForm.ToString().PadLeft(12) + "|" +
                                    eisy.WorkloadFact.ToString().PadLeft(14) + "|" +
                                    eisy.RateFact.ToString().PadLeft(12) + "|" + "\n";

                    workloadForm    += eisy.WorkloadForm;
                    overload        += eisy.Overload;
                    underload       += eisy.Underload;
                    rateFormByHours += (decimal)eisy.RateFormByHours;
                    rateForm        += eisy.RateForm;
                    workloadFact    += eisy.WorkloadFact;
                    rateFact        += (decimal)eisy.RateFact;
                }
            }
            returnString += "\n";
            returnString += "ИТОГО: ".PadRight(30) + "|" +
                            "".PadRight(20) + "|" +
                            workloadForm.ToString().PadLeft(15) + "|" +
                            overload.ToString().PadLeft(10) + "|" +
                            underload.ToString().PadLeft(10) + "|" +
                            rateFormByHours.ToString().PadLeft(20) + "|" +
                            rateForm.ToString().PadLeft(12) + "|" +
                            workloadFact.ToString().PadLeft(14) + "|" +
                            rateFact.ToString().PadLeft(12) + "|" + "\n";

            FormEditor fe = new FormEditor(returnString);

            fe.ShowDialog();
        }
Beispiel #8
0
        private static void RunCommand(string[] args)
        {
            Dictionary <string, string> arguments = new Dictionary <string, string>();

            for (int i = 2; i < args.Length; i++)
            {
                if (args[i].StartsWith("--") && i + 1 < args.Length && !args[i + 1].StartsWith("--"))
                {
                    arguments.Add(args[i].TrimStart('-'), args[++i]);
                }
                else
                if (args[i].StartsWith("--"))
                {
                    arguments.Add(args[i].TrimStart('-'), null);
                }
            }

            if (args.Length > 1)
            {
                switch (args[1])
                {
                case "mergetool":
                case "mergeconflicts":
                    if (!arguments.ContainsKey("quiet") || GitCommandHelpers.InTheMiddleOfConflictedMerge())
                    {
                        GitUICommands.Instance.StartResolveConflictsDialog();
                    }

                    return;

                case "gitbash":
                    GitCommandHelpers.RunBash();
                    return;

                case "gitignore":
                    GitUICommands.Instance.StartEditGitIgnoreDialog();
                    return;

                case "remotes":
                    GitUICommands.Instance.StartRemotesDialog();
                    return;

                case "blame":
                    if (args.Length > 2)
                    {
                        // Remove working dir from filename. This is to prevent filenames that are too
                        // long while there is room left when the workingdir was not in the path.
                        string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                        GitUICommands.Instance.StartBlameDialog(fileName);
                    }
                    else
                    {
                        MessageBox.Show("Cannot open blame, there is no file selected.", "Blame");
                    }
                    return;

                case "browse":
                    GitUICommands.Instance.StartBrowseDialog(GetParameterOrEmptyStringAsDefault(args, "-filter"));
                    return;

                case "cleanup":
                    new FormCleanupRepository().ShowDialog();
                    return;

                case "add":
                case "addfiles":
                    GitUICommands.Instance.StartAddFilesDialog();
                    return;

                case "apply":
                case "applypatch":
                    GitUICommands.Instance.StartApplyPatchDialog();
                    return;

                case "branch":
                    GitUICommands.Instance.StartCreateBranchDialog();
                    return;

                case "checkout":
                case "checkoutbranch":
                    GitUICommands.Instance.StartCheckoutBranchDialog();
                    return;

                case "checkoutrevision":
                    GitUICommands.Instance.StartCheckoutRevisionDialog();
                    return;

                case "init":
                    if (args.Length > 2)
                    {
                        GitUICommands.Instance.StartInitializeDialog(args[2]);
                    }
                    else
                    {
                        GitUICommands.Instance.StartInitializeDialog();
                    }
                    return;

                case "clone":
                    GitUICommands.Instance.StartCloneDialog();
                    return;

                case "commit":
                    Commit(arguments);
                    return;

                case "filehistory":
                    if (args.Length > 2)
                    {
                        //Remove working dir from filename. This is to prevent filenames that are too
                        //long while there is room left when the workingdir was not in the path.
                        string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                        GitUICommands.Instance.StartFileHistoryDialog(fileName);
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file history, there is no file selected.", "File history");
                    }
                    return;

                case "fileeditor":
                    if (args.Length > 2)
                    {
                        using (var formEditor = new FormEditor(args[2]))
                        {
                            if (formEditor.ShowDialog() == DialogResult.Cancel)
                            {
                                System.Environment.ExitCode = -1;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file editor, there is no file selected.", "File editor");
                    }
                    return;

                case "formatpatch":
                    GitUICommands.Instance.StartFormatPatchDialog();
                    return;

                case "pull":
                    Pull(arguments);
                    return;

                case "push":
                    Push(arguments);
                    return;

                case "settings":
                    GitUICommands.Instance.StartSettingsDialog();
                    return;

                case "viewdiff":
                    GitUICommands.Instance.StartCompareRevisionsDialog();
                    return;

                case "rebase":
                {
                    string branch = null;
                    if (arguments.ContainsKey("branch"))
                    {
                        branch = arguments["branch"];
                    }
                    GitUICommands.Instance.StartRebaseDialog(branch);
                    return;
                }

                case "merge":
                {
                    string branch = null;
                    if (arguments.ContainsKey("branch"))
                    {
                        branch = arguments["branch"];
                    }
                    GitUICommands.Instance.StartMergeBranchDialog(branch);
                    return;
                }

                case "cherry":
                    GitUICommands.Instance.StartCherryPickDialog();
                    return;

                case "revert":
                    Application.Run(new FormRevert(args[2]));
                    return;

                case "tag":
                    GitUICommands.Instance.StartCreateTagDialog();
                    return;

                case "about":
                    Application.Run(new AboutBox());
                    return;

                case "stash":
                    GitUICommands.Instance.StartStashDialog();
                    return;

                case "synchronize":
                    Commit(arguments);
                    Pull(arguments);
                    Push(arguments);
                    return;

                default:
                    Application.Run(new FormCommandlineHelp());
                    return;
                }
            }
        }