Beispiel #1
0
        private void UnifyLineEndingsInFile()
        {
            var selectedItem = this.IDE.SelectedItems.Item(1);
            var item         = selectedItem.ProjectItem;

            var choiceWindow = new LineEndingChoice(item.Name, this.DefaultLineEnding);

            if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
            {
                var supportedFileFormats = this.SupportedFileFormats;
                var supportedFileNames   = this.SupportedFileNames;

                if (item.Name.EndsWithAny(supportedFileFormats) || item.Name.EqualsAny(supportedFileNames))
                {
                    System.Threading.Tasks.Task.Run(() =>
                    {
                        Output("Unifying started...\n");
                        var numberOfChanges = 0;
                        var stopWatch       = new Stopwatch();
                        stopWatch.Start();
                        UnifyLineEndingsInProjectItem(item, choiceWindow.LineEndings, ref numberOfChanges);
                        stopWatch.Stop();
                        var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                        VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                                        OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                    });
                }
                else
                {
                    VsShellUtilities.ShowMessageBox(this, "This is not a valid source file!", "Error",
                                                    OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            }
        }
        private void UnifyLineEndingsInProjectEventHandler(object sender, EventArgs e)
        {
            var selectedItem    = this.IDE.SelectedItems.Item(1);
            var selectedProject = selectedItem.Project;

            var choiceWindow = new LineEndingChoice(selectedProject.Name, this.DefaultLineEnding);

            if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    Output("Unifying started...\n");
                    var numberOfChanges = 0;
                    this.changeLog      = this.changesManager.GetLastChanges(this.IDE.Solution);
                    var stopWatch       = new Stopwatch();
                    stopWatch.Start();
                    UnifyLineEndingsInProjectItems(selectedProject.ProjectItems, choiceWindow.LineEndings, ref numberOfChanges);
                    stopWatch.Stop();
                    var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                    this.changesManager.SaveLastChanges(this.IDE.Solution, this.changeLog);
                    this.changeLog = null;
                    VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                                    OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                });
            }
        }
Beispiel #3
0
        private void UnifyLineEndingsInSolution(bool askForLineEnding = true)
        {
            var currentSolution = this.IDE.Solution;

            var properties = currentSolution.Properties;

            foreach (Property property in properties)
            {
                if (property.Name == "Name")
                {
                    if (askForLineEnding)
                    {
                        var choiceWindow = new LineEndingChoice((property as Property).Value.ToString(), this.DefaultLineEnding);
                        if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
                        {
                            System.Threading.Tasks.Task.Run(() =>
                            {
                                Output("Unifying started...\n");
                                var stopWatch = new Stopwatch();
                                stopWatch.Start();
                                var numberOfChanges = 0;
                                foreach (Project project in currentSolution.GetAllProjects())
                                {
                                    UnifyLineEndingsInProjectItems(project.ProjectItems, choiceWindow.LineEndings, ref numberOfChanges);
                                }
                                stopWatch.Stop();
                                var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                                VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                                Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                            });
                        }
                    }
                    else
                    {
                        var lineEndings = this.DefaultLineEnding;

                        Output("Unifying started...\n");
                        int numberOfChanges = 0;
                        foreach (Project project in currentSolution.Projects)
                        {
                            UnifyLineEndingsInProjectItems(project.ProjectItems, lineEndings, ref numberOfChanges, true);
                        }
                        Output("Done\n");
                    }
                    break;
                }
            }
        }
