示例#1
0
        /// <summary>
        /// Used to control dragging options
        /// </summary>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown (e);

            if (backup != null && resized != null)
            {
                // Determine if the selected coord is on top of an annotation
                selectedAnnote = GetAnnotationAt(e.X, e.Y);

                if (selectedAnnote != null)
                {
                    _annotations.Remove(selectedAnnote);

                    selectedAnnote.Location = new Point(e.X, e.Y);
                }
                else if (_allowDrag)
                {
                    lmbDown = true;
                    dragStart = new Point(e.X, e.Y);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Used to control dragging options
        /// </summary>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp (e);

            if (selectedAnnote != null)
            {
                _annotations.Add(selectedAnnote, true);

                selectedAnnote = null;
            }
            else if (lmbDown && e.Button == MouseButtons.Right)
            {
                // Cancel the current drag
                dragWindow = Rectangle.Empty;
                lmbDown = false;
            }
            else if (lmbDown && e.Button == MouseButtons.Left)
            {
                // End the drag
                lmbDown = false;

                if (dragStart == dragEnd)
                    return;

                dragEnd = new Point(e.X, e.Y);

                if (dragStart != Point.Empty && ValidateDragWindowSize(dragEnd))
                {
                    switch (_dragOptions)
                    {
                        case DragOptions.Prompt :
                            dragWindowSave = dragWindow;
                            cmnuPrompt.Show(this, dragEnd);
                            break;
                        case DragOptions.Copy :
                            Copy();
                            break;
                        case DragOptions.Zoom :
                            Zoom();
                            break;
                    }
                }

                dragWindow = Rectangle.Empty;
                dragStart = Point.Empty;
                dragEnd = Point.Empty;
            }
        }
示例#3
0
            /// <summary>
            /// Removes an annotation from the collection
            /// </summary>
            /// <param name="annotation"></param>
            /// <returns></returns>
            public bool Remove(Annotation annotation)
            {
                foreach (Annotation annote in InnerList)
                    if (annote.Guid == annotation.Guid)
                    {
                        annotation.Changed -= new EventHandler(annotation_Changed);

                        InnerList.Remove(annote);

                        AnnotationsChanged(this, new EventArgs());

                        return true;
                    }

                return false;
            }
示例#4
0
        //public event menuclicked meventmenuclicked;
        /// <summary>
        /// Create a new extended picturebox
        /// </summary>
        public PictureBoxEx()
        {
            InitComponent();

            base.SetStyle(ControlStyles.DoubleBuffer, true);
            base.SetStyle(ControlStyles.UserPaint, true);
            base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            base.AutoScroll = true;
            this.Size = new Size(200, 200);
            this.Paint += new PaintEventHandler(PictureBoxEx_Paint);

            _diagnosticMode = false;
            _doubleClickRestore = true;
            _borderStyle = BorderStyle.None;
            _drawMode = InterpolationMode.Default;

            // Init zoom fields
            _currentZoom = 1.0F;
            _defaultZoom = 1.0F;
            _maximumZoom = 3.0F;
            _minimumZoom = 0.10F;

            // Init drag window fields
            dashPattern = new Single[]{ 5, 2, 5, 2};

            dragWindow = Rectangle.Empty;
            dragStart = Point.Empty;
            dragEnd = Point.Empty;
            dragPen = new Pen(Color.Black, 1);
            dragPen.DashStyle   = DashStyle.Custom;
            dragPen.DashPattern = dashPattern;

            _dragOptions = DragOptions.Prompt;
            _dragWindowMinimum = SystemInformation.DragSize;

            lmbDown = false;

            // Annotation fields
            _annotations = new AnnotationCollection(this);
            _annotations.AnnotationsChanged += new EventHandler(Annotations_AnnotationsChanged);
            selectedAnnote = null;

            generateTime = 0L;
            drawTime = 0L;
            setTime = 0L;
        }
示例#5
0
            /// <summary>
            /// Adds one or more annotations to the collection w/o adjustment
            /// </summary>
            /// <param name="annotations"></param>
            public void AddRange(Annotation[] annotations)
            {
                foreach (Annotation annotation in annotations)
                {
                    bool found = Remove(annotation);

                    InnerList.Add(annotation);

                    if (!found)
                        annotation.Changed += new EventHandler(annotation_Changed);
                }

                AnnotationsChanged(this, new EventArgs());
            }
示例#6
0
            /// <summary>
            /// Add an annotation to the collection
            /// </summary>
            /// <param name="text">The annotations desired text</param>
            /// <param name="font">The annotations desired font</param>
            /// <param name="color">The annotations desired color</param>
            /// <param name="location">The annotations desired location</param>
            /// <param name="adjustLocation">True if the annotation should be adjusted for the picturebox's current zoom</param>
            /// <returns>The index of the newly added annotation</returns>
            public int Add(string text, Font font, Color color, Point location, bool adjustLocation)
            {
                Annotation newAnnote = new Annotation(text, font, color, location);

                newAnnote.Changed += new EventHandler(annotation_Changed);

                return Add(newAnnote, adjustLocation);
            }
示例#7
0
            /// <summary>
            /// Add an annotation to the collection
            /// </summary>
            /// <param name="annotation">Annotation to be added</param>
            /// <param name="adjustLocation">True if the annotation should be adjusted for the picturebox's current zoom</param>
            /// <returns>The index of the newly added annotation</returns>
            public int Add(Annotation annotation, bool adjustLocation)
            {
                bool found = Remove(annotation);

                annotation.Changed += new EventHandler(annotation_Changed);

                if (adjustLocation && owner != null)
                {
                    float ratio = 1F / owner._currentZoom;

                    int adjustedX = Convert.ToInt32((annotation.X + -owner.AutoScrollPosition.X) * ratio);
                    int adjustedY = Convert.ToInt32((annotation.Y + -owner.AutoScrollPosition.Y) * ratio);

                    annotation.Location = new Point(adjustedX, adjustedY);
                }

                int index = InnerList.Add(annotation);

                if (!found)
                    AnnotationsChanged(this, new EventArgs());

                return index;
            }
示例#8
0
 /// <summary>
 /// Creates a new annotation collection
 /// </summary>
 public AnnotationCollection(PictureBoxEx owner, Annotation[] annotations)
     : this(annotations)
 {
     this.owner = owner;
 }
示例#9
0
            /// <summary>
            /// Creates a new annotation collection
            /// </summary>
            public AnnotationCollection(Annotation[] annotations)
            {
                AnnotationsChanged += new EventHandler(OnAnnotationCollection_AnnotationsChanged);

                foreach (Annotation annote in annotations)
                    Add(annote, false);
            }