VintaSoft Annotation .NET Plug-in Discussions
Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.
Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions
private void annotationViewer1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.StringFormat))
{
var str = (string)e.Data.GetData(DataFormats.StringFormat);
if (str.Length > 0)
{
float zoomFactor = ((annotationViewer1.ZoomExtended -100)/100);
Point clientLocation = annotationViewer1.PointToClient(new Point(e.X, e.Y));
PointF imageLocation = annotationViewer1.PointToImageF(new PointF(e.X, e.Y));
PointF test1 = annotationViewer1.PointToImageF(new PointF(clientLocation.X, clientLocation.Y));
float clientx = clientLocation.X * zoomFactor;
float clienty = clientLocation.Y;
StickyNoteAnnotationData stickyNote = new StickyNoteAnnotationData();
stickyNote.FillBrush = new AnnotationSolidBrush(Color.Yellow);
stickyNote.CollapsedTextData.Text = str;
stickyNote.CollapsedTextData.TextPadding = new PaddingF(0f);
stickyNote.CollapsedTextData.Font = new AnnotationFont("Tahoma", 12);
stickyNote.CollapsedTextData.AutoSize = true;
stickyNote.CanMirror = false;
stickyNote.CanResize = false;
stickyNote.CollapsedTextData.Font.Underline = true;
stickyNote.Outline.Color = Color.Red;
stickyNote.CollapsedTextData.TextAlign = ContentAlignment.MiddleCenter;
stickyNote.Location = test1;
annotationViewer1.AddAndBuildAnnotation(stickyNote);
}
}
}
// Get the cordinates of the point on screen to client Point clientLocation = annotationViewer1.PointToClient(new Point(e.X, e.Y)); // Get the point of the image in the viewer PointF imageLocation = annotationViewer1.PointToImageF(new PointF(clientLocation.X, clientLocation.Y)); // Convert the resolution to the image float multX = annotationViewer1.Image.Resolution.Horizontal/96; float multY = annotationViewer1.Image.Resolution.Vertical/96; float x = imageLocation.X/multX; float y = imageLocation.Y/multY; var stickyNote = new StickyNoteAnnotationData(); stickyNote.FillBrush = new AnnotationSolidBrush(Color.Yellow); stickyNote.CollapsedTextData.Text = str; stickyNote.CollapsedTextData.TextPadding = new PaddingF(0f); stickyNote.CollapsedTextData.Font = new AnnotationFont(defaultFont.Name, defaultFont.Size); stickyNote.CollapsedTextData.AutoSize = true; stickyNote.CanMirror = false; stickyNote.CanResize = false; stickyNote.CollapsedTextData.Font.Underline = true; stickyNote.Outline.Color = Color.Red; stickyNote.CollapsedTextData.TextAlign = ContentAlignment.MiddleCenter; // Adjust for text width Size textSize = TextRenderer.MeasureText(str, defaultFont); // DPI Adjust float w = (float)Math.Ceiling((float)textSize.Width / 96f * 100f); stickyNote.Location = new PointF(x + (w / 2) - 20, y); annotationViewer1.AddAndBuildAnnotation(stickyNote);