示例#1
0
        //private void cboStyle_DrawItem(object sender, DrawItemEventArgs e)
        //{
        //    if (e.Index >= 0)
        //    {
        //        ComboBox combo = sender as ComboBox;
        //        e.Graphics.DrawString(combo.Items[e.Index].ToString(), e.Font, new SolidBrush(Color.FromName(combo.Items[e.Index].ToString())), new Point(e.Bounds.X, e.Bounds.Y));
        //    }
        //}
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ServerInfo server = m_Servers.Values.First(entry => entry.Name == cboServer.Text);
            AllowInfo  ainfo  = AllowInfo.Create(txtChannel.Text, txtItem.Text, txtSeconds.Text, STYLE.ToString());

            if (ainfo == null)
            {
                return;
            }
            if (!Allows.ContainsKey(server))
            {
                Allows.Add(server, new List <AllowInfo>());
                Allows[server].Add(ainfo);
            }
            else
            {
                Allows[server].Add(ainfo);
            }
            if (!m_Monitors.ContainsKey(server))
            {
                m_Monitors.Add(server, new Monitor(server));
                m_Monitors[server].Start();
            }

            listView1.Items.Add(ainfo.ListViewItem(server));
        }
示例#2
0
        public frmStopNotify()
        {
            InitializeComponent();

            Text = niTask.Text = VersionInfo();
            if (INI == null)
            {
                var parser = new FileIniDataParser();
                INI = parser.ReadFile("Config.ini");
            }

            var items = INI["SETTING"]["SERVER"].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in items)
            {
                var server = ServerInfo.Create(item.Split('|'));
                if (server == null || m_Servers.ContainsKey(server.Key))
                {
                    continue;
                }
                m_Servers.Add(server.Key, server);
            }
            cboServer.Items.AddRange(m_Servers.Values.Select(e => e.Name).ToArray());

            var allows = INI["SETTING"]["STOPNOTIFY"].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var allow in allows)
            {
                var info = allow.Split('|');
                if (!m_Servers.ContainsKey(info[0]))
                {
                    continue;
                }
                var server = m_Servers[info[0]];
                var ainfo  = AllowInfo.Create(info);
                //Monitor m = new Monitor(server, ainfo);
                if (!Allows.ContainsKey(server))
                {
                    Allows.Add(server, new List <AllowInfo>());
                    Allows[server].Add(ainfo);
                }
                else
                {
                    Allows[server].Add(ainfo);
                }
                if (!m_Monitors.ContainsKey(server))
                {
                    //m_Monitors.Add(server, new Monitor(server, ainfo));
                    m_Monitors.Add(server, new Monitor(server));
                    m_Monitors[server].Start();
                }
                //else
                //{
                //    m_Monitors[server].Allow(ainfo);
                //}
                listView1.Items.Add(ainfo.ListViewItem(server));
            }

            //niTask.ShowBalloonTip(10000, "AAA", "AAA", ToolTipIcon.Error);
            //new frmMain().Show();
        }