Example #1
0
        //OutputDataReceivedイベントハンドラ
        //行が出力されるたびに呼び出される
        void OutputDataReceived(object sender,
                                DataReceivedEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Data))
            {
                // インストール・再インストール時の進捗は表示しない
                if (e.Data.IndexOf("%") < 0)
                {
                    Action action = () =>
                    {
                        // デバイスをコンボボックスに追加する
                        if (currentCommand == Command.DEVICES || currentCommand == Command.PREDEVICES)
                        {
                            int index = e.Data.IndexOf("\tdevice");
                            if (index > 0)
                            {
                                ComboBoxDevices.Items.Add(e.Data.Substring(0, index));
                                ComboBoxDevices.SelectedIndex = 0;
                            }
                        }

                        // 起動時の接続確認は表示しない
                        if (currentCommand != Command.PREDEVICES)
                        {
                            //リッチテキストボックスにフォーカスを移動
                            RichTextBoxResult.Focus();
                            //出力された文字列を表示する
                            RichTextBoxResult.AppendText(e.Data + Environment.NewLine);
                        }
                    };
                    BeginInvoke(action);
                }
            }
        }
Example #2
0
 //ErrorDataReceivedイベントハンドラ
 void ErrorDataReceived(object sender,
                        DataReceivedEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Data))
     {
         Action action = () =>
         {
             //リッチテキストボックスにフォーカスを移動
             RichTextBoxResult.Focus();
             //エラー出力された文字列を表示する
             RichTextBoxResult.AppendText(e.Data + Environment.NewLine);
         };
         BeginInvoke(action);
     }
 }