/// <summary> /// Executes the FillRectangleCommand command. /// </summary> public void ExecuteFillRectangleCommand() { // create the processing command FillRectangleCommand command = new FillRectangleCommand(); RectangularSelectionTool visualTool = null; if (_viewer.VisualTool != null && _viewer.VisualTool is RectangularSelectionTool) { visualTool = (RectangularSelectionTool)_viewer.VisualTool; if (!visualTool.Rectangle.IsEmpty) { command.Rectangles = new Rectangle[] { visualTool.Rectangle } } ; } // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Fill Rectangle Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } if (visualTool != null) { visualTool.Rectangle = Rectangle.Empty; } // execute the command ExecuteProcessingCommand(command, true); }
/// <summary> /// Deactivates this action. /// </summary> public override void Deactivate() { RectangularSelectionTool rectangularSelectionTool = (RectangularSelectionTool)VisualTool; rectangularSelectionTool.SelectionChanged -= RectangularSelectionTool_SelectionChanged; base.Deactivate(); }
/// <summary> /// Initializes a new instance of the <see cref="RectangularSelectionAction"/> class. /// </summary> /// <param name="visualTool">The visual tool.</param> /// <param name="text">The action text.</param> /// <param name="toolTip">The action tool tip.</param> /// <param name="icon">The action icon.</param> /// <param name="subActions">The sub-actions of the action.</param> public RectangularSelectionAction( RectangularSelectionTool visualTool, string text, string toolTip, Image icon, params VisualToolAction[] subActions) : base(visualTool, text, toolTip, icon, subActions) { }
/// <summary> /// Activates this action. /// </summary> public override void Activate() { base.Activate(); RectangularSelectionTool rectangularSelectionTool = (RectangularSelectionTool)VisualTool; rectangularSelectionTool.SelectionChanged += new EventHandler <SelectionChangedEventArgs>(RectangularSelectionTool_SelectionChanged); }
/// <summary> /// Starts the preview. /// </summary> public void StartPreview() { // if current tool is CustomSelectionTool if (_viewer.VisualTool is CustomSelectionTool) { CustomSelectionTool selectionTool = (CustomSelectionTool)_viewer.VisualTool; RectangleF selectionBBox = RectangleF.Empty; if (selectionTool.Selection != null) { selectionBBox = selectionTool.Selection.GetBoundingBox(); } if (selectionBBox.Width >= 1 && selectionBBox.Height >= 1) { _selectionRegionView = selectionTool.Selection.View; _processedSelectionRegionView = new SelectionRegionViewWithImageProcessingPreview(); _processedSelectionRegionView.UseViewerZoomForProcessing = UseCurrentViewerZoomWhenPreviewProcessing; selectionTool.Selection.View = _processedSelectionRegionView; _isPreviewStarted = true; return; } } // set current tool to ImageProcessingTool _viewerTool = _viewer.VisualTool; _rectangularPreview = new ImageProcessingTool(); Rectangle imageRect = new System.Drawing.Rectangle(0, 0, _viewer.Image.Width, _viewer.Image.Height); Rectangle rect = imageRect; if (_viewer.VisualTool is RectangularSelectionTool) { RectangularSelectionTool rectangularSelection = (RectangularSelectionTool)_viewer.VisualTool; if (!rectangularSelection.Rectangle.Size.IsEmpty) { if (_viewer.VisualTool is RectangularSelectionToolWithCopyPaste) { rect = rectangularSelection.Rectangle; } _rectangularSelectionToolRect = rectangularSelection.Rectangle; } } _rectangularPreview.UseViewerZoomForPreviewProcessing = UseCurrentViewerZoomWhenPreviewProcessing; _viewer.VisualTool = _rectangularPreview; _rectangularPreview.Rectangle = rect; if (rect == imageRect) { _rectangularPreview.InteractionController = null; } _isPreviewStarted = true; }