예제 #1
0
        // 测试连通性
        private void btnPing_Click(object sender, EventArgs e)
        {
            if (!txtAddrHasText)
            {
                SystemSounds.Exclamation.Play();
                MessageBox.Show(this, "Target address was not specified.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // 显示加载中窗体
            ProgressSpecifier ps = new ProgressSpecifier();

            ps.Show();

            // 尝试ping
            Ping ping = new Ping();

            byte[] sendBuf = Encoding.UTF8.GetBytes("Ping test");
            int    timeout = 500;

            PingReply rep = ping.Send(txtAddr.Text, timeout, sendBuf);

            ps.Close();
            if (rep.Status == IPStatus.Success)
            {
                MessageBox.Show(this, "Target is connectable.\nRemote Server: " + rep.Address + "\nRoundtrip Time: " + rep.RoundtripTime + " ms", "Ping Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(this, "Target is not connectable.\nRemote Server: " + rep.Address + "\nTimeout Occurred.", "Ping Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        // 检查PORT是否被占用,提示用户
        private void btnCheck_Click(object sender, EventArgs e)
        {
            if (!isPortSet)
            {
                SystemSounds.Exclamation.Play();
                MessageBox.Show(this, "Monitor port was not specified.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // 显示加载中窗体
            ProgressSpecifier ps = new ProgressSpecifier();

            ps.Show();

            bool rep = isTCPPortInUse(Int32.Parse(this.txtPort.Text));

            ps.Close();
            if (rep == false)
            {
                MessageBox.Show(this, "This port is not in use at this time.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(this, "This port is occupied at this time. Please change one.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
예제 #3
0
        // 点击了开始按钮
        private void btnStart_Click(object sender, EventArgs e)
        {
            filePath = txtPath.Text;
            port     = txtPort.Text;

            // 设置conc图像
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
            this.imgConc.Image = (System.Drawing.Image)(resources.GetObject("imgConc.Image"));

            // 显示加载中窗体
            progressBar.Style = ProgressBarStyle.Marquee;
            Thread thProgInd = new Thread(new ThreadStart(ShowProgressIndicator));

            thProgInd.Start();

            if (!txtPathHasText || !txtAddrHasText || !txtPortHasText)
            {
                thProgInd.Abort();
                ps.Close();
                progressBar.Style = ProgressBarStyle.Blocks;
                SystemSounds.Exclamation.Play();
                MessageBox.Show(this, "File/directory path, target address or target port was not specified.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!File.Exists(txtPath.Text) && !Directory.Exists(txtPath.Text))
            {
                thProgInd.Abort();
                ps.Close();
                progressBar.Style = ProgressBarStyle.Blocks;
                SystemSounds.Exclamation.Play();
                MessageBox.Show(this, "Bad file or directory: " + txtPath.Text, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                // 可以开始
                // 命令行执行
                bool isStartOK = StartConc("cl --mon-port=" + concMonitor + " --errinf-port=" + concErrInfo);
                if (isStartOK != true)
                {
                    SystemSounds.Exclamation.Play();
                    MessageBox.Show(this, "the conc core refuses to run.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // 设置控件不可用
                btnStart.Enabled     = false;
                btnAdv.Enabled       = false;
                btnBrwFile.Enabled   = false;
                btnBrwFolder.Enabled = false;
                this.txtDialogue.Clear();

                // 联系conc,及连接它的各种通讯端口
                serverAddr = txtAddr.Text;
                EstablishConnect9898();
                EstablishConnect5656();
                this.txtDialogue.Visible = true;
                this.progressBar.Visible = true;

                thProgInd.Abort();
                ps.Close();
                progressBar.Style = ProgressBarStyle.Blocks;

                this.txtStatus.Text = "Sending";
            }
        }