예제 #1
0
        /// <summary>
        /// 修改按钮
        /// </summary>
        /// <param name="section"></param>
        public void updateButton(String section)
        {
            Button btn = (Button)flowLayoutPanel.Controls[section];

            MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
            String title = monitorSection.title;

            btn.Text = title;
        }
예제 #2
0
        private void UpdateForm_Load(object sender, EventArgs e)
        {
            MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
            String title = monitorSection.title;
            String url   = monitorSection.url;
            String warn  = monitorSection.warn;

            UpdateForm_Title_TextBox.Text    = title;
            UpdateForm_Url_TextBox.Text      = url;
            UpdateForm_Warn_RichTextBox.Text = warn;
        }
예제 #3
0
        /**
         * 右键停止按钮点击事件
         * */
        private void BtnRightStopClick(Object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
            String            section  = (String)menuItem.Tag;

            // 停止监听
            iniUtils.IniWriteValue(Config.MonitorIniPath, section, "stat", "0");
            // 按钮背景置灰
            Button button = (Button)ControlUtils.GetControlInstance(flowLayoutPanel, section);

            setButtonBackColor(button, Color.LightGray);
            // 缓存数据更新为停止
            MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
            monitorSection.stat = "0";
            MonitorSections.updateMonitor(section, monitorSection);
        }
예제 #4
0
        private void BtnMouseHover(Object sender, EventArgs e)
        {
            Button currentBtn = (Button)sender;
            String section    = currentBtn.Name;

            MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
            String title = monitorSection.title;

            // 设置显示样式
            //toolTip1.AutoPopDelay = 5000;//提示信息的可见时间
            toolTip1.InitialDelay = 200;  //事件触发多久后出现提示
            toolTip1.ReshowDelay  = 0;    //指针从一个控件移向另一个控件时,经过多久才会显示下一个提示框
            toolTip1.ShowAlways   = true; //是否显示提示框
            //  设置伴随的对象.
            toolTip1.SetToolTip(currentBtn, title);
        }
예제 #5
0
        /// <summary>
        /// 定时器任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_total_Tick(object sender, EventArgs e)
        {
            List <String> sectionList = MonitorSections.getAllSections();

            for (int i = 0; i < sectionList.Count; i++)
            {
                String section = sectionList[i];
                MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
                String title = monitorSection.title;
                String url   = monitorSection.url;
                String warn  = monitorSection.warn;
                String stat  = monitorSection.stat;
                // 根据section获取控件
                object buttonObj = ControlUtils.GetControlInstance(flowLayoutPanel, section);

                if ("".Equals(stat) || "1".Equals(stat))
                {
                    Monitor monitor = new Monitor(title, url, warn, ((Button)buttonObj));
                    // 查找线程字典中是否已经存在该线程
                    if (dic.ContainsKey(section))
                    {
                        Thread sectonThread = dic[section];
                        if (sectonThread.ThreadState.Equals(ThreadState.Running))
                        {
                            // 线程还在运行中
                            continue;
                        }
                        else
                        {
                            sectonThread = new Thread(new ThreadStart(monitor.monitorUrl));
                            sectonThread.Start();
                        }
                    }
                    else
                    {
                        Thread sectonThread = new Thread(new ThreadStart(monitor.monitorUrl));
                        sectonThread.Start();
                        dic.Add(section, sectonThread);
                    }
                }
                else
                {
                    ((Button)buttonObj).BackColor = Color.LightSteelBlue;
                }
            }
        }
예제 #6
0
        private void UpdateForm_Save_Button_Click(object sender, EventArgs e)
        {
            String        title     = UpdateForm_Title_TextBox.Text;
            String        url       = UpdateForm_Url_TextBox.Text;
            String        warn      = UpdateForm_Warn_RichTextBox.Text;
            Boolean       checkFlag = true;
            StringBuilder checkMsg  = new StringBuilder();

            if ("".Equals(title))
            {
                checkFlag = false;
                checkMsg.Append("名称未填写\r\n");
            }
            if ("".Equals(url))
            {
                checkFlag = false;
                checkMsg.Append("地址未填写\r\n");
            }
            if (!checkFlag)
            {
                MessageBox.Show(checkMsg.ToString(), "错误");
            }
            else
            {
                /** 数据正常,修改ini数据,执行StartForm添加按钮和新增rdp文件操作 */
                // 生成title
                iniUtils.IniWriteValue(Config.MonitorIniPath, section, "title", title);
                iniUtils.IniWriteValue(Config.MonitorIniPath, section, "url", url);
                iniUtils.IniWriteValue(Config.MonitorIniPath, section, "warn", warn);
                /* 生成新INI结束 ************************/
                // sections缓存数据新增
                MonitorSections.MonitorSection monitorSection = MonitorSections.getMonitorByKey(section);
                monitorSection.title = title;
                monitorSection.url   = url;
                monitorSection.warn  = warn;
                MonitorSections.updateMonitor(section, monitorSection);
                /* StartForm中更新服务按钮 *************/
                mainForm.updateButton(section);
                /* 更新服务按钮完成****** *************/
                // 关闭新增窗口
                UpdateForm_Cancel_Button_Click(sender, e);
            }
        }