private int counter = 0;                                                           //successful event counter, displayed in top right corner and saved at the end of videos (event{0}.avi)

        #endregion Member Variables

        public MainWindow()           //main window constructor
        {
            timeStart = DateTime.Now; //Start time here

            //start kinect, initialize all the variables, streams, and event handlers
            #region initialize Kinect
            this.kinectSensor     = KinectSensor.GetDefault();
            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();
            this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
            this.bytesPerPixel = colorFrameDescription.BytesPerPixel;//

            this.colorPixels = new byte[colorFrameDescription.Width * colorFrameDescription.Height * this.bytesPerPixel];
            this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);

            this.depthFrameReader = this.kinectSensor.DepthFrameSource.OpenReader();
            this.depthFrameReader.FrameArrived += this.Reader_DepthFrameArrived;

            depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
            this.depthPixels      = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height];

            this.DataContext = this;

            this.kinectSensor.Open();
            #endregion

            int[] loadedSettings = fileHandler.InitializeFileStructure(); //start file handler, and load the settings for setting later
            emailHandler = new KinectBehavior_EmailHandler(fileHandler);  //start email handler
            portHandler  = new KinectBehavior_PortHandler(fileHandler);   //start port handler (and listeners for port events)
            InitializeComponent();                                        //Initialize UI Elements

            if (loadedSettings != null)
            {
                initializeSettingsAndSliders(loadedSettings);
            }
        }
        private int counter = 0; //successful event counter, displayed in top right corner and saved at the end of videos (event{0}.avi)

        #endregion Member Variables

        public MainWindow() //main window constructor
        {
            
            timeStart = DateTime.Now; //Start time here

            //start kinect, initialize all the variables, streams, and event handlers 
            #region initialize Kinect 
            this.kinectSensor = KinectSensor.GetDefault();
            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();
            this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
            this.bytesPerPixel = colorFrameDescription.BytesPerPixel;//  

            this.colorPixels = new byte[colorFrameDescription.Width * colorFrameDescription.Height * this.bytesPerPixel];
            this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);

            this.depthFrameReader = this.kinectSensor.DepthFrameSource.OpenReader();
            this.depthFrameReader.FrameArrived += this.Reader_DepthFrameArrived;

            depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
            this.depthPixels = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height];

            this.DataContext = this;

            this.kinectSensor.Open();
            #endregion

            int[] loadedSettings = fileHandler.InitializeFileStructure(); //start file handler, and load the settings for setting later
            emailHandler = new KinectBehavior_EmailHandler(fileHandler); //start email handler
            portHandler = new KinectBehavior_PortHandler(fileHandler); //start port handler (and listeners for port events)
            InitializeComponent(); //Initialize UI Elements

            if (loadedSettings != null)
            {
                initializeSettingsAndSliders(loadedSettings);
            }

        }