public override bool OnPointerMove(AnnContainer sender, AnnPointerEventArgs e) { bool handled = false; if (TargetObject != null && HasStarted) { LeadPointD pt = ClipPoint(e.Location, ClipRectangle); if (!LeadPoint.Equals(pt, _end)) { _end = pt; LeadPointCollection points = TargetObject.Points; if (points.Count > 1) { if (_clickCount % 2 != 0) { points[points.Count - 1] = pt; // end point } } AnnIntersectionPointObject intersectionPointObject = TargetObject as AnnIntersectionPointObject; if (intersectionPointObject != null) { intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint); } Working(); } handled = true; } return(handled); }
private void AdjustFusionImage_Edit(object sender, AnnRectangleObject fusionEditRect) { int subCellIndex = _cell.ActiveSubCell; int index = _cmbFusedIndex.SelectedIndex; MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index]; AnnContainer _Container = GetContainer(_cell, fusionEditRect); fusion.Rotation = (float)fusionEditRect.Angle; LeadPointD[] pt = new LeadPointD[1]; LeadRectD rect = _Container.Mapper.RectFromContainerCoordinates(fusionEditRect.Rect, AnnFixedStateOperations.None); Rectangle displayRect = _cell.GetDisplayedImageRectangle(); rect.Offset(-displayRect.Left, -displayRect.Top); pt[0].X = (float)(rect.X + rect.Width / 2); pt[0].Y = (float)(rect.Y + rect.Height / 2); LeadPointD point = LeadPointD.Create(pt[0].X, pt[0].Y); _cell.AutomationContainer.Mapper.Transform.TransformPoints(pt); float normalizedXPosition = (float)(((float)point.X - (float)displayRect.Width / 2) / fusion.FusedImage.Width * 100 / _cell.GetScale(subCellIndex)); float normalizedYPosition = (float)(((float)point.Y - (float)displayRect.Height / 2) / fusion.FusedImage.Height * 100 / _cell.GetScale(subCellIndex)); float scaleX = (float)((rect.Width / fusion.FusedImage.Width) * 100 / _cell.GetScale(subCellIndex)); float scaleY = (float)((rect.Height / fusion.FusedImage.Height) * 100 / _cell.GetScale(subCellIndex)); if (scaleX == 0) { scaleX = 0.1F; } if (scaleY == 0) { scaleY = 0.1F; } RectangleF rectangle = new RectangleF(normalizedXPosition, normalizedYPosition, Math.Abs(scaleX), Math.Abs(scaleY)); fusion.DisplayRectangle = rectangle; UpdateFusionUI(index); CellData cellData = (CellData)_cell.Tag; if (cellData.SyncCellFusion) { UpdateCellFusions(fusion, subCellIndex, index); } _cell.Invalidate(); }
private void _rasterImageViewer_MouseMove(object sender, MouseEventArgs e) { string str; if (_rasterImageViewer.Image != null) { // Show the mouse position in physical and logical (inches) coordinates PointF physical = new PointF(e.X, e.Y); PointF pixels; LeadMatrix LeadM = _rasterImageViewer.ImageTransform; Matrix M = new Matrix((float)LeadM.M11, (float)LeadM.M12, (float)LeadM.M21, (float)LeadM.M22, (float)LeadM.OffsetX, (float)LeadM.OffsetY); Transformer trans = new Transformer(M); pixels = trans.PointToLogical(physical); // Convert the logical point to inches LeadPointD inches = Automation.Container.Mapper.PointFromContainerCoordinates(LeadPointD.Create((int)pixels.X, (int)pixels.Y), AnnFixedStateOperations.Scrolling | AnnFixedStateOperations.Zooming); str = string.Format("{0},{1} px {2},{3} in", (int)pixels.X, (int)pixels.Y, inches.X.ToString("F02"), inches.Y.ToString("F02")); } else { str = string.Empty; } _mousePositionLabel.Text = str; }
public override LeadPointD[] GetThumbLocations() { LeadPointCollection pointsCollection = TargetObject.Points; LeadPointD[] points = new LeadPointD[] { pointsCollection[0], pointsCollection[1] }; return(points); }
private void _viewer_MouseDown(object sender, MouseEventArgs e) { int x, y; LeadPointD pt = _viewer.ConvertPoint(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, new LeadPointD(e.X, e.Y)); x = Convert.ToInt32(pt.X); y = Convert.ToInt32(pt.Y); switch (e.Button) { case MouseButtons.Right: _buttonPressed = MouseButton.Rigth; _xLastPos = x; _yLastPos = y; break; case MouseButtons.Left: _buttonPressed = MouseButton.Left; GetCursorData(x, y, e.X, e.Y); _xLastPos = x; _yLastPos = y; break; default: _buttonPressed = MouseButton.None; break; } }
private static AnnPointerEventArgs ConvertPointerEventArgs(InteractiveEventArgs e, bool isDoubleTap) { // Convert the point var point = LeadPointD.Create(e.Position.X, e.Position.Y); // Convert the mouse button var mouseButton = AnnMouseButton.None; if (!isDoubleTap) { if (e.MouseButton == MouseButtons.Left) { mouseButton = AnnMouseButton.Left; } if (e.MouseButton == MouseButtons.Right) { mouseButton = AnnMouseButton.Right; } } else { mouseButton = AnnMouseButton.Left; } var args = AnnPointerEventArgs.Create(mouseButton, point); args.IsHandled = e.IsHandled; return(args); }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != null) { base.Render(mapper, annObject); AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject; if (annIntersectionPointObject != null) { int count = annIntersectionPointObject.Points.Count; if (count < 2) { return; } LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations); if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null) { AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annIntersectionPointObject.Stroke.StrokeThickness); stroke.StrokeDashArray = new double[] { 3, 1, 1, 1, 1, 1 }; // DashDotDot IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity); try { if (leadPoints.Length > 2) { LeadPointD intersectionPoint = annIntersectionPointObject.IntersectionPoint; intersectionPoint = mapper.PointFromContainerCoordinates(intersectionPoint, annIntersectionPointObject.FixedStateOperations); double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations); DrawPoint(annIntersectionPointObject, engine, intersectionPoint, radius); if (leadPoints.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer) { engine.DrawLine(pen, leadPoints[3], intersectionPoint); } } } finally { engine.Destroy(pen); } } } } }
LeadPointD GetPointExtension(LeadPointD point1, double angle, double distance, double factor) { double dXRatio = factor * distance * Math.Cos(angle); double dYRatio = factor * distance * Math.Sin(angle); LeadPointD resultPoint = LeadPointD.Create((point1.X + dXRatio), (point1.Y + dYRatio)); return(resultPoint); }
protected override void MoveThumb(int thumbIndex, LeadPointD offset) { int thumbsCount = GetThumbLocations().Length; int targetPointsCount = TargetObject.Points.Count; LeadPointD firstPoint = TargetObject.Points[0]; LeadPointD lastPoint = TargetObject.Points[TargetObject.Points.Count - 1]; bool isFlipped = firstPoint.Y > lastPoint.Y; int mythumbIndex = thumbIndex; List <LeadPointD> points = new List <LeadPointD>(); foreach (var point in TargetObject.Points) { points.Add(point); } //if the object is flipped then work with the points reversely if (isFlipped) { //Reverse the points points.Reverse(); //Also reverse the thumIndex mythumbIndex = Math.Abs(thumbIndex - (thumbsCount - 1)); } int before = Math.Max(0, (mythumbIndex - 1)); int after = Math.Min(mythumbIndex + 1, thumbsCount - 1); double offsetY = offset.Y; LeadPointD beforePoint = points[before * 2]; LeadPointD current = points[mythumbIndex * 2]; LeadPointD updated = AnnTransformer.TranslatePoint(points[mythumbIndex * 2], 0, offsetY); LeadPointD afterPoint = points[after * 2]; bool x = LeadPointD.Equals(current, beforePoint) ? true : (updated.Y > (beforePoint.Y + 48)); bool y = LeadPointD.Equals(current, afterPoint) ? true : updated.Y < (afterPoint.Y - 48); if (x && y) { points[mythumbIndex * 2] = updated; points[mythumbIndex * 2 + 1] = AnnTransformer.TranslatePoint(points[mythumbIndex * 2 + 1], 0, offsetY); if (isFlipped) { points.Reverse(); } for (int i = 0; i < points.Count; i++) { TargetObject.Points[i] = SnapPointToGrid(points[i], false); } } }
private void CalculateIntersectionPoint() { double firstLineLength, cos, sin, newX, firstLinePosition; if (Points.Count < 4) { _intersectionPoint = LeadPointD.Empty; return; } LeadPointD Line1FirstPoint = Points[0]; LeadPointD Line1SecondPoint = Points[1]; LeadPointD Line2FirstPoint = Points[2]; LeadPointD Line2SecondPoint = Points[3]; //If either line1 length is 0 or line2 length is 0 return empty point. if (LeadPointD.Equals(Line2FirstPoint, Line2SecondPoint)) { _intersectionPoint = LeadPointD.Empty; return; } //Translate the system so that line1 first point is on the origin. Line1SecondPoint.X -= Line1FirstPoint.X; Line1SecondPoint.Y -= Line1FirstPoint.Y; Line2FirstPoint.X -= Line1FirstPoint.X; Line2FirstPoint.Y -= Line1FirstPoint.Y; Line2SecondPoint.X -= Line1FirstPoint.X; Line2SecondPoint.Y -= Line1FirstPoint.Y; //Calculate first line length. firstLineLength = (float)Math.Sqrt((float)(Line1SecondPoint.X * Line1SecondPoint.X + Line1SecondPoint.Y * Line1SecondPoint.Y)); //Rotate the system so that first line second point is on the positive X axis. cos = Line1SecondPoint.X / firstLineLength; sin = Line1SecondPoint.Y / firstLineLength; newX = Line2FirstPoint.X * cos + Line2FirstPoint.Y * sin; Line2FirstPoint.Y = Line2FirstPoint.Y * cos - Line2FirstPoint.X * sin; Line2FirstPoint.X = newX; newX = Line2SecondPoint.X * cos + Line2SecondPoint.Y * sin; Line2SecondPoint.Y = Line2SecondPoint.Y * cos - Line2SecondPoint.X * sin; Line2SecondPoint.X = newX; //If the lines are parallel return empty point. if (Line2FirstPoint.Y == Line2SecondPoint.Y) { _intersectionPoint = LeadPointD.Empty; return; } //Find the position of the intersection point along first line firstLinePosition = Line2SecondPoint.X + (Line2FirstPoint.X - Line2SecondPoint.X) * Line2SecondPoint.Y / (Line2SecondPoint.Y - Line2FirstPoint.Y); //Apply the founded position to first line in the original coordinate system. _intersectionPoint = LeadPointD.Create(Line1FirstPoint.X + firstLinePosition * cos, Line1FirstPoint.Y + firstLinePosition * sin); }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine; if (engine != null && engine.Context != null) { base.Render(mapper, annObject); AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject; if (annIntersectionPointObject != null) { int count = annIntersectionPointObject.Points.Count; if (count < 2) { return; } LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations); PointF[] points = AnnWinFormsRenderingEngine.ToPoints(leadPoints); if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null) { using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annIntersectionPointObject.Stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity)) { if (points.Length > 2) { LeadPointD LeadIntersectionPoint = annIntersectionPointObject.IntersectionPoint; LeadIntersectionPoint = mapper.PointFromContainerCoordinates(LeadIntersectionPoint, annIntersectionPointObject.FixedStateOperations); PointF intersectionPoint = new PointF((float)LeadIntersectionPoint.X, (float)LeadIntersectionPoint.Y); double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations); DrawPoint(annIntersectionPointObject, engine.Context, intersectionPoint, radius); if (points.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer) { pen.Brush = Brushes.Blue; pen.DashStyle = DashStyle.DashDotDot; engine.Context.DrawLine(pen, points[3], intersectionPoint); } } } } } } }
void CreateDefaultLayers() { string[] layers = new string[] { "Red", "Green", "Blue" }; LeadRectD rect = new LeadRectD(LeadPointD.Create(860, 700), LeadPointD.Create(5200, 1850)); foreach (string layer in layers) { CreateRectangle(rect, AnnSolidColorBrush.Create(layer), CreateLayer(string.Format("{0} Layer", layer))); rect.Offset(360, 360); } }
private void _viewer_MouseMove(object sender, MouseEventArgs e) { if (Automation != null && Automation.Container != null) { LeadPointD physical = new LeadPointD(e.X, e.Y); LeadPointD logical = Automation.Container.Mapper.PointToContainerCoordinates(physical); MainForm.SetStatusBarText(string.Format("{0}, {1} ({2}, {3})", physical.X, physical.Y, logical.X, logical.Y)); } else { MainForm.SetStatusBarText(string.Format("{0}, {1}", e.X, e.Y)); } }
protected override void MoveThumb(int controlPointIndex, LeadPointD pt) { LeadPointD[] locations = GetThumbLocations(); // This event gets fired event on small fraction differences so we are giving the user some margin to // be able to select the control point without deleting the table cells if ((locations[controlPointIndex].X != pt.X && Math.Abs(locations[controlPointIndex].X - pt.X) > 1) || (locations[controlPointIndex].Y != pt.Y && Math.Abs(locations[controlPointIndex].Y - pt.Y) > 1)) { (this.TargetObject as ZoneAnnotationObject).ClearTableCells(); } base.MoveThumb(controlPointIndex, pt); }
// Get the data from the clipboard private static void GetClipboardData(AnnAutomation automation, LeadPointD position, string format) { string data = string.Empty; IDataObject dataObject = Clipboard.GetDataObject(); if (data != null) { if (dataObject.GetDataPresent(format)) { data = (string)dataObject.GetData(format); automation.PasteStringAt(data, position); } } }
protected override void RenderItemPlaceholder(ImageViewerRenderEventArgs e) { // This method is called while an item is being loaded and give us a chance // to offer a hint to the user // Lets render a Loading ... message on the item var transform = this.ImageViewer.GetItemImageTransform(e.Item); var graphics = e.PaintEventArgs.Graphics; var pt = LeadPointD.Create(0, 0); pt = transform.Transform(pt); graphics.DrawString("Loading...", this.ImageViewer.Font, Brushes.Black, (float)pt.X, (float)pt.Y); }
public static LeadPointD[] GetCornerPoints(LeadRectD rect) { bool isEmpty = rect.IsEmpty; LeadPointD[] corners = { !isEmpty ? LeadPointD.Create(rect.Left, rect.Top) : LeadPointD.Create(0, 0), !isEmpty ? LeadPointD.Create(rect.Right, rect.Top) : LeadPointD.Create(0, 0), !isEmpty ? LeadPointD.Create(rect.Right, rect.Bottom) : LeadPointD.Create(0, 0), !isEmpty ? LeadPointD.Create(rect.Left, rect.Bottom) : LeadPointD.Create(0, 0), }; return(corners); }
private void DrawBarcodeData(Graphics g, RasterImage image, BarcodeData data, StringFormat sf, Brush brush, Pen pen) { LeadRect rect = data.Bounds; LeadRectD rc = new LeadRectD(rect.X, rect.Y, rect.Width, rect.Height); string line = BarcodeEngine.GetSymbologyFriendlyName(data.Symbology); if (FourPoints && data.Symbology != BarcodeSymbology.Aztec && data.Symbology != BarcodeSymbology.Maxi && data.Symbology != BarcodeSymbology.MicroQR) { LeadPointD[] pointsL = new LeadPointD[4]; Point[] points = new Point[4]; pointsL[0].X = ((int)rc.Left & 0xffff); pointsL[0].Y = ((int)rc.Left >> 16); pointsL[1].X = ((int)rc.Top & 0xffff); pointsL[1].Y = ((int)rc.Top >> 16); pointsL[2].X = ((int)rc.Width & 0xffff); pointsL[2].Y = ((int)rc.Width >> 16); pointsL[3].X = ((int)rc.Height & 0xffff); pointsL[3].Y = ((int)rc.Height >> 16); _rasterImageViewer.ImageTransform.TransformPoints(pointsL); for (int i = 0; i < 4; i++) { points[i].X = (int)pointsL[i].X; points[i].Y = (int)pointsL[i].Y; } g.DrawPolygon(pen, points); SizeF size = g.MeasureString(line, Font, points[2].X - points[0].X, sf); rc.Width = (int)size.Width + 1; rc.Height = (int)size.Height + 1; g.FillRectangle(brush, points[0].X, points[0].Y, (int)rc.Width, (int)rc.Height); g.DrawString(line, Font, Brushes.White, new RectangleF(points[0].X, points[0].Y, (int)rc.Width, (int)rc.Height), sf); } else { rc = _rasterImageViewer.ImageTransform.TransformRect(rc); rc.Inflate(3, 3); if (rc.Width < 10 || rc.Height < 10) { return; } g.DrawRectangle(pen, (int)rc.X, (int)rc.Y, (int)rc.Width, (int)rc.Height); SizeF size = g.MeasureString(line, Font, (int)rc.Width, sf); rc.Width = (int)size.Width + 1; rc.Height = (int)size.Height + 1; g.FillRectangle(brush, (int)rc.X, (int)rc.Y, (int)rc.Width, (int)rc.Height); g.DrawString(line, Font, Brushes.White, new RectangleF((int)rc.X, (int)rc.Y, (int)rc.Width, (int)rc.Height), sf); } }
void _viewer_PostRender(object sender, ImageViewerRenderEventArgs e) { if (_firstPointSelected) { double xFactor = _viewer.XScaleFactor; double yFactor = _viewer.YScaleFactor; float xOffset = -_viewer.ImageBounds.Left; float yOffset = -_viewer.ImageBounds.Top; Point[] drawPoints = new Point[_polyPoints.Count]; for (int idx = 0; idx < drawPoints.Length; idx++) { LeadPointD TempPoint = new LeadPointD(_polyPoints[idx].X, _polyPoints[idx].Y); TempPoint = _viewer.ImageTransform.Transform(TempPoint); drawPoints[idx] = new Point((int)TempPoint.X, (int)TempPoint.Y); } LeadPointD lastPointTemp = new LeadPointD(_lastPoint.X, _lastPoint.Y); lastPointTemp = _viewer.ImageTransform.Transform(lastPointTemp); Point lastPoint = new Point((int)lastPointTemp.X, (int)lastPointTemp.Y); LeadPointD currentMousePointTemp = new LeadPointD(_currentMousePoint.X, _currentMousePoint.Y); currentMousePointTemp = _viewer.ImageTransform.Transform(currentMousePointTemp); Point currentMousePoint = new Point((int)currentMousePointTemp.X, (int)currentMousePointTemp.Y); const int controlPointSize = 5; e.PaintEventArgs.Graphics.FillRectangle(Brushes.Red, CreateRectFromPoint(drawPoints[0], controlPointSize)); for (int i = 1; i < drawPoints.Length; i++) { Point prev = drawPoints[i - 1]; Point curnt = drawPoints[i]; e.PaintEventArgs.Graphics.DrawLine(Pens.Yellow, prev, curnt); if (!_drawing) { e.PaintEventArgs.Graphics.DrawLine(Pens.Yellow, drawPoints[0], drawPoints[drawPoints.Length - 1]); } e.PaintEventArgs.Graphics.FillRectangle(Brushes.Red, CreateRectFromPoint(prev, controlPointSize)); e.PaintEventArgs.Graphics.FillRectangle(Brushes.Red, CreateRectFromPoint(curnt, controlPointSize)); } e.PaintEventArgs.Graphics.FillRectangle(Brushes.Red, CreateRectFromPoint(drawPoints[0], controlPointSize)); if (_drawing && drawPoints.Length < 4) { e.PaintEventArgs.Graphics.DrawLine(Pens.Red, lastPoint, currentMousePoint); } } }
private void _viewer_MouseMove(object sender, MouseEventArgs e) { int x, y; LeadPointD pt = _viewer.ConvertPoint(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, new LeadPointD(e.X, e.Y)); x = Convert.ToInt32(pt.X); y = Convert.ToInt32(pt.Y); if (_buttonPressed == MouseButton.Rigth && _isWLImage) { if (_xLastPos < x) { _windowLevelWidth = _windowLevelWidth + (x - _xLastPos) * _scale; } else if (_xLastPos > x) { _windowLevelWidth = _windowLevelWidth - (_xLastPos - x) * _scale; } _xLastPos = x; CheckValue(ref _windowLevelWidth, _maxWidth, _minWidth); if (_yLastPos < y) { _windowLevelCenter = _windowLevelCenter + (y - _yLastPos) * _scale; } else if (_yLastPos > y) { _windowLevelCenter = _windowLevelCenter - (_yLastPos - y) * _scale; } _yLastPos = y; CheckValue(ref _windowLevelCenter, _maxLevel, _minLevel); ChangeThePalette(); } else if (_buttonPressed == MouseButton.Left) { if (!(_xLastPos == x && _yLastPos == y)) { GetCursorData(x, y, e.X, e.Y); _xLastPos = x; _yLastPos = y; } } }
private void DrawPoint(AnnMidlineObject annObject, Graphics context, PointF point, double radius) { LeadRectD pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2); LeadPointD topLeft = pointBounds.TopLeft; LeadPointD topRight = pointBounds.TopRight; LeadPointD bottomLeft = pointBounds.BottomLeft; LeadPointD bottomRight = pointBounds.BottomRight; using (Pen pen = AnnWinFormsRenderingEngine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity)) { context.DrawLine(pen, new PointF((float)topLeft.X, (float)topLeft.Y), new PointF((float)bottomRight.X, (float)bottomRight.Y)); context.DrawLine(pen, new PointF((float)bottomLeft.X, (float)bottomLeft.Y), new PointF((float)topRight.X, (float)topRight.Y)); context.DrawLine(pen, new PointF((float)point.X, (float)(point.Y - pointBounds.Width / 2)), new PointF((float)point.X, (float)(point.Y + pointBounds.Width / 2))); context.DrawLine(pen, new PointF((float)point.X - (float)pointBounds.Width / 2, (float)(point.Y)), new PointF((float)point.X + (float)pointBounds.Width / 2, (float)(point.Y))); } }
// Fire the AutomationPointerMove event protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (!IsAutomationAttached || !AutomationEnabled) { return; } if (AutomationPointerMove != null) { // Convert the point to automation location LeadPointD location = LeadPointD.Create(e.Location.X, e.Location.Y); AutomationPointerMove(this, AnnPointerEventArgs.Create(AnnMouseButton.Left, location)); } }
protected override void MoveThumb(int thumbIndex, LeadPointD offset) { AnnObject targetObject = TargetObject; LeadPointD point = targetObject.Points[thumbIndex]; targetObject.Points[thumbIndex] = ClipPoint(AnnTransformer.TranslatePoint(point, offset.X, offset.Y), ClipRectangle); AnnIntersectionPointObject intersectionPointObject = targetObject as AnnIntersectionPointObject; if (intersectionPointObject != null) { intersectionPointObject.IntersectionInsideContainer = ClipRectangle.ContainsPoint(intersectionPointObject.IntersectionPoint); } base.MoveThumb(thumbIndex, offset); }
private void UpdateFusionEditRectangle(int index) { int subCellIndex = _cell.ActiveSubCell; MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index]; AnnRectangleObject fusionEditRect = ((AnnRectangleObject)subCell.AnnotationContainer.Children[index]); double scaleRatio = _cell.GetScale(subCellIndex) / 100; Point location = _cell.GetDisplayedImageRectangle().Location; AnnContainer container = subCell.AnnotationContainer; double scale = _cell.GetScale(subCellIndex); LeadSizeD fusionEditRectSize = new LeadSizeD(); fusionEditRectSize.Width = fusion.FusedImage.Width * fusion.DisplayRectangle.Width * scale / 100; fusionEditRectSize.Height = fusion.FusedImage.Height * fusion.DisplayRectangle.Height * scale / 100; fusionEditRectSize = container.Mapper.SizeToContainerCoordinates(fusionEditRectSize); LeadPointD fusionEditRectPos = new LeadPointD(); fusionEditRectPos.X = (subCell.AnnotationContainer.Size.Width - fusionEditRectSize.Width) / 2; fusionEditRectPos.Y = (subCell.AnnotationContainer.Size.Height - fusionEditRectSize.Height) / 2; //container.Bounds fusionEditRect.Rect = new LeadRectD(fusionEditRectPos, fusionEditRectSize); AnnContainer _Container = GetContainer(_cell, fusionEditRect); fusionEditRect.Rotate(fusion.Rotation, new LeadPointD(_Container.Size.Width / 2, _Container.Size.Height / 2)); LeadPointD point = LeadPointD.Create(fusion.DisplayRectangle.X * fusion.FusedImage.Width * scaleRatio + location.X, fusion.DisplayRectangle.Y * fusion.FusedImage.Height * scaleRatio + location.Y); point = _Container.Mapper.PointToContainerCoordinates(point); fusionEditRect.Translate(point.X, point.Y); fusionEditRect.RotateCenter = new LeadPointD(fusionEditRect.Rect.Left + (fusionEditRect.Rect.Width / 2), fusionEditRect.Rect.Top + (fusionEditRect.Rect.Height / 2)); _cell.RefreshAnnotation(); _cell.Automation.Invalidate(LeadRectD.Empty); _cell.Invalidate(); }
public override void Render(AnnContainerMapper mapper, AnnObject annObject) { if (mapper == null) { ExceptionHelper.ArgumentNullException("mapper"); } if (annObject == null) { ExceptionHelper.ArgumentNullException("annObject"); } IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine; if (engine != null) { LeadPointD[] leadPoints = annObject.Points.ToArray(); int linesCount = leadPoints.Length / 2; if (linesCount > 0) { if (annObject.SupportsStroke && annObject.Stroke != null) { leadPoints = mapper.PointsFromContainerCoordinates(leadPoints, annObject.FixedStateOperations); IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annObject.Stroke, annObject.FixedStateOperations), annObject.Opacity); try { for (int i = 0; i < linesCount; ++i) { LeadPointD firstPoint = leadPoints[2 * i]; LeadPointD secondPoint = leadPoints[2 * i + 1]; engine.DrawLine(pen, firstPoint, secondPoint); } } finally { engine.Destroy(pen); } } } } }
public override LeadPointD[] GetThumbLocations() { LeadPointD[] locations = null; LeadPointD[] points = TargetObject.Points.ToArray(); int pointsCount = points.Length / 2; LeadPointD[] pts = new LeadPointD[pointsCount]; for (int i = 0; i < pointsCount; ++i) { int index = i * 2; LeadPointD start = points[index]; LeadPointD end = points[index + 1]; pts[i] = LeadPointD.Create((start.X + end.X) / 2, (start.Y + end.Y) / 2); } locations = pts; return(locations); }
protected override bool EndWorking() { LeadPointD[] points = _objectTemplate.Points.ToArray(); if (points != null && points.Length > 0) { _annParallelLinesObject.Points.Add(points[0]); _annParallelLinesObject.Points.Add(points[1]); int lineCount = LinesCount - 2; if (LinesCount > 0) { int x = (lineCount + 1); double height = _objectTemplate.Rect.Height / x; LeadPointD start = points[0]; LeadPointD end = points[1]; for (int i = 0; i < lineCount; ++i) { start = LeadPointD.Create(start.X, start.Y + height); end = LeadPointD.Create(end.X, end.Y + height); _annParallelLinesObject.Points.Add(SnapPointToGrid(start, false)); _annParallelLinesObject.Points.Add(SnapPointToGrid(end, false)); } } _annParallelLinesObject.Points.Add(points[2]); _annParallelLinesObject.Points.Add(points[3]); } _annParallelLinesObject.Labels["AnnObjectName"] = _objectTemplate.Labels["AnnObjectName"].Clone(); Container.Children.Remove(_objectTemplate); TargetObject = _annParallelLinesObject; Container.Children.Add(_annParallelLinesObject); return(base.EndWorking()); }
private void DrawPoint(AnnMidlineObject annObject, IAnnDrawEngine engine, LeadPointD point, double radius) { LeadRectD pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2); LeadPointD topLeft = pointBounds.TopLeft; LeadPointD topRight = pointBounds.TopRight; LeadPointD bottomLeft = pointBounds.BottomLeft; LeadPointD bottomRight = pointBounds.BottomRight; IAnnDrawPen pen = engine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity); try { engine.DrawLine(pen, topLeft, bottomRight); engine.DrawLine(pen, bottomLeft, topRight); engine.DrawLine(pen, new LeadPointD(point.X, (point.Y - pointBounds.Width / 2)), new LeadPointD(point.X, (point.Y + pointBounds.Width / 2))); engine.DrawLine(pen, new LeadPointD(point.X - pointBounds.Width / 2, point.Y), new LeadPointD(point.X + pointBounds.Width / 2, point.Y)); } finally { engine.Destroy(pen); } }
public override bool HitTest(LeadPointD point, double hitTestBuffer) { bool hit = base.HitTest(point, hitTestBuffer); if (hit) { AnnPolylineObject line = new AnnPolylineObject(); hit = false; int pointsCount = Points.Count / 2; for (int i = 0; i < pointsCount && !hit; ++i) { line.Points.Add(Points[2 * i]); line.Points.Add(Points[2 * i + 1]); if (line.HitTest(point, hitTestBuffer)) { hit = true; } } } return(hit); }
public override bool OnPointerDown(AnnContainer sender, AnnPointerEventArgs e) { bool handled = base.OnPointerDown(sender, e); if (e.Button != AnnMouseButton.Left) { return(handled); } _clickCount++; if (e.Button == AnnMouseButton.Left) { LeadPointD _begin = ClipPoint(e.Location, ClipRectangle); _end = _begin; LeadPointCollection points = TargetObject.Points; if (_clickCount == 1) { points.Add(_begin); points.Add(_end); } else if (_clickCount % 2 != 0) { points.Add(_begin); points.Add(_end); } StartWorking(); handled = true; } return(handled); }