Пример #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);
                FrameworkElement child = (FrameworkElement)uc.GetChildObjects().First();
                child.Visibility       = Visibility.Collapsed;
                this.statusStack.Children.Add(uc);
                this.animateExpand(child);
                statusStackMutex.ReleaseMutex();

                connectProviderHandler();
            }), null);
        }
Пример #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((FrameworkElement)uc.GetChildObjects().First(), true);
                        //this.statusStack.Children.Remove(child);
                        break;
                    }
                }
                statusStackMutex.ReleaseMutex();
                if (totalWiimotes == 0)
                {
                    this.bConnected = false;

                    disconnectProviderHandler();
                }
            }), null);
        }
Пример #3
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);
        }