Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, January 23, 2019 6:06:12 PM(UTC)
Rob Cline

Groups: Registered
Posts: 52

Thanks: 14 times

I have a document redaction and clean-up program that I support.
We only allow our users to add solid white rectangles (i.e. white-outs), redactions, and text block annotations to a document.
I don't want to expose the entire automated annotation pallette, nor can I figure out a way to incorporate individual annotation buttons into my toolstrip in the program.

Therefore, I am having to program non-automated annotations using rubberband interactions and using the resulting rectangle to create the appropriate annotation.
This means I also need to handle the automation_SetCursor event to set the selection and edit cursors into the cursor shapes the operators are already familiar with from microsoft windows.
However, I can't find anything that tells me what AnnDesignerType.Draw vs. AnnDesignerType.Edit vs AnnDesignerType.Run vs. AnnDesignerType.None mean, or how they are set.
Search the documentation and forum turned up nothing helpful about the AnnDesignerType other than they say it is an enumerated property.

Below is code from one of your samples with variables renamed for my project:
Unfortunately, there are no comments about what or how e.DesignerType is set, modified, or why.

Code:
        private void automation_SetCursor(object sender, AnnCursorEventArgs e)
        {
            // If there's an interactive mode working and its not automation, then don't do anything

            if (CurrentImageViewer.WorkingInteractiveMode != null 
                && CurrentImageViewer.WorkingInteractiveMode.Id != DocumentViewer.AnnotationsInteractiveModeId)
                return;

            var annAutomation = sender as AnnAutomation;
            Cursor newCursor = null;

            if (annAutomation.ActiveContainer == null || !annAutomation.ActiveContainer.IsEnabled)
            {
                newCursor = Cursors.Default;
            }
            else
            {
                switch (e.DesignerType)
                {
                    case AnnDesignerType.Draw:
                        {
                            var allow = true;

                            if (annAutomation.CurrentDesigner is AnnDrawDesigner drawDesigner
                                && !drawDesigner.IsTargetObjectAdded && e.PointerEvent != null)
                            {
                                // See if we can draw or not (i.e. did the user just select an existing container)
                                // HitTestContainer returns the first container found under the e.PointerEvent.Location
                                allow = annAutomation.HitTestContainer(e.PointerEvent.Location, false) != null;
                            }

                            if (allow)
                            {
                                var annAutomationObject = annAutomation.Manager.FindObjectById(e.Id);
                                if (annAutomationObject != null)
                                    newCursor = annAutomationObject.DrawCursor as Cursor;
                            }
                            else
                            {
                                newCursor = Cursors.No;
                            }
                        }
                        break;

                    case AnnDesignerType.Edit:
                        if (e.IsRotateCenter)
                            newCursor = AutomationManagerHelper.AutomationCursors[CursorType.RotateCenterControlPoint];
                        else if (e.IsRotateGripper)
                            newCursor = AutomationManagerHelper.AutomationCursors[CursorType.RotateGripperControlPoint];
                        else if (e.ThumbIndex < 0)
                        {
                            if (e.DragDropEvent != null && !e.DragDropEvent.Allowed)
                                newCursor = Cursors.No;
                            else
                                newCursor = AutomationManagerHelper.AutomationCursors[CursorType.SelectedObject];
                        }
                        else
                        {
                            newCursor = AutomationManagerHelper.AutomationCursors[CursorType.ControlPoint];
                        }
                        break;

                    case AnnDesignerType.Run:
                        newCursor = AutomationManagerHelper.AutomationCursors[CursorType.Run];
                        break;

                    default:
                        newCursor = AutomationManagerHelper.AutomationCursors[CursorType.SelectObject];
                        break;
                }
            }

            if (CurrentImageViewer.Cursor != newCursor)
                CurrentImageViewer.Cursor = newCursor;
        }

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, January 24, 2019 1:48:23 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Rob,

