public void Complete(Vector2 startingPoint, Vector2 point, bool isOutNodeDistance) { // Selection if (this.Mode == ListViewSelectionMode.None) { return; } this.HandleMode = BrushHandleMode.None; Matrix3x2 inverseMatrix = this.ViewModel.CanvasTransformer.GetInverseMatrix(); Vector2 canvasStartingPoint = Vector2.Transform(startingPoint, inverseMatrix); Vector2 canvasPoint = Vector2.Transform(point, inverseMatrix); // Snap if (this.IsSnap) { canvasPoint = this.Snap.Snap(canvasPoint); this.Snap.Default(); } this.TransparencyComplete(canvasStartingPoint, canvasPoint); // Cursor CoreCursorExtension.IsManipulationStarted = false; CoreCursorExtension.Cross(); this.ViewModel.Invalidate(InvalidateMode.HD); // Invalidate }
/// <summary> /// It controls the transformation of brush. /// </summary> /// <param name="mode"> The mode. </param> /// <param name="startingPoint"> The starting point. </param> /// <param name="point"> The point. </param> public void Controller(BrushHandleMode mode, Vector2 startingPoint, Vector2 point) { switch (this.Type) { case BrushType.None: break; case BrushType.Color: break; case BrushType.LinearGradient: { switch (mode) { case BrushHandleMode.Center: this.Center = point; return; case BrushHandleMode.YPoint: this.YPoint = point; return; } } break; case BrushType.RadialGradient: { switch (mode) { case BrushHandleMode.Center: { Vector2 center = point; Vector2 yPoint = center + this.StartingYPoint - this.StartingCenter; this.Center = center; this.YPoint = yPoint; } return; case BrushHandleMode.YPoint: this.YPoint = point; return; } } break; case BrushType.EllipticalGradient: case BrushType.Image: { switch (mode) { case BrushHandleMode.Center: { Vector2 center = point; Vector2 offset = point - startingPoint; this.Center = center; this.XPoint = offset + this.StartingXPoint; this.YPoint = offset + this.StartingYPoint; } return; case BrushHandleMode.XPoint: { float radiusY = Vector2.Distance(this.StartingYPoint, this.StartingCenter); this.XPoint = point; this.YPoint = BrushBase.XToY(point, this.StartingCenter, radiusY); } return; case BrushHandleMode.YPoint: { float radiusX = Vector2.Distance(this.StartingXPoint, this.StartingCenter); this.XPoint = BrushBase.YToX(point, this.StartingCenter, radiusX); this.YPoint = point; } return; } } return; default: return; } }