public WiiProviderSettings(WiiProvider pWiiProvider)
        {
            InitializeComponent();

            this.pWiiProvider = pWiiProvider;

            // Create a calibration window and hide it.
            this.pCalibrationWindow = new CalibrationWindow();
            this.pCalibrationWindow.Visibility = Visibility.Hidden;

            this.pWiiProvider.OnNewFrame += new EventHandler<FrameEventArgs>(pWiiProvider_OnNewFrame);
            this.pWiiProvider.OnConnect += new Action<int,int>(pWiiProvider_OnConnect);
            this.pWiiProvider.OnDisconnect += new Action<int,int>(pWiiProvider_OnDisconnect);
        }
Beispiel #2
0
        public WiiProviderSettings(WiiProvider pWiiProvider)
        {
            InitializeComponent();

            this.pWiiProvider = pWiiProvider;

            // Create a calibration window and hide it.
            this.pCalibrationWindow            = new CalibrationWindow();
            this.pCalibrationWindow.Visibility = Visibility.Hidden;

            this.pWiiProvider.OnNewFrame   += new EventHandler <FrameEventArgs>(pWiiProvider_OnNewFrame);
            this.pWiiProvider.OnConnect    += new Action <int, int>(pWiiProvider_OnConnect);
            this.pWiiProvider.OnDisconnect += new Action <int, int>(pWiiProvider_OnDisconnect);
        }
Beispiel #3
0
        /// <summary>
        /// This is called internally when calibration is finished.
        /// </summary>
        private void finishedCalibration()
        {
            // Die if we have no provider.
            if (this.pWiiProvider == null)
            {
                throw new Exception("Cannot finish calibration without an input provider!");
            }

            // Re-enable the transformation step in the provider.
            pWiiProvider.TransformResults = true;

            // Feed that data into the provider.
            Vector vScreenSize = new Vector(this.ActualWidth, this.ActualHeight);

            this.pWiiProvider.setCalibrationData(pSourceRectangle, pDestinationRectangle, vScreenSize);

            // Detach the event handler.
            this.pWiiProvider.OnNewFrame -= pEventHandler;

            // Dereference the provider.
            this.pWiiProvider = null;

            // Hide the calibration point.
            Dispatcher.BeginInvoke((Action) delegate()
            {
                // Hide the calibration point.
                this.CalibrationPoint.Visibility = Visibility.Hidden;

                // Ensure the form is at the back, the correct size and visible.
                Canvas.SetTop(this, 0.0);
                Canvas.SetLeft(this, 0.0);
                Canvas.SetZIndex(this, -999);
                this.Width  = 0; // (double)this.Parent.GetValue(Canvas.ActualWidthProperty);
                this.Height = 0; // (double)this.Parent.GetValue(Canvas.ActualHeightProperty);

                // Raise the event.
                if (OnCalibrationFinished != null)
                {
                    OnCalibrationFinished(pSourceRectangle, pDestinationRectangle, vScreenSize);
                }
            });
        }
