コード例 #1
0
        private void MoveClickHandler(System.Drawing.Point point)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            Bitmap clone = (Bitmap)Image.FromFile(ImagePath);

            BlackPixels.GetCombinationPairs()
            .Select(t => new
            {
                Points = t,
                line   = PointUtils.GetPolarLineFromCartesianPoints(t),
            })
            .Where(p =>
            {
                var index = _accumulator.GetAccumulatorIndex(p.line);
                return(index[0] == point.X && index[1] == point.Y);
            })
            .SelectMany(p => new[] { p.Points.Item1, p.Points.Item2 })
            .ToList()
            .ForEach(p => clone.SetPixel(p.X, p.Y, Color.Magenta));


            Source = clone;

            watch.Stop();
            Console.WriteLine("click: Measured time: " + watch.Elapsed.TotalMilliseconds + " ms.");
        }
コード例 #2
0
        private System.Drawing.Point RefineLocationPoint(System.Drawing.Point point)
        {
            int x = point.X - this.Size.Width + 10; // 10 estimates the window border

            if (x < 0)
            {
                x = 0;
            }

            int y = point.Y + EstimateCaretHeight();

            if (y + this.Height > Screen.PrimaryScreen.Bounds.Height)     // if it does not fit underneath
            {
                if (point.Y - this.Height < 0)                            // and neither fits above
                {
                    y = Screen.PrimaryScreen.Bounds.Height - this.Height; // it's better to put it underneath
                }
                else // otherwise put it above
                {
                    y = point.Y - this.Height;
                }
            }

            return(new Point(x, y));
        }
コード例 #3
0
        public void Draw()
        {
            if (caption.GetTextBox() != null || caption.GetTextBox().Width > 0 ||
                caption.GetTextBox().Height > 0)
            {
                switch (context.CaptionPosition)
                {
                case "top":
                    offset = new Point(0, (int)MathF.Round((float)-20));
                    break;

                case "bottom":
                    offset = new Point(0, (int)MathF.Round((float)context.shape.GetShape().Height));
                    break;

                case "left":
                    offset = new Point(-5 * caption.GetTextBox().Text.Length, 0);
                    caption.GetTextBox().HorizontalContentAlignment = HorizontalAlignment.Right;
                    break;

                case "right":
                    offset = new Point((int)MathF.Round((float)context.shape.GetShape().Width), 0);
                    break;

                default:
                    offset = new Point(0, 0);
                    break;
                }
            }
            //caption.SetText("Yeet");
            caption.SetPosition(new Point(context.shape.GetPosition().X + offset.X, context.shape.GetPosition().Y + offset.Y));
        }
コード例 #4
0
        private bool calibrate(Sliver sl)
        {
            int xx;
            var sp = new System.Drawing.Point(sl.left - 20, top);
            var dp = new System.Drawing.Point(sl.left + 20, top + height);

            calBitmap = (Bitmap)sc.Capture(sp, dp);
            for (int x = 0; x < calBitmap.Width; x++)
            {
                for (int y = 0; y < 200; y++)
                {
                    var pixel = calBitmap.GetPixel(x, y);
                    if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255)
                    {
                        pixel = calBitmap.GetPixel(x, y + 1);
                        if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255)
                        {
                            sl.left      += (x - 20);
                            sl.calibrated = true;
                            return(true);
                        }
                        pixel = calBitmap.GetPixel(x, y + 2);
                        if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255)
                        {
                            sl.left      += (x - 20);
                            sl.calibrated = true;
                            return(true);
                        }
                    }
                }
            }

            sl.calibrated = false;
            return(false);
        }
コード例 #5
0
        private System.Drawing.Point[] ToPointsArray(List <IntPoint> points)
        {
            System.Drawing.Point[] array = new System.Drawing.Point[points.Count];
            for (int i = 0, n = points.Count; i < n; i++)
            {
                array[i] = new System.Drawing.Point(points[i].X, points[i].Y);
            }

            return(array);
        }
