Example #1
0
        private MeshGeometry3D BuildMesh(Point3D p0, Point3D p1, Point3D p2, Point3D p3,
            Point2D q0, Point2D q1, Point2D q2, Point2D q3)
        {
            var mesh = new MeshGeometry3D();
            mesh.Positions.Add(p0);
            mesh.Positions.Add(p1);
            mesh.Positions.Add(p2);
            mesh.Positions.Add(p3);

            var normal = CalculateNormal(p0, p1, p2);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q3);
            mesh.TextureCoordinates.Add(q2);
            mesh.TextureCoordinates.Add(q1);

            normal = CalculateNormal(p2, p3, p0);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(0);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q0);
            mesh.TextureCoordinates.Add(q1);
            mesh.TextureCoordinates.Add(q2);

            mesh.Freeze();
            return mesh;
        }
Example #2
0
 public static void Main(string[] arguments)
 {
     var a = new Point(-1, 1);
     Console.WriteLine(a);
     var b = a;
     Console.WriteLine(b);
 }
Example #3
0
 // We use the left mouse button to do exclusive capture of the mouse so we can drag and drag
 // to rotate the cube without ever leaving the control
 private void OnGraphicsControlHwndLButtonDown(object sender, MouseEventArgs e)
 {
     _output.AppendLine("Mouse left button down");
     _previousPosition = e.GetPosition(this);
     GraphicsControl.CaptureMouse();
     GraphicsControl.Focus();
 }
Example #4
0
        public static KeyValuePair<bool, System.Windows.Point> OptimalTwoSumProblem(Dictionary<int, bool> hashmap, int targetSum)
        {
            bool sumExists = false;
            int a = int.MinValue;
            int remainder = int.MinValue;
            System.Windows.Point summands;

            foreach (int key in hashmap.Keys)
            {
                a = key;
                remainder = targetSum - key;

                if (hashmap.ContainsKey(remainder))
                {
                    sumExists = true;
                    hashmap[key] = true;
                    hashmap[remainder] = true;
                    break;
                }
            }

            if (sumExists)
            {
                summands = new System.Windows.Point(a, remainder);
            }
            else
            {
                summands = new System.Windows.Point();
            }

            return new KeyValuePair<bool,System.Windows.Point>(sumExists, summands);
        }
 public WpfPoint[] Transform (Coordinate[] model)
 {
     var ret = new WpfPoint[model.Length];
     for (var i = 0; i < model.Length; i++ )
         ret[i] = new WpfPoint(model[i].X, model[i].Y);
         return ret;
 }
Example #6
0
 static Terrain3D()
 {
     {
     SX = new double[17];
     SZ = new double[17];
     int i = 0;
     for (double d = 0; d < 2; d += 0.125)
     {
       i++;
       SX[i] = Math.Cos(Math.PI * d);
       SZ[i] = Math.Sin(Math.PI * d);
     }
       }
       {
     TEXTURE_COORDINATES = new PointCollection(17);
     TEXTURE_COORDINATES.Add(new Point(0, 0));
     Point p = new Point(1, 0);
     int i = -1;
     while (++i < 16) TEXTURE_COORDINATES.Add(p);
     TEXTURE_COORDINATES.Freeze();
       }
       {
     TRIANGLE_INDICES = new Int32Collection(48);
     for (int i = 1; i < 16; i++)
     {
       TRIANGLE_INDICES.Add(0);
       TRIANGLE_INDICES.Add(i + 1);
       TRIANGLE_INDICES.Add(i);
     }
     TRIANGLE_INDICES.Add(0);
     TRIANGLE_INDICES.Add(1);
     TRIANGLE_INDICES.Add(16);
     TRIANGLE_INDICES.Freeze();
       }
 }
        public TextToSpeechDecal()
        {
            MetaData = new AudioMetaData();
            CanResize = false;
            Stretch = System.Windows.Media.Stretch.None;
            Center = new System.Windows.Point(0.5,1);
            PinPoint = new System.Windows.Point(0.5,1);
            CanMove = false;

            #if !SILVERLIGHT
            Play = new DelegateCommand(() =>
            {
                if (!string.IsNullOrEmpty(MetaData.Source) && !_isSpeaking)
                {
                    synthesizer = new SpeechSynthesizer();
                    synthesizer.Rate = -1;

                    synthesizer.SpeakAsync(MetaData.Source);
                    _isSpeaking = true;
                    // always dispose resources!
                    synthesizer.SpeakCompleted += new EventHandler<System.Speech.Synthesis.SpeakCompletedEventArgs>(task_SpeakCompleted);
                }
            }, () =>
            {
                return !string.IsNullOrEmpty(MetaData.Source);
            });
            #endif
        }
Example #8
0
		public PopoverBackend ()
		{
			Border = new System.Windows.Controls.Border {
				BorderBrush = Brushes.Black,
				CornerRadius = new System.Windows.CornerRadius (15),
				Padding = new System.Windows.Thickness (15),
				BorderThickness = new System.Windows.Thickness (1),
				Background = new SolidColorBrush (Color.FromArgb (230, 230, 230, 230))
			};

			NativeWidget = new System.Windows.Controls.Primitives.Popup {
				AllowsTransparency = true,
				Child = Border,
				Placement = System.Windows.Controls.Primitives.PlacementMode.Custom,
				StaysOpen = false,
				Margin = new System.Windows.Thickness (10),
			};

			NativeWidget.CustomPopupPlacementCallback = (popupSize, targetSize, offset) => {
				var location = new System.Windows.Point (targetSize.Width / 2 - popupSize.Width / 2, 0);
				if (ActualPosition == Popover.Position.Top)
					location.Y = targetSize.Height;
				else
					location.Y = -popupSize.Height;

				return new[] {
					new System.Windows.Controls.Primitives.CustomPopupPlacement (location, System.Windows.Controls.Primitives.PopupPrimaryAxis.Horizontal)
				};
			};

			NativeWidget.Closed += NativeWidget_Closed;
		}
