void client_RecieveDataEvent(object sender, string e)
        {
            string[] cmds = e.Split('_', '|');

            if (cmds[0].ToUpper() == "NOONCE")
            {
                this.key = cmds[1];
                if (App.curUser.Permision.mana_device)
                {
                    this.client.sendData("ADMIN_" + (App.curUser.User_Name + key + App.curUser.Pass).MD5String());
                }
                else
                {
                    this.client.sendData("USER_" + (App.curUser.User_Name + key + App.curUser.Pass).MD5String());
                }
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "CONTROL" && cmds[0] == "OK")
            {
                this.client.canControl = true;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                {
                    this.Next.Visibility = System.Windows.Visibility.Visible;
                }));
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "PLAY" && cmds[0] == "OK")
            {
                this.isPlay = true;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                {
                    this.UIBtnPlay.Text = "\uf04d";
                }));
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "STOP" && cmds[0] == "OK")
            {
                this.isPlay = false;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                {
                    this.UIBtnPlay.Text = "\uf04b";
                }));
            }
            else if (cmds.Length > 4 && cmds[0] == "PLAY")
            {
                //PLAY|1_5_12_0.2292163
                Console.WriteLine(e);
                this.media = new PlayEvent()
                {
                    Media = Code.Media.MediaData.Info(Convert.ToInt32(cmds[3])), Postion = float.Parse(cmds[4], CultureInfo.InvariantCulture.NumberFormat)
                };
            }
            else
            {
                Console.WriteLine(e);
            }
        }
 public UIDevice()
 {
     InitializeComponent();
     th_OnlineDevice = new Thread(RunThreadFunctionOnlineDevice);
     th_OnlineDevice.IsBackground = true;
     th_MediaPlay = new Thread(RunThreadFunctionMediaPlay);
     th_MediaPlay.IsBackground = true;
     th_MediaPlay.SetApartmentState(ApartmentState.STA);
     client = new alta_client();
     client.ConnectErr += client_ConnectErr;
     client.ConnectSuccess += client_ConnectSuccess;
     client.RecieveDataEvent += client_RecieveDataEvent;
     this.media = null;
 }
 public UIDevice()
 {
     InitializeComponent();
     th_OnlineDevice = new Thread(RunThreadFunctionOnlineDevice);
     th_OnlineDevice.IsBackground = true;
     th_MediaPlay = new Thread(RunThreadFunctionMediaPlay);
     th_MediaPlay.IsBackground = true;
     th_MediaPlay.SetApartmentState(ApartmentState.STA);
     client                   = new alta_client();
     client.ConnectErr       += client_ConnectErr;
     client.ConnectSuccess   += client_ConnectSuccess;
     client.RecieveDataEvent += client_RecieveDataEvent;
     this.media               = null;
 }
 private void RunThreadFunctionMediaPlay()
 {
     while (true)
     {
         if (media != null )
         {
             if (this.PlayMediaEvent != null)
             {
                 this.PlayMediaEvent(this, this.media);
             }
             media = null;
         }
         Thread.Sleep(200);
     }
 }
 private void RunThreadFunctionMediaPlay()
 {
     while (true)
     {
         if (media != null)
         {
             if (this.PlayMediaEvent != null)
             {
                 this.PlayMediaEvent(this, this.media);
             }
             media = null;
         }
         Thread.Sleep(200);
     }
 }
示例#6
0
 void item_PlayMediaEvent(object sender, PlayEvent e)
 {
     if (e.Media != null && !this.isPlayingMedia)
     {
         this.Dispatcher.Invoke(() =>
         {
             UIView.Media.MediaPlayer player = new UIView.Media.MediaPlayer();
             player.Width  = 1366;
             player.Height = 668;
             player.setLeft(0);
             player.setTop(90);
             player.Media       = e.Media;
             player.Position    = e.Postion;
             player.CloseEvent += Player_CloseEvent;
             this.UIRoot.Children.Add(player);
             this.isPlayingMedia = true;
         });
     }
 }
        void client_RecieveDataEvent(object sender, string e)
        {
            string[] cmds = e.Split('_', '|');

            if (cmds[0].ToUpper() == "NOONCE")
            {
                this.key = cmds[1];
                if (App.curUser.Permision.mana_device)
                {
                    this.client.sendData("ADMIN_" + (App.curUser.User_Name + key + App.curUser.Pass).MD5String());
                }
                else
                {
                    this.client.sendData("USER_" + (App.curUser.User_Name + key + App.curUser.Pass).MD5String());
                }
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "CONTROL" && cmds[0] == "OK")
            {
                this.client.canControl = true;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                   {

                       this.Next.Visibility = System.Windows.Visibility.Visible;
                   }));
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "PLAY" && cmds[0] == "OK")
            {
                this.isPlay = true;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                 {
                     this.UIBtnPlay.Text = "\uf04d";
                 }));
            }
            else if (cmds.Length > 2 && cmds[2].ToUpper() == "STOP" && cmds[0] == "OK")
            {
                this.isPlay = false;
                this.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
                 {
                     this.UIBtnPlay.Text = "\uf04b";
                 }));
            }
            else if (cmds.Length>4 && cmds[0]=="PLAY")
            {
                //PLAY|1_5_12_0.2292163
                Console.WriteLine(e);
                this.media = new PlayEvent() { Media = Code.Media.MediaData.Info(Convert.ToInt32(cmds[3])), Postion = float.Parse(cmds[4], CultureInfo.InvariantCulture.NumberFormat) };
            }
            else
            {
                Console.WriteLine(e);
            }
        }
 void item_PlayMediaEvent(object sender, PlayEvent e)
 {
     if (e.Media != null && !this.isPlayingMedia)
     {
         this.Dispatcher.Invoke(() =>
         {
             UIView.Media.MediaPlayer player = new UIView.Media.MediaPlayer();
             player.Width = 1366;
             player.Height = 668;
             player.setLeft(0);
             player.setTop(90);
             player.Media = e.Media;
             player.Position = e.Postion;
             player.CloseEvent += Player_CloseEvent;
             this.UIRoot.Children.Add(player);
             this.isPlayingMedia = true;
         });
         
     }
 }