public void InstallLineHandle(int pointIndex) { var handle = new LineHandle(new Ellipse(this[pointIndex].X, this[pointIndex].Y, 10, 10), pointIndex, this); handle.SetSnapTargets(SnapTargets.Center); AddHandle(handle); }
public override void OnMouseMove(Canvas canvas, float mouseX, float mouseY, bool isShiftKey, bool isCtrlKey) { if (!_isInitialized) { _isInitialized = true; _line = new Line(0, 0, 0, 0); _line.SetSnapTargets(SnapTargets.Vertices); _lineHandle = new LineHandle(new Ellipse(mouseX, mouseY, 10, 10), 0, _line) { CanBeSnapTarget = false, FillColor = Colors.Transparent }; foreach (var snapPolicy in canvas.GetSnapPolicies()) { snapPolicy.InitSnap(canvas, _lineHandle.GetSnapPoints(), new [] { _lineHandle }); } canvas.Selection.Clear(); canvas.AddFigure(_lineHandle); } var snapPoint = new Point(mouseX, mouseY); var isSnapped = false; foreach (var snapPolicy in canvas.GetSnapPolicies()) { Point delta; isSnapped = snapPolicy.Snap(canvas, snapPoint, 0, 0, mouseX, mouseY, out snapPoint, out delta, new[] { _lineHandle }); if (isSnapped) { break; } } if (isSnapped) { mouseX = snapPoint.X; mouseY = snapPoint.Y; } _lineHandle.ForceSetPositionCenter(mouseX, mouseY); if (_clickCount == 0) { _line[0] = new Point(mouseX, mouseY); _line[1] = new Point(mouseX, mouseY); } else { _line[1] = new Point(mouseX, mouseY); } }
/// <summary> /// Creates the handles for the manipulation of the object. /// </summary> private void CreateHandles() { var segments = this.GetRectangle(); this.rightWidthHandle = this.handleManager.CreateLineHandle(segments[0], HandleLocationType.Other, HandleEffectType.Geometry); this.topHeightHandle = this.handleManager.CreateLineHandle(segments[1], HandleLocationType.Other, HandleEffectType.Geometry); this.leftWidthHandle = this.handleManager.CreateLineHandle(segments[2], HandleLocationType.Other, HandleEffectType.Geometry); this.bottomHeightHandle = this.handleManager.CreateLineHandle(segments[3], HandleLocationType.Other, HandleEffectType.Geometry); this.AttachHandlers(); }
/// <summary> /// Returns the line number, text content, and marker status of the given line, which can be either a number or a handle returned by setMarker. /// The returned object has the structure {line, handle, text, markerText, markerClass, lineClass, bgClass}. /// </summary> /// <param name="line"></param> /// <returns></returns> public LineInfo lineInfo(LineHandle line) { return null; }
/// <summary> /// Register a function that should be called when the line is deleted from the document. /// </summary> /// <param name="line"></param> /// <param name="func"></param> public void onDeleteLine(LineHandle line, JsAction func) { }
/// <summary> /// The inverse of hideLine—re-shows a previously hidden line, by number or by handle. /// </summary> /// <param name="line"></param> /// <returns></returns> public LineHandle showLine(LineHandle line) { return null; }
/// <summary> /// Hide the given line (either by number or by handle). Hidden lines don't show up in the editor, and their numbers are skipped when line numbers are enabled. /// Deleting a region around them does delete them, and coping a region around will include them in the copied text. /// </summary> /// <param name="line"></param> /// <returns></returns> public LineHandle hideLine(LineHandle line) { return null; }
/// <summary> /// Set a CSS class name for the given line. line can be a number or a line handle (as returned by setMarker or this function). /// className will be used to style the text for the line, and backgroundClassName to style its background (which lies behind the selection). /// Pass null to clear the classes for a line. /// </summary> /// <param name="line"></param> /// <param name="className"></param> /// <param name="backgroundClassName"></param> /// <returns></returns> public LineHandle setLineClass(LineHandle line, JsString className, JsString backgroundClassName) { return null; }
/// <summary> /// Clears a marker created with setMarker. /// line can be either a number or a handle returned by setMarker (since a number may now refer to a different line if something was added or deleted). /// </summary> /// <param name="line"></param> public void clearMarker(LineHandle line) { }