Beispiel #4
0
        /// <summary>
        /// Method to begin calibration.
        /// </summary>
        /// <param name="pWiiProvider">A reference to the input provider we want to calibrate.</param>
        public void beginCalibration(WiiProvider pWiiProvider)
        {
            // Store a reference to the WiiInput provider.
            this.pWiiProvider = pWiiProvider;

            // Die if we have no provider.
            if (this.pWiiProvider == null)
            {
                throw new Exception("Cannot begin calibrate without an input provider!");
            }

            // Wipe the rectangles.
            this.pSourceRectangle      = new WiiProvider.CalibrationRectangle();
            this.pDestinationRectangle = new WiiProvider.CalibrationRectangle();

            // Disable the transformation step in the provider.
            pWiiProvider.TransformResults = false;

            // Give us an event for the input.
            pEventHandler            = new EventHandler <FrameEventArgs>(pWiiProvider_OnNewFrame);
            pWiiProvider.OnNewFrame += pEventHandler;

            // Set our calibration phase to 1.
            this.iCalibrationPhase = 1;

            // Show the calibration point.
            this.CalibrationPoint.Visibility = Visibility.Visible;

            // Ensure the form is at the top, the correct size and visible.
            Canvas.SetTop(this, 0.0);
            Canvas.SetLeft(this, 0.0);
            Canvas.SetZIndex(this, 999);
            this.Width  = (double)this.Parent.GetValue(Canvas.ActualWidthProperty);
            this.Height = (double)this.Parent.GetValue(Canvas.ActualHeightProperty);

            // Step into the calibration.
            this.movePoint(0.1, 0.1);
            this.stepCalibration();
        }
 void CalibrationCanvas_OnCalibrationFinished(WiiProvider.CalibrationRectangle arg1, WiiProvider.CalibrationRectangle arg2, Vector arg3)
 {
     this.Hide();
 }
 /// <summary>
 /// Creates a wrapper object for persisting calibration data.
 /// </summary>
 /// <param name="pSource">The source calibration rectangle</param>
 /// <param name="pDestination">The destination calibration rectangle</param>
 /// <param name="vScreenSize">The screen size</param>
 public PersistentCalibrationData(WiiProvider.CalibrationRectangle pSource, WiiProvider.CalibrationRectangle pDestination, Vector vScreenSize)
 {
     this.Source = pSource;
     this.Destination = pDestination;
     this.ScreenSize = vScreenSize;
     this.TimeStamp = DateTime.Now;
 }
        /// <summary>
        /// This is called when calibration is finished.
        /// </summary>
        private void CalibrationCanvas_OnCalibrationFinished(WiiProvider.CalibrationRectangle pSource, WiiProvider.CalibrationRectangle pDestination, Vector vScreenSize)
        {
            // Persist the calibration data
            if (!savePersistentCalibration("./Calibration.dat", new PersistentCalibrationData(pSource, pDestination, vScreenSize)))
            {
                // Error - Failed to save calibration data
                MessageBox.Show("Failed to save calibration data", "Touchmote", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Close the calibration window.
            if (pCalibrationWindow != null)
            {
                pCalibrationWindow.Visibility = System.Windows.Visibility.Hidden;
            }
        }
        /// <summary>
        /// Method to begin calibration.
        /// </summary>
        /// <param name="pWiiProvider">A reference to the input provider we want to calibrate.</param>
        public void beginCalibration(WiiProvider pWiiProvider)
        {
            // Store a reference to the WiiInput provider.
            this.pWiiProvider = pWiiProvider;

            // Die if we have no provider.
            if (this.pWiiProvider == null)
                throw new Exception("Cannot begin calibrate without an input provider!");

            // Wipe the rectangles.
            this.pSourceRectangle = new WiiProvider.CalibrationRectangle();
            this.pDestinationRectangle = new WiiProvider.CalibrationRectangle();

            // Disable the transformation step in the provider.
            pWiiProvider.TransformResults = false;

            // Give us an event for the input.
            pEventHandler = new EventHandler<FrameEventArgs>(pWiiProvider_OnNewFrame);
            pWiiProvider.OnNewFrame += pEventHandler;

            // Set our calibration phase to 1.
            this.iCalibrationPhase = 1;

            // Show the calibration point.
            this.CalibrationPoint.Visibility = Visibility.Visible;

            // Ensure the form is at the top, the correct size and visible.
            Canvas.SetTop(this, 0.0);
            Canvas.SetLeft(this, 0.0);
            Canvas.SetZIndex(this, 999);
            this.Width = (double)this.Parent.GetValue(Canvas.ActualWidthProperty);
            this.Height = (double)this.Parent.GetValue(Canvas.ActualHeightProperty);

            // Step into the calibration.
            this.movePoint(0.1, 0.1);
            this.stepCalibration();
        }
        /// <summary>
        /// This is called internally when calibration is finished.
        /// </summary>
        private void finishedCalibration()
        {
            // Die if we have no provider.
            if (this.pWiiProvider == null)
                throw new Exception("Cannot finish calibration without an input provider!");

            // Re-enable the transformation step in the provider.
            pWiiProvider.TransformResults = true;

            // Feed that data into the provider.
            Vector vScreenSize = new Vector(this.ActualWidth, this.ActualHeight);
            this.pWiiProvider.setCalibrationData(pSourceRectangle, pDestinationRectangle, vScreenSize);

            // Detach the event handler.
            this.pWiiProvider.OnNewFrame -= pEventHandler;

            // Dereference the provider.
            this.pWiiProvider = null;

            // Hide the calibration point.
            Dispatcher.BeginInvoke((Action)delegate()
            {
                // Hide the calibration point.
                this.CalibrationPoint.Visibility = Visibility.Hidden;

                // Ensure the form is at the back, the correct size and visible.
                Canvas.SetTop(this, 0.0);
                Canvas.SetLeft(this, 0.0);
                Canvas.SetZIndex(this, -999);
                this.Width = 0;// (double)this.Parent.GetValue(Canvas.ActualWidthProperty);
                this.Height = 0;// (double)this.Parent.GetValue(Canvas.ActualHeightProperty);

                // Raise the event.
                if (OnCalibrationFinished != null)
                    OnCalibrationFinished(pSourceRectangle, pDestinationRectangle, vScreenSize);
            });
        }