public CanvasWindowGestureView(GestureParser gestureParser)
        {
            _gestureParser = gestureParser;
            RegisterEventHandlers();
            var waitCanvasWindow = new AutoResetEvent(false);
            new Thread(() =>
            {
                _canvasWindow = new CanvasWindow()
                {
                    //最初的时候放在屏幕以外
                    Visible = false,
                    IgnoreInput = true,
                    NoActivate = true,
                    TopMost = true
                };
                waitCanvasWindow.Set();
                _canvasWindow.ShowDialog();
            }) { Name = "CanvasWindow" }.Start();

            waitCanvasWindow.WaitOne();

            InitDefaultProperties();
            _fadeOuTimer.Elapsed += OnFadeOutTimerElapsed;
            SystemEvents.DisplaySettingsChanged += SystemDisplaySettingsChanged;
        }
        public void Dispose()
        {
            if (IsDisposed) return;

            #region unregistor events
            _gestureParser.IntentRecognized -= HandleIntentRecognized;
            _gestureParser.IntentInvalid -= HandleIntentInvalid;
            _gestureParser.IntentOrPathCanceled -= HandleIntentOrPathCanceled;

            _gestureParser.PathTracker.PathStart -= HandlePathStart;
            _gestureParser.PathTracker.PathGrow -= HandlePathGrow;
            _gestureParser.PathTracker.PathTimeout -= HandlePathTimeout;
            _gestureParser.IntentReadyToExecute -= HandleIntentReadyToExecute;
            _gestureParser.IntentReadyToExecuteOnModifier -= HandleIntentReadyToExecuteOnModifier;

            _gestureParser.GestureCaptured -= HandleGestureRecorded;
            _gestureParser.CommandReportStatus -= HandleCommandReportStatus;

            #endregion

            #region dispose pens
            _mainPen.Dispose();
            _middleBtnPen.Dispose();
            _borderPen.Dispose();
            _alternativePen.Dispose();
            _shadowPen.Dispose();
            _dirtyMarkerPen.Dispose();
            #endregion

            if (_bitmap != null)
            {
                _bitmap.Dispose();
                _bitmap = null;
            }
            if (_canvasWindow != null)
            {
                _canvasWindow.Dispose();
                _canvasWindow = null;
            }
            if (_gPath != null)
            {
                _gPath.Dispose();
                _gPath = null;
            }
            if (_gPathDirty != null)
            {
                _gPathDirty.Dispose();
                _gPathDirty = null;
            }

            if (_labelPath != null)
            {
                _labelPath.Dispose();
                _labelPath = null;
            }
            if (_labelFont != null)
            {
                _labelFont.Dispose();
                _labelFont = null;
            }

            if (_fadeOuTimer != null)
            {
                _fadeOuTimer.Elapsed -= OnFadeOutTimerElapsed;
                _fadeOuTimer.Dispose();
                _fadeOuTimer = null;
            }

            SystemEvents.DisplaySettingsChanged -= SystemDisplaySettingsChanged;

            Debug.WriteLine("Dispose");
            IsDisposed = true;
        }