コード例 #6
0
 public void ShowAtPoint(System.Drawing.Point point)
 {
     if (this.Enabled)
     {
         this.Location = RefineLocationPoint(point);
         this.Show();
         //this.Visible = this.Enabled;
         windowListener.Focus();
     }
 }
コード例 #7
0
        public static uint GetDpi(IntPtr hwnd, DpiType dpiType)
        {
            var  screen = Screen.FromHandle(hwnd);
            var  pnt = new System.Drawing.Point(screen.Bounds.Left + 1, screen.Bounds.Top + 1);
            var  mon = MonitorFromPoint(pnt, 2 /*MONITOR_DEFAULTTONEAREST*/);
            uint dpiX, dpiY;

            GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY);
            return(dpiX);
        }
コード例 #8
0
ファイル: TestW.xaml.cs プロジェクト: Nekohim3/BDOA
 private void UIElement_OnMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (clicado)
     {
         System.Drawing.Point pos;
         Imports.GetCursorPos(out pos);
         Left += (pos.X - lm.X);
         Top  += (pos.Y - lm.Y);
         lm    = pos;
     }
 }
コード例 #9
0
        private void MoveOverAccumulatorHandler(System.Drawing.Point point)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();


            Debug.WriteLine("{{X=" + point.X + ", Y=" + point.Y + ", Value=" + _accumulator[point.X, point.Y] + "}}");
            var line = _accumulator.GetLineFromIndex(new List <int>()
            {
                point.X, point.Y
            });

            var minLine = new PolarPointF()
            {
                Rho   = line.Rho - _accumulator.RhoDelta / 2,
                Theta = line.Theta - _accumulator.ThetaDelta / 2,
            };

            var maxLine = new PolarPointF()
            {
                Rho   = line.Rho + _accumulator.RhoDelta / 2,
                Theta = line.Theta + _accumulator.ThetaDelta / 2,
            };

            Debug.WriteLine("Minimum: " + minLine);
            Debug.WriteLine("maximum: " + maxLine);

            using (Bitmap clone = (Bitmap)Image.FromFile(ImagePath))
            {
                using (var graphics = Graphics.FromImage(clone))
                {
                    var tempLine1 = new PolarPointF()
                    {
                        Rho   = line.Rho,
                        Theta = minLine.Theta
                    };
                    var tempLine2 = new PolarPointF()
                    {
                        Rho   = line.Rho,
                        Theta = maxLine.Theta
                    };
                    DrawPolarLine(tempLine1, graphics, new Pen(Color.Chartreuse, 1));
                    DrawPolarLine(tempLine2, graphics, new Pen(Color.Green, 1));

                    DrawPolarLine(line, graphics, new Pen(Color.Red, 2));
                }


                Source = clone;
            }
            watch.Stop();
            Console.WriteLine("move: Measured time: " + watch.Elapsed.TotalMilliseconds + " ms.");
        }
コード例 #10
0
        // Convert list of AForge.NET's IntPoint to array of .NET's Point
        private static System.Drawing.Point[] PointsListToArray(List <IntPoint> list)
        {
            System.Drawing.Point[] array = new System.Drawing.Point[list.Count];

            for (int i = 0, n = list.Count; i < n; i++)
            {
                array[i] = new System.Drawing.Point(list[i].X, list[i].Y);
            }

            return(array);
        }
