Esempio n. 1
0
 private static void EraseProgressLogTrace(int cursorTop)
 {
     Console.CursorTop  = cursorTop;
     Console.CursorLeft = 0;
     ConsoleUtils.ShowNLinesOnConsole(4, ConsoleColor.Black);
     Console.CursorTop  = cursorTop;
     Console.CursorLeft = 0;
 }
            internal void Display(ConsoleColor backColor)
            {
                Console.CursorTop  = m_CursorTop;
                Console.CursorLeft = 0;
                ConsoleUtils.ShowNLinesOnConsole(m_NbLines, backColor);

                Console.CursorTop       = m_CursorTop;
                Console.CursorLeft      = 0;
                Console.BackgroundColor = backColor;
                m_DisplayProc(m_DisplayInfo);

                // Reset cursor to beginning of the row displayed to avoid cursor trace!
                Console.CursorTop  = m_CursorTop;
                Console.CursorLeft = 0;
            }
        private static UpDownEnterAllNextQuit ConsoleAskUpDownEnterAllNextQuit(bool showMenu, bool showEnd, int cursorTop)
        {
            if (showMenu)
            {
                Debug.Assert(Console.CursorTop == cursorTop);
                Console.WriteLine();
                Console.CursorLeft      = 0;
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Open source decl? Up/Down/Enter -- " + (showEnd ? "" : "Show Next? n  -- Show All? a -- ") + "Stop? any key");
                Console.ForegroundColor = ConsoleColor.White;
            }

            var consoleKeyInfo = Console.ReadKey();

            var keyChar = Char.ToLower(consoleKeyInfo.KeyChar);

            if (!showEnd && (keyChar == 'n' || keyChar == 'a'))
            {
                // Erase the menu!
                Console.CursorTop = cursorTop;
                ConsoleUtils.ShowNLinesOnConsole(4, ConsoleColor.Black);
                Console.CursorTop = cursorTop;
                // HACK: need to erase a second time, sometime erasing just once is not enought??
                ConsoleUtils.ShowNLinesOnConsole(4, ConsoleColor.Black);
                Console.CursorTop = cursorTop;

                return(keyChar == 'n' ? UpDownEnterAllNextQuit.Next : UpDownEnterAllNextQuit.All);
            }

            switch (consoleKeyInfo.Key)
            {
            case ConsoleKey.DownArrow:
                return(UpDownEnterAllNextQuit.Down);

            case ConsoleKey.UpArrow:
                return(UpDownEnterAllNextQuit.Up);

            case ConsoleKey.Enter:
                return(UpDownEnterAllNextQuit.Enter);
            }

            return(UpDownEnterAllNextQuit.Quit);
        }
