예제 #1
0
  protected Annotation Create(Rect rct, String txt, bool IsReadOnly)
  {
      Pen pen = new Pen(Brushes.Yellow, 3);        
      RectangleGeometry geo;       
      geo = new RectangleGeometry(rct);
      Annotation obj = new Annotation(pen, geo, null, IsReadOnly);
 
      return obj;
  }
예제 #2
0
        private Annotation Create (Rect rect, string commentText, bool IsReadOnly, double radiusX, double radiusY)
        {
            Pen pen = new Pen(Brushes.Goldenrod, 3);
            pen.LineJoin = PenLineJoin.Round;

            CommentBoxControl commentBox = new CommentBoxControl();
            commentBox.IsReadOnly = IsReadOnly;
            commentBox.Text = commentText;
            commentBox.Width = 275;
            commentBox.Height = 165;
            visualChildren.Add(commentBox);

            Annotation annotation = new Annotation(pen, new RectangleGeometry(rect, radiusX, radiusY), commentBox, commentText, IsReadOnly);

            return annotation;
        }
예제 #3
0
        private void GetFocusedObject (Point cursorPosition)
        {
            if (_FocusedAnnotation != null)
            {
                CheckResizeLines(cursorPosition);
                if (!_FocusedAnnotation.Marking.FillContains(cursorPosition, 2.0, ToleranceType.Absolute) 
                    && ResizeTopLine == null 
                    && ResizeBottomLine == null 
                    && ResizeLeftLine == null 
                    && ResizeRightLine == null)
                {
                    SetAnnotationDeselected(_FocusedAnnotation);
                    ResizeTopLine = null;
                    ResizeLeftLine = null;
                    ResizeBottomLine = null;
                    ResizeRightLine = null;
                    m_ResizeFocusedObject = false;
                    m_MoveFocusedObject = false;
                    _FocusedAnnotation = null;
                    this.Cursor = System.Windows.Input.Cursors.SizeAll;
                }
            }

            if (_FocusedAnnotation == null)
            {
                foreach (Annotation annotation in _Annotations)
                {
                    if (_FocusedAnnotation == null && !annotation.IsReadOnly && annotation.Marking.FillContains(cursorPosition, 2.0, ToleranceType.Absolute))
                    {
                        _FocusedAnnotation = annotation;
                        _FocusedAnnotation.CommentBox.Visibility = System.Windows.Visibility.Visible;
                        _FocusedAnnotation.Pen.Brush = Brushes.Goldenrod;
                    }
                    else
                    {
                        SetAnnotationDeselected(annotation);
                    }
                }
            }
            InvalidateVisual();
        }
예제 #4
0
        private void DrawAnnotation(Annotation annotation, DrawingContext drawingContext)
        {
            Point startPoint = PointToWindowCoordinates(annotation.StartPoint);
            Point endPoint = PointToWindowCoordinates(annotation.EndPoint);
            RectangleGeometry rectGeo = new RectangleGeometry(new Rect(startPoint, endPoint), annotation.Marking.RadiusX, annotation.Marking.RadiusY);
            Brush fill = (Enabled) ? Brushes.Transparent : null;
            drawingContext.DrawGeometry(fill, annotation.Pen, rectGeo);

            if (annotation.CommentBox.Visibility == Visibility.Visible)
            {
                Point commentBoxPoint = PointToWindowCoordinates(annotation.CommentBoxBottomLeft);
                if (annotation.Marking.RadiusX != 0)
                {
                    drawingContext.DrawLine(annotation.Pen, new Point(rectGeo.Rect.TopRight.X, rectGeo.Rect.TopRight.Y + rectGeo.Rect.Height / 2), commentBoxPoint);
                }
                else
                {
                    drawingContext.DrawLine(annotation.Pen, rectGeo.Rect.TopRight, commentBoxPoint);
                }
            }
        }
예제 #5
0
 private void SetAnnotationDeselected(Annotation annotation)
 {
     annotation.CommentBox.Visibility = System.Windows.Visibility.Hidden;
     annotation.Pen = new Pen(Brushes.Green, 3);
     annotation.Pen.LineJoin = PenLineJoin.Round;
 }
