コード例 #1
0
ファイル: ToolPointer.cs プロジェクト: marlonnn/Cii.Lar
        public override void OnMouseUp(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            if (selectMode == SelectionMode.NetSelection)
            {
                //pictureBox.RectNetSelection = Rectangle.Empty;

                //if (Math.Abs(startPoint.X - lastPoint.X) > 3 || Math.Abs(startPoint.Y - lastPoint.Y) > 3)
                //{
                //    // Make group selection
                //    pictureBox.GraphicsList.SelectInRectangle(pictureBox,
                //        DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint));
                //}
                selectMode = SelectionMode.None;
            }

            if (selectMode == SelectionMode.Move && wasMove)
            {
                foreach (DrawObject o in pictureBox.GraphicsList.Selection)
                {
                    o.Move(pictureBox, o.MovingOffset.X, o.MovingOffset.Y);
                    o.MovingOffset = Point.Empty;
                }

                // gate could be moved, but lost selection
                foreach (DrawObject o in pictureBox.GraphicsList)
                {
                    o.MovingOffset = Point.Empty;
                }
                selectMode = SelectionMode.None;
                pictureBox.Refresh();
            }
            wasMove = false;
        }
コード例 #2
0
ファイル: ToolPolygon.cs プロジェクト: marlonnn/Cii.Lar
        public override void OnMouseUp(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            newPolygon.Creating = false;
            newPolygon          = null;

            base.OnMouseUp(pictureBox, e);
        }
コード例 #3
0
ファイル: DrawObject.cs プロジェクト: marlonnn/Cii.Lar
        public virtual void DrawTracker(Graphics g, ZWPictureBox pictureBox)
        {
            if (Selected)
            {
                SolidBrush brush = new SolidBrush(Color.White);
                Pen        pen   = new Pen(GraphicsPropertiesManager.GetPropertiesByName("Text").Color,
                                           GraphicsPropertiesManager.GetPropertiesByName("Text").PenWidth);

                for (int i = 1; i <= HandleCount; i++)
                {
                    if (!IsHandleVisible(i))
                    {
                        continue;
                    }

                    Rectangle r = GetHandleRectangle(pictureBox, i);
                    r.Offset(MovingOffset);
                    try
                    {
                        g.DrawRectangle(pen, r);
                        g.FillRectangle(brush, r);
                    }
                    catch (System.Exception ex)
                    {
                        Selected = false;
                    }
                }
                pen.Dispose();
                brush.Dispose();
            }
        }
コード例 #4
0
 public DrawLine(ZWPictureBox pictureBox, int x1, int y1, int x2, int y2) : this()
 {
     this.pictureBox = pictureBox;
     startDataPoint  = new Point(x1, y1);
     endDataPoint    = new Point(x2, y2);
     this.GraphicsProperties.GraphicsPropertiesChangedHandler += pictureBox.GraphicsPropertiesChangedHandler;
 }
コード例 #5
0
ファイル: DrawObject.cs プロジェクト: marlonnn/Cii.Lar
 public HitTestResult HitTest(ZWPictureBox pictureBox, Point point, bool forSelection, bool hitTestHandle = true)
 {
     if (Selected && hitTestHandle)
     {
         for (int i = 1; i <= HandleCount; i++)
         {
             if (CheckHandleRegion(pictureBox, i, point))
             {
                 return(new HitTestResult(ElementType.Handle, i));
             }
         }
     }
     UpdateHitTestRegions();
     if (forSelection)
     {
         return(HitTestForSelection(pictureBox, point));
     }
     else
     {
         for (int i = 0; i < pictureBox.GraphicsList.Count; i++)
         {
             PointF dataPoint = point;
             if (HitTest(i, dataPoint))
             {
                 return(new HitTestResult(ElementType.Gate, i));
             }
         }
         return(new HitTestResult(ElementType.Nothing, -1));
     }
 }