コード例 #11
0
        private bool shouldDisplay(System.Drawing.Point a, System.Drawing.Point b, System.Drawing.Point c)
        {
            Vector3 v1    = new Vector3(b.X - a.X, b.Y - a.Y, 0);
            Vector3 v2    = new Vector3(c.X - a.X, c.Y - a.Y, 0);
            Vector3 cross = Vector3.Cross(v1, v2);

            if (cross.Z > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #12
0
        public static uint GetDpi(System.Drawing.Point point, DpiType dpiType)
        {
            var mon = MonitorFromPoint(point, 2 /*MONITOR_DEFAULTTONEAREST*/);

            try
            {
                uint dpiX, dpiY;
                GetDpiForMonitor(mon, dpiType, out dpiX, out dpiY);
                return(dpiX);
            }
            catch
            {
                // fallback for Windows 7 and older - not 100% reliable
                Graphics graphics = Graphics.FromHdc(mon);
                float    dpiXX    = graphics.DpiX;
                return(Convert.ToUInt32(dpiXX));
            }
        }
コード例 #13
0
        private int FindClosestPoint(System.Drawing.Point point)
        {
            int result      = -1;
            int entityIndex = GetEntityUnderMouseCursor(point);

            if (entityIndex != -1)
            {
                Entity ent = Entities[entityIndex];
                if (ent is ICurve)
                {
                    result = FindClosestVertex(point, 8, out _measureEndPoint);
                }
            }
            else
            {
                _measureEndPoint = null;
            }
            return(result);
        }
コード例 #14
0
ファイル: DragDropLib.cs プロジェクト: gouming/BetterExplorer
        /// <summary>
        /// Sets the drag image.
        /// </summary>
        /// <param name="dataObject">The DataObject to set the drag image on.</param>
        /// <param name="image">The drag image.</param>
        /// <param name="cursorOffset">The location of the cursor relative to the image.</param>
        public static void SetDragImage(this IDataObject dataObject, Image image, System.Drawing.Point cursorOffset)
        {
            ShDragImage shdi = new ShDragImage();

            Win32Size size;

            size.cx            = image.Width;
            size.cy            = image.Height;
            shdi.sizeDragImage = size;

            Win32Point wpt;

            wpt.x         = cursorOffset.X;
            wpt.y         = cursorOffset.Y;
            shdi.ptOffset = wpt;

            shdi.crColorKey = Color.Magenta.ToArgb();

            // This HBITMAP will be managed by the DragDropHelper
            // as soon as we pass it to InitializeFromBitmap. If we fail
            // to make the hand off, we'll delete it to prevent a mem leak.
            IntPtr hbmp = GetHbitmapFromImage(image);

            shdi.hbmpDragImage = hbmp;

            try
            {
                IDragSourceHelper sourceHelper = (IDragSourceHelper) new DragDropHelper();

                try
                {
                    sourceHelper.InitializeFromBitmap(ref shdi, (ComIDataObject)dataObject);
                }
                catch (NotImplementedException ex)
                {
                    throw new Exception("A NotImplementedException was caught. This could be because you forgot to construct your DataObject using a DragDropLib.DataObject", ex);
                }
            }
            catch
            {
                DeleteObject(hbmp);
            }
        }
コード例 #15
0
        void DrawTriangle(System.Drawing.Point a, System.Drawing.Point b, System.Drawing.Point c)
        {
            if (shouldDisplay(a, b, c))
            {
                return;
            }

            var line1 = new Line
            {
                X1              = a.X,
                X2              = b.X,
                Y1              = a.Y,
                Y2              = b.Y,
                Stroke          = new SolidColorBrush(Colors.Black),
                StrokeThickness = 5
            };

            var line2 = new Line
            {
                X1              = b.X,
                X2              = c.X,
                Y1              = b.Y,
                Y2              = c.Y,
                Stroke          = new SolidColorBrush(Colors.Black),
                StrokeThickness = 5
            };


            var line3 = new Line
            {
                X1              = c.X,
                X2              = a.X,
                Y1              = c.Y,
                Y2              = a.Y,
                Stroke          = new SolidColorBrush(Colors.Black),
                StrokeThickness = 5
            };

            MyCanvas.Children.Add(line1);
            MyCanvas.Children.Add(line2);
            MyCanvas.Children.Add(line3);
        }
コード例 #16
0
        private bool CheckEveSystem()
        {
            if (curImage == null)
            {
                return(false);
            }
            var sp = new System.Drawing.Point();
            var dp = new System.Drawing.Point();

            sp.X     = sLeft;
            sp.Y     = sTop;
            dp.X     = sWidth + sLeft;
            dp.Y     = sHeight + sTop;
            curImage = sc.Capture(sp, dp);
            int currentEveSystemBid = 0;

            curBitmap = (Bitmap)curImage;

            for (int x = 0; x < sWidth; x++)
            {
                for (int y = 0; y < sHeight; y++)
                {
                    var pixel = curBitmap.GetPixel(x, y);
                    if (pixel.R == 0xFF && pixel.B == 0xFF && pixel.G == 0xFF)
                    {
                        currentEveSystemBid++;
                    }
                }
            }
            if (eveSystemBid != currentEveSystemBid)
            {
                eveSystemBid = currentEveSystemBid;
                if (isOutPathValid)
                {
                    SaveEveSystemBMP();  //If EveSystem bitmap white bits are different, we are likely in a new system.
                }
                return(true);
            }
            return(false);
        }
コード例 #17
0
        private void SaveEveSystemBMP()
        {
            if (outFolder.Text == null || outFolder.Text.Length < 2)
            {
                return;
            }
            sHeight = (int)gcwSystem.Height;
            sWidth  = (int)gcwSystem.Width;
            sTop    = (int)gcwSystem.Top;
            sLeft   = (int)gcwSystem.Left;
            Properties.Settings.Default.sLeft   = sLeft;
            Properties.Settings.Default.sTop    = sTop;
            Properties.Settings.Default.sWidth  = sWidth;
            Properties.Settings.Default.sHeight = sHeight;
            Properties.Settings.Default.Save();
            var sp = new System.Drawing.Point(sLeft, sTop);
            var dp = new System.Drawing.Point(sLeft + sWidth, sTop + sHeight);

            curImage = sc.Capture(sp, dp);

            curBitmap = (Bitmap)curImage;
            Bitmap resized = new Bitmap(curBitmap, new System.Drawing.Size(curBitmap.Width * 2, curBitmap.Height * 2));
            string fname   = outFolder.Text + "\\system.bmp";

            if (isOutPathValid)
            {
                resized.Save(fname);
            }
            resized.Dispose();
            if (gcwShowing)
            {
                gcwLocal.Hide();
                gcwSystem.Hide();
            }
            if (File.Exists(outFolder.Text + "\\system.txt"))
            {
                File.Delete(outFolder.Text + "\\system.txt");
            }
        }
コード例 #18
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            // save the current mouse position
            _mouseLocation = RenderContextUtility.ConvertPoint(GetMousePosition(e));

            // if start is valid and actionMode is None and it's not in the toolbar area

            if (_currentPoint == null || ActionMode != actionType.None || GetToolBar().Contains(_mouseLocation))
            {
                base.OnMouseMove(e);

                return;
            }

            base.OnMouseMove(e);

            FindClosestPoint(_mouseLocation);

            // paint the viewport surface
            PaintBackBuffer();

            // consolidates the drawing
            SwapBuffers();
        }
コード例 #19
0
        private void UpdateMouseState()
        {
            // If we call the form client functions before the form has
            // been made visible it will cause the wrong window size to
            // be applied at startup.
            if (!Form.Visible)
            {
                return;
            }

            POINTSTRUCT pos;

            GetCursorPos(out pos);
            MapWindowPoints(new HandleRef(null, IntPtr.Zero), new HandleRef(Form, Form.Handle), out pos, 1);
            var clientPos    = new System.Drawing.Point(pos.X, pos.Y);
            var withinClient = Form.ClientRectangle.Contains(clientPos);
            var buttons      = Control.MouseButtons;

            var previousState = MouseState.LeftButton;

            MouseState.X            = clientPos.X;
            MouseState.Y            = clientPos.Y;
            MouseState.LeftButton   = (buttons & MouseButtons.Left) == MouseButtons.Left ? ButtonState.Pressed : ButtonState.Released;
            MouseState.MiddleButton = (buttons & MouseButtons.Middle) == MouseButtons.Middle ? ButtonState.Pressed : ButtonState.Released;
            MouseState.RightButton  = (buttons & MouseButtons.Right) == MouseButtons.Right ? ButtonState.Pressed : ButtonState.Released;
            MouseState.XButton1     = (buttons & MouseButtons.XButton1) == MouseButtons.XButton1 ? ButtonState.Pressed : ButtonState.Released;
            MouseState.XButton2     = (buttons & MouseButtons.XButton2) == MouseButtons.XButton2 ? ButtonState.Pressed : ButtonState.Released;

            // Don't process touch state if we're not active
            // and the mouse is within the client area.
            if (!_platform.IsActive || !withinClient)
            {
                if (MouseState.LeftButton == ButtonState.Pressed)
                {
                    // Release mouse TouchLocation
                    var touchX = MathHelper.Clamp(MouseState.X, 0, Form.ClientRectangle.Width - 1);
                    var touchY = MathHelper.Clamp(MouseState.Y, 0, Form.ClientRectangle.Height - 1);
                    TouchPanelState.AddEvent(0, TouchLocationState.Released, new Vector2(touchX, touchY), true);
                }
                return;
            }

            TouchLocationState?touchState = null;

            if (MouseState.LeftButton == ButtonState.Pressed)
            {
                if (previousState == ButtonState.Released)
                {
                    touchState = TouchLocationState.Pressed;
                }
                else
                {
                    touchState = TouchLocationState.Moved;
                }
            }
            else if (previousState == ButtonState.Pressed)
            {
                touchState = TouchLocationState.Released;
            }

            if (touchState.HasValue)
            {
                TouchPanelState.AddEvent(0, touchState.Value, new Vector2(MouseState.X, MouseState.Y), true);
            }
        }
コード例 #20
0
 private static extern IntPtr MonitorFromPoint([In] System.Drawing.Point pt, [In] uint dwFlags);
コード例 #21
0
 /// <summary>
 /// updates the auto-filling X and Y coordinates
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(GeoMouseArgs e)
 {
     
     if (_standBy) return;
     _coordinateDialog.X = e.GeographicLocation.X;
     _coordinateDialog.Y = e.GeographicLocation.Y;
     if (_coordinates != null && _coordinates.Count > 0)
     {
         List<System.Drawing.Point> points = new List<System.Drawing.Point>();
         foreach (Coordinate coord in _coordinates)
         {
             points.Add(Map.ProjToPixel(coord));
         }
         Rectangle oldRect = Global.GetRectangle(_mousePosition, points[points.Count - 1]);
         Rectangle newRect = Global.GetRectangle(e.Location, points[points.Count - 1]);
         Rectangle invalid = Rectangle.Union(newRect, oldRect);
         invalid.Inflate(20, 20);
         Map.Invalidate(invalid);
     }
     _mousePosition = e.Location;
     base.OnMouseMove(e);
 }
コード例 #22
0
        private void UpdateObjectIndicators()
        {
            canvas.Children.Clear();

            //if the image is originally only 320x240, the indicator-coordinates have to be scaled up
            int scale = 1;
            if (_tableManager.LastRecognitionDataPacket.correctedDepthImage.Width == 320)
                scale = 2;

            foreach(TableObject obj in _objectlist.Where(o => o.Center != null))
            {
                Rectangle r = new Rectangle();

                //Place the rectangle so that the object is in its center
                int x, y;
                if (((bool)rb_video.IsChecked || (bool)rb_indicator.IsChecked))
                {
                    x = obj.Center.ColorX - (int) Math.Round((double) obj.Radius/2);
                    y = obj.Center.ColorY - (int) Math.Round((double) obj.Radius/2);
                }
                else
                {
                    x = obj.Center.DepthX * scale - (int)Math.Round((double)obj.Radius / 2);
                    y = obj.Center.DepthY * scale - (int)Math.Round((double)obj.Radius / 2);
                }
                if (x < 0)
                    x = 0;
                if (y < 0)
                    y = 0;

                r.Margin = new Thickness(x, y, 0, 0);
                r.Width = obj.Radius;
                r.Height = obj.Radius;
                int id = obj.ObjectID;
                if (id > 99)
                    id = 99;

                r.Stroke = new SolidColorBrush(Colors.Red);

                TextBlock blck = new TextBlock();
                blck.Text = obj.ObjectID.ToString();

                if (obj.TrackingStatus == TableObject.ETrackingStatus.LongTermTracked)
                {
                    blck.Text += "L";
                }
                else if (obj.TrackingStatus == TableObject.ETrackingStatus.ShortlyTracked)
                {
                    blck.Text += "S";
                }
                else if (obj.TrackingStatus == TableObject.ETrackingStatus.LongTermGuessed)
                {
                    blck.Text += "G";
                }
                else
                {
                    blck.Text += "N";
                }
                blck.Foreground = new SolidColorBrush(Colors.Red);
                blck.Margin = new Thickness(x, y, 0, 0);

                //If rotation is defined, add rotation indicator
                if (obj.RotationDefined)
                {
                    Point pdest;
                    Vector dest = obj.DirectionVector*20;
                    if (!((bool)rb_video.IsChecked||(bool)rb_indicator.IsChecked))
                    {
                        pdest = new System.Drawing.Point((int) Math.Round(obj.Center.DepthX*scale + dest.X),
                                                               (int) Math.Round(obj.Center.DepthY*scale + dest.Y));
                    }
                    else
                    {
                        pdest = new System.Drawing.Point((int)Math.Round(obj.Center.ColorX + dest.X),
                                                               (int)Math.Round(obj.Center.ColorY + dest.Y));
                    }
                    Line l = new Line();

                    if (!((bool)rb_video.IsChecked || (bool)rb_indicator.IsChecked))
                    {
                        l.X1 = obj.Center.DepthX*scale;
                        l.Y1 = obj.Center.DepthY*scale;
                    }
                    else
                    {
                        l.X1 = obj.Center.ColorX;
                        l.Y1 = obj.Center.ColorY;
                    }

                    l.X2 = pdest.X;
                    l.Y2 = pdest.Y;
                    l.Stroke = new SolidColorBrush(Colors.Pink);
                    canvas.Children.Add(l);
                }
                canvas.Children.Add(r);
                canvas.Children.Add(blck);
            }

            //Hand objects+
            if (_tableManager.LastRecognitionDataPacket.HandObj != null)
            {
                HandObject ho = _tableManager.LastRecognitionDataPacket.HandObj;
                ho.PointsAt = PositionMapper.GetColorCoordinatesfromDepth(ho.PointsAt);

                Ellipse e = new Ellipse();
                e.Height = 5;
                e.Width = 5;
                e.Stroke = new SolidColorBrush(Colors.Cyan);
                canvas.Children.Add(e);
                if (((bool)rb_video.IsChecked || (bool)rb_indicator.IsChecked))
                {
                    Canvas.SetLeft(e, ho.PointsAt.ColorX);
                    Canvas.SetTop(e, ho.PointsAt.ColorY);
                }
                else
                {
                    Canvas.SetLeft(e, ho.PointsAt.DepthX * scale);
                    Canvas.SetTop(e, ho.PointsAt.DepthY * scale);
                }
            }
        }
コード例 #23
0
        public static void PixelIsColor(this Assert assert, System.Drawing.Point pixel, System.Drawing.Color expectedColor, Bitmap actualImage)
        {
            var actualColor = actualImage.GetPixel(pixel.X, pixel.Y);

            Assert.AreEqual(expectedColor, actualColor, $"Expected color at pixel {pixel} did not match actual color");
        }
コード例 #24
0
        private void PictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (trackBar4.Enabled == true)
            {
                //new code
                Point endingPoint = e.Location;

                int    ex    = endingPoint.X;
                int    ey    = endingPoint.Y;
                Shapes shape = currentShape;

                if (drag)
                {
                    if (!trails)
                    {
                        shapes.Last().setX2(ex);
                        shapes.Last().setY2(ey);
                    }
                    else
                    {
                        shapes.Last().setX2(ex);
                        shapes.Last().setY2(ey);
                        if (randColor)
                        {
                            KnownColor[] names           = (KnownColor[])Enum.GetValues(typeof(KnownColor));
                            KnownColor   randomColorName = names[randomGen.Next(names.Length)];
                            randomColor = Color.FromKnownColor(randomColorName);
                        }

                        switch (shape)
                        {
                        case Shapes.LINE:
                            if (randColor)
                            {
                                shapes.Add(new APLine(x, y, ex, ey, randomColor, brushWidth));
                            }
                            else
                            {
                                shapes.Add(new APLine(x, y, ex, ey, userColor, brushWidth));
                            };
                            break;

                        case Shapes.OVAL:
                            if (randColor)
                            {
                                shapes.Add(new APOval(x, y, ex, ey, randomColor, brushWidth));
                            }
                            else
                            {
                                shapes.Add(new APOval(x, y, ex, ey, userColor, brushWidth));
                            };
                            break;

                        case Shapes.BOX:
                            if (randColor)
                            {
                                shapes.Add(new APBox(x, y, ex, ey, randomColor, brushWidth));
                            }
                            else
                            {
                                shapes.Add(new APBox(x, y, ex, ey, userColor, brushWidth));
                            };
                            break;

                        default:
                            break;
                        }
                    }

                    Refresh();
                }
            }

            else
            {
                //my code
                try
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        current = e.Location;
                        g.DrawLine(p, old, current);
                        old = current;
                    }
                    else
                    {
                    }
                }
                catch
                {
                    /*stops from crashing if drawing fails */
                }
                int crpX, crpY, rectW, rectH;
            }
        }
