/// <summary> /// Called by the framework to set the tool context. /// </summary> public void SetContext(IToolContext context) { _context = context; }
/// <summary> /// Disposes of this object; override this method to do any necessary cleanup. /// </summary> /// <param name="disposing">True if this object is being disposed, false if it is being finalized.</param> protected virtual void Dispose(bool disposing) { if (disposing) { _context = null; } }
/// <summary> /// Constructs a toolset based on the specified extension point and context. /// </summary> /// <remarks> /// The toolset will attempt to instantiate and initialize all /// extensions of the specified tool extension point that pass the /// specified filter. /// </remarks> /// <param name="toolExtensionPoint">The tool extension point that provides the tools.</param> /// <param name="context">The tool context to pass to each tool.</param> /// <param name="filter">Only tools that match the specified extension filter are loaded into the /// tool set. If null, all tools extending the extension point are loaded.</param> public ToolSet(IExtensionPoint toolExtensionPoint, IToolContext context, ExtensionFilter filter) : this(toolExtensionPoint.CreateExtensions(filter), context) { }
private void CleanInternal(IToolContext context) { Filters?.ForEach(f => f.Clear(context)); }
public override void Clean(IToolContext context) { base.Clean(context); CleanInternal(context); }
/// <summary> /// Constructs a toolset based on the specified extension point and context. /// </summary> /// <remarks> /// The toolset will attempt to instantiate and initialize all /// extensions of the specified tool extension point. /// </remarks> /// <param name="toolExtensionPoint">The tool extension point that provides the tools.</param> /// <param name="context">The tool context to pass to each tool.</param> public ToolSet(IExtensionPoint toolExtensionPoint, IToolContext context) : this(toolExtensionPoint, context, null) { }
public abstract bool Process(IToolContext context, ref double x, ref double y);
public SkiaExportContainerPresenter(IToolContext context, IContainerView view) { _context = context; _view = view; }
/// <inheritdoc/> public override void OnToolInactive(ToolEvent e, IToolContext context) { // Clear index of previously painted tile. this.lastPaintIndex = TileIndex.invalid; }
public static bool TryToSelect(IToolContext context, SelectionMode mode, SelectionTargets targets, Modifier selectionModifier, Point2 point, double radius, Modifier modifier) { var shapePoint = mode.HasFlag(SelectionMode.Point) && targets.HasFlag(SelectionTargets.Shapes) ? context.HitTest?.TryToGetPoint(context.CurrentContainer.Shapes, point, radius, null) : null; var shape = mode.HasFlag(SelectionMode.Shape) && targets.HasFlag(SelectionTargets.Shapes) ? context.HitTest?.TryToGetShape(context.CurrentContainer.Shapes, point, radius) : null; var guidePoint = mode.HasFlag(SelectionMode.Point) && targets.HasFlag(SelectionTargets.Guides) ? context.HitTest?.TryToGetPoint(context.CurrentContainer.Guides, point, radius, null) : null; var guide = mode.HasFlag(SelectionMode.Shape) && targets.HasFlag(SelectionTargets.Guides) ? context.HitTest?.TryToGetShape(context.CurrentContainer.Guides, point, radius) : null; if (shapePoint != null || shape != null || guidePoint != null || guide != null) { bool haveNewSelection = (shapePoint != null && !context.Renderer.SelectedShapes.Contains(shapePoint)) || (shape != null && !context.Renderer.SelectedShapes.Contains(shape)) || (guidePoint != null && !context.Renderer.SelectedShapes.Contains(guidePoint)) || (guide != null && !context.Renderer.SelectedShapes.Contains(guide)); if (context.Renderer.SelectedShapes.Count >= 1 && !haveNewSelection && !modifier.HasFlag(selectionModifier)) { return(true); } else { if (shapePoint != null) { if (modifier.HasFlag(selectionModifier)) { if (context.Renderer.SelectedShapes.Contains(shapePoint)) { Log.Info($"Deselected Shape Point: {shapePoint.GetType()}"); shapePoint.Deselect(context.Renderer); } else { Log.Info($"Selected Shape Point: {shapePoint.GetType()}"); shapePoint.Select(context.Renderer); } return(context.Renderer.SelectedShapes.Count > 0); } else { context.Renderer.SelectedShapes.Clear(); Log.Info($"Selected Shape Point: {shapePoint.GetType()}"); shapePoint.Select(context.Renderer); return(true); } } else if (shape != null) { if (modifier.HasFlag(selectionModifier)) { if (context.Renderer.SelectedShapes.Contains(shape)) { Log.Info($"Deselected Shape: {shape.GetType()}"); shape.Deselect(context.Renderer); } else { Log.Info($"Selected Shape: {shape.GetType()}"); shape.Select(context.Renderer); } return(context.Renderer.SelectedShapes.Count > 0); } else { context.Renderer.SelectedShapes.Clear(); Log.Info($"Selected Shape: {shape.GetType()}"); shape.Select(context.Renderer); return(true); } } else if (guidePoint != null) { if (modifier.HasFlag(selectionModifier)) { if (context.Renderer.SelectedShapes.Contains(guidePoint)) { Log.Info($"Deselected Guide Point: {guidePoint.GetType()}"); guidePoint.Deselect(context.Renderer); } else { Log.Info($"Selected Guide Point: {guidePoint.GetType()}"); guidePoint.Select(context.Renderer); } return(context.Renderer.SelectedShapes.Count > 0); } else { context.Renderer.SelectedShapes.Clear(); Log.Info($"Selected Guide Point: {guidePoint.GetType()}"); guidePoint.Select(context.Renderer); return(true); } } else if (guide != null) { if (modifier.HasFlag(selectionModifier)) { if (context.Renderer.SelectedShapes.Contains(guide)) { Log.Info($"Deselected Guide: {guide.GetType()}"); guide.Deselect(context.Renderer); } else { Log.Info($"Selected Guide: {guide.GetType()}"); guide.Select(context.Renderer); } return(context.Renderer.SelectedShapes.Count > 0); } else { context.Renderer.SelectedShapes.Clear(); Log.Info($"Selected Guide: {guide.GetType()}"); guide.Select(context.Renderer); return(true); } } } } return(false); }
public static bool TryToSelect(IToolContext context, SelectionMode mode, SelectionTargets targets, Modifier selectionModifier, Rect2 rect, double radius, Modifier modifier) { var shapes = mode.HasFlag(SelectionMode.Shape) && targets.HasFlag(SelectionTargets.Shapes) ? context.HitTest?.TryToGetShapes(context.CurrentContainer.Shapes, rect, radius) : null; var guides = mode.HasFlag(SelectionMode.Shape) && targets.HasFlag(SelectionTargets.Guides) ? context.HitTest?.TryToGetShapes(context.CurrentContainer.Guides, rect, radius) : null; if (shapes != null || guides != null) { if (shapes != null) { if (modifier.HasFlag(selectionModifier)) { foreach (var shape in shapes) { if (context.Renderer.SelectedShapes.Contains(shape)) { Log.Info($"Deselected Shape: {shape.GetType()}"); shape.Deselect(context.Renderer); } else { Log.Info($"Selected Shape: {shape.GetType()}"); shape.Select(context.Renderer); } } return(context.Renderer.SelectedShapes.Count > 0); } else { Log.Info($"Selected Shapes: {shapes?.Count ?? 0}"); context.Renderer.SelectedShapes.Clear(); foreach (var shape in shapes) { shape.Select(context.Renderer); } return(true); } } else if (guides != null) { if (modifier.HasFlag(selectionModifier)) { foreach (var guide in guides) { if (context.Renderer.SelectedShapes.Contains(guide)) { Log.Info($"Deselected Guide: {guide.GetType()}"); guide.Deselect(context.Renderer); } else { Log.Info($"Selected Guide: {guide.GetType()}"); guide.Select(context.Renderer); } } return(context.Renderer.SelectedShapes.Count > 0); } else { Log.Info($"Selected Guides: {guides?.Count ?? 0}"); context.Renderer.SelectedShapes.Clear(); foreach (var guide in guides) { guide.Select(context.Renderer); } return(true); } } } return(false); }
public abstract void Find(IToolContext context, BaseShape shape);
public override void LeftDown(IToolContext context, double x, double y, Modifier modifier) { base.LeftDown(context, x, y, modifier); PathTool.Move(); }