コード例 #6
0
        public override HitTestResult HitTestForSelection(ZWPictureBox pictureBox, Point point)
        {
            Rectangle rect = new Rectangle(Point.Ceiling(startDataPoint), new Size((int)(endDataPoint.X - startDataPoint.X), 1));

            rect.Inflate(0, this.SelectionHitTestWidth);
            return(rect.Contains(point) ? new HitTestResult(ElementType.Gate, 0) : new HitTestResult(ElementType.Nothing, -1));
        }
コード例 #7
0
ファイル: DrawEllipse.cs プロジェクト: marlonnn/Cii.Lar
        /// <summary>
        /// draw ellipse graphic
        /// </summary>
        /// <param name="g"></param>
        /// <param name="pictureBox"></param>
        public override void Draw(Graphics g, ZWPictureBox pictureBox)
        {
            if (ellipseForDraw == null)
            {
                ellipseForDraw = new Ellipse(startPoint, endPoint, coeffcient, drawAreaSize);
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen pen = new Pen(Color.FromArgb(GraphicsProperties.Alpha, GraphicsProperties.Color), GraphicsProperties.PenWidth))
            {
                try
                {
                    OrgMatrix   = g.Transform;
                    g.Transform = DrawMatrix;

                    g.TranslateTransform(MovingOffset.X, MovingOffset.Y, MatrixOrder.Append);

                    g.DrawEllipse(pen, ellipseForDraw.Rectangle);

                    g.Transform = OrgMatrix;
                }
                catch
                {
                    g.Transform = OrgMatrix;
                }
            }
        }
コード例 #8
0
 public DrawPolyLine(ZWPictureBox pictureBox, int x1, int y1, int x2, int y2)
     : base(pictureBox, x1, y1, x2, y2)
 {
     InitializeGraphicsProperties();
     this.RegisterUpdateStatisticsHandler();
     this.GraphicsProperties.GraphicsPropertiesChangedHandler += pictureBox.GraphicsPropertiesChangedHandler;
 }
コード例 #9
0
ファイル: ToolPolygon.cs プロジェクト: marlonnn/Cii.Lar
        public override void OnMouseMove(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            pictureBox.Cursor = Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (newPolygon == null)
            {
                return;
            }
            Point point    = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));
            int   distance = (point.X - lastX) * (point.X - lastX) + (point.Y - lastY) * (point.Y - lastY);

            if (distance < minDistance)
            {
                // Distance between last two points is less than minimum -
                // move last point
                newPolygon.MoveHandleTo(pictureBox, point, newPolygon.PointCount);
            }
            else
            {
                // Add new point
                newPolygon.AddPoint(pictureBox, point, false);
                lastX = point.X;
                lastY = point.Y;
            }
            pictureBox.Refresh();
        }
コード例 #10
0
        public override void Draw(Graphics g, ZWPictureBox pictureBox)
        {
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode      = SmoothingMode.AntiAlias;
            SolidBrush brush = new SolidBrush(this.GraphicsProperties.Color);

            GraphicsPath path1   = new GraphicsPath();
            GraphicsPath path2   = new GraphicsPath();
            Region       region1 = new Region();
            Region       region2 = new Region();

            for (int i = 0; i < count; i++)
            {
                path1.AddEllipse(OutterCircles[i].Rectangle.X, OutterCircles[i].Rectangle.Y,
                                 OutterCircles[i].Rectangle.Width, OutterCircles[i].Rectangle.Height);

                path2.AddEllipse(InnerCircles[i].Rectangle.X, InnerCircles[i].Rectangle.Y,
                                 InnerCircles[i].Rectangle.Width, InnerCircles[i].Rectangle.Height);
                if (i == 0)
                {
                    region1 = new Region(path1);
                    region2 = new Region(path2);
                }
                region1.Union(new Region(path1));
                region2.Union(new Region(path2));
            }
            region1.Exclude(region2);
            g.FillRegion(brush, region1);
            brush.Dispose();
            path1.Dispose();
            path2.Dispose();
            region1.Dispose();
        }