コード例 #25
0
 public void MouseDrag(System.Drawing.Point pos)
 {
 }
コード例 #26
0
 protected override void OnMouseDown(GeoMouseArgs e)
 {
     _mousePosition = e.Location;
     if(_dragging)
     {
         if(e.Button == MouseButtons.Right)
         {
             _dragging = false;
             Map.Invalidate();
         }
     }
     else
     {
         if(_selectedFeature != null)
         {
             Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
             
             IEnvelope env = Map.PixelToProj(mouseRect);
             
             if(CheckForVertexDrag(e)) return;
            
             // No vertex selection has occured.
             if(!_selectedFeature.Intersects(env.ToPolygon()))
             {
                 // We are clicking down outside of the given polygon, so clear our selected feature 
                 UnSelectFeature();
                 return;
             }
            
         }
        
         if(_activeFeature != null)
         {
             
             // Don't start dragging a vertices right away for polygons and lines.  
             // First you select the polygon, which displays the vertices, then they can be moved.
             if(_featureSet.FeatureType == FeatureTypes.Polygon)
             {
                 
                 _selectedFeature = _activeFeature;
                 _activeFeature = null;
                 IPolygonCategory sc = _selectedCategory as IPolygonCategory;
                 if (sc == null)
                 {
                     _selectedCategory = new PolygonCategory(Color.FromArgb(55, 0, 255, 255), Color.Blue, 1);
                     _selectedCategory.LegendItemVisible = false;
                 }
                 
                 _layer.SetCategory(_selectedFeature, _selectedCategory);
             }
             else if (_featureSet.FeatureType == FeatureTypes.Line)
             {
                 
                 _selectedFeature = _activeFeature;
                 _activeFeature = null;
                 ILineCategory sc = _selectedCategory as ILineCategory;
                 if (sc == null)
                 {
                     _selectedCategory = new LineCategory(Color.Cyan, 1);
                     _selectedCategory.LegendItemVisible = false;
                 }
                 _layer.SetCategory(_selectedFeature, _selectedCategory);
             }
             else
             {
                 _dragging = true;
                 _dragCoord = _activeFeature.Coordinates[0];
                 MapPointLayer mpl = _layer as MapPointLayer;
                 if(mpl != null)
                 {
                     mpl.SetVisible(_activeFeature, false);
                 }
                 IPointCategory sc = _selectedCategory as IPointCategory;
                 if(sc == null)
                 {
                     IPointSymbolizer ps = _layer.GetCategory(_activeFeature).Symbolizer.Copy() as IPointSymbolizer;
                     if(ps != null)
                     {
                         ps.SetFillColor(Color.Cyan);
                         _selectedCategory = new PointCategory(ps);
                     }
 
                 }
             }
         }
         Map.MapFrame.Initialize();
         Map.Invalidate();
     }
 }