Example #9
0
 protected override void SetEndPoint(Point value)
 {
     _graphics.DrawImage(_initialBitmap, _rectangle, _rectangle, GraphicsUnit.Pixel);
     EndPoint = new DrawingPoint((int)(value.X / ViewModel.Zoom), (int)(value.Y / ViewModel.Zoom));
     _graphics.DrawLine(_pen, StartPoint, EndPoint);
     ViewModel.ImageToDisplay = ViewModel.ImageToDisplay;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DebuggingDemo"/> class.
 /// </summary>
 public DebuggingDemo()
 {
   System.Windows.Media.Matrix matrix = new System.Windows.Media.Matrix();
   System.Windows.Point point = new System.Windows.Point();
   point.X = 3;
   matrix.Rotate(10);
 }
        public void Setup()
        {
            m_StartPoint = new Point(-10.0,
                                     -10.0);
            m_EndPoint = new Point(10.0,
                                   10.0);
            m_LineDirection = Constants.LineDirection.Forward;

            m_Line = new Line(m_StartPoint,
                              m_EndPoint);

            m_WindowsStartPoint = new System.Windows.Point(100.0,
                                                           200.0);
            m_WindowsEndPoint = new System.Windows.Point(300.0,
                                                         400.0);

            m_GeometryPointToWindowsPointConverter = Substitute.For <IGeometryPointToWindowsPointConverter>();
            m_GeometryPointToWindowsPointConverter.Point.Returns(m_WindowsStartPoint,
                                                                 m_WindowsEndPoint);

            m_Sut = new LineToWindowPointsConverter(m_GeometryPointToWindowsPointConverter)
                    {
                        Line = m_Line
                    };
            m_Sut.Line = m_Line;
            m_Sut.LineDirection = m_LineDirection;
            m_Sut.Convert();
        }
Example #12
0
        /// <summary>
        /// 每当鼠标键按下后,都将调用此方法。继承自MapAction。
        /// </summary>
        /// <param name="e">包含事件数据的MouseEventArgs</param>
        protected override void MouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.MouseLeftButtonDown(e);

            _isDown = true;
            _oldPoint = e.GetPosition(Map);
            Map.Cursor = Cursors.Hand;
        }
Example #13
0
 protected override void SetEndPoint(Point position)
 {
     graphics.DrawImage(initialBitmap, rectangle, rectangle, GraphicsUnit.Pixel);
     StartPoint = new DrawingPoint((int)(position.X / ViewModel.Zoom), (int)(position.Y / ViewModel.Zoom));
     points.Add(StartPoint);
     graphics.DrawCurve(pen, points.ToArray());
     ViewModel.ImageToDisplay = ViewModel.ImageToDisplay;
 }
        private System.Windows.Point NewPointRelativeToOrigin(double x,
                                                              double y)
        {
            var newPoint = new System.Windows.Point(Origin.X + x,
                                                    Origin.Y + -y);

            return newPoint;
        }
Example #15
0
 public static PathFigure BezierFromIntersection(Point startPt, Point int1, Point int2, Point endPt)
 {
     double x1, y1, x2, y2;
     Bez4pts1(startPt.X, startPt.Y, int1.X, int1.Y, int2.X, int2.Y, endPt.X, endPt.Y, out x1, out y1, out x2, out y2);
     PathFigure p = new PathFigure { StartPoint = startPt };
     p.Segments.Add(new BezierSegment { Point1 = new Point(x1, y1), Point2 = new Point(x2, y2), Point3 = endPt });
     return p;
 }
        /// <inheritdoc />
        internal override void SetLocation(Vector2 point)
        {
            var controlCoords = new System.Windows.Point(element.ActualWidth * point.X,
                                                         element.ActualHeight * point.Y);

            var screenCoords = element.PointToScreen(controlCoords);

            SetCursorPos((int)screenCoords.X, (int)screenCoords.Y);
        }
        // http://msdn.microsoft.com/en-us/library/bb259689.aspx
        public void ProcessRequest(HttpContext context)
        {
            uint x, y, z;

            //Parse request parameters
            if (!uint.TryParse(context.Request.Params["x"], out x))
                throw (new ArgumentException("Invalid parameter"));
            if (!uint.TryParse(context.Request.Params["y"], out y))
                throw (new ArgumentException("Invalid parameter"));
            if (!uint.TryParse(context.Request.Params["z"], out z))
                throw (new ArgumentException("Invalid parameter"));

            // Create a bitmap of size 256x256
            using (var bmp = new Bitmap(256, 256))
            // get graphics from bitmap
            using (var graphics = Graphics.FromImage(bmp))
            {
                // draw background
                //var brush = new LinearGradientBrush(new Point(0, 0), new Point(256, 256),
                //    Color.LightBlue, Color.Transparent);
                //graphics.FillRectangle(brush, new Rectangle(0, 0, 256, 256));
                //brush.Dispose();

                var rect = TransformTools.TileToWgs(x, y, z);
                int left = (int)Math.Floor(rect.Left);
                int right = (int)Math.Floor(rect.Right);
                int top = (int)Math.Floor(rect.Top);
                int bottom = (int)Math.Floor(rect.Bottom);

                for (int lon = left; lon <= right; lon++)
                {
                    for (int lat = top; lat <= bottom; lat++)
                    {
                        var g1 = new System.Windows.Point(lon, lat);
                        var g2 = new System.Windows.Point(lon + 1, lat + 1);
                        var p1 = TransformTools.WgsToTile(x, y, z, g1);
                        var p2 = TransformTools.WgsToTile(x, y, z, g2);

                        graphics.DrawLine(Pens.Black, new System.Drawing.Point((int)p1.X, (int)p1.Y), new System.Drawing.Point((int)p2.X, (int)p1.Y));
                        graphics.DrawLine(Pens.Black, new System.Drawing.Point((int)p1.X, (int)p1.Y), new System.Drawing.Point((int)p1.X, (int)p2.Y));
                    }
                }

                //Stream the image to the client
                using (var memoryStream = new System.IO.MemoryStream())
                {
                    // Saving a PNG image requires a seekable stream, first save to memory stream
                    // http://forums.asp.net/p/975883/3646110.aspx#1291641
                    bmp.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
                    var buffer = memoryStream.ToArray();

                    context.Response.ContentType = "image/png";
                    context.Response.OutputStream.Write(buffer, 0, buffer.Length);
                }
            }
        }
Example #18
0
        private void GestureListener_PinchStarted(object sender, PinchStartedGestureEventArgs e)
        {
            // Store the initial rotation angle and scaling
            InitialScale = ImageTransformation.ScaleX;
            // Calculate the center for the zooming
            System.Windows.Point firstTouch = e.GetPosition(ComicImage, 0);
            System.Windows.Point secondTouch = e.GetPosition(ComicImage, 1);

            Center = new System.Windows.Point(firstTouch.X + (secondTouch.X - firstTouch.X) / 2.0, firstTouch.Y + (secondTouch.Y - firstTouch.Y) / 2.0);
        }
Example #19
0
		private Point ConvertPosition(Point position)
		{
			if (!Hwnd.Equals(RelativeTo))
			{
				NativeMethods.POINT point = position.ToPOINT();
				NativeMethods.MapWindowPoints(Hwnd, RelativeTo, ref point, 1);
				return point.ToPoint();
			}
			return position;
		}
 public WpfPoint[] Transform(ICoordinateSequence modelSequence)
 {
     var res = new WpfPoint[modelSequence.Count];
     for (var i = 0; i < modelSequence.Count; i++)
     {
         res[i] = Transform(modelSequence.GetOrdinate(i, Ordinate.X),
                            modelSequence.GetOrdinate(i, Ordinate.Y));
     }
     return res;
 }