コード例 #11
0
        /// <summary>
        /// draw object
        /// </summary>
        /// <param name="g"></param>
        /// <param name="pictureBox"></param>
        public override void Draw(Graphics g, ZWPictureBox pictureBox)
        {
            Point p1 = Point.Empty; // previous point
            Point p2 = Point.Empty; // current point

            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen pen = new Pen(GraphicsProperties.Color, GraphicsProperties.PenWidth))
            {
                PointFEnumerator enumerator = pointArray.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    p1 = Point.Ceiling(enumerator.Current);
                    p1.Offset(MovingOffset);
                }
                while (enumerator.MoveNext())
                {
                    p2 = Point.Ceiling(enumerator.Current);
                    p2.Offset(MovingOffset);
                    g.DrawLine(pen, p1, p2);
                    p1 = p2;
                }
                enumerator.Reset();
                if (enumerator.MoveNext())
                {
                    p2 = Point.Ceiling(enumerator.Current);
                    p2.Offset(MovingOffset);
                    g.DrawLine(pen, p1, p2);
                }
            }
        }
コード例 #12
0
 public IDSCamera(ZWPictureBox picturebox)
 {
     this.picturebox    = picturebox;
     this.displayHandle = picturebox.Handle;
     this.uEyeCamera    = new uEye.Camera();
     CameraSizeControl  = new CameraSizeControl(uEyeCamera);
 }
コード例 #13
0
ファイル: DrawCircle.cs プロジェクト: marlonnn/Cii.Lar
        public override void Draw(Graphics g, ZWPictureBox pictureBox)
        {
            if (OutterCircle == null)
            {
                OutterCircle = new Circle(CenterPoint, OutterCircleSize);
            }
            if (InnerCircle == null)
            {
                InnerCircle = new Circle(CenterPoint, InnerCircleSize);
            }
            //path for the outer and inner circles
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.SmoothingMode      = SmoothingMode.AntiAlias;
            using (GraphicsPath path = new GraphicsPath())
            {
                if (Flashing)
                {
                    brush = new SolidBrush(this.flickCount % 2 == 1 ? this.GraphicsProperties.Color : Color.LightSalmon);
                }
                else
                {
                    brush = new SolidBrush(this.GraphicsProperties.Color);
                }

                path.AddEllipse(OutterCircle.Rectangle.X, OutterCircle.Rectangle.Y,
                                OutterCircle.Rectangle.Width, OutterCircle.Rectangle.Height);
                path.AddEllipse(InnerCircle.Rectangle.X, InnerCircle.Rectangle.Y,
                                InnerCircle.Rectangle.Width, InnerCircle.Rectangle.Height);
                g.FillPath(brush, path);
            }
            DrawCross(g);
            brush.Dispose();
        }
コード例 #14
0
        public override void Move(ZWPictureBox pictureBox, int deltaX, int deltaY)
        {
            Point s = Point.Ceiling(startDataPoint), e = Point.Ceiling(endDataPoint);

            startDataPoint = new Point(s.X + deltaX, s.Y + deltaY);
            endDataPoint   = new Point(e.X + deltaX, e.Y + deltaY);
        }
コード例 #15
0
        public override void OnMouseDown(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            Point point = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));

            CenterPoint = new PointF(point.X, point.Y);
            this.pictureBox.Invalidate();
        }
