示例#1
0
 static void wiimote_ExtensionAttached(object sender, WiimoteExtensionEventArgs e)
 {
     IWiimote wiimote = (IWiimote)sender;
     
     // We can retrieve the attached extension by doing the following:
     IWiimoteExtension extension = e.Extension;
     // The extension is also available through 'wiimote.Extension'.
     
     // Here we can check what type of extension the attached extension is.
     // In this example we will only cover the Nunchuk, but we can also check for other available extensions.
     if (extension is NunchukExtension)
     {
         wiimote.SetReportingMode(ReportingMode.ButtonsAccelerometer16Extension);
         Console.WriteLine("A nunchuk attached to the Wiimote.");
     }
     // A few 'dummy-extensions' are available to detect various undefined situations.
     else if (extension is InvalidExtension)
     {
         Console.WriteLine("An extension was partially connected or the extension was erroneous.");
     }
     
     // UnknownExtension is a dummy-extension that that the attached extension
     // is not supported by Wii Device Library (or any other extension that is registered in WiimoteExtensionRegistry).
     else if (extension is UnknownExtension)
     {
         Console.WriteLine("An extension was connected, but was not recognized by Wii Device Library.");
     }
     else
     {
         Console.WriteLine("An extension was connected, but was not recognized by this example.");
     }
     wiimote.SetReportingMode(wiimote.ReportingMode);
 }
 private void ExtensionDetached(object sender, WiimoteExtensionEventArgs args)
 {
     Gtk.Application.Invoke(delegate
     {
         GtkAlignment2.Remove(_ExtensionInformation.Widget);
         _ExtensionInformation = null;
     });
 }
示例#3
0
 static void wiimote_ExtensionDetached(object sender, WiimoteExtensionEventArgs e)
 {
     IWiimote wiimote = (IWiimote)sender;
     IWiimoteExtension extension = e.Extension;
     if (extension is NunchukExtension)
     {
         Console.WriteLine("A nunchuk was detached from the Wiimote.");
     }
     wiimote.SetReportingMode(wiimote.ReportingMode);
 }
示例#4
0
 void Wiimote_ExtensionDetached(object sender, WiimoteExtensionEventArgs e)
 {
     Invoke(new System.Threading.ThreadStart(delegate()
     {
         while (extensionBox.Controls.Count > 0)
         {
             Control c = extensionBox.Controls[0];
             extensionBox.Controls.RemoveAt(0);
             c.Dispose();
         }
         extensionBox.Text             = "Extension";
         extensionBox.Height           = 50;
         this.Height                   = extensionBox.Top + extensionBox.Height;
         reportingmodeBox.SelectedItem = Wiimote.ReportingMode;
     }));
 }
 private void ExtensionAttached(object sender, WiimoteExtensionEventArgs args)
 {
     Gtk.Application.Invoke(delegate {
         if (_Wiimote.Extension is NunchukExtension)
         {
             _ExtensionInformation = new NunchukInformation((NunchukExtension)_Wiimote.Extension);
             GtkAlignment2.Add(_ExtensionInformation.Widget);
         }
         else if (_Wiimote.Extension is GuitarExtension)
         {
             _ExtensionInformation = new GuitarInformation((GuitarExtension)_Wiimote.Extension);
             GtkAlignment2.Add(_ExtensionInformation.Widget);
         }
         else if (_Wiimote.Extension is ClassicControllerExtension)
         {
             _ExtensionInformation = new ClassicControllerInformation((ClassicControllerExtension)_Wiimote.Extension);
             GtkAlignment2.Add(_ExtensionInformation.Widget);
         }
     });
 }
示例#6
0
        void Wiimote_ExtensionAttached(object sender, WiimoteExtensionEventArgs e)
        {
            IWiimoteExtension wiimoteExtension = Wiimote.Extension;

            Invoke(new Action <IWiimoteExtension>(delegate(IWiimoteExtension extension)
            {
                Control extensionControl = null;
                if (extension is NunchukExtension)
                {
                    NunchukUserControl nunchukUC = new NunchukUserControl();
                    nunchukUC.Nunchuk            = (NunchukExtension)extension;
                    extensionControl             = nunchukUC;
                }
                else if (extension is ClassicControllerExtension)
                {
                    ClassicControllerUserControl classicControllerUC = new ClassicControllerUserControl();
                    classicControllerUC.ClassicController            = (ClassicControllerExtension)extension;
                    extensionControl = classicControllerUC;
                }
                else if (extension is GuitarExtension)
                {
                    GuitarUserControl guitarUC = new GuitarUserControl();
                    guitarUC.Guitar            = (GuitarExtension)extension;
                    extensionControl           = guitarUC;
                }

                ExtensionControl = (IExtensionControl)extensionControl;
                if (extensionControl != null)
                {
                    extensionBox.Height = extensionControl.Height + 50;
                    extensionBox.Text   = extension.GetType().Name;
                    extensionBox.Controls.Add(extensionControl);
                    extensionControl.Dock = DockStyle.Fill;
                    this.Height           = extensionBox.Top + extensionBox.Height;
                }
                reportingmodeBox.SelectedItem = Wiimote.ReportingMode;
            }), wiimoteExtension);
        }