コード例 #1
0
 private void testLayout()
 {
     for (int i = 0; i < 30; i++)
     {
         DisplayView view = new DisplayView();
         view.MouseDoubleClick += view_MouseDoubleClick;
         container.Children.Add(view);
     }
     this.RefreshLayout();
 }
コード例 #2
0
 void view_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (this.selected == sender)
     {
         this.selected = null;
         this.TancfsToAll();
     }
     else if (this.selected == null)
     {
         this.selected = sender as DisplayView;
         this.TancfsToSingle(selected);
     }
     else
     {
         this.TancfsToSingle(sender as DisplayView);
         this.selected = sender as DisplayView;
     }
 }
コード例 #3
0
        // 解析服务器发送的内容
        void client_DatagramReceived(object sender, ReceivedEventArgs <byte[]> e)
        {
            using (BackgroundWorker bw = new BackgroundWorker())
            {
                bw.DoWork += (_sender, _e) =>
                {
                    _e.Result = _e.Argument;
                };
                bw.RunWorkerCompleted += (_sender, _e) =>
                {
                    if (client == null || !client.Connected)
                    {
                        return;
                    }
                    try
                    {
                        DisplayView ctrl    = null;
                        var         message = new Message(_e.Result as byte[]);
                        switch (message.Command)
                        {
                        case Command.Logout:
                            dispalyViewBuffer.Remove(message.Sender);
                            container.Children.Remove(ctrl);
                            this.RefreshLayout();

                            barPersonCount.Content = message["uc"];
                            break;

                        case Command.Login:
                            if (dispalyViewBuffer.ContainsKey(message.Sender))
                            {
                                ctrl = dispalyViewBuffer[message.Sender];
                            }
                            else
                            {
                                ctrl = new DisplayView();
                                ctrl.MouseDoubleClick += view_MouseDoubleClick;
                                container.Children.Add(ctrl);
                                dispalyViewBuffer.Add(message.Sender, ctrl);
                                this.RefreshLayout();
                            }
                            barPersonCount.Content = message["uc"];
                            break;

                        case Command.Audio:
                            if (dispalyViewBuffer.ContainsKey(message.Sender))
                            {
                                ctrl = dispalyViewBuffer[message.Sender];
                                ctrl.AudioOutput(message.Body);
                            }
                            break;

                        case Command.Video:
                            if (dispalyViewBuffer.ContainsKey(message.Sender))
                            {
                                ctrl = dispalyViewBuffer[message.Sender];
                                ctrl.VideoOutput(message.BitmapBody);
                            }
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(" -> .received .error");
                        Console.WriteLine(ex.ToString());
                    }
                };
                bw.RunWorkerAsync(e.Datagram);
            }
        }