コード例 #27
0
 public static System.Windows.Point ToPoint(this System.Drawing.Point pt, int left, int top)
 {
     return(new System.Windows.Point(pt.X + left, pt.Y + top));
 }
コード例 #28
0
ファイル: BlobsScanner.cs プロジェクト: boo1ean/bom-bom
        // Convert list of AForge.NET's IntPoint to array of .NET's Point
        private static System.Drawing.Point[] PointsListToArray(List<IntPoint> list)
        {
            System.Drawing.Point[] array = new System.Drawing.Point[list.Count];

            for (int i = 0, n = list.Count; i < n; i++)
            {
                array[i] = new System.Drawing.Point(list[i].X, list[i].Y);
            }

            return array;
        }
コード例 #29
0
ファイル: Utils.cs プロジェクト: Maxhyt/AutoQTun
 public static bool MoveMouse(System.Drawing.Point target, bool human = true, int steps = 100)
 {
     Cursor.Position = target;
     return(Cursor.Position == target);
 }
コード例 #30
0
ファイル: GDIMap.cs プロジェクト: osome/DotSpatial
 /// <summary>
 /// Converts a single point location into an equivalent geographic coordinate
 /// </summary>
 /// <param name="position">The client coordinate relative to the map control</param>
 /// <returns>The geographic ICoordinate interface</returns>
 public Coordinate PixelToProj(System.Drawing.Point position)
 {
     return(_gdiMapFrame.PixelToProj(position));
 }