Example #21
0
        private Point GetTextureCoordinate(double t, double y)
        {
            var TYtoUV = new Matrix();
            TYtoUV.Scale(1/(2*Math.PI), -0.5);

            var p = new Point(t, y);
            p = p*TYtoUV;

            return p;
        }
Example #22
0
 public static IEnumerable<System.Windows.Point> ConvertToPointCollection(this string polygon)
 {
     foreach (Match match in regex.Matches(polygon))
     {
         double x, y;
         if (!double.TryParse(match.Groups[1].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out x) ||
             !double.TryParse(match.Groups[2].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out y)) continue;
         var p = new System.Windows.Point(x, y);
         yield return p;
     }
 }
Example #23
0
 protected override void SetStartPoint(Point value)
 {
     StartPoint = new DrawingPoint((int)(value.X / ViewModel.Zoom), (int)(value.Y / ViewModel.Zoom));
     Bitmap bitmap = ViewModel.ImageToDisplay.Source;
     _initialBitmap = ViewModel.Image.Source;
     _rectangle = ViewModel.Image.GetFullRectangle();
     _graphics = Graphics.FromImage(bitmap);
     _pen = new Pen(ViewModel.SelectedColor, ViewModel.StrokeThickness);
     _pen.EndCap = LineCap.Round;
     _pen.StartCap = LineCap.Round;
 }
Example #24
0
 protected override void Finish(Point value)
 {
     ViewModel.ComandList.AddNew(new Bitmap(ViewModel.Image.Source));
     _graphics.DrawImage(_initialBitmap, _rectangle, _rectangle, GraphicsUnit.Pixel);
     EndPoint = new DrawingPoint((int)(value.X / ViewModel.Zoom), (int)(value.Y / ViewModel.Zoom));
     Bitmap bitmap = ViewModel.Image.Source;
     _graphics = Graphics.FromImage(bitmap);
     _graphics.DrawLine(_pen, StartPoint, EndPoint);
     ViewModel.RefreshImage();
     ViewModel.OnCommandExecuted();
 }
Example #25
0
        public void ShouldComputeSectionMiddlePoint()
        {
            var firstPoint = new System.Windows.Point(-3, -4);
            var secondPoint = new System.Windows.Point(1, 2);
            var expectedPoint = new System.Windows.Point(-1, -1);

            var actualPoint = GeometricalHelper.ComputesSectionMiddle(firstPoint, secondPoint);

            Assert.AreEqual(expectedPoint.X, actualPoint.X);
            Assert.AreEqual(expectedPoint.Y, actualPoint.Y);
        }
        public Cursor GetCursor(IRect handleRect, IRect parentRect)
        {
            var discretizedHandle = handleRect.MiddlePoint();
            var edgeSizeOfEquivalentSquare = parentRect.Size.EdgeOfEquivaletSquare();

            var x = Geometrics.LinearProportion(discretizedHandle.X, parentRect.Width, edgeSizeOfEquivalentSquare);
            var y = Geometrics.LinearProportion(discretizedHandle.Y, parentRect.Height, edgeSizeOfEquivalentSquare);

            var equivalentDiscretizedHandle = new Point(x, y);

            return GetCursorFromPointsInSquare(edgeSizeOfEquivalentSquare, equivalentDiscretizedHandle);
        }
Example #27
0
        void mouseListner_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                var el = sender as System.Windows.UIElement;
                isDraggable = true;
                lastMouseDownPoint = e.GetPosition(el);
                //高速で動かしたときでも追従させる
                el.CaptureMouse();

            }
        }
Example #28
0
 public override void Recalculate()
 {
     if (XExpression == null
         || XExpression.Value == null
         || YExpression == null
         || YExpression.Value == null)
     {
         return;
     }
     Coordinates = new System.Windows.Point(XExpression.Value(), YExpression.Value());
     Exists = Coordinates.Exists();
 }
        public static Cursor GetCursorFromPointsInSquare(double sideSize, Point end)
        {
            var halfSide = sideSize / 2;

            var center = new Point(halfSide, halfSide);

            var deg = Geometrics.GetDegress(center.ActLike<IPoint>(), end.ActLike<IPoint>());

            var segment = GetHotSpotSegment(deg);

            return CursorFromSegment(segment);
        }
Example #30
0
 public AgentBase(int id, Scenario scenario, int group, int speed)
 {
     this._id = id;
     this.scenario = scenario;
     this._group = group;
     this._maxspeed = speed;
     this.WayPointsList = new List<WayPoint>();
     SpeedRatio = 1.0;
     cell = new Point(-1, -1);
     position = new System.Windows.Point(-1, -1);
     lifeThread = new Thread(Life);
 }
 public static POINT FromPoint(System.Windows.Point pt)
 {
     return(new POINT {
         X = (int)pt.X, Y = (int)pt.Y
     });
 }
Example #32
0
 public Line(System.Windows.Point pointOne, System.Windows.Point pointTwo)
 {
     this.PointOne = pointOne;
     this.PointTwo = pointTwo;
 }
Example #33
0
 public static Point RotateRadians(this Point v, double radians)
 {
     var ca = Math.Cos(radians);
     var sa = Math.Sin(radians);
     return new Point((float)(ca * v.X - sa * v.Y), (float)(sa * v.X + ca * v.Y));
 }
Example #34
0
 public RoomSection(double x, double y)
 {
     ID       = Guid.NewGuid();
     Location = new System.Windows.Point(x, y);
 }
Example #35
0
 public static Point FlipBoth(this Point p, Point origin)
 {
     return new Point(origin.X - (p.X - origin.X), origin.Y - (p.Y - origin.Y));
 }
