VintaSoft Imaging .NET SDK and Plug-ins Discussions
Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.
Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions
CreateGridGuidancePointAnnotationViews(new PointF((float)(imageWidth * 0.15) * 1F, (float)(imageHeight * 0.1) * 1F), "Point en haut a gauche", "GridPoint.TopLeft");
DrawAllAnnotations();
//This function create the annotationView and store it into a List<AnnotationView>
private void CreateGridGuidancePointAnnotationViews(PointF location, string toolTip, string name)
{
RectangleAnnotationData rectAnnotationData = new RectangleAnnotationData
{
CanResize = false,
ToolTip = toolTip,
CanRotate = false,
FillBrush = new AnnotationSolidBrush(Color.Blue),
Border = false,
Symmetry = true,
Location = location,
Size = new SizeF(10F, 10F),
Outline = {Color = Color.Red, Width = 0.5F}
};
AnnotationView annotationView = new RectangleAnnotationView(rectAnnotationData);
annotationView.Name = name;
annotationView.MouseUp += annotationView_MouseUp;
annotationView.MouseDown += annotationView_MouseDown;
annotationView.StateChanged += annotationView_StateChanged;
annotationView.Click += annotationView_Click;
annotationView.DoubleClick += annotationView_DoubleClick;
annotationView.StateChanged +=annotationView_StateChanged;
StoreAnnotationVIew(name, annotationView);
StoreAnnotationData(name, rectAnnotationData);
}
public void annotationView_DoubleClick(object sender, MouseEventArgs e)
{
throw new NotImplementedException();
}
public void annotationView_Click(object sender, MouseEventArgs e)
{
MessageBox.Show("testdfg");
}
public void annotationView_StateChanged(object sender, EventArgs e)
{
//MessageBox.Show("testdfg");
}
public void annotationView_MouseDown(object sender, MouseEventArgs e)
{
AnnotationView annotationView = (AnnotationView)sender;
MessageBox.Show("test cccc");
}
public void annotationView_MouseUp(object sender, MouseEventArgs e)
{
MessageBox.Show("test fff");
AnnotationView annotationView = (AnnotationView) sender;
}
private void DrawAllAnnotations()
{
//TODO: to check
//TODO: by steps show the correct value
AnnotationViewer annotationViewer = View.GetAnnotationViewer();
annotationViewer.AnnotationViewCollection.Clear();
foreach (var annotationView in _annotationsViewStorage.Values)
{
if (annotationView.IsVisible)
{
annotationView.MouseUp += annotationView_MouseUp;
annotationView.MouseDown += annotationView_MouseDown;
annotationView.StateChanged += annotationView_StateChanged;
annotationView.Click += annotationView_Click;
annotationView.DoubleClick += annotationView_DoubleClick;
annotationViewer.AnnotationViewCollection.Add(annotationView);
}
}
}
My first trouble is with the outline, I specified it to be red but it's still in a blueish color when the annotationView is selected. I must be setting it wrong and I would like some pointer on how to define it. The outline need to be very subtule or I will perhaps have to remove it completely (I do not yet have that information so I'm checking for both).I think you not correctly specified the outline color, i.e. you mixed up color channel values in color value.My first trouble is with the outline, I specified it to be red but it's still in a blueish color when the annotationView is selected. I must be setting it wrong and I would like some pointer on how to define it. The outline need to be very subtule or I will perhaps have to remove it completely (I do not yet have that information so I'm checking for both).
My second problem is with the mouse event, only the state_changed is fired with my code.The AnnotationVisualTool class is used for interacting between annotation and user and you should subscribe to events of this class if you want to monitor mouse interaction with annotation. More info please read here: https://www.vintasoft.com/docs/vsimaging ... Forms.html
I tried to specify the mouse event when I created the annotation and when I add them to the AnnotationViewer but none of the mouse event get fired. ...
private void AddAnnotationViewerMouseEvents()
{
AnnotationVisualTool annotationVisualTool = View.GetAnnotationViewer().AnnotationVisualTool;
annotationVisualTool.MouseDown += annotationVisualTool_MouseDown;
annotationVisualTool.MouseUp += annotationVisualTool_MouseUp;
annotationVisualTool.MouseMove += annotationVisualTool_MouseMove;
}
void annotationVisualTool_MouseMove(object sender, VisualToolMouseEventArgs e)
{
}
void annotationVisualTool_MouseUp(object sender, VisualToolMouseEventArgs e)
{
AnnotationVisualTool anno = (AnnotationVisualTool)sender;
if (null != anno.FocusedAnnotationView)
{
anno.FocusedAnnotationView.FillBrush = new AnnotationSolidBrush(Color.Red);
}
}
void annotationVisualTool_MouseDown(object sender, VisualToolMouseEventArgs e)
{
AnnotationVisualTool anno = (AnnotationVisualTool)sender;
if (null != anno.FocusedAnnotationView)
{
anno.FocusedAnnotationView.FillBrush = new AnnotationSolidBrush(Color.GreenYellow);
}
}
I get some weird behavior with that code. I created 8 rectangles on the annotationViewer I'm using with the following function:
private AnnotationView CreateGridGuidancePointAnnotationView(PointF location, string toolTip, string name)
{
var pointLocation = location;
pointLocation.X -= 5F;
pointLocation.Y -= 5F;
RectangleAnnotationData rectAnnotationData = new RectangleAnnotationData
{
CanResize = false,
ToolTip = toolTip,
CanRotate = false,
FillBrush = new AnnotationSolidBrush(Color.Blue),
Border = false,
Symmetry = true,
Location = pointLocation,
Size = new SizeF(10F, 10F)
};
AnnotationView annotationView = new RectangleAnnotationView(rectAnnotationData);
annotationView.Name = name;
return annotationView;
}
When I click on one rectangle, it moves with my mouse, but it doesn't change color until I release the left button. internal void ToggleCurrentAction(ViewerActions action, bool buttonIsChecked)
{
switch (action)
{
case ViewerActions.PanImage:
if (buttonIsChecked)
{
DesactivateAllOtherMenuButton(action);
PanTool panTool = new PanTool();
View.GetAnnotationViewer().VisualTool = panTool;
_currentAction = ViewerActions.PanImage;
}
else
{
View.GetAnnotationViewer().VisualTool = null;
_currentAction = ViewerActions.None;
}
break;
}
}
Best regards,... PanTool panTool = new PanTool(); View.GetAnnotationViewer().VisualTool = new CompositeVisualTool(panTool, View.GetAnnotationViewer().AnnotationVisualTool); ...Best regards, Alexander