コード例 #1
0
ファイル: Control.cs プロジェクト: wdstest/ReVision
        public override async Task FireEvent(WSEventArgs evt)
        {
            if (this.Parent == null && this.ControlName != "Form")
            {
                return;
            }

            if (this.Parent != null && !this.Parent.IsHandleCreated)
            {
                return;
            }
            else if (this.Parent == null && !this.IsHandleCreated && evt.EventType != "FormCreate")
            {
                return;
            }

            if (Socket != null)
            {
                await base.FireEvent(evt);
            }
            //else if (Application.Current != null && Application.Current.Value.Socket != null)
            //{
            //    this.Socket = Application.Current.Value.Socket;
            //}
            //else if (Parent != null)
            //{
            //    await Parent.FireEvent(evt);
            //}
        }
コード例 #2
0
        public override async Task ProcessMessage(WSEventArgs args)
        {
            var clientId = GetId(args.ClientId);

            if (clientId == this.ClientId)
            {
                switch (args.EventType)
                {
                case "fancytreecreate":
                    IsHandleCreated = true;
                    break;

                case "fancytreebeforeactivate":
                    if (BeforeSelect != null)
                    {
                        BeforeSelect(this, new TreeViewCancelEventArgs(null, false, TreeViewAction.ByMouse));
                    }
                    break;

                case "fancytreeclick":
                {
                    if (AfterSelect != null)
                    {
                        var node = this.Nodes.Where(n => n.Name == args.Value.ToString()).FirstOrDefault();
                        AfterSelect(this, new TreeViewEventArgs(node));
                    }
                }
                break;
                }
            }
            await base.ProcessMessage(args);
        }
コード例 #3
0
 private async Task ProcessFormMessage(WSEventArgs command)
 {
     foreach (var frm in this.Forms.ToArray())
     {
         await frm.ProcessMessage(command);
     }
 }
コード例 #4
0
        public async Task ProcessMessage(WSEventArgs command)
        {
            var id = GetId(command.ClientId);

            if (Components.ContainsKey(id))
            {
                await Components[id].ProcessMessage(command);
            }
            else
            {
                await instance.ProcessFormMessage(command);
            }
        }
コード例 #5
0
ファイル: Component.cs プロジェクト: wdstest/ReVision
        public virtual async Task FireEvent(WSEventArgs evt)
        {
            try
            {
                if (this.State == WebSocketState.Open)
                {
                    string str = string.Empty;
                    ArraySegment <byte> buffer;
                    while (EventQueue.Count > 0)
                    {
                        var queuedEvent = EventQueue.Dequeue();
                        if (queuedEvent == null)
                        {
                            continue;
                        }
                        str = JsonConvert.SerializeObject(queuedEvent, Formatting.None, new JsonSerializerSettings
                        {
                            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                        });
                        if (string.IsNullOrEmpty(str))
                        {
                            continue;
                        }
                        buffer = new ArraySegment <byte>(Encoding.UTF8.GetBytes(str));
                        await Socket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
                    }

                    str = JsonConvert.SerializeObject(evt, new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    });
                    buffer = new ArraySegment <byte>(Encoding.UTF8.GetBytes(str));
                    await Socket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
                }
                else
                {
                    EventQueue.Enqueue(evt);
                }
            }
            catch (InvalidOperationException)
            {
                EventQueue.Enqueue(evt);
            }
            catch (Exception)
            {
                EventQueue.Enqueue(evt);
                throw;
            }
        }
コード例 #6
0
ファイル: TabControl.cs プロジェクト: wdstest/ReVision
        public override async Task ProcessMessage(WSEventArgs args)
        {
            var id = GetId(args.ClientId);

            if (this.ClientId == id)
            {
                switch (args.EventType)
                {
                case "selectedIndexChanged":
                    this.SelectedIndex = Convert.ToInt32(args.Value);
                    break;
                }
            }
            await base.ProcessMessage(args);
        }
コード例 #7
0
        public override Task ProcessMessage(WSEventArgs args)
        {
            var id = GetId(args.ClientId);

            if (this.ClientId == id)
            {
                switch (args.EventType)
                {
                case "checkChanged":
                {
                    this.Checked = (bool)args.Value;
                }
                break;
                }
            }
            return(base.ProcessMessage(args));
        }
