Exemplo n.º 1
0
        void client_CommandReceived(object sender , CommandEventArgs e)
        {
            switch(e.Command.CommandType)
            {
                case(CommandType.Message):
                    if ( e.Command.Target.Equals(IPAddress.Broadcast) )
                        this.txtMessages.Text += e.Command.SenderName + ": " + e.Command.MetaData + Environment.NewLine;
                    else if ( !this.IsPrivateWindowOpened(e.Command.SenderName) )
                    {
                        this.OpenPrivateWindow(e.Command.SenderIP , e.Command.SenderName , e.Command.MetaData);
                        ShareUtils.PlaySound(ShareUtils.SoundType.NewMessageWithPow);
                    }
                    break;

                case(CommandType.FreeCommand):
                    string [] newInfo = e.Command.MetaData.Split(new char [] { ':' });
                    this.AddToList(newInfo [0] , newInfo [1]);
                    ShareUtils.PlaySound(ShareUtils.SoundType.NewClientEntered);
                    break;
                case (CommandType.SendClientList ):
                    string [] clientInfo = e.Command.MetaData.Split(new char[]{':'});
                    this.AddToList(clientInfo [0] , clientInfo [1]);
                    break;
                case(CommandType.ClientLogOffInform):
                    this.RemoveFromList(e.Command.SenderName);
                    break;
            }
        }
Exemplo n.º 2
0
 void CommandReceived(object sender, CommandEventArgs e)
 {
     if (e.Command.CommandType == CommandType.IsNameExists)
     {
         if (e.Command.MetaData.ToLower() == "true")
         {
             var popup = new frmPopup(PopupSkins.SmallInfoSkin);
             popup.ShowPopup("Error", "The Username is already exists !", 300, 2000, 2000);
             Client.Disconnect();
             SetEnablity(true);
         }
         else
         {
             _canClose = true;
             Close();
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Occurs when a command received from a remote client.
 /// </summary>
 /// <param name="e">The received command.</param>
 protected virtual void OnCommandReceived(CommandEventArgs e)
 {
     if (CommandReceived != null)
     {
         var target = CommandReceived.Target as Control;
         if (target != null && target.InvokeRequired)
         {
             target.Invoke(CommandReceived, new object[] { this, e });
         }
         else
         {
             CommandReceived(this, e);
         }
     }
 }
Exemplo n.º 4
0
 private void private_CommandReceived(object sender, CommandEventArgs e)
 {
     switch (e.Command.CommandType)
     {
         case (CommandType.Message):
             if (!e.Command.Target.Equals(IPAddress.Broadcast) && e.Command.SenderIp.Equals(this._targetIp))
             {
                 txtMessages.Text += e.Command.SenderName + ": " + e.Command.MetaData + Environment.NewLine;
                 if (!_activated)
                 {
                     if (WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized)
                         ShareUtils.PlaySound(ShareUtils.SoundType.NewMessageReceived);
                     else
                         ShareUtils.PlaySound(ShareUtils.SoundType.NewMessageWithPow);
                     Flash(Handle, FlashMode.FlashwAll, 3);
                 }
             }
             break;
     }
 }
Exemplo n.º 5
0
 public void SetMessage(object sender, CommandEventArgs e)
 {
     if (e.Command.CommandType == CommandType.Message)
     {
         switch (e.Command.MetaData)
         {
             case "start":
                 {
                     Marks.Checked = true;
                     StartClick(sender, e);
                 }
                 break;
             case "cancel":
                 {
                     StopClick(sender, e);
                 }
                 break;
             case "mark":
                 {
                     SendMarks();
                 }
                 break;
             case "getimage":
                 {
                     CreateCelTClick(sender, e);
                 }
                 break;
             case "getcameralist":
                 {
                     GetCameraList();
                 } break;
             default:
                 {
                     SetCameraDevice(e.Command.MetaData);
                 }
                 break;
         }
     }
 }
Exemplo n.º 6
0
        void client_CommandReceived(object sender, CommandEventArgs e)
        {
            _clientName = e.Command.SenderName;
            switch (e.Command.CommandType)
            {
                case (CommandType.Message):
                    if (e.Command.Target.Equals(IPAddress.Broadcast))
                    {
                        var points = e.Command.MetaData.Split(' ');
                        bool boolen;
                        var isPoint = bool.TryParse(points[0], out boolen);

                        if (isPoint)
                        {
                            switch (points.Length)
                            {
                                case 3:
                                    var x = int.Parse(points[1]);
                                    var y = int.Parse(points[2]);

                                    pictureBox1.CreateGraphics().FillEllipse(Brushes.Red, x - 7/2, y - 7/2, 6, 6);
                                    pictureBox1.CreateGraphics().DrawEllipse(new Pen(Brushes.Black, 1), x - 7/2, y - 7/2, 7, 7);

                                    break;
                                case 2:
                                    if ((_shotTime - DateTime.Now).TotalSeconds <= 3)
                                    {
                                        txtMessages.Text += e.Command.SenderName + ": " + e.Command.MetaData.Split(' ')[1] + Environment.NewLine;

                                        int shot;
                                        var isShot = int.TryParse(points[1], out shot);
                                        if (isShot)
                                        {
                                            _shotOnServer = true;
                                            _shots.RemoveAt(_shots.Count - 1);
                                            _shots.Add(shot);
                                            _timer.Elapsed += OnTimedEvent;
                                            _timer.Interval = 1000;
                                            _timer.Start();
                                        }
                                    }
                                    break;
                            }
                        }
                        else
                        {
                            Sound.Play("mark");
                            var hasPoint = int.TryParse(points[1], out _fullMark);
                            _timerMark.Interval = 1500;
                            _timerMark.Elapsed += OnTimerMarkEvent;
                            _timerMark.Start();
                            txtMessages.Text += "-----------------------" + Environment.NewLine + string.Format("Оценка: {0}", _fullMark) + Environment.NewLine;
                        }
                    }

                    else if (!IsPrivateWindowOpened(e.Command.SenderName))
                    {
                        OpenPrivateWindow(e.Command.SenderIp, e.Command.SenderName, e.Command.MetaData);
                        ShareUtils.PlaySound(ShareUtils.SoundType.NewMessageWithPow);
                    }
                    break;

                case (CommandType.FreeCommand):
                    var newInfo = e.Command.MetaData.Split(new[] {':'});
                    AddToList(newInfo[0], newInfo[1]);
                    ShareUtils.PlaySound(ShareUtils.SoundType.NewClientEntered);
                    break;
                case (CommandType.SendClientList):
                    var clientInfo = e.Command.MetaData.Split(new[] {':'});
                    AddToList(clientInfo[0], clientInfo[1]);
                    break;
                case (CommandType.ClientLogOffInform):
                    RemoveFromList(e.Command.SenderName);
                    break;
            }
        }