Esempio n. 4
0
        internal static bool TryGetAssembliesToCompareAndAnalyzeThem(out ICompareContext compareContext)
        {
            var analysisManager = new NDependServicesProvider().AnalysisManager;

            var top = Console.CursorTop;

            Console.CursorLeft = 0;

            IProject           projectOlder, projectNewer;
            IAnalysisResultRef analysisResultRefOlder, analysisResultRefNewer;

            Console.WriteLine("Please choose older and newer versions of the code base...");

            bool dialogOk = analysisManager.ShowDialogBuildComparison(
                ConsoleUtils.MainWindowHandle,
                out projectOlder,
                out analysisResultRefOlder,
                out projectNewer,
                out analysisResultRefNewer);

            if (!dialogOk)
            {
                compareContext = null;
                return(false);
            }


            var nbLinesToErase = Console.CursorTop - top;

            Console.CursorTop  = top;
            Console.CursorLeft = 0;
            ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase, ConsoleColor.Black);
            Console.CursorTop  = top;
            Console.CursorLeft = 0;


            //
            // Load or analyze
            //
            IAnalysisResult analysisResultOlder, analysisResultNewer;

            if (analysisResultRefOlder == null)
            {
                Debug.Assert(projectOlder != null);
                Console.WriteLine("Analyze older version of assemblies");
                analysisResultOlder = RunAnalysisShowProgressOnConsole(projectOlder);
            }
            else
            {
                Console.WriteLine("Load older analysis result");
                analysisResultOlder = LoadAnalysisShowProgressOnConsole(analysisResultRefOlder);
            }

            if (analysisResultRefNewer == null)
            {
                Debug.Assert(projectNewer != null);
                Console.WriteLine("Analyze newer version of assemblies");
                analysisResultNewer = RunAnalysisShowProgressOnConsole(projectNewer);
            }
            else
            {
                Console.WriteLine("Load newer analysis result");
                analysisResultNewer = LoadAnalysisShowProgressOnConsole(analysisResultRefNewer);
            }

            //
            // Re-erase
            //
            var nbLinesToErase2 = Console.CursorTop - top;

            Console.CursorTop  = top;
            Console.CursorLeft = 0;
            ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase2, ConsoleColor.Black);
            Console.CursorTop  = top;
            Console.CursorLeft = 0;


            //
            // Show compare description
            //
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("Comparing: ");
            Console.ForegroundColor = ConsoleColor.White;
            ShowAnalysisResultRefDescription(analysisResultOlder.AnalysisResultRef);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("     with: ");
            Console.ForegroundColor = ConsoleColor.White;
            ShowAnalysisResultRefDescription(analysisResultNewer.AnalysisResultRef);

            compareContext = analysisResultNewer.CodeBase.CreateCompareContextWithOlder(analysisResultOlder.CodeBase);
            return(true);
        }
Esempio n. 5
0
        internal static bool TryChooseProject(out IProject project)
        {
            var ndependServicesProvider = new NDependServicesProvider();
            var projectManager          = ndependServicesProvider.ProjectManager;
            var visualStudioManager     = ndependServicesProvider.VisualStudioManager;

CHOOSE_PROJECT:
            var top = Console.CursorTop;

            Console.CursorLeft = 0;

            Console.WriteLine("Please choose...");
            Console.WriteLine("  a) an existing NDepend project");
            Console.WriteLine("  b) one or several Visual Studio solutions to analyze");
            Console.WriteLine("  c) one or several .NET assemblies to analyze");
            Console.WriteLine("");
            var c = Char.ToLower(Console.ReadKey().KeyChar);

            Console.WriteLine();

            switch (c)
            {
            case 'a':
                if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project))
                {
                    goto TRY_AGAIN;
                }
                break;

            case 'b': {
                ICollection <IAbsoluteFilePath> solutions;
                if (!visualStudioManager.ShowDialogSelectVisualStudioSolutionsOrProjects(ConsoleUtils.MainWindowHandle, out solutions))
                {
                    goto TRY_AGAIN;
                }
                var assemblies = new List <IAbsoluteFilePath>();
                foreach (var solution in solutions)
                {
                    assemblies.AddRange(visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(solution));
                }
                project = projectManager.CreateTemporaryProject(assemblies, TemporaryProjectMode.Temporary);
                break;
            }

            case 'c': {
                ICollection <IAbsoluteFilePath> assemblies;
                if (!projectManager.ShowDialogSelectAssemblies(ConsoleUtils.MainWindowHandle, out assemblies))
                {
                    goto TRY_AGAIN;
                }
                project = projectManager.CreateTemporaryProject(assemblies, TemporaryProjectMode.Temporary);
                break;
            }

            case (char)Keys.Escape:  // ESC to exit!
                project = null;
                return(false);

            default:
TRY_AGAIN:
                var nbLinesToErase = Console.CursorTop - top;
                Console.CursorTop  = top;
                Console.CursorLeft = 0;
                ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase, ConsoleColor.Black);
                Console.WriteLine("(ESC to exit)");
                Console.CursorTop  = top;
                Console.CursorLeft = 0;
                goto CHOOSE_PROJECT;
            }
            Debug.Assert(project != null);



            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("Project selected: ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(project.Properties.Name);
            Console.WriteLine();
            return(true);
        }