示例#1
0
        public override void PaintAnno(Graphics g, object anno, ICoorConverter cvt = null)
        {
            if (anno.GetType() != AnnoType)
            {
                return;
            }

            Annotation annotation = (Annotation)anno;

            g.SmoothingMode = SmoothingMode.HighQuality;

            //将矩形转换成点数组
            System.Drawing.Point[] rect = new System.Drawing.Rectangle(
                annotation.x, annotation.y, annotation.width, annotation.height).ConvertToQuadraPoints();

            //转换坐标
            if (cvt != null)
            {
                for (int i = 0; i < rect.Length; i++)
                {
                    rect[i] = cvt.Convert(rect[i]);
                }
            }

            //打印类别文本
            annotation.DrawCategory(g, rect[0], font, pen.Color, pen.Color.GetReverse());

            //打印矩形
            g.DrawPolygon(pen, rect);
        }
示例#2
0
        public override bool DelegateMouseUp(object sender, MouseEventArgs e, ICoorConverter cvt = null)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                if (Status == BrushStatus.Free)
                {
                    Status = BrushStatus.Tuning;
                }
                else if (Status == BrushStatus.Building)
                {
                    Status = BrushStatus.Free;
                }
                break;

            case MouseButtons.Right:
                if (Status == BrushStatus.Tuning)
                {
                    Status = BrushStatus.Free;
                }
                break;
            }
            (sender as Control).Invalidate();

            return(true);
        }
示例#3
0
        public override void PaintAnno(Graphics g, object anno, ICoorConverter cvt = null)
        {
            if (anno.GetType() != AnnoType)
            {
                return;
            }

            //Annotation annotation = (Annotation)anno;
            g.SmoothingMode = SmoothingMode.HighQuality;

            throw new NotImplementedException();
        }
示例#4
0
        public override bool DelegateMouseMove(object sender, MouseEventArgs e, ICoorConverter cvt = null)
        {
            if ((ModifierKeys & Keys.Control) == Keys.Control)
            {
                return(true);
            }

            System.Drawing.Point point = e.Location;
            if (cvt != null)
            {
                point = cvt.ReConvert(point);
            }

            if (Utils.Judge.Mouse.Left(e))
            {
                if (Status == BrushStatus.Free || Status == BrushStatus.Building)
                {
                    Status = BrushStatus.Building;
                    System.Drawing.Rectangle rect = RectangleTransform.FromTwoPoints(downPoint, point);

                    TempAnno.x      = rect.X;
                    TempAnno.y      = rect.Y;
                    TempAnno.width  = rect.Width;
                    TempAnno.height = rect.Height;
                }
                else
                {
                    Size delta = new Size(point.X - downPoint.X, point.Y - downPoint.Y);

                    TempAnno.x = downTempAnno.x + delta.Width;
                    TempAnno.y = downTempAnno.y + delta.Height;
                }
                (sender as Control).Invalidate();
                GlobalMessage.Add("status", TempAnno.ToString());
            }
            else if (e.Button == MouseButtons.None)
            {
                if (Status == BrushStatus.Free && TempAnno != null)
                {
                    TempAnno.x = point.X - TempAnno.width / 2;
                    TempAnno.y = point.Y - TempAnno.height / 2;

                    (sender as Control).Invalidate();
                    GlobalMessage.Add("status", TempAnno.ToString());
                }
            }

            return(true);
        }
示例#5
0
 public override void DelegatePaint(object sender, PaintEventArgs e, ICoorConverter cvt = null)
 {
     if (TempAnno != null)
     {
         if (Status == BrushStatus.Tuning)
         {
             pen.DashStyle = DashStyle.Solid;
         }
         else
         {
             pen.DashStyle = DashStyle.Dash;
         }
         PaintAnno(e.Graphics, TempAnno, cvt);
     }
 }
示例#6
0
        //Override
        public override bool DelegateMouseDown(object sender, MouseEventArgs e, ICoorConverter cvt = null)
        {
            if (Utils.Judge.Mouse.Left(e))
            {
                System.Drawing.Point point = e.Location;
                if (cvt != null)
                {
                    point = cvt.ReConvert(point);
                }
                downPoint    = point;
                downTempAnno = TempAnno.Clone() as Annotation;
            }

            return(true);
        }
示例#7
0
 public virtual void DelegatePaint(object sender, PaintEventArgs e, ICoorConverter cvt = null)
 {
     ;
 }
示例#8
0
 public virtual void DelegateKeyPress(object sender, KeyPressEventArgs e, ICoorConverter cvt = null)
 {
     ;
 }
示例#9
0
 public virtual bool DelegateProcessCmdKey(object sender, ref Message msg, Keys keyData, ICoorConverter cvt = null) => true;
示例#10
0
 public virtual bool DelegateClick(object sender, EventArgs e, ICoorConverter cvt           = null) => true;
示例#11
0
 public virtual bool DelegateMouseWheel(object sender, MouseEventArgs e, ICoorConverter cvt = null) => true;
示例#12
0
 public override void PaintAnno(Graphics g, object anno, ICoorConverter cvt = null)
 {
     throw new NotImplementedException();
 }
示例#13
0
 /// <summary>
 /// 给定GDI+绘图图面和标注实例,将实例绘制到指定图面中。
 /// </summary>
 /// <param name="g">GDI+绘图图面</param>
 /// <param name="anno">标注实例</param>
 /// <param name="cvt">坐标变换规则</param>
 ///
 public abstract void PaintAnno(Graphics g, object anno, ICoorConverter cvt = null);
示例#14
0
        public override bool DelegateProcessCmdKey(object sender, ref Message msg, Keys keyData, ICoorConverter cvt = null)
        {
            //键值是否已处理。
            bool handled = false;

            if (TempAnno != null)
            {
                switch (keyData)
                {
                case Keys.W:
                case Keys.Up:
                    TempAnno.height++;
                    handled = true;
                    break;

                case Keys.S:
                case Keys.Down:
                    TempAnno.height = Math.Max(0, TempAnno.height - 1);
                    handled         = true;
                    break;

                case Keys.D:
                case Keys.Right:
                    TempAnno.width++;
                    handled = true;
                    break;

                case Keys.A:
                case Keys.Left:
                    TempAnno.width = Math.Max(0, TempAnno.width - 1);
                    handled        = true;
                    break;

                case Keys.Back:
                    if (Status == BrushStatus.Tuning)
                    {
                        Status = BrushStatus.Free;
                    }
                    handled = true;
                    break;

                case Keys.Enter:
                case Keys.Space:
                    if (Status == BrushStatus.Free)
                    {
                        Status  = BrushStatus.Tuning;
                        handled = true;
                    }
                    break;
                }
            }

            if (handled)
            {
                (sender as Control).Invalidate();
            }
            return(!handled);
        }