Example #36
0
        public System.Windows.Point[] getVecinos(System.Windows.Point punto)
        {
            int i   = 0;
            int ran = 0;

            System.Windows.Point[] aux;

            List <Cell> vecinos = new List <Cell>();//creo una lista para usarlo como auxiliar y retornarlo

            //revisa la celda superior,con respecto a la celda actual dentro de las dimensiones del laberinto
            if ((int)punto.Y - 1 >= 0)
            {
                //si la linea horizontal superior esta derribado
                if (Cells[(int)punto.X, (int)punto.Y].Walls[0] == 0)
                {
                    //agrego en la lista de vecinos la celda derecha con respecto a celdaActual
                    vecinos.Add(Cells[(int)punto.X, (int)punto.Y - 1]);
                }
            }

            //revisa la celda izquierda,dentro de las dimensiones del laberinto
            if ((int)punto.X - 1 >= 0)
            {
                //si la linea vertical izquierda con respecto a la celda actual,esta derribado
                if (Cells[(int)punto.X, (int)punto.Y].Walls[1] == 0)
                {
                    //agrego en la lista de vecinos la celda izquierda con respecto a celdaActual
                    vecinos.Add(Cells[(int)punto.X - 1, (int)punto.Y]);
                }
            }
            //revisa la celda inferior, con respecto a la celda actual dentro de las dimensiones del laberinto
            if ((int)punto.Y + 1 <= kDimension - 1)
            {
                //si la linea inferior horizontal esta derribado
                if (Cells[(int)punto.X, (int)punto.Y].Walls[2] == 0)
                {
                    //agrego en la lista de vecinos la celda derecha con respecto a celdaActual
                    vecinos.Add(Cells[(int)punto.X, (int)punto.Y + 1]);
                }
            }

            //revisa la celda derecha,dentro de las dimensiones del laberinto
            if ((int)punto.X + 1 <= kDimension - 1)
            {
                //si la linea vertical derecha con respecto a la celda actual esta derribado
                if (Cells[(int)punto.X, (int)punto.Y].Walls[3] == 0)
                {
                    //agrego en la lista de vecinos la celda derecha con respecto a celdaActual
                    vecinos.Add(Cells[(int)punto.X + 1, (int)punto.Y]);
                }
            }

            aux = new System.Windows.Point[vecinos.Count];//le paso aux la longitud de la lista
            while (vecinos.Count > 0)
            {
                ran    = Cell.TheRandom.Next(0, vecinos.Count);
                aux[i] = vecinos[ran].punto; //devuelve puntos
                vecinos.RemoveAt(ran);
                i++;                         //i es una variable local
            }
            return(aux);
        }
 public static System.Windows.Point Scale(this System.Windows.Point point, float scale)
 {
     return(new System.Windows.Point((int)(point.X * scale), (int)(point.Y * scale)));
 }
        public void loadrobotconfig(String ipAddr, String host, String NameObj, int port, double CriticalEnergyAt, double GoodEnergyAt, System.Windows.Point initialPos, double initialheadingangle)
        {
            RobotAgent temp = new RobotAgent();

            temp.IpAddress           = ipAddr;
            temp.Hostname            = host;
            temp.NameID              = NameObj;
            temp.Port                = port;
            temp.InitialPostion      = initialPos;
            temp.InitialHeadingAngle = initialheadingangle;
            RegistrationAgent.robotAgentRegisteredList.Add(temp.NameID, temp);
            pif.updateTreeviewRobotConfig(temp.NameID);
        }
        public void loadpath_direct(String Name, String Name_sp, String Name_ep, System.Windows.Point possp, System.Windows.Point posep)
        {
            PathModel ptempPath = new PathModel(pif.content.map, PathModel.PATH_TYPE_DIRECT);

            ptempPath.setName(Name);
            RegistrationAgent.pathRegistrationList.Add(ptempPath);
            HalfPoint    halfpoint_sp = pif.findobjecthalfpoint(Name_sp);
            StationModel pstation_sp  = pif.findobjectstation(Name_sp);

            if (halfpoint_sp != null)
            {
                pif.SetObjectPath_StartPoint(halfpoint_sp);
            }
            else if (pstation_sp != null)
            {
                pif.SetObjectPath_StartPoint(pstation_sp);
            }
            HalfPoint    halfpoint_ep = pif.findobjecthalfpoint(Name_ep);
            StationModel pstation_ep  = pif.findobjectstation(Name_ep);

            if (halfpoint_ep != null)
            {
                pif.SetObjectPath_EndPoint(halfpoint_ep);
            }
            else if (pstation_ep != null)
            {
                pif.SetObjectPath_EndPoint(pstation_ep);
            }


            ptempPath.drawdirectpath(possp, posep);
            ptempPath.ondraw();
            pif.refreshpath();
        }
        protected override void OnToolMouseMove(MapViewMouseEventArgs e)
        {
            if (_selectedRaster == null)
            {
                return;
            }
            // bIsMouseMoveActive is preventing the creation of too many threads  via QueuedTask.Run
            // especially if imagery is via a remote service
            if (bIsMouseMoveActive)
            {
                return;
            }
            bIsMouseMoveActive = true;
            System.Diagnostics.Debug.WriteLine($@"{DateTime.Now} OnToolMouseMove");
            QueuedTask.Run(() =>
            {
                try
                {
                    // create a pixelblock representing a 3x3 window to hold the raster values
                    var pixelBlock = _selectedRaster.CreatePixelBlock(3, 3);

                    // determine the cursor position in mapping coordinates
                    var clientCoords = new System.Windows.Point(e.ClientPoint.X, e.ClientPoint.Y);
                    if (clientCoords == null || ActiveMapView == null)
                    {
                        return;
                    }
                    var mapPointAtCursor = ActiveMapView.ClientToMap(clientCoords);
                    if (mapPointAtCursor == null)
                    {
                        return;
                    }

                    // create a container to hold the pixel values
                    Array pixelArray = new object[pixelBlock.GetWidth(), pixelBlock.GetHeight()];

                    // reproject the raster envelope to match the map spatial reference
                    var rasterEnvelope = GeometryEngine.Instance.Project(_selectedRaster.GetExtent(), mapPointAtCursor.SpatialReference);

                    // if the cursor is within the extent of the raster
                    if (GeometryEngine.Instance.Contains(rasterEnvelope, mapPointAtCursor))
                    {
                        // find the map location expressed in row,column of the raster
                        var pixelLocationAtRaster = _selectedRaster.MapToPixel(mapPointAtCursor.X, mapPointAtCursor.Y);

                        // fill the pixelblock with the pointer location
                        _selectedRaster.Read(pixelLocationAtRaster.Item1, pixelLocationAtRaster.Item2, pixelBlock);

                        if (_bandindex != -1)
                        {
                            // retrieve the actual pixel values from the pixelblock representing the red raster band
                            pixelArray = pixelBlock.GetPixelData(_bandindex, false);
                        }
                    }
                    else
                    {
                        // fill the container with 0s
                        Array.Clear(pixelArray, 0, pixelArray.Length);
                    }

                    // pass the pass the raster values to the view model
                    RasterValuesPaneViewModel.Current.RasterValues = ConvertArray(pixelArray);
                }
                finally
                {
                    bIsMouseMoveActive = false;
                }
            });
        }
Example #41
0
        public void TestMethod2()
        {
            var p = new System.Windows.Point(10, 10);

            Assert.IsTrue(true);
        }
Example #42
0
        /// <summary>
        /// Returns an open bezier curve pathgeometry with 4 points
        /// </summary>
        /// <param name="P1"></param>
        /// <param name="P2"></param>
        /// <param name="P3"></param>
        /// <param name="P4"></param>
        /// <returns></returns>
        public static PathGeometry MakeBezierGeometry(System.Windows.Point P1, System.Windows.Point P2, System.Windows.Point P3, System.Windows.Point P4)
        {
            BezierSegment myBezier     = new BezierSegment(P2, P3, P4, true);
            PathFigure    myPathFigure = new PathFigure();

            myPathFigure.StartPoint = P1;
            myPathFigure.Segments.Add(myBezier);
            PathGeometry myPathGeometry = new PathGeometry();

            myPathGeometry.Figures.Add(myPathFigure);
            return(myPathGeometry);
        }