コード例 #16
0
        public override void MoveHandleTo(ZWPictureBox pictureBox, Point point, int handleNumber)
        {
            OutterCircles.Clear();
            InnerCircles.Clear();

            EndCenterPoint = point;
            float dx = EndCenterPoint.X - StartCenterPoint.X;
            float dy = EndCenterPoint.Y - StartCenterPoint.Y;

            var k      = dy / dx;
            var length = Math.Sqrt(dx * dx + dy * dy);

            OutterCircles.Add(new Circle(StartCenterPoint, OutterCircleSize));
            InnerCircles.Add(new Circle(StartCenterPoint, InnerCircleSize));
            for (int i = 1; i < count; i++)
            {
                float x = 0;
                float y = 0;
                if (dx == 0)
                {
                    x = StartCenterPoint.X;
                    if (dx < 0)
                    {
                        y = StartCenterPoint.Y - 20 * i;
                    }
                    else
                    {
                        y = StartCenterPoint.Y + 20 * i;
                    }
                }
                else if (dy == 0)
                {
                    if (dy < 0)
                    {
                        x = StartCenterPoint.X - 20 * i;
                    }
                    else
                    {
                        x = StartCenterPoint.X + 20 * i;
                    }
                    y = StartCenterPoint.Y;
                }
                else
                {
                    if ((dx > 0 && dy > 0) || (dx > 0 && dy < 0))
                    {
                        x = (float)(StartCenterPoint.X + 20 * i / Math.Sqrt(1 + k * k));
                        y = (float)(StartCenterPoint.Y + k * 20 * i / Math.Sqrt(1 + k * k));
                    }
                    else if ((dx < 0 && dy < 0) || (dx < 0 && dy > 0))
                    {
                        x = (float)(StartCenterPoint.X - 20 * i / Math.Sqrt(1 + k * k));
                        y = (float)(StartCenterPoint.Y - k * 20 * i / Math.Sqrt(1 + k * k));
                    }
                }
                OutterCircles.Add(new Circle(new PointF(x, y), OutterCircleSize));
                InnerCircles.Add(new Circle(new PointF(x, y), InnerCircleSize));
            }
        }
コード例 #17
0
ファイル: ToolObject.cs プロジェクト: marlonnn/Cii.Lar
 /// <summary>
 /// call when press "Escape" key
 /// </summary>
 /// <param name="drawArea"></param>
 /// <param name="cancelSelection"></param>
 public override void OnCancel(ZWPictureBox pictureBox, bool cancelSelection)
 {
     // cancel adding
     if (pictureBox.GraphicsList.Count > 0 && pictureBox.GraphicsList[0].Creating)
     {
         pictureBox.GraphicsList.DeleteLastAddedObject();
     }
 }
コード例 #18
0
ファイル: DrawEllipse.cs プロジェクト: marlonnn/Cii.Lar
        public override void Move(ZWPictureBox pictureBox, int deltaX, int deltaY)
        {
            PointF ps = ellipseForDraw.StartPoint;
            PointF pe = ellipseForDraw.EndPoint;

            ellipseForDraw.StartPoint = new PointF(ps.X + deltaX, ps.Y + deltaY);
            ellipseForDraw.EndPoint   = new PointF(pe.X + deltaX, pe.Y + deltaY);
        }
コード例 #19
0
 public static LaserFactory GetInstance(ZWPictureBox picturebox)
 {
     if (factory == null)
     {
         factory = new LaserFactory(picturebox);
     }
     return(factory);
 }
コード例 #20
0
        public AlignLaser(ZWPictureBox pictureBox) : base()
        {
            this.pictureBox = pictureBox;
            circles         = new List <Circle>();
            string jsonConfig = JsonFile.ReadJsonConfigString();

            circles = JsonFile.GetConfigFromJsonText <List <Circle> >(jsonConfig);
        }
コード例 #21
0
ファイル: DrawRectangle.cs プロジェクト: marlonnn/Cii.Lar
 public DrawRectangle(ZWPictureBox pictureBox, int x, int y, int width, int height) : this()
 {
     this.pictureBox = pictureBox;
     InitializeGraphicsProperties();
     this.ObjectType = ObjectType.Rectangle;
     rectangle       = new Rectangle(x, y, width, height);
     SetRectangle(rectangle);
     this.GraphicsProperties.GraphicsPropertiesChangedHandler += pictureBox.GraphicsPropertiesChangedHandler;
 }
コード例 #22
0
ファイル: DrawObject.cs プロジェクト: marlonnn/Cii.Lar
        public virtual void DrawTest(Graphics g, ZWPictureBox pictureBox)
        {
            SolidBrush brush = new SolidBrush(GraphicsPropertiesManager.GetPropertiesByName("Text").Color);
            RectangleF r     = GetTextF(this.Name, g, this.ID);

            r.Offset(MovingOffset);
            g.DrawString(this.Name, this.Font, brush, r);
            brush.Dispose();
        }
