Example #1
0
 private void InitForm_Load(object sender, EventArgs e)
 {
     blacklist = new Blacklist("blacklist.txt");
     server    = new CmdServer("0.0.0.0", 5566, (c) => {
         Log(String.Format("s1 Client {0} connect\n", new object[] { c.ClientInfo }));
         // send diff with default blacklist
         c.SendAsync(blacklist.ToByteArray());
         if (IsLockScreen)
         {
             c.SendAsync(new byte[] { 2, 0 }); // LockScreen event
         }
     }, null, (c) => {
         Log(String.Format("s1 Client {0} disconnect\n", new object[] { c }));
     });
     stream_server = new CmdServer("0.0.0.0", 5567, (c) =>
     {
         Log(String.Format("s2 Client {0} connect\n", new object[] { c.ClientInfo }));
     }, (c) =>
     {
         if (!IsLockScreen)
         {
             c.Close();
             return(false);
         }
         return(true);
     }, (c) =>
     {
         Log(String.Format("s2 Client {0} disconnect\n", new object[] { c }));
     });
     this.Message.Text = "Bind CmdServer Success\r\n";
     form1             = new Form1(server, this, blacklist);
     form1.Show();
 }
Example #2
0
        public Form1(CmdServer server, InitForm msgForm, Blacklist blist)
        {
            this.cmdServer = server;
            this.msgForm   = msgForm;
            InitializeComponent();
            this.blacklist = new BlacklistControl(listView1, blist);
            addForm        = new AddForm();

            listView1.ContextMenuStrip = ClsMServer.MenuFactory.Produce(
                () =>
            {
                DialogResult r = addForm.ShowDialog();
                if (r == DialogResult.OK)
                {
                    blacklist.Add(addForm.AddString);
                }
            },
                () =>
            {
                // Enable
                Byte[] msg = blacklist.Enable();
                if (msg != null)
                {
                    cmdServer.Broadcast(msg);
                }
            },
                () =>
            {
                Byte[] msg = blacklist.Disable();
                if (msg != null)
                {
                    cmdServer.Broadcast(msg);
                }
            },
                () =>
            {
                msgForm.LockScreen();
            },
                () =>
            {
                msgForm.UnLockScreen();
            });
        }