Example #43
0
        // wpp書き込み
        public static string WppWrite(string _filePath, List <Project> _projectList)
        {
            try
            {
                if (_projectList.Count > 0)
                {
                    var _xml  = new XDocument();
                    var _root = new XElement(ConstantsWPP.root, "");

                    _root.Add(new XElement(ConstantsWPP.map, ""));
                    _root.Add(new XElement(ConstantsWPP.LatOrigin, _projectList[0].MissionData.Latitude));
                    _root.Add(new XElement(ConstantsWPP.LonOrigin, _projectList[0].MissionData.Longitude));

                    int j = 0;
                    foreach (var _project in _projectList)
                    {
                        var _mission = new XElement(ConstantsWPP.mission, "");
                        _mission.Add(new XElement(ConstantsWPP.ID, ""));

                        PointLatLng          _p1 = new PointLatLng(_projectList[0].MissionData.Latitude, _projectList[0].MissionData.Longitude);
                        PointLatLng          _p2 = new PointLatLng(_project.MissionData.Latitude, _project.MissionData.Longitude);
                        System.Windows.Point _p  = MeterPerLatLng(_p1, _p2);
                        _mission.Add(new XElement(ConstantsWPP.NS_Transition, _p.X));
                        _mission.Add(new XElement(ConstantsWPP.EW_Transition, _p.Y));
                        _mission.Add(new XElement(ConstantsWPP.V_Transition, 0));
                        _mission.Add(new XElement(ConstantsWPP.ScaleX, _project.MissionData.ScaleX));
                        _mission.Add(new XElement(ConstantsWPP.ScaleY, _project.MissionData.ScaleY));
                        _mission.Add(new XElement(ConstantsWPP.ScaleZ, _project.MissionData.ScaleZ));
                        _mission.Add(new XElement(ConstantsWPP.Rotation, _project.MissionData.Rotation * Math.PI / 180));
                        // Waypoint
                        int i = 0;
                        foreach (var _waypointData in _project.WaypointData)
                        {
                            var _waypoint = new XElement(ConstantsWPP.waypoint, "");
                            _waypoint.Add(new XElement(ConstantsWPP.ID, _waypointData.ID));
                            _waypoint.Add(new XElement(ConstantsWPP.x, _waypointData.x));
                            _waypoint.Add(new XElement(ConstantsWPP.y, _waypointData.y));
                            _waypoint.Add(new XElement(ConstantsWPP.height, _waypointData.Height));
                            _waypoint.Add(new XElement(ConstantsWPP.psi, (_waypointData.Heading * Math.PI / 180)));                             //  rad->deg 変換));
                            //_waypoint.Add(new XElement(ConstantsWPP.speed, _waypointData));
                            _waypoint.Add(new XElement(ConstantsWPP.accuracy, _waypointData.ThreasholdH));
                            _waypoint.Add(new XElement(ConstantsWPP.wait, _waypointData.Wait));
                            _waypoint.Add(new XElement(ConstantsWPP.func_id, _waypointData.Function));

                            //_waypoint.Add(new XElement(ConstantsWPP.speed, _project.PathData[i].Speed));
                            _waypoint.Add(new XElement(ConstantsWPP.speed, _waypointData.Speed));

                            _mission.Add(_waypoint);
                            i++;
                        }
                        _root.Add(_mission);
                        j++;
                    }
                    _xml.Add(_root);
                    _xml.Save(_filePath);

                    return(_xml.ToString());
                }

                return("");
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("(401) MultiWaypoint FileOpen Error: " + ex.Message);
                return("");
            }
        }
Example #44
0
        /// <summary>
        /// Render plot view region of line chart component.
        /// </summary>
        /// <param name="dc">Platform no-associated drawing context.</param>
        protected override void OnPaint(DrawingContext dc)
        {
            var axisChart = base.Chart as AxisChart;

            if (axisChart == null)
            {
                return;
            }

            var ds = Chart.DataSource;

            var g          = dc.Graphics;
            var clientRect = this.ClientBounds;


#if WINFORM
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style     = axisChart.DataSerialStyles[r];
                var lastPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Drawing.PointF point;

                    if (pt.hasValue)
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Drawing.PointF(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    path.AddLine(lastPoint, point);
                    lastPoint = point;
                }

                var endPoint = new System.Drawing.PointF(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);

                if (lastPoint != endPoint)
                {
                    path.AddLine(lastPoint, endPoint);
                }

                path.CloseFigure();

                g.FillPath(style.FillColor, path);

                path.Reset();
            }

            path.Dispose();
#elif WPF
            for (int r = 0; r < ds.SerialCount; r++)
            {
                var style = axisChart.DataSerialStyles[r];

                var seg = new System.Windows.Media.PathFigure();

                seg.StartPoint = new System.Windows.Point(axisChart.PlotColumnPoints[0], axisChart.ZeroHeight);

                for (int c = 0; c < ds.CategoryCount; c++)
                {
                    var pt = axisChart.PlotDataPoints[r][c];

                    System.Windows.Point point;

                    if (pt.hasValue)
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight - pt.value);
                    }
                    else
                    {
                        point = new System.Windows.Point(axisChart.PlotColumnPoints[c], axisChart.ZeroHeight);
                    }

                    seg.Segments.Add(new System.Windows.Media.LineSegment(point, true));
                }

                var endPoint = new System.Windows.Point(axisChart.PlotColumnPoints[ds.CategoryCount - 1], axisChart.ZeroHeight);
                seg.Segments.Add(new System.Windows.Media.LineSegment(endPoint, true));

                seg.IsClosed = true;

                var path = new System.Windows.Media.PathGeometry();
                path.Figures.Add(seg);
                g.FillPath(style.LineColor, path);
            }
#endif // WPF
        }
