예제 #1
0
파일: ConsoleUI.cs 프로젝트: thbin/TraceLab
        public static void Run(ApplicationViewModel application)
        {
            if (ConsoleInstance != null)
            {
                throw new InvalidOperationException("Console UI is already running!");
            }

            ConsoleInstance = new ConsoleUI(application);

            ConsoleInstance.ComponentLibraryScannningWaiter.Wait();

            ConsoleInstance.DisplayExistingLogs();
            ConsoleInstance.StartListenToLogEvents();

            ConsoleInstance.Exit = false;

            while (!ConsoleInstance.Exit)
            {
                Console.Write("#> ");
                string input = Console.ReadLine();
                if (ConsoleInstance.ParseInput(input) == false)
                {
                    Console.WriteLine("Command is incorrect. Display commands using ?");
                }
            }

            //cleanup
            LogViewModel.DestroyLogTargets();
        }
예제 #2
0
        /// <summary>
        /// Handler for closing main window event.
        /// The handler activates exit action.
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void MainWindow_DeleteEvent(object o, DeleteEventArgs args)
        {
            m_mainWindowCounter--;

            //quit application if it was the last window
            if (m_mainWindowCounter == 0)
            {
                Application.Quit();
                args.RetVal = true;

                //destroys all nlog rule targets
                LogViewModel.DestroyLogTargets();
            }
        }
예제 #3
0
        /// <summary>
        /// Handler for closing main window event.
        /// The handler activates exit action.
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void MainWindow_DeleteEvent(object o, DeleteEventArgs args)
        {
            bool quitApp = true;


            if (m_applicationContext.Application.Experiment != null && (m_applicationContext.Application.Experiment.IsModified || m_applicationContext.Application.Experiment.ExperimentInfo.IsModified))
            {
                //show a new dialog to warn the user he's closing the program without saving
                ResponseType response = ResponseType.None;

                Dialog dialog = new Dialog(
                    "Modified Experiment Not Saved",
                    null,
                    DialogFlags.Modal,
                    "Yes", ResponseType.Yes,
                    "No", ResponseType.No
                    );

                dialog.VBox.Add(new Label(CLOSE_MAIN_WINDOW_WARN_MSG));
                dialog.ShowAll();

                response = (ResponseType)dialog.Run();

                if ((response == ResponseType.Yes))
                {
                    m_mainWindowCounter--;
                }
                else
                {
                    args.RetVal = true;
                    quitApp     = false;
                }
                dialog.Destroy();
            }
            else
            {
                m_mainWindowCounter--;
            }


            if (m_mainWindowCounter == 0 && quitApp)
            {
                Application.Quit();
                args.RetVal = true;

                //destroys all nlog rule targets
                LogViewModel.DestroyLogTargets();
            }
        }