/// <summary> /// Get eraser cursor. /// </summary> /// <returns></returns> protected override Cursor GetCurrentCursor() { if (InkCanvasEditingMode.EraseByPoint == _cachedEraseMode) { if (_cachedPointEraserCursor == null) { _cachedStylusShape = InkCanvas.EraserShape; // NTRAID-WINDOWS#1430638-2006/01/04-WAYNEZEN, // The eraser cursor should respect the InkCanvas' Transform properties as the pen tip. Matrix xf = GetElementTransformMatrix(); if (!xf.IsIdentity) { // Zero the offsets if the element's transform in invertable. // Otherwise fallback the matrix to the identity. if (xf.HasInverse) { xf.OffsetX = 0; xf.OffsetY = 0; } else { xf = Matrix.Identity; } } _cachedPointEraserCursor = PenCursorManager.GetPointEraserCursor(_cachedStylusShape, xf); } return(_cachedPointEraserCursor); } else { return(PenCursorManager.GetStrokeEraserCursor()); } }
// Token: 0x06006D68 RID: 28008 RVA: 0x001F6988 File Offset: 0x001F4B88 protected override Cursor GetCurrentCursor() { if (InkCanvasEditingMode.EraseByPoint == this._cachedEraseMode) { if (this._cachedPointEraserCursor == null) { this._cachedStylusShape = base.InkCanvas.EraserShape; Matrix tranform = base.GetElementTransformMatrix(); if (!tranform.IsIdentity) { if (tranform.HasInverse) { tranform.OffsetX = 0.0; tranform.OffsetY = 0.0; } else { tranform = Matrix.Identity; } } DpiScale dpi = base.InkCanvas.GetDpi(); this._cachedPointEraserCursor = PenCursorManager.GetPointEraserCursor(this._cachedStylusShape, tranform, dpi.DpiScaleX, dpi.DpiScaleY); } return(this._cachedPointEraserCursor); } return(PenCursorManager.GetStrokeEraserCursor()); }
// Token: 0x06006DC8 RID: 28104 RVA: 0x001F8E30 File Offset: 0x001F7030 internal static Cursor GetPointEraserCursor(StylusShape stylusShape, Matrix tranform, double dpiScaleX, double dpiScaleY) { DrawingAttributes drawingAttributes = new DrawingAttributes(); if (stylusShape.GetType() == typeof(RectangleStylusShape)) { drawingAttributes.StylusTip = StylusTip.Rectangle; } else { drawingAttributes.StylusTip = StylusTip.Ellipse; } drawingAttributes.Height = stylusShape.Height; drawingAttributes.Width = stylusShape.Width; drawingAttributes.Color = Colors.Black; if (!tranform.IsIdentity) { drawingAttributes.StylusTipTransform *= tranform; } if (!DoubleUtil.IsZero(stylusShape.Rotation)) { Matrix identity = Matrix.Identity; identity.Rotate(stylusShape.Rotation); drawingAttributes.StylusTipTransform *= identity; } return(PenCursorManager.GetPenCursor(drawingAttributes, true, false, dpiScaleX, dpiScaleY)); }
// Token: 0x06006DE7 RID: 28135 RVA: 0x001FA101 File Offset: 0x001F8301 protected override Cursor GetCurrentCursor() { if (base.InkCanvas.SelectionAdorner.IsMouseOver) { return(PenCursorManager.GetSelectionCursor(this._hitResult, base.InkCanvas.FlowDirection == FlowDirection.RightToLeft)); } return(null); }
internal static Cursor GetStrokeEraserCursor() { if (PenCursorManager.s_StrokeEraserCursor == null) { Drawing drawing = PenCursorManager.CreateStrokeEraserDrawing(); PenCursorManager.s_StrokeEraserCursor = PenCursorManager.CreateCursorFromDrawing(drawing, new Point(5.0, 5.0)); } return(PenCursorManager.s_StrokeEraserCursor); }
/// <summary> /// Retrieve the cursor /// </summary> /// <returns></returns> protected override Cursor GetCurrentCursor() { // // We only show the selection related cursor when the mouse is over the SelectionAdorner. // If mouse is outside of the SelectionAdorner, we let the system to pick up the default cursor. if ( InkCanvas.SelectionAdorner.IsMouseOver ) { return PenCursorManager.GetSelectionCursor(_hitResult, (this.InkCanvas.FlowDirection == FlowDirection.RightToLeft)); } else { return null; } }
/// <summary> /// Retrieve the cursor /// </summary> /// <returns></returns> protected override Cursor GetCurrentCursor() { // NTRAID:WINDOWSOS#1648430-2006/05/12-WAYNEZEN, // We only show the selection related cursor when the mouse is over the SelectionAdorner. // If mouse is outside of the SelectionAdorner, we let the system to pick up the default cursor. if (InkCanvas.SelectionAdorner.IsMouseOver) { return(PenCursorManager.GetSelectionCursor(_hitResult, (this.InkCanvas.FlowDirection == FlowDirection.RightToLeft))); } else { return(null); } }
private static Cursor CreateCursorFromDrawing(Drawing drawing, Point hotspot) { Cursor arrow = Cursors.Arrow; Rect bounds = drawing.Bounds; double width = bounds.Width; double height = bounds.Height; int num = IconHelper.AlignToBytes(bounds.Width, 1); int num2 = IconHelper.AlignToBytes(bounds.Height, 1); bounds.Inflate(((double)num - width) / 2.0, ((double)num2 - height) / 2.0); int xHotspot = (int)Math.Round(hotspot.X - bounds.Left); int yHotspot = (int)Math.Round(hotspot.Y - bounds.Top); DrawingVisual visual = PenCursorManager.CreateCursorDrawingVisual(drawing, num, num2); RenderTargetBitmap rtb = PenCursorManager.RenderVisualToBitmap(visual, num, num2); byte[] pixels = PenCursorManager.GetPixels(rtb, num, num2); NativeMethods.IconHandle iconHandle = IconHelper.CreateIconCursor(pixels, num, num2, xHotspot, yHotspot, false); if (iconHandle.IsInvalid) { return(Cursors.Arrow); } return(CursorInteropHelper.CriticalCreate(iconHandle)); }
// Token: 0x06006DD6 RID: 28118 RVA: 0x001F9A9A File Offset: 0x001F7C9A protected override Cursor GetCurrentCursor() { return(PenCursorManager.GetSelectionCursor(this._hitResult, base.InkCanvas.FlowDirection == FlowDirection.RightToLeft)); }
// Token: 0x06006DCF RID: 28111 RVA: 0x001F9190 File Offset: 0x001F7390 private static Drawing CreatePenDrawing(DrawingAttributes drawingAttributes, bool isHollow, bool isRightToLeft, double dpiScaleX, double dpiScaleY) { Stroke stroke = new Stroke(new StylusPointCollection { new StylusPoint(0.0, 0.0) }, new DrawingAttributes { Color = drawingAttributes.Color, Width = drawingAttributes.Width, Height = drawingAttributes.Height, StylusTipTransform = drawingAttributes.StylusTipTransform, IsHighlighter = drawingAttributes.IsHighlighter, StylusTip = drawingAttributes.StylusTip }); stroke.DrawingAttributes.Width = PenCursorManager.ConvertToPixel(stroke.DrawingAttributes.Width, dpiScaleX); stroke.DrawingAttributes.Height = PenCursorManager.ConvertToPixel(stroke.DrawingAttributes.Height, dpiScaleY); double num = Math.Min(SystemParameters.PrimaryScreenWidth / 2.0, SystemParameters.PrimaryScreenHeight / 2.0); Rect bounds = stroke.GetBounds(); bool flag = false; if (DoubleUtil.LessThan(bounds.Width, 1.0)) { stroke.DrawingAttributes.Width = 1.0; flag = true; } else if (DoubleUtil.GreaterThan(bounds.Width, num)) { stroke.DrawingAttributes.Width = num; flag = true; } if (DoubleUtil.LessThan(bounds.Height, 1.0)) { stroke.DrawingAttributes.Height = 1.0; flag = true; } else if (DoubleUtil.GreaterThan(bounds.Height, num)) { stroke.DrawingAttributes.Height = num; flag = true; } if (flag) { stroke.DrawingAttributes.StylusTipTransform = Matrix.Identity; } if (isRightToLeft) { Matrix stylusTipTransform = stroke.DrawingAttributes.StylusTipTransform; stylusTipTransform.Scale(-1.0, 1.0); if (stylusTipTransform.HasInverse) { stroke.DrawingAttributes.StylusTipTransform = stylusTipTransform; } } DrawingGroup drawingGroup = new DrawingGroup(); DrawingContext drawingContext = null; try { drawingContext = drawingGroup.Open(); if (isHollow) { stroke.DrawInternal(drawingContext, stroke.DrawingAttributes, isHollow); } else { stroke.Draw(drawingContext, stroke.DrawingAttributes); } } finally { if (drawingContext != null) { drawingContext.Close(); } } return(drawingGroup); }
internal static Cursor GetPenCursor(DrawingAttributes drawingAttributes, bool isHollow, bool isRightToLeft, double dpiScaleX, double dpiScaleY) { Drawing drawing = PenCursorManager.CreatePenDrawing(drawingAttributes, isHollow, isRightToLeft, dpiScaleX, dpiScaleY); return(PenCursorManager.CreateCursorFromDrawing(drawing, new Point(0.0, 0.0))); }