Beispiel #4
0
        private void UnifyLineEndingsInFolder()
        {
            var selectedItem = IDE.SelectedItems.Item(1);
            var projectItem  = selectedItem.ProjectItem;

            var choiceWindow = new LineEndingChoice(selectedItem.Name);

            if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    Output("Unifying started...\n");
                    var numberOfChanges = 0;
                    var stopWatch       = new Stopwatch();
                    stopWatch.Start();
                    UnifyLineEndingsInProjectItems(projectItem.ProjectItems, choiceWindow.LineEndings, ref numberOfChanges);
                    stopWatch.Stop();
                    var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                    VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                                    OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                });
            }
        }
        private void UnifyLineEndingsInSolution(bool askForLineEnding = true)
        {
            var currentSolution = this.IDE.Solution;

            var properties = currentSolution.Properties;
            foreach (Property property in properties)
            {
                if (property.Name == "Name")
                {
                    if (askForLineEnding)
                    {
                        var choiceWindow = new LineEndingChoice((property as Property).Value.ToString(), this.DefaultLineEnding);
                        if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
                        {
                            System.Threading.Tasks.Task.Run(() =>
                                {
                                    Output("Unifying started...\n");
                                    var stopWatch = new Stopwatch();
                                    stopWatch.Start();
                                    var numberOfChanges = 0;
                                    foreach (Project project in currentSolution.GetAllProjects())
                                    {
                                        UnifyLineEndingsInProjectItems(project.ProjectItems, choiceWindow.LineEndings, ref numberOfChanges);
                                    }
                                    stopWatch.Stop();
                                    var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                                    VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                        OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                                    Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                                });
                        }
                    }
                    else
                    {
                        var lineEndings = this.DefaultLineEnding;

                        Output("Unifying started...\n");
                        int numberOfChanges = 0;
                        foreach (Project project in currentSolution.Projects)
                        {
                            UnifyLineEndingsInProjectItems(project.ProjectItems, lineEndings, ref numberOfChanges, true);
                        }
                        Output("Done\n");
                    }
                    break;
                }
            }
        }
        private void UnifyLineEndingsInProject()
        {
            var selectedItem = this.IDE.SelectedItems.Item(1);
            var selectedProject = selectedItem.Project;

            var choiceWindow = new LineEndingChoice(selectedProject.Name, this.DefaultLineEnding);
            if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
            {
                System.Threading.Tasks.Task.Run(() =>
                    {
                        Output("Unifying started...\n");
                        var numberOfChanges = 0;
                        var stopWatch = new Stopwatch();
                        stopWatch.Start();
                        UnifyLineEndingsInProjectItems(selectedProject.ProjectItems, choiceWindow.LineEndings, ref numberOfChanges);
                        stopWatch.Stop();
                        var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                        VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                        Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                    });
            }
        }
        private void UnifyLineEndingsInFile()
        {
            var selectedItem = this.IDE.SelectedItems.Item(1);
            var item = selectedItem.ProjectItem;

            var choiceWindow = new LineEndingChoice(item.Name, this.DefaultLineEnding);
            if (choiceWindow.ShowDialog() == true && choiceWindow.LineEndings != LineEndingsChanger.LineEndings.None)
            {
                var supportedFileFormats = this.SupportedFileFormats;
                var supportedFileNames = this.SupportedFileNames;

                if (item.Name.EndsWithAny(supportedFileFormats) || item.Name.EqualsAny(supportedFileNames))
                {
                    System.Threading.Tasks.Task.Run(() =>
                        {
                            Output("Unifying started...\n");
                            var numberOfChanges = 0;
                            var stopWatch = new Stopwatch();
                            stopWatch.Start();
                            UnifyLineEndingsInProjectItem(item, choiceWindow.LineEndings, ref numberOfChanges);
                            stopWatch.Stop();
                            var secondsElapsed = stopWatch.ElapsedMilliseconds / 1000.0;
                            VsShellUtilities.ShowMessageBox(this, string.Format("Successfully changed {0} line endings in {1} seconds!", numberOfChanges, secondsElapsed), "Success",
                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                            Output(string.Format("Done in {0} seconds\n", secondsElapsed));
                        });
                }
                else
                {
                    VsShellUtilities.ShowMessageBox(this, "This is not a valid source file!", "Error",
                        OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            }
        }