public MouseAppModel() { settings = new MouseAppSettings(); }
//----------------------------------- //Constructor //----------------------------------- public MainWindow() { settings = new MouseAppSettings(true); //get the kinect this.kinectSensor = KinectSensor.GetDefault(); //open the reader for color frames this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader(); //wire handler for frame arrival this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; //create the colorFrameDescription from the ColorFrameSource FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); // create the bitmap to display this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // get the coordinate mapper this.coordinateMapper = this.kinectSensor.CoordinateMapper; // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.colorOverlay = new DrawingImage(this.drawingGroup); // get size of color space this.displayWidth = colorFrameDescription.Width; this.displayHeight = colorFrameDescription.Height; this.deskHeight = Screen.PrimaryScreen.Bounds.Height; this.deskWidth = Screen.PrimaryScreen.Bounds.Width; handDispBuffer = new List<float>(); handDispTimes = new List<TimeSpan>(); handStates = new List<HandState>(); detectors = new List<GestureDetector>(); int maxBodies = this.kinectSensor.BodyFrameSource.BodyCount; for (int i = 0; i < maxBodies; ++i) { GestureDetector detector = new GestureDetector(this.kinectSensor, "TwistWrist"); detectors.Add(detector); } activeTime = TimeSpan.MinValue; handStateTime = TimeSpan.MinValue; driftStartTime = TimeSpan.MinValue; handStillPoint = new Point3D(); //Mouse cursor and PHIZ attributes phiz = new PHIZTracker(); kinectCoreWindow = KinectCoreWindow.GetForCurrentThread(); kinectCoreWindow.PointerMoved += kinectCoreWindow_PointerMoved; // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // use the window object as the view model in this simple example this.DataContext = this; // set the status text this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; handBrush = new Brush[5]; handBrush[(int)(HandState.Closed)] = handClosedBrush; handBrush[(int)(HandState.Open)] = handOpenBrush; handBrush[(int)(HandState.Lasso)] = handLassoBrush; handBrush[(int)(HandState.Unknown)] = handUnknownBrush; handBrush[(int)(HandState.NotTracked)] = handNotTrackedBrush; InitializeComponent(); this.OptionsColumn.Width = new System.Windows.GridLength(140); this.OptionsRow.Height = new System.Windows.GridLength(35); UpdateBoundaries(); sim = new InputSimulator(); }