Beispiel #1
0
        /// <summary>
        /// This is called when the wii remote is connected
        /// </summary>
        /// <param name="obj"></param>
        private void pWiiProvider_OnConnect(int ID, int totalWiimotes)
        {
            // Dispatch it.
            Dispatcher.BeginInvoke(new Action(delegate()
            {
                this.bConnected = true;


                if (totalWiimotes == 1)
                {
                    this.connectedCount.Content = "One Wiimote connected";
                }
                else
                {
                    this.connectedCount.Content = totalWiimotes + " Wiimotes connected";
                }
                statusStackMutex.WaitOne();
                WiimoteStatusUC uc = new WiimoteStatusUC(ID);
                uc.Visibility      = Visibility.Collapsed;
                this.statusStack.Children.Add(uc);
                this.animateExpand(uc);
                statusStackMutex.ReleaseMutex();

                //connectProviderHandler();
            }), null);
        }
Beispiel #2
0
        /// <summary>
        /// This is called when the wii remote is disconnected
        /// </summary>
        /// <param name="obj"></param>
        private void pWiiProvider_OnDisconnect(int ID, int totalWiimotes)
        {
            // Dispatch it.
            Dispatcher.BeginInvoke(new Action(delegate()
            {
                if (totalWiimotes == 1)
                {
                    this.connectedCount.Content = "One Wiimote connected";
                }
                else
                {
                    this.connectedCount.Content = totalWiimotes + " Wiimotes connected";
                }
                statusStackMutex.WaitOne();
                foreach (UIElement child in this.statusStack.Children)
                {
                    WiimoteStatusUC uc = (WiimoteStatusUC)child;
                    if (uc.ID == ID)
                    {
                        this.animateCollapse(uc, true);
                        //this.statusStack.Children.Remove(child);
                        break;
                    }
                }
                statusStackMutex.ReleaseMutex();
                if (totalWiimotes == 0)
                {
                    this.bConnected = false;

                    //disconnectProviderHandler();
                }
            }), null);
        }
Beispiel #3
0
 /// <summary>
 /// This is called when the battery state changes.
 /// </summary>
 /// <param name="obj"></param>
 private void pWiiProvider_OnStatusUpdate(WiimoteStatus status)
 {
     // Dispatch it.
     Dispatcher.BeginInvoke(new Action(delegate()
     {
         statusStackMutex.WaitOne();
         foreach (UIElement child in this.statusStack.Children)
         {
             WiimoteStatusUC uc = (WiimoteStatusUC)child;
             if (uc.ID == status.ID)
             {
                 uc.updateStatus(status);
             }
         }
         statusStackMutex.ReleaseMutex();
     }), null);
 }
Beispiel #4
0
        /// <summary>
        /// This is called when the wii remote is connected
        /// </summary>
        /// <param name="obj"></param>
        private void pWiiProvider_OnConnect(int ID, int totalWiimotes)
        {
            // Dispatch it.
            Dispatcher.BeginInvoke(new Action(delegate()
            {
                this.bConnected = true;

                if (totalWiimotes == 1)
                {
                    this.connectedCount.Content = "One Wiimote connected";
                }
                else
                {
                    this.connectedCount.Content = totalWiimotes+" Wiimotes connected";
                }
                statusStackMutex.WaitOne();
                WiimoteStatusUC uc = new WiimoteStatusUC(ID);
                FrameworkElement child = (FrameworkElement)uc.GetChildObjects().First();
                child.Visibility = Visibility.Collapsed;
                this.statusStack.Children.Add(uc);
                this.animateExpand(child);
                statusStackMutex.ReleaseMutex();

                connectProviderHandler();

            }), null);
        }