Example #45
0
 public static Point Into(this WpfPoint point) =>
 new Point((float)point.X, (float)point.Y);
        private static bool DispatchLivePreviewBitmapMessage(ref System.Windows.Forms.Message m, TaskbarWindow taskbarWindow)
        {
            if (m.Msg == (int)TaskbarNativeMethods.WmDwmSendIconicLivePreviewBitmap)
            {
                // Try to get the width/height
                int width  = (int)(((long)m.LParam) >> 16);
                int height = (int)(((long)m.LParam) & (0xFFFF));

                // Default size for the thumbnail
                Size realWindowSize = new Size(200, 200);

                if (taskbarWindow.TabbedThumbnail.WindowHandle != IntPtr.Zero)
                {
                    TabbedThumbnailNativeMethods.GetClientSize(taskbarWindow.TabbedThumbnail.WindowHandle, out realWindowSize);
                }
                else if (taskbarWindow.TabbedThumbnail.WindowsControl != null)
                {
                    realWindowSize = new Size(
                        Convert.ToInt32(taskbarWindow.TabbedThumbnail.WindowsControl.RenderSize.Width),
                        Convert.ToInt32(taskbarWindow.TabbedThumbnail.WindowsControl.RenderSize.Height));
                }

                // If we don't have a valid height/width, use the original window's size
                if (width <= 0)
                {
                    width = realWindowSize.Width;
                }
                if (height <= 0)
                {
                    height = realWindowSize.Height;
                }

                // Fire an event to let the user update their bitmap
                // Raise the event
                taskbarWindow.TabbedThumbnail.OnTabbedThumbnailBitmapRequested(false, new Size(width, height));

                // capture the bitmap for the given control
                // If the user has already specified us a bitmap to use, use that.
                IntPtr hBitmap = taskbarWindow.TabbedThumbnail.CurrentHBitmap == IntPtr.Zero ? GrabBitmap(taskbarWindow, realWindowSize) : taskbarWindow.TabbedThumbnail.CurrentHBitmap;

                // If we have a valid parent window handle,
                // calculate the offset so we can place the "peek" bitmap
                // correctly on the app window
                if (taskbarWindow.TabbedThumbnail.ParentWindowHandle != IntPtr.Zero && taskbarWindow.TabbedThumbnail.WindowHandle != IntPtr.Zero)
                {
                    System.Drawing.Point offset = new System.Drawing.Point();

                    // if we don't have a offset specified already by the user...
                    if (!taskbarWindow.TabbedThumbnail.PeekOffset.HasValue)
                    {
                        offset = WindowUtilities.GetParentOffsetOfChild(taskbarWindow.TabbedThumbnail.WindowHandle, taskbarWindow.TabbedThumbnail.ParentWindowHandle);
                    }
                    else
                    {
                        offset = new System.Drawing.Point(Convert.ToInt32(taskbarWindow.TabbedThumbnail.PeekOffset.Value.X),
                                                          Convert.ToInt32(taskbarWindow.TabbedThumbnail.PeekOffset.Value.Y));
                    }

                    // Only set the peek bitmap if it's not null.
                    // If it's null (either we didn't get the bitmap or size was 0),
                    // let DWM handle it
                    if (hBitmap != IntPtr.Zero)
                    {
                        if (offset.X >= 0 && offset.Y >= 0)
                        {
                            TabbedThumbnailNativeMethods.SetPeekBitmap(
                                taskbarWindow.WindowToTellTaskbarAbout,
                                hBitmap, offset,
                                taskbarWindow.TabbedThumbnail.DisplayFrameAroundBitmap);
                        }
                    }

                    // If the bitmap we have is not coming from the user (i.e. we created it here),
                    // then make sure we delete it as we don't need it now.
                    if (taskbarWindow.TabbedThumbnail.CurrentHBitmap == IntPtr.Zero)
                    {
                        ShellNativeMethods.DeleteObject(hBitmap);
                    }

                    return(true);
                }
                // Else, we don't have a valid window handle from the user. This is mostly likely because
                // we have a WPF UIElement control. If that's the case, use a different screen capture method
                // and also couple of ways to try to calculate the control's offset w.r.t it's parent.
                else if (taskbarWindow.TabbedThumbnail.ParentWindowHandle != IntPtr.Zero &&
                         taskbarWindow.TabbedThumbnail.WindowsControl != null)
                {
                    System.Windows.Point offset;

                    if (!taskbarWindow.TabbedThumbnail.PeekOffset.HasValue)
                    {
                        // Calculate the offset for a WPF UIElement control
                        // For hidden controls, we can't seem to perform the transform.
                        GeneralTransform objGeneralTransform = taskbarWindow.TabbedThumbnail.WindowsControl.TransformToVisual(taskbarWindow.TabbedThumbnail.WindowsControlParentWindow);
                        offset = objGeneralTransform.Transform(new System.Windows.Point(0, 0));
                    }
                    else
                    {
                        offset = new System.Windows.Point(taskbarWindow.TabbedThumbnail.PeekOffset.Value.X, taskbarWindow.TabbedThumbnail.PeekOffset.Value.Y);
                    }

                    // Only set the peek bitmap if it's not null.
                    // If it's null (either we didn't get the bitmap or size was 0),
                    // let DWM handle it
                    if (hBitmap != IntPtr.Zero)
                    {
                        if (offset.X >= 0 && offset.Y >= 0)
                        {
                            TabbedThumbnailNativeMethods.SetPeekBitmap(
                                taskbarWindow.WindowToTellTaskbarAbout,
                                hBitmap, new System.Drawing.Point((int)offset.X, (int)offset.Y),
                                taskbarWindow.TabbedThumbnail.DisplayFrameAroundBitmap);
                        }
                        else
                        {
                            TabbedThumbnailNativeMethods.SetPeekBitmap(
                                taskbarWindow.WindowToTellTaskbarAbout,
                                hBitmap,
                                taskbarWindow.TabbedThumbnail.DisplayFrameAroundBitmap);
                        }
                    }

                    // If the bitmap we have is not coming from the user (i.e. we created it here),
                    // then make sure we delete it as we don't need it now.
                    if (taskbarWindow.TabbedThumbnail.CurrentHBitmap == IntPtr.Zero)
                    {
                        ShellNativeMethods.DeleteObject(hBitmap);
                    }

                    return(true);
                }
                else
                {
                    // Else (no parent specified), just set the bitmap. It would take over the entire
                    // application window (would work only if you are a MDI app)

                    // Only set the peek bitmap if it's not null.
                    // If it's null (either we didn't get the bitmap or size was 0),
                    // let DWM handle it
                    if (hBitmap != null)
                    {
                        TabbedThumbnailNativeMethods.SetPeekBitmap(taskbarWindow.WindowToTellTaskbarAbout, hBitmap, taskbarWindow.TabbedThumbnail.DisplayFrameAroundBitmap);
                    }

                    // If the bitmap we have is not coming from the user (i.e. we created it here),
                    // then make sure we delete it as we don't need it now.
                    if (taskbarWindow.TabbedThumbnail.CurrentHBitmap == IntPtr.Zero)
                    {
                        ShellNativeMethods.DeleteObject(hBitmap);
                    }

                    return(true);
                }
            }
            return(false);
        }
Example #47
0
 public RoomSection(System.Windows.Point location)
 {
     ID       = Guid.NewGuid();
     Location = location;
 }
Example #48
0
 public static extern IntPtr WindowFromPoint(System.Windows.Point point);
Example #49
0
 public static Point FlipY(this Point p, Point origin)
 {
     return new Point(p.X, origin.Y - (p.Y - origin.Y));
 }