コード例 #31
0
 private void ImageWorkspace_Workspace_TriggerFourPointStraightenEvent(System.Drawing.Point topLeft, System.Drawing.Point topRight, System.Drawing.Point bottomleft, System.Drawing.Point bottomRight)
 {
     _appService.FourPointStraighten(new Point[] { topLeft, topRight, bottomleft, bottomRight }, null);
 }
コード例 #32
0
 public static System.Windows.Point ToPoint(this System.Drawing.Point pt)
 {
     return(new System.Windows.Point(pt.X, pt.Y));
 }
コード例 #33
0
ファイル: DragDropLib.cs プロジェクト: gouming/BetterExplorer
        /// <summary>
        /// Sets the drag image as the rendering of a control.
        /// </summary>
        /// <param name="dataObject">The DataObject to set the drag image on.</param>
        /// <param name="control">The Control to render as the drag image.</param>
        /// <param name="cursorOffset">The location of the cursor relative to the control.</param>
        public static void SetDragImage(this IDataObject dataObject, Control control, System.Drawing.Point cursorOffset)
        {
            int width  = control.Width;
            int height = control.Height;

            Bitmap bmp = new Bitmap(width, height);

            control.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));

            SetDragImage(dataObject, bmp, cursorOffset);
        }
コード例 #34
0
 public static System.Windows.Point ToPoint(this System.Drawing.Point pt, int left, int top, int mul)
 {
     return(new System.Windows.Point((pt.X + left) * mul, (pt.Y + top) * mul));
 }
コード例 #35
0
        protected override void OnMouseMove(GeoMouseArgs e)
        {
            _mousePosition = e.Location;
            if(_dragging)
            {
               UpdateDragCoordiante(e);
            }
            else
            {
                if(_selectedFeature != null)
                {
                    VertexHighlight(e);
                }
                else
                {

                    // Before a shape is selected it should be possible to highlight shapes to indicate which one will be selected.
                    bool requiresInvalidate = false;
                    if(_activeFeature != null)
                    {
                        if (ShapeRemoveHighlight(e)) requiresInvalidate = true;
                    }
                    if(_activeFeature == null)
                    {
                        if (ShapeHighlight(e)) requiresInvalidate = true;
                    }

                    if(requiresInvalidate)
                    {
                        Map.MapFrame.Initialize();
                        Map.Invalidate();
                    }           
                }

                // check to see if the coordinates intersect with a shape in our current featureset.
            }

        }