Пример #1
0
        // ログに内容を追加
        private void addLog(string str)
        {
            var dt       = DateTime.Now;
            var bindData = DataContext as MainWindowDC;

            bindData.LoggingText += dt.ToString("hh:mm:ss ") + str + "\n";
            LoggingTextBox.ScrollToEnd();
        }
Пример #2
0
 //! データをLoggingTextBoxにロギング
 public void AddText(string text)
 {
     if (LoggingTextBox.InvokeRequired)
     {
         Invoke(new AddTextLog(AddText), new object[] { text });
         return;
     }
     LoggingTextBox.AppendText(text + "\n");
 }
Пример #3
0
        private void WriteLogLine()
        {
            if (string.IsNullOrWhiteSpace(LoggingTextBox.Text))
            {
                return;
            }

            _logManager.WriteLine(LoggingTextBox.Text);

            LoggingTextBox.Text = string.Empty;
            LoggingTextBox.Focus();
        }
Пример #4
0
 internal void Log(string message)
 {
     if (LoggingTextBox.InvokeRequired)
     {
         LoggingTextBox.Invoke(new Action(() => Log(message)));
     }
     else
     {
         AppendToLog(message);
         AppendToLog(Environment.NewLine);
         AppendToLog(Environment.NewLine);
     }
 }
Пример #5
0
 private void AppendToLog(string message)
 {
     LoggingTextBox.AppendText(message);
 }
Пример #6
0
        //! サーバ群をONにする
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (on_flg)
            {
                return;
            }
            //! ログをクリアする
            LoggingTextBox.Text = "";
            LoggingTextBox.Refresh();

            //! プロキシサーバを起動させる
            proxy = new Sample.HTTProxy();
            {
                //! 入力にプロキシを使用する場合の処理
                if (InProxyCheckBox.Checked)
                {
                    proxy.SetUpProxy(InHostTextBox.Text, int.Parse(InPortTextBox.Text));
                }
            }
            {
                //! 出力の状態によって初期化方法を変える
                var port0      = int.Parse(OutPort0TextBox.Text);
                var port1      = int.Parse(OutPort1TextBox.Text);
                var port2      = int.Parse(OutPort2TextBox.Text);
                var branch1Flg = (OutBranch1CheckBox.Enabled && OutBranch1CheckBox.Checked);
                var branch2Flg = (OutBranch2CheckBox.Enabled && OutBranch2CheckBox.Checked);
                if (branch1Flg)
                {
                    if (branch2Flg)
                    {
                        proxy.Start(port0, port1, port2);
                    }
                    else
                    {
                        proxy.Start(port0, port1);
                    }
                }
                else
                {
                    if (branch2Flg)
                    {
                        proxy.Start(port0, port2);
                    }
                    else
                    {
                        proxy.Start(port0);
                    }
                }
            }
            {
                //! ダミーとなるサーバも起動させる
                var dummyPort1 = int.Parse(DummyPort1TextBox.Text);
                var dummyPort2 = int.Parse(DummyPort2TextBox.Text);
                var dummy1Flg  = (DummyPort1CheckBox.Enabled && DummyPort1CheckBox.Checked);
                var dummy2Flg  = (DummyPort2CheckBox.Enabled && DummyPort2CheckBox.Checked);
                if (dummy1Flg)
                {
                    listener1 = new HttpListener();
                    string prefix = string.Format("http://{0}:{1}/", IPAddress.Loopback, dummyPort1);
                    listener1.Prefixes.Add(prefix);
                    try {
                        listener1.Start();
                        AddText(string.Format("DummyPort1({0}) : Started.", dummyPort1));
                    } catch (HttpListenerException ex) {
                        AddText(string.Format("Exception at starting HttpListener\n{0}", ex.ToString()));
                    }
                }
                if (dummy2Flg)
                {
                    listener2 = new HttpListener();
                    string prefix = string.Format("http://{0}:{1}/", IPAddress.Loopback, dummyPort2);
                    listener2.Prefixes.Add(prefix);
                    try {
                        listener2.Start();
                        AddText(string.Format("DummyPort2({0}) : Started.", dummyPort2));
                    } catch (HttpListenerException ex) {
                        AddText(string.Format("Exception at starting HttpListener\n{0}", ex.ToString()));
                    }
                }
            }
            {
                //! on_flgおよびボタンの状態を変更する
                on_flg = true;
                StartButton.Enabled = false;
                StopButton.Enabled  = true;
            }
        }