Regarding your original idea, you can disable any/all of the buttons within the annotation toolbar. Additionally, these buttons only perform a single action: when clicked they update AnnAutomationManager.CurrentObjectId property to some pre-determined integer. Should you want to have control over which buttons are visible, you have a few options, here are two I recommend:

  • Allow the default toolbar to be created, then remove the buttons you don't want to be used before displaying the toolbar. Something like the following:
    Code:
    
    var allowedButtons = new HashSet<int>()
    {
       Leadtools.Annotations.Engine.AnnObject.SelectObjectId,
       Leadtools.Annotations.Engine.AnnObject.RectangleObjectId,
       // etc.
    };
    var helper = new Leadtools.Annotations.WinForms.AutomationManager.Helper(annAutomationManager);
    helper.CreateToolBar();
    var allButtons = helper.ToolBar.Buttons.ToList(); // Cache list to allow deletion during foreach loop
    foreach (var button in allButtons)
       if (!(button.Tag is int && allowedButtons.Contains((int)button.Tag)))
          helper.ToolBar.Buttons.Remove(button);
    // TODO: Add helper.ToolBar to your visible controls
    

  • Create your own toolbar manually. You can find a reference for how this should be performed within the AutomationManagerHelper source included with our SDK here:
    LEADTOOLS 20\Examples\DotNet\CS\Leadtools.Annotations.Winforms\Common\Helpers\AutomationManagerHelper.cs

And for your AnnDesignerType question, these correspond to the following

  • Draw: User is adding an annotation to the screen. For example, the user just clicked the rectangle button from the annotation toolbar, and is dragging a region on the screen. The active designer here would be the AnnRectangleDrawDesigner.
  • Edit: User is modifying an existing annotation. For example, the user has a rectangle selected, and is dragging one of the corner points to resize. The active designer here would be the AnnRectangleEditDesigner.
  • None: The AnnAutomationManager.UserMode property is currently Render, and no user interaction can take place.
  • Run: The UserMode is currently Run, and all clicks will fire the AnnAutomation.Run event.

If you are using an older version of our SDK, have any further questions regarding the information above, or would like a sample project, please let me know.

Thanks,
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Rob Cline on 1/24/2019(UTC)
 
#3 Posted : Thursday, January 24, 2019 2:02:31 PM(UTC)
Rob Cline

Groups: Registered
Posts: 52

Thanks: 14 times

Thanks.

I'm using version 20.
I had not looked at LEADTOOLS 20\Examples\DotNet\CS\Leadtools.Annotations.Winforms\Common\Helpers\AutomationManagerHelper.cs as an example of working with automated annotations.

If the example above allows me to use the automated creation of my three annotation types then that will GREATLY simplify my code.
 
#4 Posted : Thursday, January 24, 2019 2:46:21 PM(UTC)
Anthony Northrup

Groups: Registered, Tech Support, Administrators
Posts: 199

Was thanked: 28 time(s) in 28 post(s)

Hello Rob,

That AutomationManagerHelper file is responsible for all toolbar creation in our demos, so it's definitely a good resource. If you want to customize the default properties of a particular annotation type, such as making the rectangles white, you'll need to customize the templates stored on the AnnAutomationManager:
Code:

var manager = new Leadtools.Annotations.Automation.AnnAutomationManager();
// This will configure all the icons for later use by the toolbar,
//   and configure default annotation properties such as having a red stroke
manager.CreateDefaultObjects();

// Update the default rectangle
var autoObject = manager.FindObjectById(
   Leadtools.Annotations.Engine.AnnObject.RectangleObjectId
);
var template = autoObject.?ObjectTemplate as Leadtools.Annotations.Engine.AnnRectangleObject;
if (template != null)
   template.Fill = Leadtools.Annotations.Engine.AnnSolidColorBrush.Create("white");

Relevant documentation links:

Thanks,
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
thanks 1 user thanked Anthony Northrup for this useful post.
Rob Cline on 1/24/2019(UTC)
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.090 seconds.