コード例 #8
0
ファイル: Form.cs プロジェクト: wdstest/ReVision
        public override async Task ProcessMessage(WSEventArgs args)
        {
            if (OnProcessMessage != null)
            {
                OnProcessMessage(this, args);
            }

            var clientId = GetId(args.ClientId);

            if (clientId == this.ClientId)
            {
                switch (args.EventType)
                {
                    case "FormClose":
                        {
                            if (this.FormClosed != null)
                            {
                                this.FormClosed(this, new FormClosedEventArgs());
                            }
                            Visible = false;
                        }
                        break;
                    case "WindowStateChange":
                        {
                            try
                            {
                                JObject frm = (JObject)args.Value;
                                this.Size = new System.Drawing.Size(frm.Value<int>("width"), frm.Value<int>("height"));
                                WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), frm.Value<string>("state"), true);
                            }
                            catch { }
                            break;
                        }
                    case "Load":
                        {
                            if (this.Load != null)
                            {
                                this.Load(this, EventArgs.Empty);
                            }
                        }
                        break;
                }
            }
            await base.ProcessMessage(args);
        }
コード例 #9
0
ファイル: UserControl.cs プロジェクト: wdstest/ReVision
        public override async Task ProcessMessage(WSEventArgs args)
        {
            var clientId = GetId(args.ClientId);

            if (clientId == this.ClientId)
            {
                switch (args.EventType)
                {
                case "Load":
                {
                    if (this.Load != null)
                    {
                        this.Load(this, EventArgs.Empty);
                    }
                }
                break;
                }
            }
            await base.ProcessMessage(args);
        }
コード例 #10
0
ファイル: LinkLabel.cs プロジェクト: wdstest/ReVision
        public override Task ProcessMessage(WSEventArgs args)
        {
            var id = GetId(args.ClientId);

            if (this.ClientId == id)
            {
                switch (args.EventType)
                {
                case "linkClicked":
                {
                    if (LinkClicked != null)
                    {
                        LinkClicked(this, new LinkLabelLinkClickedEventArgs());
                    }
                }
                break;
                }
            }

            return(base.ProcessMessage(args));
        }
コード例 #11
0
ファイル: Component.cs プロジェクト: wdstest/ReVision
 public virtual async Task ProcessMessage(WSEventArgs args)
 {
 }
コード例 #12
0
ファイル: Control.cs プロジェクト: wdstest/ReVision
        public override async Task ProcessMessage(WSEventArgs args)
        {
            var id = GetId(args.ClientId);

            if (this.ClientId == id)
            {
                switch (args.EventType)
                {
                case "click":
                {
                    FirePublicEvent(this, "Click", new object[] { this, EventArgs.Empty });
                }
                break;

                case "textchanged":
                {
                    UpdateProperty(this, "Text", args.Value);
                }
                break;

                case "mousemove":
                {
                    if (MouseMove != null)
                    {
                        JObject j = (JObject)args.Value;
                        var     e = j.ToObject <MouseEventArgs>();
                        MouseMove(this, e);
                    }
                }
                break;

                case "mousedown":
                {
                    if (MouseDown != null)
                    {
                        JObject j = (JObject)args.Value;
                        var     e = j.ToObject <MouseEventArgs>();
                        MouseDown(this, e);
                    }
                }
                break;

                case "mouseup":
                {
                    if (MouseUp != null)
                    {
                        JObject j = (JObject)args.Value;
                        var     e = j.ToObject <MouseEventArgs>();
                        MouseUp(this, e);
                    }
                }
                break;

                case "mouseleave":
                {
                    if (MouseLeave != null)
                    {
                        MouseLeave(this, EventArgs.Empty);
                    }
                }
                break;

                case "mouseenter":
                {
                    if (MouseEnter != null)
                    {
                        MouseEnter(this, EventArgs.Empty);
                    }
                }
                break;

                case "keyDown":
                {
                    if (KeyDown != null)
                    {
                        JObject j = (JObject)args.Value;
                        var     e = j.ToObject <KeyEventArgs>();

                        KeyDown(this, e);
                    }
                }
                break;

                case "keyPress":
                {
                    if (KeyPress != null)
                    {
                        JObject j = (JObject)args.Value;
                        var     e = j.ToObject <KeyPressEventArgs>();

                        KeyPress(this, e);
                    }
                }
                break;
                }
            }
            else
            {
                foreach (var ctrl in this.Controls.ToArray())
                {
                    await ctrl.ProcessMessage(args);
                }
            }
        }
コード例 #13
0
 public override Task FireEvent(WSEventArgs evt)
 {
     return(base.FireEvent(evt));
 }