Exemplo n.º 1
0
        /// <summary>
        /// Used to clean up after a  plot has been closed, as the process is simply put into the background.
        /// If this is called when the process does not exist yet, it does nothing.
        /// </summary>
        public static void ClosePlot()
        {
            Console.WriteLine("Close Requested...");
            //PlotExe.CloseMainWindow();
            //Console.WriteLine(PlotExe.ExitCode);
            //PlotExe.Kill();
            //PlotExe.WaitForExit();

            int errorCode = 0;

            if (PlotExe.HasExited)
            {
                errorCode = PlotExe.ExitCode;
            }
            PlotExe.Dispose();

            if (errorCode == 15)
            {
                Application.OpenForms.OfType <LoginScreen>().SingleOrDefault().Close();
            }

            MPAiSoundMainMenu menu = new MPAiSoundMainMenu();

            menu.Show();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method called by the button to show the  plot.
        /// If there is already a  plot running, it is brought into the foreground.
        /// If not, a new process is created.
        ///
        /// requestedPlotType determines if RunPlot runs a Vowel or Formant Plot.
        /// requestedVoiceType determines if we use heratage/ modern and masculine/feminine for the plots.
        /// </summary>
        public static void RunPlot(PlotType?requestedPlotType, VoiceType requestedVoiceType)
        {
            exitRequest = false;
            plotType    = requestedPlotType;
            voiceType   = requestedVoiceType;

            var deviceEnum = new MMDeviceEnumerator();
            var devices    = deviceEnum.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToList();

            if (devices.Count == 0)
            {
                if (plotType == PlotType.VOWEL_PLOT)
                {
                    MPAiMessageBoxFactory.Show("No recording device detected.\nVowel Plot requires a working microphone to function correctly.\nPlease plug in Microphone, or update Drivers.");
                }
                else if (plotType == PlotType.FORMANT_PLOT)
                {
                    MPAiMessageBoxFactory.Show("No recording device detected.\nFormant Plot requires a working microphone to function correctly.\nPlease plug in Microphone or update Drivers.");
                }

                MPAiSoundMainMenu menu = new MPAiSoundMainMenu();
                menu.Show();
            }
            else
            {
                foreach (var process in Process.GetProcessesByName("MPAiVowelRunner"))
                {
                    process.Kill();
                    process.WaitForExit();
                    process.Dispose();
                }
                foreach (var process in Process.GetProcessesByName("MPAiPlotRunner"))
                {
                    process.Kill();
                    process.WaitForExit();
                    process.Dispose();
                }
                if (PlotStarted(GetPlotTitle()) == 1)
                {
                    StartPlot();
                }
                else
                {
                    ShowPlot(GetPlotTitle());
                }
            }
        }