예제 #1
0
        private void onPause()
        {
            toolStripButtonPause.Checked = true;
            toolStripButtonRun.Checked   = false;
            if (state == runState.running)
            {
                state = runState.paused;
                Thread _ThreadPause = new Thread(new ThreadStart(Pause));
                _ThreadPause.Start();

                UpdateProperties();
                if (LDDebug.breakLabels.Contains(label))
                {
                    string labelText = LDDebug.breakText[LDDebug.breakLabels.IndexOf(label)];
                    if (checkedListBoxLabels.Items.Contains(labelText))
                    {
                        checkedListBoxLabels.SelectedIndex = checkedListBoxLabels.Items.IndexOf(labelText);
                    }
                    //toolStripStatusLabelBP.Text = labelText.Length > 30 ? labelText.Substring(0, System.Math.Min(labelText.Length, 30)) + "..." : labelText;
                    toolStripStatusLabelBP.Text = labelText;
                }
                else
                {
                    //toolStripStatusLabelBP.Text = label.Length > 30 ? label.Substring(0, System.Math.Min(label.Length, 30)) + "..." : label;
                    toolStripStatusLabelBP.Text = label;
                }
                while (toolStripStatusLabelBP.Text.Contains("  "))
                {
                    toolStripStatusLabelBP.Text = toolStripStatusLabelBP.Text.Replace("  ", " ");
                }
            }
        }
예제 #2
0
        public void workRunMMDK()
        {
            try
            {
                logMMDK($"正在等待Mirai启动...");

                while (State != runState.mmdkInit)
                {
                    Thread.Sleep(500);
                    if (State == runState.exit)
                    {
                        // exit
                        logMMDK("退出bot");
                        return;
                    }
                }

                logMMDK($"Mirai启动完成,开始启动bot...");

                bot = new MainProcess();
                bot.processOutput += new processOutputHandler(logMMDK);
                bot.Init(config, miraiInfo);

                State = runState.ok;
                logMMDK($"bot启动完成,开始接受数据。");
            }
            catch (Exception ex)
            {
                logMMDK(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
예제 #3
0
        public void workRunMirai()
        {
            try
            {
                //logMirai($"正在启动Mirai...");
                State        = runState.miraiInit;
                MiraiProcess = new Process();

                MiraiProcess.StartInfo.WorkingDirectory = libPath;
                //MiraiProcess.StartInfo.FileName = miraiPath;
                MiraiProcess.StartInfo.FileName               = $"{libPath}/{miraiPath}";
                MiraiProcess.StartInfo.UseShellExecute        = false;
                MiraiProcess.StartInfo.CreateNoWindow         = true;
                MiraiProcess.StartInfo.RedirectStandardOutput = true;
                MiraiProcess.StartInfo.RedirectStandardInput  = true;
                MiraiProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8;

                MiraiProcess.Start();
                MiraiProcess.StandardInput.AutoFlush = true;
                //MiraiProcess.StandardInput.WriteLine($"");
                //MiraiProcess.StandardInput.WriteLine("exit");
                //MiraiProcess.StandardInput.Close();


                var reader = MiraiProcess.StandardOutput;


                while (!reader.EndOfStream && State != runState.exit)
                {
                    string line = reader.ReadLine();
                    logMirai(line);

                    if (line.Contains("启动完成"))
                    {
                        // ok
                        // State = runState.mmdkInit;
                        string cmd = $"login {config["qq"]} {config["passwd"]}";
                        logMirai($">> {cmd}");
                        MiraiProcess.StandardInput.WriteLine(cmd);
                    }
                    else if (line.Contains("Login successful") && State == runState.miraiInit)
                    {
                        // ok 2
                        State = runState.mmdkInit;
                    }
                }
                //MiraiProcess.StandardInput.WriteLine("exit");
                //MiraiProcess.StandardInput.Close();

                logMirai("退出Mirai");
                //output = MiraiProcess.StandardOutput.ReadToEnd();
                MiraiProcess.WaitForExit();
            }
            catch (Exception ex)
            {
                logMirai(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
예제 #4
0
 private void onResume()
 {
     updateBreakpoints();
     toolStripButtonPause.Checked = false;
     toolStripButtonRun.Checked   = true;
     if (state == runState.paused)
     {
         nodeSelected      = null;
         textBoxValue.Text = "";
         state             = runState.running;
     }
 }
예제 #5
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                config.save();
                if (MiraiProcess != null)
                {
                    bot.Exit();
                    SystemInfo.EndProcess(MiraiProcess.ProcessName);
                    SystemInfo.EndProcess("java");
                    MiraiProcess.Dispose();
                    //MiraiProcess.Kill();
                    //MiraiProcess.StandardInput.WriteLine("exit");
                }


                State = runState.exit;

                //Environment.Exit(0);
            }
            catch
            {
            }
        }
예제 #6
0
 private void onExit()
 {
     state           = runState.running;
     LDDebug.running = false;
 }
예제 #7
0
파일: FormDebug.cs 프로젝트: litdev1/LitDev
 private void onResume()
 {
     updateBreakpoints();
     toolStripButtonPause.Checked = false;
     toolStripButtonRun.Checked = true;
     if (state == runState.paused)
     {
         nodeSelected = null;
         textBoxValue.Text = "";
         state = runState.running;
     }
 }
예제 #8
0
파일: FormDebug.cs 프로젝트: litdev1/LitDev
        private void onPause()
        {
            toolStripButtonPause.Checked = true;
            toolStripButtonRun.Checked = false;
            if (state == runState.running)
            {
                state = runState.paused;
                Thread _ThreadPause = new Thread(new ThreadStart(Pause));
                _ThreadPause.Start();

                UpdateProperties();
                if (LDDebug.breakLabels.Contains(label))
                {
                    string labelText = LDDebug.breakText[LDDebug.breakLabels.IndexOf(label)];
                    if (checkedListBoxLabels.Items.Contains(labelText)) checkedListBoxLabels.SelectedIndex = checkedListBoxLabels.Items.IndexOf(labelText);
                    //toolStripStatusLabelBP.Text = labelText.Length > 30 ? labelText.Substring(0, System.Math.Min(labelText.Length, 30)) + "..." : labelText;
                    toolStripStatusLabelBP.Text = labelText;
                }
                else
                {
                    //toolStripStatusLabelBP.Text = label.Length > 30 ? label.Substring(0, System.Math.Min(label.Length, 30)) + "..." : label;
                    toolStripStatusLabelBP.Text = label;
                }
                while (toolStripStatusLabelBP.Text.Contains("  ")) toolStripStatusLabelBP.Text = toolStripStatusLabelBP.Text.Replace("  ", " ");
            }
        }
예제 #9
0
파일: FormDebug.cs 프로젝트: litdev1/LitDev
 private void onExit()
 {
     state = runState.running;
     LDDebug.running = false;
 }