コード例 #23
0
        /// <summary>
        /// draw line graphic
        /// </summary>
        /// <param name="g"></param>
        /// <param name="pictureBox"></param>
        public override void Draw(Graphics g, ZWPictureBox pictureBox)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen pen = new Pen(Color.FromArgb(GraphicsProperties.Alpha, GraphicsProperties.Color), GraphicsProperties.PenWidth))
            {
                g.DrawLine(pen, startDataPoint.X, startDataPoint.Y, endDataPoint.X, endDataPoint.Y);
            }
        }
コード例 #24
0
ファイル: ToolObject.cs プロジェクト: marlonnn/Cii.Lar
        /// <summary>
        /// add new object to picturebox
        /// </summary>
        /// <param name="pictureBox"></param>
        /// <param name="o"></param>
        protected void AddNewObject(ZWPictureBox pictureBox, DrawObject o)
        {
            pictureBox.GraphicsList.UnselectAll();

            o.Selected = true;
            o.Creating = true;

            pictureBox.GraphicsList.Add(o);
        }
コード例 #25
0
 public LaserFactory(ZWPictureBox picturebox)
 {
     this.picturebox                = picturebox;
     this.fixedLaser                = new FixedLaser(picturebox);
     this.activeLaser               = new ActiveLaser(picturebox);
     this.alignLaser                = new AlignLaser(picturebox);
     alignLaser.ZoomHandler        += picturebox.ZoomHandler;
     alignLaser.ButtonStateHandler += picturebox.ButtonStateHandler;
 }
コード例 #26
0
        public DrawPolygon(ZWPictureBox pictureBox, int x1, int y1, int x2, int y2) : this()
        {
            this.pictureBox      = pictureBox;
            pointArray           = new PointFList();
            pointArrayProportion = new PointFList();

            AddPoint(pictureBox, new Point(x1, y1), false);
            AddPoint(pictureBox, new Point(x2, y2), false);
        }
コード例 #27
0
ファイル: ActiveLaser.cs プロジェクト: marlonnn/Cii.Lar
        public override void OnMouseDown(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            mouseDownPoint = e.Location;

            Point point = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX),
                                    (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));

            activeCircle.OnMouseDown(point);
            this.pictureBox.Invalidate();
        }
コード例 #28
0
ファイル: ToolPolygon.cs プロジェクト: marlonnn/Cii.Lar
        public override void OnMouseDown(ZWPictureBox pictureBox, MouseEventArgs e)
        {
            Point point = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));

            newPolygon = new DrawPolygon(pictureBox, point.X, point.Y, point.X + 1, point.Y + 1);
            AddNewObject(pictureBox, newPolygon);

            lastX = point.X;
            lastY = point.Y;
        }
コード例 #29
0
 public override void OnMouseDown(ZWPictureBox pictureBox, MouseEventArgs e)
 {
     clickCount++;
     if (clickCount % 2 == 1)
     {
         startPoint = new Point((int)(e.X / pictureBox.Zoom - pictureBox.OffsetX), (int)(e.Y / pictureBox.Zoom - pictureBox.OffsetY));
         drawObject = new DrawRectangle(pictureBox, startPoint.X, startPoint.Y, 1, 1);
         AddNewObject(pictureBox, drawObject);
     }
 }
コード例 #30
0
        public FixedLaser(ZWPictureBox pictureBox) : base()
        {
            this.pictureBox = pictureBox;
            float pulseSize = SysConfig.GetSysConfig().LaserConfig.PulseSize;

            OutterCircleSize = new SizeF(pulseSize + SysConfig.GetSysConfig().LaserConfig.GraphicsProperties.ExclusionSize,
                                         pulseSize + SysConfig.GetSysConfig().LaserConfig.GraphicsProperties.ExclusionSize);
            InnerCircleSize = new SizeF(pulseSize, pulseSize);
            this.GraphicsProperties.GraphicsPropertiesChangedHandler += GraphicsPropertiesChangedHandler;
        }