예제 #6
0
        protected override void RemoveItem_Click (object sender, EventArgs e)
        {
            base.RemoveItem_Click(sender, e);

            if (_FocusedAnnotation != null && !_FocusedAnnotation.IsReadOnly)
            {
                _Annotations.Remove(_FocusedAnnotation);
                visualChildren.Remove(_FocusedAnnotation.CommentBox);
                _FocusedAnnotation = null;
            }

            InvalidateVisual();
        }
예제 #7
0
 protected override void AdornedElement_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (Enabled)
     {
         _FocusedAnnotation = null;
         InvalidateVisual();
     }
 }
예제 #8
0
        protected override void AdornedElement_MouseMove (object sender, MouseEventArgs e)
        {
            base.AdornedElement_MouseMove(sender, e);

            if (Enabled && !m_MoveFocusedObject && !m_ResizeFocusedObject && MainContextMenuOpen == false)
            {
                if (e.LeftButton == MouseButtonState.Pressed && !ContextMenu.IsLoaded && _CanCreateAnnotations)
                {
                    Point CurrentPoint = PointToImageCoordinates(e.GetPosition(this));

                    if (_Annotations.Count < 20)
                    {
                        Rect rect = new Rect(_StartPoint, CurrentPoint);

                        if (rect.Width > 10)
                        {
                            _FocusedAnnotation = (_IsEllipse) ? Create(rect, String.Empty, false, Double.MaxValue, Double.MaxValue) : Create(rect, String.Empty, false, 0, 0);
                            _Annotations.Add(_FocusedAnnotation);
                            _FocusedAnnotation.EndPoint = CurrentPoint;
                            ResizeLeftLine = null;
                            ResizeTopLine = null;
                            ResizeBottomLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.BottomLeft, _FocusedAnnotation.Marking.Rect.BottomRight);
                            ResizeRightLine = new LineGeometry(_FocusedAnnotation.Marking.Rect.TopRight, _FocusedAnnotation.Marking.Rect.BottomRight);
                            m_ResizeFocusedObject = true;
                            Cursor = System.Windows.Input.Cursors.Pen;
                            CaptureMouse();
                        }
                    }
                    else
                    {
                        MessageBox.Show(L3.Cargo.Common.Resources.MaxAnnotationErrorMessage);
                    }
                }
                InvalidateVisual();
            }

        }
예제 #9
0
        protected override void AdornedElement_MouseMove (object sender, MouseEventArgs e)
        {
            base.AdornedElement_MouseMove(sender, e);

            if (LeftMouseBtnWasPressed)
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    Point CurrentPoint = PointToImageCoordinates(e.GetPosition(this));

                    if (m_CurrentAOI != null)
                    {
                        m_CurrentAOI.EndPoint = CurrentPoint;
                    }
                    else
                    {
                        Rect tmpRect = new Rect(_StartPoint, CurrentPoint);

                        if (tmpRect.Width > 10)
                            m_CurrentAOI = Create(tmpRect, null, false);
                    }
                    InvalidateVisual();
                }

                if (e.LeftButton == MouseButtonState.Released)
                {
                    if (m_CurrentAOI != null)
                    {
                        Point startPoint = m_CurrentAOI.StartPoint;
                        Point endPoint = m_CurrentAOI.EndPoint;

                        CreateWindow(startPoint, endPoint);

                        m_CurrentAOI = null;
                        LeftMouseBtnWasPressed = false;
                        InvalidateVisual();
                    }
                }
            }
        }
예제 #10
0
        protected override void OnMouseLeftButtonUp (MouseButtonEventArgs e)
        {
            
            if (m_CurrentAOI != null)
            {
                Point startPoint = m_CurrentAOI.StartPoint;
                Point endPoint = m_CurrentAOI.EndPoint;

                CreateWindow(startPoint, endPoint);

                m_CurrentAOI = null;
                LeftMouseBtnWasPressed = false;
                InvalidateVisual();
            }
        }