Example #50
0
        public override void OnRender(DrawingContext dc, System.Windows.Size renderSize)
        {
            DateTime now = Now;

            if (now > nextTradingDayBegin)
            {
                tradingDayBegin     = sessionIterator.GetTradingDayBeginLocal(sessionIterator.ActualTradingDayExchange);
                tradingDayEnd       = sessionIterator.ActualTradingDayEndLocal;
                nextTradingDayBegin = Core.Globals.MaxDate;
            }
            else if (sessionIterator.IsNewSession(now, false))
            {
                sessionIterator.GetNextSession(now, false);
                if (sessionIterator.IsInSession(now, false, true))
                {
                    tradingDayBegin = sessionIterator.GetTradingDayBeginLocal(sessionIterator.ActualTradingDayExchange);
                    tradingDayEnd   = sessionIterator.ActualTradingDayEndLocal;
                }
                else
                {
                    nextTradingDayBegin = sessionIterator.GetTradingDayBeginLocal(sessionIterator.ActualTradingDayExchange);
                }
            }

            if (downAreaBrush == null)
            {
                downAreaBrush = new SolidColorBrush()
                {
                    Color = (downArea as SolidColorBrush).Color, Opacity = (double)Opacity / 100
                }
            }
            ;
            if (upAreaBrush == null)
            {
                upAreaBrush = new SolidColorBrush()
                {
                    Color = (upArea as SolidColorBrush).Color, Opacity = (double)Opacity / 100
                }
            }
            ;
            if (downOutlinePen == null)
            {
                downOutlinePen = new Pen(downOutline, 1);
            }
            if (upOutlinePen == null)
            {
                upOutlinePen = new Pen(upOutline, 1);
            }

            int  firstIdx    = Math.Max(0, BarsArray[0].GetBar(tradingDayBegin));
            bool isInSession = now >= tradingDayBegin && now < tradingDayEnd;
            List <LineSegment> lineSegmentsDown = new List <LineSegment>();
            List <LineSegment> lineSegmentsUp   = new List <LineSegment>();
            int    margin      = 1;
            double maxCloseOnX = double.MinValue;
            double minCloseOnX = double.MinValue;
            double maxPrice    = double.MinValue;
            int    maxX        = -1;
            double minPrice    = double.MaxValue;
            int    minX        = margin;
            int    netHeight   = (int)Math.Floor(renderSize.Height) - margin;
            int    netWidth    = (int)Math.Floor(renderSize.Width) - 2 * margin;
            int    prevX       = -1;
            int    prevY       = -1;

            System.Windows.Point startPoint = new System.Windows.Point();
            int    yPreviousClose           = -1;
            double previousClose            = !isInSession && firstIdx > 0 ? BarsArray[0].GetClose(firstIdx - 1) : lastClose;

            BarsArray[0].BarsSeries.SyncRoot.EnterReadLock();
            try
            {
                minPrice = Math.Min(previousClose, minPrice);
                maxPrice = Math.Max(previousClose, maxPrice);

                for (int idx = firstIdx; idx < BarsArray[0].Count; idx++)
                {
                    double close = BarsArray[0].GetClose(idx);
                    minPrice = Math.Min(close, minPrice);
                    maxPrice = Math.Max(close, maxPrice);
                }

                if (minPrice == double.MaxValue || maxPrice == double.MinValue || previousClose == double.MinValue)
                {
                    return;
                }

                for (int idx = firstIdx; idx < BarsArray[0].Count; idx++)
                {
                    DateTime time = BarsArray[0].GetTime(idx);
                    if (time > tradingDayEnd)
                    {
                        break;
                    }

                    double close = BarsArray[0].GetClose(idx);
                    int    x     = margin + Convert.ToInt32(netWidth * time.Subtract(tradingDayBegin).TotalSeconds / Math.Max(1, tradingDayEnd.Subtract(tradingDayBegin).TotalSeconds));
                    maxCloseOnX = x == prevX?Math.Max(close, maxCloseOnX) : close;

                    minCloseOnX = x == prevX?Math.Min(close, minCloseOnX) : close;

                    double closeOnX = minCloseOnX.ApproxCompare(minPrice) == 0              ? minCloseOnX
                                                                                                : maxCloseOnX.ApproxCompare(maxPrice) == 0      ? maxCloseOnX
                                                                                                : close.ApproxCompare(previousClose) > 0        ? maxCloseOnX : minCloseOnX;
                    int y = margin + Convert.ToInt32(((maxPrice - closeOnX) / Math.Max(BarsArray[0].Instrument.MasterInstrument.TickSize, maxPrice - minPrice)) * (netHeight - margin));

                    if (idx == firstIdx)
                    {
                        yPreviousClose = margin + Convert.ToInt32(((maxPrice - previousClose) / Math.Max(BarsArray[0].Instrument.MasterInstrument.TickSize, maxPrice - minPrice)) * (netHeight - margin));;
                        startPoint     = new System.Windows.Point(x, yPreviousClose);
                    }
                    if (idx == BarsArray[0].Count - 1)
                    {
                        maxX = x;
                    }

                    bool isCrossover = prevY <yPreviousClose && y> yPreviousClose || prevY > yPreviousClose && y < yPreviousClose;
                    if (x == prevX)
                    {
                        lineSegmentsUp[lineSegmentsUp.Count - 1]   = new LineSegment(new System.Windows.Point(x, Math.Min(y, yPreviousClose)), isCrossover ? true : y <= yPreviousClose);
                        lineSegmentsDown[lineSegmentsUp.Count - 1] = new LineSegment(new System.Windows.Point(x, Math.Max(y, yPreviousClose)), isCrossover ? true : y > yPreviousClose);
                    }
                    else
                    {
                        lineSegmentsUp.Add(new LineSegment(new System.Windows.Point(x, Math.Min(y, yPreviousClose)), isCrossover ? true : y <= yPreviousClose));
                        lineSegmentsDown.Add(new LineSegment(new System.Windows.Point(x, Math.Max(y, yPreviousClose)), isCrossover ? true : y > yPreviousClose));
                    }

                    prevX = x;
                    prevY = y;
                }
            }
            finally
            {
                BarsArray[0].BarsSeries.SyncRoot.ExitReadLock();
            }

            if (lineSegmentsUp.Count > 0)
            {
                List <PathFigure> pathFiguresOutlineUp = new List <PathFigure>();
                pathFiguresOutlineUp.Add(new PathFigure(startPoint, lineSegmentsUp.ToArray(), false));
                dc.DrawGeometry(null, upOutlinePen, new PathGeometry(pathFiguresOutlineUp));

                lineSegmentsUp.Add(new LineSegment(new System.Windows.Point(maxX, yPreviousClose), true));
                lineSegmentsUp.Add(new LineSegment(new System.Windows.Point(minX, yPreviousClose), true));

                List <PathFigure> pathFiguresFillUp = new List <PathFigure>();
                pathFiguresFillUp.Add(new PathFigure(startPoint, lineSegmentsUp.ToArray(), true));
                PathGeometry pgFillUp = new PathGeometry(pathFiguresFillUp);
                dc.DrawGeometry(upAreaBrush, null, pgFillUp);

                List <PathFigure> pathFiguresOutlineDown = new List <PathFigure>();
                pathFiguresOutlineDown.Add(new PathFigure(startPoint, lineSegmentsDown.ToArray(), false));
                dc.DrawGeometry(null, downOutlinePen, new PathGeometry(pathFiguresOutlineDown));

                lineSegmentsDown.Add(new LineSegment(new System.Windows.Point(maxX, yPreviousClose), true));
                lineSegmentsDown.Add(new LineSegment(new System.Windows.Point(minX, yPreviousClose), true));

                List <PathFigure> pathFiguresFillDown = new List <PathFigure>();
                pathFiguresFillDown.Add(new PathFigure(startPoint, lineSegmentsDown.ToArray(), true));
                PathGeometry pgFillDown = new PathGeometry(pathFiguresFillDown);
                dc.DrawGeometry(downAreaBrush, null, pgFillDown);
            }
        }
