示例#1
0
        public void SetTask(Message message)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        TraceOps.Out("WebControl Client recived Message: " + message.GetCommand());
                        if (message.GetCommand() == "open_browser")
                        {
                            var d = new PluginCallback(_control.StartBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "open_custom_browser")
                        {
                            var d = new PluginCallback(_control.StartCustomBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "close_browser")
                        {
                            var d = new PluginCallback(_control.StopBrowser);
                            _mainForm.Invoke(d, new object[] { });
                        }

                        if (message.GetCommand() == "change_url")
                        {
                            var p     = message.GetParameter();
                            var value = "";

                            if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                            {
                                value = Message.GetAttribute(p, "url");
                            }

                            if (value != "")
                            {
                                _control.SetUrl(value);
                            }

                            var d = new PluginCallback(_control.ChangeUrl);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
示例#2
0
        public void SetTask(Message message)
        {
            TraceOps.Out("ZtreeControl Client recived Message: " + message.GetCommand());
            if (message.GetCommand() == "start_zleaf")
            {
                var d = new PluginCallback(_control.StartZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "stop_zleaf")
            {
                var d = new PluginCallback(_control.StopZLeaf);
                _mainForm.Invoke(d, new object[] { });
            }

            if (message.GetCommand() == "set_preferences")
            {
                var p      = message.GetParameter();
                var xvalue = "";
                var yvalue = "";
                var wvalue = "";
                var hvalue = "";

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    xvalue = Message.GetAttribute(p, "X");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    yvalue = Message.GetAttribute(p, "Y");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    wvalue = Message.GetAttribute(p, "W");
                }

                if (p.GetLength(0) > 0 && p.GetLength(1) > 1)
                {
                    hvalue = Message.GetAttribute(p, "H");
                }

                try
                {
                    if (xvalue != "")
                    {
                        ClientModel.X = Convert.ToInt32(xvalue);
                    }
                    if (yvalue != "")
                    {
                        ClientModel.Y = Convert.ToInt32(yvalue);
                    }
                    if (wvalue != "")
                    {
                        ClientModel.W = Convert.ToInt32(wvalue);
                    }
                    if (hvalue != "")
                    {
                        ClientModel.H = Convert.ToInt32(hvalue);
                    }

                    var np = new string[, ] {
                        { }, { }
                    };
                    var nm = new Message(np, true, "zleaf_config_changed", "Server");
                    _messageQueue.SetMessage(nm);
                }
                catch (Exception e)
                {
                    TraceOps.Out(e.ToString());
                }
            }
        }