Example #1
0
 public void SetDiBitmap(DiBitmap bmp, Point drawAt)
 {
     SetHBitmap(bmp.HBitmap, _bounds, drawAt, new Rectangle(0, 0, bmp.Size.Width, bmp.Size.Height), 255);
 }
Example #2
0
 public void SetDiBitmap(DiBitmap bmp, Rectangle newWindowBounds, Point drawAt, Rectangle dirtyRect, byte opacity)
 {
     SetHBitmap(bmp.HBitmap, newWindowBounds, drawAt, new Rectangle(0, 0, _bounds.Width, _bounds.Height), opacity);
 }
Example #3
0
 public void SetDiBitmap(DiBitmap bmp)
 {
     SetHBitmap(bmp.HBitmap, _bounds, new Point(), new Rectangle(new Point(), bmp.Size), 255);
 }
Example #4
0
 public void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect, byte opacity)
 {
     SetHBitmap(bmp.HBitmap, _bounds, new Point(), dirtyRect, opacity);
 }
Example #5
0
        public void SetDiBitmap(DiBitmap bmp, Rectangle newWindowBounds, Point drawAt, Rectangle dirtyRect, byte opacity)
        {
            SetHBitmap(bmp.HBitmap, newWindowBounds, drawAt, new Rectangle(0, 0, _bounds.Width, _bounds.Height), opacity);

        }
Example #6
0
 public void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect)
 {
     SetDiBitmap(bmp, dirtyRect, 255);
 }
Example #7
0
 public void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect, byte opacity)
 {
     SetHBitmap(bmp.HBitmap, _bounds, new Point(), dirtyRect, opacity);
 }
Example #8
0
 public void SetDiBitmap(DiBitmap bmp, Point drawAt)
 {
     SetHBitmap(bmp.HBitmap, _bounds, drawAt, new Rectangle(0, 0, bmp.Size.Width, bmp.Size.Height), 255);
 }
Example #9
0
 public void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect)
 {
     SetDiBitmap(bmp,dirtyRect,255);
 }
Example #10
0
 public void SetDiBitmap(DiBitmap bmp)
 {
     SetHBitmap(bmp.HBitmap, _bounds, new Point(), new Rectangle(new Point(), bmp.Size), 255);
 }
        private void EndView()
        {
            Debug.WriteLine("EndView");
            using (_bitmap)
            {
                if (ShowPath)
                {
                    var g = _bitmap.BeginDraw();

                    _gPath.Widen(_dirtyMarkerPen);
                    g.SetClip(_gPath);
                    g.Clear(Color.Transparent);
                    _bitmap.EndDraw();

                    var pathDirty = Rectangle.Ceiling(_gPath.GetBounds());
                    pathDirty.Offset(_screenBounds.X, _screenBounds.Y);
                    pathDirty.Intersect(_screenBounds);
                    pathDirty.Offset(-_screenBounds.X, -_screenBounds.Y); //挪回来变为基于窗口的坐标

                    _canvasWindow.SetDiBitmap(_bitmap, pathDirty);

                    _gPath.Reset();
                    _gPathDirty.Reset();

                    /*_gPath.Dispose();
                    _gPath = null;
                    _gPathDirty.Dispose();
                    _gPathDirty = null;*/

                }

                if (_labelVisible)//ShowCommandName)
                {
                    var g = _bitmap.BeginDraw();
                    g.SetClip(_labelRect);
                    g.Clear(Color.Transparent);
                    _bitmap.EndDraw();

                    _canvasWindow.SetDiBitmap(_bitmap, Rectangle.Ceiling(_labelRect));

                    _labelPath.Reset();

                    HideLabel();
                    _labelChanged = false;
                }

            }
            _bitmap = null;

            _canvasWindow.Visible = false;

            _labelRect = default(Rectangle);//todo: dirtyRect也是多余
        }
        private void BeginView()
        {
            Debug.WriteLine("BeginView");
            StopFadeout();

            _bitmap = new DiBitmap(_screenBounds.Size);
            _canvasOpacity = 255;
            _canvasWindow.Bounds = _screenBounds;

            _canvasWindow.TopMost = true;
            _canvasWindow.Visible = true;

            if (ShowPath)
            {
                _pathVisible = true;
                _pathPen = _alternativePen;

                //_gPath = new GraphicsPath();
                //_gPathDirty = new GraphicsPath();
            }

            if (ShowCommandName)
            {
                _labelVisible = false;
            }
        }
        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;
        }
 private void SystemDisplaySettingsChanged(object sender, EventArgs e)
 {
     _screenBounds = Native.GetScreenBounds();
     _canvasBuf = new DiBitmap(_screenBounds.Size);
     _dpiFactor = Native.GetScreenDpi() / 96.0f;
 }
        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();

            _canvasBuf = new DiBitmap(_screenBounds.Size);

            InitDefaultProperties();
            _fadeOuTimer.Elapsed += OnFadeOutTimerElapsed;
            SystemEvents.DisplaySettingsChanged += SystemDisplaySettingsChanged;
        }