Example #51
0
 public static Point FlipX(this Point p, Point origin)
 {
     return new Point(origin.X - (p.X - origin.X),p.Y);
 }
 /// <summary>
 /// Convert WPF point to drawing point
 /// </summary>
 /// <param name="p">WPF point</param>
 /// <returns>Drawing Point</returns>
 public static System.Drawing.PointF ToDrawingPointF(this System.Windows.Point p)
 {
     return(new System.Drawing.PointF((float)p.X, (float)p.Y));
 }
Example #53
0
 public void MouseDoun(object sender, MouseButtonEventArgs e)
 {
     CorectPoint = e.GetPosition(null);
 }
 public System.Drawing.Point PointToClient(System.Drawing.Point point)
 {
     System.Windows.Point sourcePoint      = new System.Windows.Point(point.X, point.Y);
     System.Windows.Point destinationPoint = _window.PointFromScreen(sourcePoint);
     return(new System.Drawing.Point((int)(0.5 + destinationPoint.X), (int)(0.5 + destinationPoint.Y)));
 }
Example #55
0
        public void PopulateAvailableColumns(List <Collumns> AvailableCols, ShellView ShellView, System.Windows.Point Location)
        {
            BrowserControl = ShellView;
            for (int i = 1; i < AvailableCols.Count; i++)
            {
                if (!String.IsNullOrEmpty(AvailableCols[i].Name))
                {
                    ListViewItem lvi = new ListViewItem(AvailableCols[i].Name);
                    lvi.Tag = AvailableCols[i];
                    if (AvailableCols[i].IsColumnHandler)
                    {
                        lvi.ForeColor = Color.Red;
                    }
                    foreach (Collumns collumn in ShellView.Collumns)
                    {
                        if (collumn.pkey.fmtid == AvailableCols[i].pkey.fmtid && collumn.pkey.pid == AvailableCols[i].pkey.pid)
                        {
                            lvi.Checked = true;
                        }
                    }

                    lvColumns.Items.Add(lvi);
                }
            }
            Opacity = 0;
            if (lvColumns.Items.Count > 0)
            {
                Show(ShellView);
            }
            this.Location = new Point((int)Location.X, (int)Location.Y);
            //this.lvColumns.Sort(); //'this didn't do anything... lol.
            this.lvColumns.Sorting = SortOrder.Ascending;
            Opacity = 255;
        }
 public System.Windows.Point PointToScreen(System.Windows.Point point)
 {
     return(default(System.Windows.Point));
 }
Example #57
0
 public static double getAngle(System.Windows.Point a, System.Windows.Point b, double offset, int dir)
 {
     return(monitorAngle(getAlpha(a, b) + offset, dir));
 }
Example #58
0
        public async void SelectByRectangle()
        {
            try
            {
                FeatureLayer featureLayer = (FeatureLayer)this.mapView.Map.Layers[1];

                featureLayer.ClearSelection();

                // Get the Editor associated with the MapView. The Editor enables drawing and editing graphic objects.
                Esri.ArcGISRuntime.Controls.Editor myEditor = this.mapView.Editor;

                // Get the Envelope that the user draws on the Map. Execution of the code stops here until the user is done drawing the rectangle.
                Geometry geometry = await myEditor.RequestShapeAsync(DrawShape.Rectangle);

                Envelope envelope = geometry.Extent;     // The Extent of the returned geometry should be exactly the same shape as the DrawShape.Rectangle.

                if (envelope != null)
                {
                    // Get the lower-left MapPoint (real world coordinates) from the Envelope the user drew on the Map and then translate it into
                    // a Microsoft Point object.
                    MapPoint             mapPoint1     = new MapPoint(envelope.Extent.XMin, envelope.YMin);
                    System.Windows.Point windowsPoint1 = this.mapView.LocationToScreen(mapPoint1);

                    // Get the upper-right MapPoint (real world coordinates) from the Envelope the user drew on the Map and then translate it into
                    // a Microsoft Point object.
                    MapPoint             mapPoint2     = new MapPoint(envelope.Extent.XMax, envelope.YMax);
                    System.Windows.Point windowsPoint2 = this.mapView.LocationToScreen(mapPoint2);

                    // Create a Windows Rectangle from the Windows Point objects.
                    System.Windows.Rect windowsRect = new System.Windows.Rect(windowsPoint1, windowsPoint2);

                    // Get the FeatureTable from the FeatureLayer.
                    FeatureTable featureTable = featureLayer.FeatureTable;

                    // Get the number of records in the FeatureTable.
                    long count = featureTable.RowCount;

                    // Use the FeatureLayer.HitTestAsync Method to retrieve the FeatureLayer IDs that are within or cross the envelope that was
                    // drawn on the Map by the user. It is important to note that by passing in the variable myRowCount (which is the maximum
                    // number of features in the FeatureLayer), you are able to select up to the number of features in the FeatureLayer. If
                    // you were to leave off this optional last parameter then the HitTestAsync would only return one record!
                    featureLayerRowIDs = await featureLayer.HitTestAsync(this.mapView, windowsRect, System.Convert.ToInt32(count));

                    if (featureLayerRowIDs.Length > 0)
                    {
                        // We have at least one record in the FeatureLayer selected.

                        // Cause the features in the FeatureLayer to highlight (cyan) in the Map.
                        featureLayer.SelectFeatures(featureLayerRowIDs);
                    }
                }
            }
            catch (System.Threading.Tasks.TaskCanceledException)
            {
                // This exception occurred because the user has already clicked the button but has not drawn a rectangle on the Map yet.
                Messenger.Default.Send <NotificationMessage>(new NotificationMessage("Drag a rectangle across the map to select some features."));
            }
            catch (System.Exception ex)
            {
                // We had some kind of issue. Display to the user so it can be corrected.
                Messenger.Default.Send <NotificationMessage>(new NotificationMessage(ex.Message));
            }
        }
Example #59
0
 public static Point ToPoint(this UIPoint point)
 {
     return(new Point(point.X, point.Y, 0.0));
 }
Example #60
0
 public static Point2d ToPoint2d(this System.Windows.Point point)
 {
     return(new Point2d(point.X, point.Y));
 }