public MainWindow()
        {
            // Initialize logger
            LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>();
            this.Log().Debug("Initialize UI components");
            InitializeComponent();
            this.Log().Debug("Initialize KinectWorker");
            this.kinectWorker = new KinectWorker();
            Bitmap gradient = (Bitmap)Bitmap.FromFile("Gradient\\gradient3.jpg");

            this.stabilizingWorker = new StabilizingWorker(this.kinectWorker);
            this.topographicWorker = new TopographicWorker(this.stabilizingWorker);
            this.topographicWorker.OutputDataReady += new EventHandler <BitmapReadyEventArgs>(kinectWorker_DataReady);
            this.topographicWorker.Gradient         = gradient;
        }
        /// <summary>
        /// launch all workers with last available settings
        /// </summary>
        private void launchWorkers()
        {
            // Initialize output bitmap
            this.colorBitmap = new WriteableBitmap(this.selectedWidth, this.selectedHeight, 96.0, 96.0, PixelFormats.Bgr32, null);
            // Set the image we display to point to the bitmap where we'll put the image data
            this.img.Source = this.colorBitmap;

            if (outputWindow != null)
            {
                outputWindow.updateBitmap(this.colorBitmap);
            }
            // Initialize Kinect Worker
            this.kinectWorker          = new KinectWorker();
            this.kinectWorker.MinDepth = (int)kinectSandboxUI.Properties.Settings.Default.MinDepth;
            this.kinectWorker.MaxDepth = (int)kinectSandboxUI.Properties.Settings.Default.MaxDepth;
            this.kinectWorker.setBoundingBox(this.startPoint, this.selectedWidth, this.selectedHeight);
            // If stabilization required Initialize StabilizingWorker
            if (kinectSandboxUI.Properties.Settings.Default.Stabilization)
            {
                this.stabilizingWorker          = new StabilizingWorker(this.kinectWorker);
                this.stabilizingWorker.MinDepth = (int)kinectSandboxUI.Properties.Settings.Default.MinDepth;
                this.stabilizingWorker.MaxDepth = (int)kinectSandboxUI.Properties.Settings.Default.MaxDepth;
                this.stabilizingWorker.setBoundingBox(this.startPoint, this.selectedWidth, this.selectedHeight);
            }
            Bitmap gradient = this.getGradient();

            if (kinectSandboxUI.Properties.Settings.Default.Stabilization)
            {
                this.topographicWorker = new TopographicWorker(this.stabilizingWorker);
            }
            else
            {
                this.topographicWorker = new TopographicWorker(this.kinectWorker);
            }
            this.topographicWorker.MinDepth = (int)kinectSandboxUI.Properties.Settings.Default.MinDepth;
            this.topographicWorker.MaxDepth = (int)kinectSandboxUI.Properties.Settings.Default.MaxDepth;
            this.topographicWorker.Isolines = (int)kinectSandboxUI.Properties.Settings.Default.Isolines;
            this.topographicWorker.setBoundingBox(this.startPoint, this.selectedWidth, this.selectedHeight);
            if (gradient != null)
            {
                this.topographicWorker.Gradient = gradient;
            }
            // Wire output data event
            this.topographicWorker.OutputDataReady += new EventHandler <BitmapReadyEventArgs>(worker_OutputDataReady);


            if (this.kinectWorker.IsKinectReady())
            {
                // Launch Threads
                this.Log().Debug("Launch KinectWorker from thread " + Thread.CurrentThread.ManagedThreadId);
                if (this.stabilizingWorker != null)
                {
                    // Launch stabilizing thread
                    stabilizingThread      = new Thread(this.stabilizingWorker.Start);
                    stabilizingThread.Name = "StabilizingWorker";
                    stabilizingThread.Start();
                }

                if (this.topographicWorker != null)
                {
                    //launch TopographicWorker Thread
                    topographicThread      = new Thread(this.topographicWorker.Start);
                    topographicThread.Name = "TopographicWorker";
                    topographicThread.Start();
                }

                if (this.kinectWorker != null)
                {
                    // Launch KinectWorker Thread
                    kinectThread      = new Thread(this.kinectWorker.Start);
                    kinectThread.Name = "KinectWorker";
                    kinectThread.Start();
                }
                this.btStart.IsEnabled     = false;
                this.btStop.IsEnabled      = true;
                this.btSaveImage.IsEnabled = true;
                this.menSettings.IsEnabled = false;
                this.isRunning             = true;
                // Launch stabilizing thread
            }
            else
            {
                this.displayError("No kinect device connected.");
            }
        }