Ejemplo n.º 1
1
 internal StylusAsyncPlugin(IStylusReaderHooks subject, Control attached)
 {
     Graphics g = subject.CreateGraphics();
     attachedControl = attached;
     this.ratio = new PointF(g.DpiX / 2540.0f, g.DpiY / 2540.0f);
     this.subject = subject;
 }
Ejemplo n.º 2
1
        public unsafe Point GetNextPoint(Rectangle rectTrack, byte* pIn, Size sizeIn, double[] Qu, double[] PuY0)
        {
            double[] w = new double[256];//方向权值
            for (int i = 0; i < 256; i++)
            {
                w[i] = Math.Sqrt(Qu[i] / PuY0[i]);
            }

            PointF center = new PointF(
                (float)rectTrack.Left + (float)rectTrack.Width / 2,
                (float)rectTrack.Top + (float)rectTrack.Height / 2);
            SizeF H = new SizeF((float)rectTrack.Width / 2, (float)rectTrack.Height / 2);
            double numeratorX = 0, numeratorY = 0;//分子
            double denominatorX = 0, denominatorY = 0;//分母
            for (int y = rectTrack.Top; y < rectTrack.Bottom; y++)
            {
                for (int x = rectTrack.Left; x < rectTrack.Right; x++)
                {
                    int index = DataManager.GetIndex(x, y, sizeIn.Width);
                    byte u = pIn[index];
                    //计算以高斯分布为核函数自变量X的值
                    double X = ((Math.Pow((x - center.X), 2) + Math.Pow((y - center.Y), 2))
                            / (Math.Pow(H.Width, 2) + Math.Pow(H.Height, 2)));
                    //负的高斯分布核函数的值
                    double Gi = -Math.Exp(-Math.Pow(X, 2) / 2) / Math.Sqrt(2 * Math.PI);

                    numeratorX += x * w[u] * Gi;
                    numeratorY += y * w[u] * Gi;
                    denominatorX += w[u] * Gi;
                    denominatorY += w[u] * Gi;
                }
            }
            return new Point((int)(numeratorX / denominatorX), (int)(numeratorY / denominatorY));
        }
 public int Enumerate(ref PointF[] points, ref byte[] types)
 {
     if (points.Length != types.Length)
     {
         throw SafeNativeMethods.Gdip.StatusException(2);
     }
     int resultCount = 0;
     int num2 = Marshal.SizeOf(typeof(GPPOINTF));
     int length = points.Length;
     byte[] buffer = new byte[length];
     IntPtr memoryPts = Marshal.AllocHGlobal((int) (length * num2));
     try
     {
         int status = SafeNativeMethods.Gdip.GdipPathIterEnumerate(new HandleRef(this, this.nativeIter), out resultCount, memoryPts, buffer, length);
         if (status != 0)
         {
             throw SafeNativeMethods.Gdip.StatusException(status);
         }
         if (resultCount < length)
         {
             SafeNativeMethods.ZeroMemory((IntPtr) (((long) memoryPts) + (resultCount * num2)), (UIntPtr) ((length - resultCount) * num2));
         }
         points = SafeNativeMethods.Gdip.ConvertGPPOINTFArrayF(memoryPts, length);
         buffer.CopyTo(types, 0);
     }
     finally
     {
         Marshal.FreeHGlobal(memoryPts);
     }
     return resultCount;
 }
        public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
        {
            base.DidRotate (fromInterfaceOrientation);

            scrollView.Frame = new RectangleF(0,0,baseView.Bounds.Width,baseView.Bounds.Height-36);
            pageControl.Frame = new RectangleF(0,baseView.Bounds.Height-36,baseView.Bounds.Width,36);

            int count = pageControl.Pages;

            RectangleF scrollFrame = scrollView.Frame;
            scrollFrame.Width = scrollFrame.Width * count;
            scrollView.ContentSize = scrollFrame.Size;

            for (int i=0; i<count; i++)
            {
                RectangleF frame = scrollView.Frame;
                PointF location = new PointF();
                location.X = frame.Width * i;

                frame.Location = location;

                scrollView.Subviews[i].Frame = frame;

            }

            float pageOffset = scrollView.Frame.Width*pageControl.CurrentPage;

            PointF p = new PointF(pageOffset, 0);
            scrollView.SetContentOffset(p,true);
        }
Ejemplo n.º 5
0
		private static void TestCalibration(string pixelShape, bool uncalibrated, PointF pt1, PointF pt2, double calibrationValue, double expectedRowSpacing, double expectedColSpacing)
		{
			using (IPresentationImage image = ProtractorRoiTests.GetCalibrationTestImage(pixelShape, uncalibrated))
			{
				Trace.WriteLine(string.Format("TEST {0} image with {1} pixels", uncalibrated ? "uncalibrated" : "calibrated", pixelShape));
				Trace.WriteLine(string.Format("calibrating [{0}, {1}] to {2} mm", pt1, pt2, calibrationValue));

				PolylineGraphic lineGraphic;
				IOverlayGraphicsProvider overlayGraphicsProvider = (IOverlayGraphicsProvider) image;
				overlayGraphicsProvider.OverlayGraphics.Add(new VerticesControlGraphic(lineGraphic = new PolylineGraphic()));
				lineGraphic.CoordinateSystem = CoordinateSystem.Source;
				lineGraphic.Points.Add(pt1);
				lineGraphic.Points.Add(pt2);
				lineGraphic.ResetCoordinateSystem();

				CalibrationTool.TestCalibration(calibrationValue, lineGraphic);

				IImageSopProvider imageSopProvider = (IImageSopProvider) image;

				Trace.WriteLine(string.Format("Pixel Spacing (Actual)/(Expected): ({0:F4}:{1:F4})/({2:F4}:{3:F4})",
					imageSopProvider.Frame.NormalizedPixelSpacing.Row, imageSopProvider.Frame.NormalizedPixelSpacing.Column,
					expectedRowSpacing, expectedColSpacing));

				float percentErrorRow = Math.Abs((float)((imageSopProvider.Frame.NormalizedPixelSpacing.Row - expectedRowSpacing) / expectedRowSpacing * 100F));
				float percentErrorCol = Math.Abs((float)((imageSopProvider.Frame.NormalizedPixelSpacing.Column - expectedColSpacing) / expectedColSpacing * 100F));
				
				Trace.WriteLine(String.Format("Percent Error (Row/Column): {0:F3}%/{1:F3}%", percentErrorRow, percentErrorCol));

				Assert.AreEqual(expectedColSpacing, imageSopProvider.Frame.NormalizedPixelSpacing.Column, 0.005, "Column Spacing appears to be wrong");
				Assert.AreEqual(expectedRowSpacing, imageSopProvider.Frame.NormalizedPixelSpacing.Row, 0.005, "Row Spacing appears to be wrong");

				Assert.IsTrue(percentErrorCol < 1.5, "Column Spacing appears to be wrong");
				Assert.IsTrue(percentErrorRow < 1.5, "Row Spacing appears to be wrong");
			}
		}
 public void AddString(string s,	FontFamily family,	int style, float emSize, PointF origin, StringFormat format)
 {
     var font = new Font (family.Name, emSize, (FontStyle)style);
     var layoutRect = RectangleF.Empty;
     layoutRect.Location = origin;
     NativeDrawString (s, font, Color.Red, layoutRect, format);
 }
Ejemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            PointF text = new PointF(CMB_coordsystem.Right + 3, 3);

            //Enum.GetValues(typeof(CoordsSystems), CMB_coordsystem.Text);

            if (System == CoordsSystems.GEO.ToString())
            {
                e.Graphics.DrawString(Lat.ToString("0.000000") + " " + Lng.ToString("0.000000") + "   " + Alt.ToString("0.00"), this.Font, new SolidBrush(this.ForeColor), text, StringFormat.GenericDefault);
            }
            else  if (System == CoordsSystems.UTM.ToString())
            {
                UTM utm = (UTM)point;
                //utm.East.ToString("0.00") + " " + utm.North.ToString("0.00")
                e.Graphics.DrawString(utm.ToString() + "   " + Alt.ToString("0.00"), this.Font, new SolidBrush(this.ForeColor), text, StringFormat.GenericDefault);
            }
            else if (System == CoordsSystems.MGRS.ToString())
            {
                MGRS mgrs = (MGRS)point;
                mgrs.Precision = 5;
                e.Graphics.DrawString(mgrs.ToString() + "   " + Alt.ToString("0.00"), this.Font, new SolidBrush(this.ForeColor), text, StringFormat.GenericDefault);
            }
        }
Ejemplo n.º 8
0
 //for building characters from xml file
 public nCharacter(string hexName, float anchorX, float anchorY, float width)
 {
     _Name = hexName;
     _AnchorPoint = new PointF(anchorX, anchorY);
     _Width = width;
     //guessValues(false, true, true, false);
 }
        private void button1_Click(object sender, EventArgs e)
        {
            PointF NWCoord = new PointF();
            NWCoord.X = float.Parse(tbNWLngDeg.Text);
            if(NWCoord.X>0)
                NWCoord.X += float.Parse(tbNWLngMin.Text) / 60.0f;
            else
                NWCoord.X -= float.Parse(tbNWLngMin.Text) / 60.0f;
            NWCoord.Y = float.Parse(tbNWLatDeg.Text);
            if (NWCoord.Y > 0)
                NWCoord.Y += float.Parse(tbNWLatMin.Text) / 60.0f;
            else
                NWCoord.Y -= float.Parse(tbNWLatMin.Text) / 60.0f;

            PointF SECoord = new PointF();
            SECoord.X = float.Parse(tbSELngDeg.Text);
            if(SECoord.X>0)
                SECoord.X += float.Parse(tbSELngMin.Text) / 60.0f;
            else
                SECoord.X -= float.Parse(tbSELngMin.Text) / 60.0f;
            SECoord.Y = float.Parse(tbSELatDeg.Text);
            if(SECoord.Y>0)
                SECoord.Y += float.Parse(tbSELatMin.Text) / 60.0f;
            else
                SECoord.Y -= float.Parse(tbSELatMin.Text) / 60.0f;

            openStreetMapViewer1.TopLeftCoord = NWCoord;
            openStreetMapViewer1.BottomRightCoord = SECoord;
        }
Ejemplo n.º 10
0
 public SvgCubicCurveSegment(PointF start, PointF firstControlPoint, PointF secondControlPoint, PointF end)
 {
     this.Start = start;
     this.End = end;
     this._firstControlPoint = firstControlPoint;
     this._secondControlPoint = secondControlPoint;
 }
Ejemplo n.º 11
0
        void drawRandomTree()
        {
            t=Tree.Generate(gen_type,
                            depth: tree_depth,
                            max_breadth: tree_breadth, // 40,100
                            num_first_children : -1,
                            max_nodes : -1);

            //t.root.Visible=false;

            depthMap=DepthMap.Generate(t.MaxDepth, rand);

            t.Root.Point.X = this.splitContainer1.Panel2.Width / 2;
            t.Root.Point.Y = this.splitContainer1.Panel2.Height / 2;

            radius = new PointF();
            radius.Y = (float)branch_radius;
            radius.X=radius.Y;

#if RADIAL
            t.LayoutRadial2D(radius, edge_length, layout_type, chkGrow.Checked);
#else
            t.LayoutTopDown2D(radius, edge_length, layout_type, chkGrow.Checked);
#endif

            Render();
        }
Ejemplo n.º 12
0
        public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
        {
            int cornerSize			= (int)GraphConstants.CornerSize * 2;
            int connectorSize		= (int)GraphConstants.ConnectorSize;
            int halfConnectorSize	= (int)Math.Ceiling(connectorSize / 2.0f);

            var height				= size.Height;
            var width				= size.Width;
            var halfWidth			= width / 2.0f;
            var halfHeight			= height / 2.0f;
            var connectorOffset		= (int)Math.Floor((GraphConstants.MinimumItemHeight - GraphConstants.ConnectorSize) / 2.0f);
            var left				= location.X;
            var top					= location.Y;
            var right				= location.X + width;
            var bottom				= location.Y + height;

            var path = new GraphicsPath(FillMode.Winding);
            path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
            path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);

            path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
            path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
            path.CloseFigure();
            return path;
        }
Ejemplo n.º 13
0
		internal override void updateModify(PointF current, InteractionState ist)
		{
			base.updateModify(current, ist);

			PointF pt1 = flowChart.InteractionStartPoint;
			PointF pt2 = current;
			PointF ptTLA = new PointF(rcSaved.Left, rcSaved.Top);
			ptTLA.X += pt2.X - pt1.X;
			ptTLA.Y += pt2.Y - pt1.Y;
			ptTLA = flowChart.AlignPointToGrid(ptTLA);
	
			base.modifyDX = ptTLA.X - ptLastTopLeft.X;
			base.modifyDY = ptTLA.Y - ptLastTopLeft.Y;
			ptLastTopLeft = ptTLA;

			if (base.modifyHandle == 8)
			{
				// translate all points of arrows having both their ends selected
				foreach (Arrow arrow in arrowsToMove)
					arrow.translatePoints(base.modifyDX, base.modifyDY);

				// modify selected objects
				foreach (ChartObject obj in selectedItems)
					if (!ignoreItem(obj, ist) && obj.canModify(base.modifyHandle) &&
						!(obj is Arrow && arrowsToMove.Contains(obj)))
							obj.modifyTranslate(base.modifyDX, base.modifyDY, true);
				rect.Offset(base.modifyDX, base.modifyDY);
			}
		}
Ejemplo n.º 14
0
 /// <summary>
 /// Creates a new instance of TextSymbolizer
 /// </summary>
 public LabelSymbolizer()
 {
     Angle = 0;
     UseAngle = false;
     LabelAngleField = null;
     UseLabelAngleField = false;
     BorderVisible = false;
     BorderColor = Color.Black;
     BackColor = Color.AntiqueWhite;
     BackColorEnabled = false;
     DropShadowColor = Color.FromArgb(20, 0, 0, 0);
     DropShadowEnabled = false;
     DropShadowGeographicOffset = new Coordinate(0, 0);
     DropShadowPixelOffset = new PointF(2F, 2F);
     FontSize = 10F;
     FontFamily = "Arial Unicode MS";
     FontStyle = FontStyle.Regular;
     FontColor = Color.Black;
     HaloColor = Color.White;
     HaloEnabled = false;
     ScaleMode = ScaleMode.Symbolic;
     LabelPlacementMethod = LabelPlacementMethod.Centroid;
     PartsLabelingMethod = PartLabelingMethod.LabelLargestPart;
     PreventCollisions = true;
     PriorityField = "FID";
     Orientation = ContentAlignment.MiddleCenter;
 }
Ejemplo n.º 15
0
        public ShipSprite(PointF initialPosition)
            : base(NSBundle.MainBundle.PathForResource ("spaceship", "png"))
        {
            CGPath boundingPath = new CGPath ();
            boundingPath.MoveToPoint (-12f, -38f);
            boundingPath.AddLineToPoint (12f, -38f);
            boundingPath.AddLineToPoint (9f, 18f);
            boundingPath.AddLineToPoint (2f, 38f);
            boundingPath.AddLineToPoint (-2f, 38f);
            boundingPath.AddLineToPoint (-9f, 18f);
            boundingPath.AddLineToPoint (-12f, -38f);
            #if false
            // Debug overlay
            SKShapeNode shipOverlayShape = new SKShapeNode () {
                Path = boundingPath,
                StrokeColor = UIColor.Clear,
                FillColor = UIColor.FromRGBA (0f, 1f, 0f, 0.5f)
            };
            ship.AddChild (shipOverlayShape);
            #endif
            var body = SKPhysicsBody.BodyWithPolygonFromPath (boundingPath);
            body.CategoryBitMask = Category.Ship;
            body.CollisionBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge;
            body.ContactTestBitMask = body.CollisionBitMask;
            body.LinearDamping = 0;
            body.AngularDamping = 0.5f;

            PhysicsBody = body;
            Position = initialPosition;
        }
Ejemplo n.º 16
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Image<Bgr, Byte> frame = capture.QueryFrame();


            if (frame != null)
            {

                // add cross hairs to image
                int totalwidth = frame.Width;
                int totalheight = frame.Height;
                PointF[] linepointshor = new PointF[] { 
                    new PointF(0, totalheight/2),
                    new PointF(totalwidth, totalheight/2)
                  
                };
                PointF[] linepointsver = new PointF[] { 
                    new PointF(totalwidth/2, 0),
                    new PointF(totalwidth/2, totalheight)
                  
                };
                frame.DrawPolyline(Array.ConvertAll<PointF, Point>(linepointshor, Point.Round), false, new Bgr(Color.AntiqueWhite), 1);
                frame.DrawPolyline(Array.ConvertAll<PointF, Point>(linepointsver, Point.Round), false, new Bgr(Color.AntiqueWhite), 1);



                pictureBox1.Image = frame.ToBitmap();
            }
        }
Ejemplo n.º 17
0
 public static PointF Transform(float[, ] matrix, float X, float Y)
 {
     PointF result = new PointF();
     result.X = (X * matrix[0, 0]) + (Y * matrix[0, 1]) + (matrix[0, 2]);
     result.Y = (X * matrix[1, 0]) + (Y * matrix[1, 1]) + (matrix[1, 2]);
     return result;
 }
Ejemplo n.º 18
0
		public static void RenderGlyphToContext (CGContext context, PointF position, Glyph g, Fnt font, byte[] palette, int offset)
		{
			byte[] buf = new byte[g.Width * g.Height * 4];
			int i = 0;

			for (int y = g.Height - 1; y >= 0; y--) {
				for (int x = g.Width - 1; x >= 0; x--) {
					if (g.Bitmap[y,x] == 0)
						buf [i + 0] = 0;
					else if (g.Bitmap[y,x] == 1)
						buf [i + 0] = 255;
					else
						buf [i + 0] = 128;

					buf[i + 1] = palette[ (g.Bitmap[y,x]) * 3 + offset + 0];
					buf[i + 2] = palette[ (g.Bitmap[y,x]) * 3 + offset + 1];
					buf[i + 3] = palette[ (g.Bitmap[y,x]) * 3 + offset + 2];

					if (buf[i+1] == 252 && buf[i+2] == 0 && buf[i+3] == 252)
						buf[i + 0] = 0;

					i += 4;
				}
			}

			CGImage glyphImage = CreateImage (buf, (ushort)g.Width, (ushort)g.Height, 32, g.Width * 4);
			
			context.DrawImage (new RectangleF (position, new SizeF (g.Width, g.Height)), glyphImage);
		}
Ejemplo n.º 19
0
 /// <summary>
 ///    <para>
 ///       Initializes a new instance of the <see cref='System.Drawing.RectangleF'/>
 ///       class with the specified location
 ///       and size.
 ///    </para>
 /// </summary>
 public RectangleF(PointF location, SizeF size)
 {
     _x = location.X;
     _y = location.Y;
     _width = size.Width;
     _height = size.Height;
 }
 private static PointF[] ToPointF(Coordinate[] coordinates)
 {
     var ret = new PointF[coordinates.Length];
     for( var i = 0; i < coordinates.Length; i++)
         ret[i] = new PointF((float)coordinates[i].X, (float)coordinates[i].Y);
     return ret;
 }
        /// <summary>
        /// Called when the touches end or the recognizer state fails
        /// </summary>
        public override void Reset()
        {
            base.Reset ();

            strokeUp = false;
            midpoint = PointF.Empty;
        }
Ejemplo n.º 22
0
		public AbsoluteMouseEventArgs(MouseButtons button, PointF location, float zoom)
		{
			this.button = button;
			this.x = location.X;
			this.y = location.Y;
			this.zoom = zoom;
		}
Ejemplo n.º 23
0
        private void KeyPressed(object sender, KeyPressEventArgs e)
        {
            var graphics = Graphics.FromImage(bitmap);

            if (previousCharacterPoint == previousPoint)
                characterCounter++;
            else
            {
                characterCounter = 0;
                line = 0;
            }

            if (e.KeyChar == (char)Keys.Delete || e.KeyChar == (char)Keys.Back)
                characterCounter -= 2;

            if (e.KeyChar == (char)Keys.Return || e.KeyChar == (char)Keys.Enter)
            {
                line++;
                characterCounter = 0;
            }

            var p = new PointF(previousPoint.X + (10 * characterCounter), previousPoint.Y - 5 + (10 * line));

            if ((p.X + 10) > totalScreen.Width)
            {
                characterCounter = 0;
                line++;
            }

            graphics.DrawString(e.KeyChar.ToString(), new Font("Courier New", 12), new SolidBrush(Color.FromArgb(128, Color.Black)), p);

            previousCharacterPoint = previousPoint;
        }
Ejemplo n.º 24
0
		public CalloutView (string text, PointF pt, NSObject target, Selector sel) : base(_initframe)
		{
			SetAnchorPoint (pt);
			Initialize ();
			Text = text;
			AddButtonTarget (target, sel);
		}
Ejemplo n.º 25
0
 private double GetSlope (PointF p1, PointF p2)
 {
     if ((p2.Y - p1.Y) != 0)
         return (p1.X - p2.X) / (p2.Y - p1.Y);
     else
         return double.PositiveInfinity;
 }
Ejemplo n.º 26
0
 public virtual void Rotate(float angle, PointF center)
 {
     Matrix tempMatrix = new Matrix();
     tempMatrix.RotateAt(angle, center);
     tempMatrix.Multiply(TransformationMatrix);
     TransformationMatrix = tempMatrix;
 }
Ejemplo n.º 27
0
    /// <summary>
    /// Generates a list of triangles from an interior point (<paramref name="cx"/>;<paramref name="cy"/>)
    /// to each point of the source <paramref name="points"/>. The path must be closed and describe a simple polygon,
    /// where no connection between (cx; cy) and any path point crosses the border (this means, from (cx; cy),
    /// each path point must be reached directly).
    /// The generated triangles are in the same form as if we would have generated a triangle fan,
    /// but this method returns them in the form of a triangle list.
    /// </summary>
    /// <param name="points">The source points which enclose the shape to triangulate.</param>
    /// <param name="cx">X coordinate of an interior point of the <paramref name="points"/>.</param>
    /// <param name="cy">Y coordinate of an interior point of the <paramref name="points"/>.</param>
    /// <param name="zCoord">Z coordinate of the returned vertices.</param>
    /// <param name="verts">Returns a list of vertices describing a triangle list.</param>
    public static void FillPolygon_TriangleList(PointF[] points, float cx, float cy, float zCoord, out PositionColoredTextured[] verts)
    {
      verts = null;
      PointF[] pathPoints = AdjustPoints(points);
      int pointCount = pathPoints.Length;
      if (pointCount <= 2) return;
      if (pointCount == 3)
      {
        verts = new PositionColoredTextured[3];

        verts[0].Position = new Vector3(pathPoints[0].X, pathPoints[0].Y, zCoord);
        verts[1].Position = new Vector3(pathPoints[1].X, pathPoints[1].Y, zCoord);
        verts[2].Position = new Vector3(pathPoints[2].X, pathPoints[2].Y, zCoord);
        return;
      }
      bool closed = pathPoints[0] == pathPoints[pointCount - 1];
      if (closed)
        pointCount--;
      int verticeCount = pointCount * 3;
      verts = new PositionColoredTextured[verticeCount];
      for (int i = 0; i < pointCount; i++)
      {
        int offset = i * 3;
        verts[offset].Position = new Vector3(cx, cy, zCoord);
        verts[offset + 1].Position = new Vector3(pathPoints[i].X, pathPoints[i].Y, zCoord);
        if (i + 1 < pointCount)
          verts[offset + 2].Position = new Vector3(pathPoints[i + 1].X, pathPoints[i + 1].Y, zCoord);
        else
          verts[offset + 2].Position = new Vector3(pathPoints[0].X, pathPoints[0].Y, zCoord);
      }
    }
Ejemplo n.º 28
0
        public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {

            GraphicsPath gpSeekPosition = new GraphicsPath();
            gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
            gpSeekPosition.Widen(this.m_pOneWidth);
            this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));

            if (this.m_isMouseDown == true) {

                if (pntMouseLocation.X < pntDrawOffset.X) {
                    this.SeekerPosition = 0.0F;
                }
                else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
                    this.SeekerPosition = 1.0F;
                }
                else {
                    this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
                }
            }

            float xBeginningOffset = pntDrawOffset.X;

            pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);

            this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            gpSeekPosition.Dispose();
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Vytvoří konvexní obal z daných vertexů
        /// </summary>
        /// <param name="Vertices">Vertexy</param>
        /// <returns>Pole vertexů tvořící konvexní obal</returns>
        public static PointF[] GetConvexHull(PointF[] Vertices)
        {
            int n = Vertices.Length, k = 0;
            PointF[] Hull = new PointF[2 * n],Sorted = new PointF[Vertices.Length];
            Vertices.CopyTo(Sorted, 0);

            Array.Sort<PointF>(Sorted, new Comparison<PointF>(LexicalPointComparison));

            for (int i = 0; i < n; i++)
            {
                while (k >= 2 && zc((PointF)Hull[k - 2],(PointF)Hull[k - 1], Sorted[i]) <= 0) k--;
                Hull[k++] = Sorted[i];
            }

            for (int i = n - 2, t = k + 1; i >= 0; i--)
            {
                while (k >= t && zc((PointF)Hull[k - 2], (PointF)Hull[k - 1], Sorted[i]) <= 0) k--;
                Hull[k++] = Sorted[i];
            }

            PointF[] Ret = new PointF[k-1];
            for (int i = 0; i < k - 1; i++)
            {
                Ret[i].X = Hull[i].X;
                Ret[i].Y = Hull[i].Y;
            }
            return Ret;
        }
Ejemplo n.º 30
0
        public void LoadPath(string filename)
        {
            using (StreamReader sr = new StreamReader(filename))
             {
            string line;
            while ((line = sr.ReadLine()) != null)
            {
               if (line == "start" || line == "end")
                  continue;

               string[] str = line.Split(' ');
               if (str.Length < 5)
                  break;
               PointF p = new PointF();

               p.X = float.Parse(str[4]);
               p.Y = float.Parse(str[3]);

               m_pointsF.Add(p);

               string [] time = str[1].Split(':');
               float secs = float.Parse( time[1] ) * 60 + float.Parse( time[2] );
               float vel = float.Parse( str[5] ) * 1.852f;

               m_velTime.Add(new PointF(secs, vel));
            }
             }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// NS, 2013-10-01 Add circle outline in current symbol :)
        /// </summary>
        /// <param name="g"></param>
        /// <param name="point"></param>
        /// <param name="symbol"></param>
        /// <param name="symbolscale"></param>
        /// <param name="offset"></param>
        /// <param name="rotation"></param>
        /// <param name="map"></param>
        /// <param name="circleradius"></param>
        /// <param name="radius"></param>
        /// <param name="circleline"></param>
        public static void DrawPointWithCircle(Graphics g, IPoint point, Bitmap symbol, float symbolscale, PointF offset,
                                               float rotation, Map map, bool circleradius, int radius, Pen circleline)
        {
            if (point == null)
            {
                return;
            }

            System.Drawing.PointF pp = SharpMap.Utilities.Transform.WorldtoMap(point.Coordinate, map);

            Matrix startingTransform = g.Transform;

            g.CompositingMode = CompositingMode.SourceOver;

            if (circleradius)
            {
                //NS, 2013-10-14, Add SmootingMode
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.DrawEllipse(circleline, (pp.X - radius), (pp.Y - radius), radius * 2f, radius * 2f);
            }

            //NS, 2013-10-02, resize symbol
            //Size aSize = new Size((int)(symbol.Width * map.Zoom), (int)(symbol.Height * map.Zoom));
            //if (!aSize.IsEmpty)
            //{
            //    Bitmap bmpSymbol = new Bitmap(symbol, aSize);
            //    symbol = bmpSymbol;
            //}

            if (rotation != 0 && !Single.IsNaN(rotation))
            {
                SizeF  size           = new SizeF(symbol.Width / 2, symbol.Height / 2);
                PointF rotationCenter = PointF.Add(new PointF(pp.X - size.Width, pp.Y - size.Height), size);

                Matrix transform = new Matrix();
                transform.RotateAt(rotation, rotationCenter);

                g.Transform = transform;

                if (symbolscale == 1f)
                {
                    g.DrawImageUnscaled(symbol, (int)(pp.X - symbol.Width / 2 + offset.X), (int)(pp.Y - symbol.Height / 2 + offset.Y));
                }
                else
                {
                    float width  = symbol.Width * symbolscale;
                    float height = symbol.Height * symbolscale;
                    g.DrawImage(symbol, (int)pp.X - width / 2 + offset.X * symbolscale, (int)pp.Y - height / 2 + offset.Y * symbolscale, width, height);
                }

                g.Transform = startingTransform;
            }
            else
            {
                if (symbolscale == 1f)
                {
                    g.DrawImageUnscaled(symbol, (int)(pp.X - symbol.Width / 2 + offset.X), (int)(pp.Y - symbol.Height / 2 + offset.Y));
                }
                else
                {
                    float width  = symbol.Width * symbolscale;
                    float height = symbol.Height * symbolscale;
                    g.DrawImage(symbol, (int)pp.X - width / 2 + offset.X * symbolscale, (int)pp.Y - height / 2 + offset.Y * symbolscale, width, height);
                }
            }
        }
Ejemplo n.º 32
0
        protected override void RenderPath(FillStyle fs, StrokeStyle ss, List <IShapeData> sh, bool silverlight)
        {
            // <Path Fill="#FFFF0000"
            // StrokeThickness="0.00491913" StrokeLineJoin="Round" Stroke="#FF014393"
            // Data="M 196.667,4L 388.667,100L 388.667,292L 196.667,388L 4.66669,292L 4.66669,100L 196.667,4 Z "/>
            if (sh.Count == 0)
            {
                return;
            }

            xw.WriteStartElement("Path");

            bool isGradient    = false;
            bool isTiledBitmap = false;

            if (fs != null)
            {
                if (fs.FillType == FillType.Solid)
                {
                    Color c = ((SolidFill)fs).Color;
                    xw.WriteStartAttribute("Fill");
                    xw.WriteColor(c);
                    xw.WriteEndAttribute();

                    // try to clean up faint edges
                    if (ss == null && c != new Color(0xFF, 0xFF, 0xFF) && c.A != 0)
                    {
                        ss = new SolidStroke(0.3F, c);
                    }
                }
                else if (
                    fs.FillType == FillType.Linear ||
                    fs.FillType == FillType.Radial ||
                    fs.FillType == FillType.Focal)
                {
                    isGradient = true;
                }
                else if (fs.FillType == FillType.Image)
                {
                    // Fill="{StaticResource vb_1}"
                    ImageFill img = (ImageFill)fs;
                    if (img.IsTiled || silverlight)
                    {
                        isTiledBitmap = true;// this causes bitmap to be written inline
                    }
                    else
                    {
                        string brushName = imageBrushes[img.ImagePath];
                        xw.WriteStartAttribute("Fill");
                        xw.WriteValue("{StaticResource " + brushName + "}");
                        xw.WriteEndAttribute();
                    }
                }
            }
            if (ss != null)
            {
                if (ss is SolidStroke)
                {
                    // StrokeThickness="3" StrokeLineJoin="Round" Stroke="#FF014393"
                    // StrokeStartLineCap="Round"
                    // StrokeEndLineCap="Round"
                    SolidStroke st = (SolidStroke)ss;

                    xw.WriteStartAttribute("StrokeThickness");
                    xw.WriteFloat(st.LineWidth);
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("StrokeLineJoin");
                    xw.WriteString("Round");
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("StrokeStartLineCap");
                    xw.WriteString("Round");
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("StrokeEndLineCap");
                    xw.WriteString("Round");
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("Stroke");
                    xw.WriteColor(st.Color);
                    xw.WriteEndAttribute();
                }
            }
            float minX = float.PositiveInfinity;
            float minY = float.PositiveInfinity;
            float maxX = float.NegativeInfinity;
            float maxY = float.NegativeInfinity;

            xw.WriteStartAttribute("Data");

            xw.WriteMoveTo(sh[0].StartPoint);

            Point lastPoint = sh[0].StartPoint;

            for (int i = 0; i < sh.Count; i++)
            {
                IShapeData sd = sh[i];
                if (lastPoint != sd.StartPoint)
                {
                    xw.WriteMoveTo(sd.StartPoint);
                }
                switch (sd.SegmentType)
                {
                case SegmentType.Line:
                    xw.WriteLineTo(sd.EndPoint);
                    lastPoint = sd.EndPoint;
                    break;

                case SegmentType.CubicBezier:
                    CubicBezier cb = (CubicBezier)sd;
                    xw.WriteCubicCurveTo(cb.Control0, cb.Control1, cb.Anchor1);
                    lastPoint = cb.EndPoint;
                    minX      = Math.Min(minX, cb.Control0.X);
                    maxX      = Math.Max(maxX, cb.Control0.X);
                    minY      = Math.Min(minY, cb.Control0.Y);
                    maxY      = Math.Max(maxY, cb.Control0.Y);
                    minX      = Math.Min(minX, cb.Control1.X);
                    maxX      = Math.Max(maxX, cb.Control1.X);
                    minY      = Math.Min(minY, cb.Control1.Y);
                    maxY      = Math.Max(maxY, cb.Control1.Y);
                    break;

                case SegmentType.QuadraticBezier:
                    QuadBezier qb = (QuadBezier)sd;
                    xw.WriteQuadraticCurveTo(qb.Control, qb.Anchor1);
                    lastPoint = qb.EndPoint;
                    minX      = Math.Min(minX, qb.Control.X);
                    maxX      = Math.Max(maxX, qb.Control.X);
                    minY      = Math.Min(minY, qb.Control.Y);
                    maxY      = Math.Max(maxY, qb.Control.Y);
                    break;
                }

                // need bounds for gradient :(
                if (isGradient)
                {
                    minX = Math.Min(minX, sd.StartPoint.X);
                    maxX = Math.Max(maxX, sd.StartPoint.X);
                    minY = Math.Min(minY, sd.StartPoint.Y);
                    maxY = Math.Max(maxY, sd.StartPoint.Y);

                    minX = Math.Min(minX, sd.EndPoint.X);
                    maxX = Math.Max(maxX, sd.EndPoint.X);
                    minY = Math.Min(minY, sd.EndPoint.Y);
                    maxY = Math.Max(maxY, sd.EndPoint.Y);
                }
            }
            xw.WriteEndAttribute();

            if (isGradient)
            {
                GradientFill gf = (GradientFill)fs;
                // need a gradient def here
                if (fs.FillType == FillType.Linear)
                {
                    //<Path.Fill>
                    //    <LinearGradientBrush StartPoint="0.14706,0.532137" EndPoint="1.14962,0.55353">
                    //        <LinearGradientBrush.GradientStops>
                    //            <GradientStop Color="#FF4A4A4A" Offset="0"/>
                    //            <GradientStop Color="#FFB0B0B0" Offset="0.412067"/>
                    //            <GradientStop Color="#FFBBBBBB" Offset="0.638141"/>
                    //            <GradientStop Color="#FF545454" Offset="1"/>
                    //        </LinearGradientBrush.GradientStops>
                    //    </LinearGradientBrush>
                    //</Path.Fill>
                    xw.WriteStartElement("Path.Fill");

                    xw.WriteStartElement("LinearGradientBrush");

                    Matrix           m    = gf.Transform;
                    Rectangle        r    = GradientFill.GradientVexRect;
                    sysDraw2D.Matrix m2   = new sysDraw2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY);
                    float            midY = r.Point.Y + (r.Size.Height / 2);
                    sysDraw.PointF   pt0  = new sysDraw.PointF(r.Point.X, midY);
                    sysDraw.PointF   pt1  = new sysDraw.PointF(r.Point.X + r.Size.Width, midY);
                    sysDraw.PointF[] pts  = new sysDraw.PointF[] { pt0, pt1 };
                    m2.TransformPoints(pts);

                    float ratX = 1 / (maxX - minX);
                    float ratY = 1 / (maxY - minY);
                    float d0x  = (pts[0].X - minX) * ratX;
                    float d0y  = (pts[0].Y - minY) * ratY;
                    float d1x  = (pts[1].X - minX) * ratX;
                    float d1y  = (pts[1].Y - minY) * ratY;

                    xw.WriteStartAttribute("StartPoint");
                    xw.WritePoint(new Point(d0x, d0y));
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("EndPoint");
                    xw.WritePoint(new Point(d1x, d1y));
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("SpreadMethod");
                    xw.WriteValue("Pad");
                    xw.WriteEndAttribute();

                    xw.WriteStartElement("LinearGradientBrush.GradientStops");
                    for (int i = 0; i < gf.Stops.Count; i++)
                    {
                        xw.WriteStartElement("GradientStop");

                        xw.WriteStartAttribute("Color");
                        xw.WriteColor(gf.Fills[i]);
                        xw.WriteEndAttribute();

                        xw.WriteStartAttribute("Offset");
                        xw.WriteFloat(gf.Stops[i]);
                        xw.WriteEndAttribute();

                        xw.WriteEndElement(); // GradientStop
                    }
                    xw.WriteEndElement();     // LinearGradientBrush.GradientStops
                    xw.WriteEndElement();     // LinearGradientBrush
                    xw.WriteEndElement();     // Path.Fill
                }
                else if (fs.FillType == FillType.Radial)
                {
                    //<Ellipse.Fill>
                    //    <RadialGradientBrush RadiusX="0.622359" RadiusY="0.604589" Center="0.5,0.5" GradientOrigin="0.5,0.5">
                    //        <RadialGradientBrush.RelativeTransform>
                    //            <TransformGroup/>
                    //        </RadialGradientBrush.RelativeTransform>
                    //        <GradientStop Color="#95000000" Offset="0.347222"/>
                    //        <GradientStop Color="#007877A7" Offset="0.773148"/>
                    //    </RadialGradientBrush>
                    //</Ellipse.Fill>

                    xw.WriteStartElement("Path.Fill");

                    xw.WriteStartElement("RadialGradientBrush");

                    Matrix           m    = gf.Transform;
                    Rectangle        r    = GradientFill.GradientVexRect;
                    sysDraw2D.Matrix m2   = new sysDraw2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY);
                    float            midX = r.Point.X + (r.Size.Width / 2);
                    float            midY = r.Point.Y + (r.Size.Height / 2);
                    sysDraw.PointF   pt0  = new sysDraw.PointF(midX, midY);                     // center
                    sysDraw.PointF   pt1  = new sysDraw.PointF(r.Point.X + r.Size.Width, midY); // radius vector
                    sysDraw.PointF[] pts  = new sysDraw.PointF[] { pt0, pt1 };
                    m2.TransformPoints(pts);

                    float ratX = 1 / (maxX - minX);
                    float ratY = 1 / (maxY - minY);
                    float d0x  = (pts[0].X - minX) * ratX;
                    float d0y  = (pts[0].Y - minY) * ratY;
                    float d1x  = (pts[1].X - pts[0].X);
                    //float d1y = (pts[1].Y - pts[0].Y) * ratY;

                    float rad = (float)Math.Sqrt(d1x * d1x);
                    xw.WriteStartAttribute("RadiusX");
                    xw.WriteFloat(rad * ratX);
                    xw.WriteEndAttribute();
                    xw.WriteStartAttribute("RadiusY");
                    xw.WriteFloat(rad * ratY);
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("Center");
                    xw.WritePoint(new Point(d0x, d0y));
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("GradientOrigin");
                    xw.WritePoint(new Point(d0x, d0y));
                    xw.WriteEndAttribute();

                    xw.WriteStartAttribute("SpreadMethod");
                    xw.WriteValue("Pad");
                    xw.WriteEndAttribute();

                    //xw.WriteStartElement("RadialGradientBrush.GradientStops");
                    for (int i = 0; i < gf.Stops.Count; i++)
                    {
                        xw.WriteStartElement("GradientStop");

                        xw.WriteStartAttribute("Color");
                        xw.WriteColor(gf.Fills[i]);
                        xw.WriteEndAttribute();

                        xw.WriteStartAttribute("Offset");
                        xw.WriteFloat(1 - gf.Stops[i]); // xaml fill is reversed from gdi
                        xw.WriteEndAttribute();

                        xw.WriteEndElement(); // GradientStop
                    }
                    //xw.WriteEndElement(); // LinearGradientBrush.GradientStops
                    xw.WriteEndElement(); // LinearGradientBrush
                    xw.WriteEndElement(); // Path.Fill
                }
            }
            else if (isTiledBitmap)
            {
                //<Path.Fill>
                //   <ImageBrush ImageSource="Resources\bmp_1.jpg" TileMode="Tile" RelativeTransform=".2,0,0,.2,0,0"/>
                //</Path.Fill>

                ImageFill img = (ImageFill)fs;

                xw.WriteStartElement("Path.Fill");
                xw.WriteStartElement("ImageBrush");

                xw.WriteStartAttribute("ImageSource");
                xw.WriteValue(img.ImagePath);
                xw.WriteEndAttribute();

                if (!silverlight)
                {
                    xw.WriteStartAttribute("TileMode");
                    xw.WriteValue("Tile");
                    xw.WriteEndAttribute();
                }

                //xw.WriteStartAttribute("ViewportUnits");
                //xw.WriteValue("Absolute");
                //xw.WriteEndAttribute();

                Matrix pMatrix = ApplyMatrixToShape(sh, img.Matrix, images[img.ImagePath].StrokeBounds);
                //Matrix pMatrix = ApplyMatrixToImage(img.Matrix, images[img.ImagePath].Bounds);
                xw.WriteStartAttribute("RelativeTransform");
                xw.WriteMatrix(pMatrix);
                //xw.WriteMatrix(img.Matrix);
                xw.WriteEndAttribute();

                xw.WriteEndElement(); // Path.Fill
                xw.WriteEndElement(); // ImageBrush
            }
            xw.WriteEndElement();     // Path
        }
Ejemplo n.º 33
0
 internal override void updatePoint(System.Drawing.PointF p)
 {
     points[Index] = p;
 }
Ejemplo n.º 34
0
        private void DrawTagNode(Dictionary <string, CardImg> tpks)
        {
            if (!Parameter.isSupportMulArea)
            {//不是多区域时,只有一张地图
                if (null == CurBitMap)
                {
                    return;
                }
            }
            Graphics g = null;

            try
            {
                if (!Parameter.isSupportMulArea)
                {
                    g = Graphics.FromImage(CurBitMap);
                }
            }
            catch (System.InvalidOperationException)
            {
                return;
            }
            float wscale = 0.0f, hscale = 0.0f;

            if (!Parameter.isSupportMulArea)
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            }
            Brush  tagbrush = Brushes.Green;
            TagPen linetagpen = null; Pen linepen;

            System.Drawing.PointF[] points = null;
            double mapx = 0.0d, mapy = 0.0d, panelx = 0.0d, panely = 0.0d;
            string strtagid = "", strgroupid = "";

            foreach (CardImg tpk in tpks.Values)
            {
                strtagid = tpk.ID[0].ToString("X2") + tpk.ID[1].ToString("X2");
                if (tpk.Name == null || "".Equals(tpk.Name))
                {
                    tpk.Name = Ini.GetValue(Ini.CardPath, strtagid, Ini.Name);
                }
                if (!"".Equals(StrTagInfor) && !StrTagInfor.Equals(tpk.Name) && !StrTagInfor.Equals(tpk.ID[0].ToString("X2") + tpk.ID[1].ToString("X2")))
                {
                    continue;
                }
                if (Parameter.isSupportMulArea)
                {//支持多区域
                    strgroupid = tpk.GroupID[0].ToString("X2") + tpk.GroupID[1].ToString("X2");
                    Group group = null;
                    if (!frm.Groups.TryGetValue(strgroupid, out group))
                    {
                        continue;
                    }
                    DxfMapParam.ClearDxf();
                    CurBitMap = DxfMapParam.GetDxfMap(group.grouppath, Dxf.scale, DrawPanel.Width / 2, DrawPanel.Height / 2, DrawPanel.Width, DrawPanel.Height);
                    if (null == CurBitMap)
                    {
                        continue;
                    }
                    DrawPanel.CreateGraphics().DrawImageUnscaled(CurBitMap, 0, 0);
                    g         = Graphics.FromImage(CurBitMap);
                    wscale    = (float)DrawPanel.Width / group.actualwidth;
                    hscale    = (float)DrawPanel.Height / group.actualheight;
                    mrscale   = wscale > hscale ? hscale : wscale;
                    mapwid    = group.actualwidth * mrscale;
                    mapheight = group.actualheight * mrscale;
                }
                // 计算Tag在地图上的坐标
                mapx = mrscale * tpk.CardPoint.x;
                mapy = mrscale * tpk.CardPoint.y;
                // Tag在面板中的坐标
                panelx = (DrawPanel.Width - mapwid) / 2 + mapx;
                panely = (DrawPanel.Height - mapheight) / 2 + mapy;
                if (tpk.LocaType == TPPID.TagCommonLocal)
                {
                    tagbrush = Brushes.Green;
                }
                if (tpk.isOverNoMove)
                {
                    tagbrush = Brushes.Black;
                }
                if (tpk.isLowBattery)
                {
                    tagbrush = Brushes.Indigo;
                }
                if (tpk.LocaType == TPPID.TagWarmLocal)
                {
                    tagbrush = Brushes.Red;
                }
                if (TraceMode == 0)
                {
                    if (panelx <= 0 || panely <= 0)
                    {
                        continue;
                    }
                    g.FillEllipse(tagbrush, (float)(panelx - 4), (float)panely - 4, 8, 8);
                    if (null == tpk.Name || "".Equals(tpk.Name))
                    {
                        g.DrawString(tpk.ID[0].ToString("X2") + tpk.ID[1].ToString("X2"), new Font("宋体", 12), Brushes.Red, (float)(panelx + 4), (float)(panely + 6));
                    }
                    else
                    {
                        g.DrawString(tpk.Name + "(" + tpk.ID[0].ToString("X2") + tpk.ID[1].ToString("X2") + ")", new Font("宋体", 12), Brushes.Red, (float)(panelx + 4), (float)(panely + 6));
                    }
                }
                else
                {
                    linetagpen = GetTagPen(strtagid);
                    if (null == linetagpen)
                    {
                        if (AllTagPens.Count >= 6)
                        {
                            continue;
                        }
                        linetagpen = new TagPen();
                        System.Buffer.BlockCopy(tpk.ID, 0, linetagpen.ID, 0, 2);
                        linepen           = Get6Color();
                        linetagpen.tagpen = linepen;
                        linetagpen.Name   = tpk.Name;
                        AllTagPens.Add(linetagpen);
                        if (panelx >= 0 && panely >= 0)
                        {
                            linetagpen.oldx = panelx;
                            linetagpen.oldy = panely;
                        }
                    }
                    else
                    {
                        if (linetagpen.oldx <= 0 || linetagpen.oldy <= 0)
                        {
                            linetagpen.oldx = panelx;
                            linetagpen.oldy = panely;
                            return;
                        }
                        if (panelx > 0 && panely > 0)
                        {
                            if (null == points)
                            {
                                points = new PointF[2];
                            }
                            points[0] = new System.Drawing.PointF((float)linetagpen.oldx, (float)linetagpen.oldy);
                            points[1] = new System.Drawing.PointF((float)panelx, (float)panely);
                            try
                            {
                                g.DrawCurve(linetagpen.tagpen, points);
                            }
                            catch (System.OutOfMemoryException ex)
                            {
                                FreeMemory();
                                Console.WriteLine("内存不足!" + ex.ToString());
                            }
                        }
                        linetagpen.oldx = panelx; linetagpen.oldy = panely;
                    }
                }
                if (Parameter.isSupportMulArea)
                {
                    if (null == CurBitMap)
                    {
                        return;
                    }
                    DrawPanel_Paint(null, null);
                }
            }
            if (!Parameter.isSupportMulArea)
            {
                if (null == CurBitMap)
                {
                    return;
                }
                DrawPanel_Paint(null, null);
            }
            if (TraceMode == 1)
            {
                if (null == AllTagPens)
                {
                    return;
                }
                if (AllTagPens.Count <= 0)
                {
                    return;
                }
                int logox1 = 15, logoy1 = 0, logox2 = 45, logoy2 = 0;
                for (int i = 0; i < AllTagPens.Count; i++)
                {
                    if (null == AllTagPens[i])
                    {
                        continue;
                    }
                    if (AllTagPens[i].isLogo)
                    {
                        continue;
                    }
                    logoy1 = logoy2 = (i + 1) * 25;
                    if (null == AllTagPens[i].tagpen)
                    {
                        continue;
                    }
                    g.DrawLine(AllTagPens[i].tagpen, new System.Drawing.Point(logox1, logoy1), new System.Drawing.Point(logox2, logoy2));
                    if (null == AllTagPens[i].Name || "".Equals(AllTagPens[i].Name))
                    {
                        g.DrawString(AllTagPens[i].ID[0].ToString("X2") + AllTagPens[i].ID[1].ToString("X2"), new Font("宋体", 12), AllTagPens[i].tagpen.Brush, logox2 + 5, logoy2 - 8);
                    }
                    else
                    {
                        g.DrawString(AllTagPens[i].Name + "(" + AllTagPens[i].ID[0].ToString("X2") + AllTagPens[i].ID[1].ToString("X2") + ")", new Font("宋体", 12), AllTagPens[i].tagpen.Brush, logox2 + 5, logoy2 - 8);
                    }
                    AllTagPens[i].isLogo = true;
                }
            }
            if (null != g)
            {
                g.Dispose();
            }
        }
        public static void ExtractAnimation(WzSubProperty parent, string savePath, bool apngFirstFrame)
        {
            List <Bitmap> bmpList                    = new List <Bitmap>(parent.WzProperties.Count);
            List <int>    delayList                  = new List <int>(parent.WzProperties.Count);
            Point         biggestPng                 = new Point(0, 0);
            Point         SmallestEmptySpace         = new Point(65535, 65535);
            Point         MaximumPngMappingEndingPts = new Point(0, 0);

            foreach (WzImageProperty subprop in parent.WzProperties)
            {
                if (subprop is WzCanvasProperty)
                {
                    //System.Drawing.PointF origin = ((WzCanvasProperty)subprop).GetCanvasOriginPosition();
                    WzPngProperty png = ((WzCanvasProperty)subprop).PngProperty;
                    if (png.Height > biggestPng.Y)
                    {
                        biggestPng.Y = png.Height;
                    }
                    if (png.Width > biggestPng.X)
                    {
                        biggestPng.X = png.Width;
                    }
                }
            }
            List <WzCanvasProperty> sortedProps = new List <WzCanvasProperty>();

            foreach (WzImageProperty subprop in parent.WzProperties)
            {
                if (subprop is WzCanvasProperty)
                {
                    sortedProps.Add((WzCanvasProperty)subprop);
                    WzPngProperty         png    = ((WzCanvasProperty)subprop).PngProperty;
                    System.Drawing.PointF origin = ((WzCanvasProperty)subprop).GetCanvasOriginPosition();

                    Point StartPoints          = new Point(biggestPng.X - (int)origin.X, biggestPng.Y - (int)origin.Y);
                    Point PngMapppingEndingPts = new Point(StartPoints.X + png.Width, StartPoints.Y + png.Height);
                    if (StartPoints.X < SmallestEmptySpace.X)
                    {
                        SmallestEmptySpace.X = StartPoints.X;
                    }
                    if (StartPoints.Y < SmallestEmptySpace.Y)
                    {
                        SmallestEmptySpace.Y = StartPoints.Y;
                    }
                    if (PngMapppingEndingPts.X > MaximumPngMappingEndingPts.X)
                    {
                        MaximumPngMappingEndingPts.X = PngMapppingEndingPts.X;
                    }
                    if (PngMapppingEndingPts.Y > MaximumPngMappingEndingPts.Y)
                    {
                        MaximumPngMappingEndingPts.Y = PngMapppingEndingPts.Y;
                    }
                }
            }
            sortedProps.Sort(new Comparison <WzCanvasProperty>(PropertySorter));
            for (int i = 0; i < sortedProps.Count; i++)
            {
                WzCanvasProperty subprop = sortedProps[i];
                if (i.ToString() != subprop.Name)
                {
                    Warning.Error(string.Format(Properties.Resources.AnimError, i.ToString()));
                    return;
                }
                Bitmap bmp = subprop.PngProperty.GetImage(false);
                System.Drawing.PointF origin = subprop.GetCanvasOriginPosition();
                bmpList.Add(OptimizeBitmapTransparent(bmp, new WzVectorProperty("", origin.X, origin.Y), biggestPng, SmallestEmptySpace, MaximumPngMappingEndingPts));

                WzIntProperty delayProp = (WzIntProperty)subprop["delay"];
                int           delay     = 100;
                if (delayProp != null)
                {
                    delay = delayProp.Value;
                }
                delayList.Add(delay);
            }
            Apng apngBuilder = new Apng();

            if (apngFirstFrame)
            {
                apngBuilder.AddFrame(new Frame(CreateIncompatibilityFrame(new Size(bmpList[0].Width, bmpList[0].Height)), 1, 1));
            }
            for (int i = 0; i < bmpList.Count; i++)
            {
                apngBuilder.AddFrame(new Frame(bmpList[i], getNumByDelay(delayList[i]), getDenByDelay(delayList[i])));
            }
            apngBuilder.WriteApng(savePath, apngFirstFrame, true);
        }
Ejemplo n.º 36
0
 System.Drawing.PointF AddVectors(System.Drawing.PointF a, System.Drawing.PointF b)
 {
     return(new System.Drawing.PointF(x: a.X + b.X, y: a.Y + b.Y));
 }
Ejemplo n.º 37
0
        public static void FindClickedObject <T>(
            this Report Report,
            string objectName,
            int pageN,
            float left,
            float top,
            Action <T, ReportPage, int> action
            )
            where T : ComponentBase
        {
            if (Report.PreparedPages == null)
            {
                return;
            }

            bool found = false;

            while (pageN < Report.PreparedPages.Count && !found)
            {
                ReportPage page = Report.PreparedPages.GetPage(pageN);
                if (page != null)
                {
                    ObjectCollection allObjects = page.AllObjects;
                    var point = new System.Drawing.PointF(left + 1, top + 1);
                    foreach (Base obj in allObjects)
                    {
                        if (obj is ReportComponentBase)
                        {
                            ReportComponentBase c = obj as ReportComponentBase;
                            if (c is TableBase)
                            {
                                TableBase table = c as TableBase;
                                for (int i = 0; i < table.RowCount; i++)
                                {
                                    for (int j = 0; j < table.ColumnCount; j++)
                                    {
                                        TableCell textcell = table[j, i];
                                        if (textcell.Name == objectName)
                                        {
                                            RectangleF rect = new RectangleF(table.Columns[j].AbsLeft,
                                                                             table.Rows[i].AbsTop,
                                                                             textcell.Width,
                                                                             textcell.Height);
                                            if (rect.Contains(point))
                                            {
                                                action(textcell as T, page, pageN);
                                                found = true;
                                                break;
                                            }
                                        }
                                    }
                                    if (found)
                                    {
                                        break;
                                    }
                                }
                            }
                            else if (c is T)
                            {
                                if (c.Name == objectName && c.AbsBounds.Contains(point))
                                {
                                    action(c as T, page, pageN);
                                    found = true;
                                    break;
                                }
                            }
                            if (found)
                            {
                                break;
                            }
                        }
                    }
                    page.Dispose();
                    pageN++;
                }
            }
        }
Ejemplo n.º 38
0
        public List <double[]> getSignatures(System.Windows.Forms.DataVisualization.Charting.DataPointCollection dataPoints)
        {
            int             r1 = -1, r2 = 0;
            double          weight = 0, totalWeight = 0;
            List <double[]> sigList = new List <double[]>();


            //double area = dataPoints.
            int length = dataPoints.Count;

            for (int i = length - 1; i > 0; i--)
            {
                double angCurrent = dataPoints[i].YValues[0];
                if ((angCurrent > 0.01) && (r1 == -1))
                {
                    r1 = i;
                }
                ;
                if (r1 != -1 && angCurrent < 0.05)
                {
                    r2 = i;
                    //r1 = 0;
                }
                if ((r1 != -1 && r2 != 0) && (Math.Abs(r2 - r1) > 5))// && r2 != 0)
                {
                    dataPoints[r2].Color = System.Drawing.Color.Yellow;

                    dataPoints[r1].Color = System.Drawing.Color.Red;

                    var myMem = new MemStorage();
                    Contour <System.Drawing.PointF> myCont  = new Contour <System.Drawing.PointF>(myMem);
                    System.Drawing.PointF           myPoint = new System.Drawing.PointF();



                    for (int t = r1 - 1; t > r2 + 1; t--)
                    {
                        myPoint.X = ((float)dataPoints[t].XValue);
                        myPoint.Y = (float)dataPoints[t].YValues[0];
                        //weight = weight + dataPoints[t].YValues[0];
                        dataPoints[t].Color = System.Drawing.Color.Silver;
                        myCont.Push(myPoint);
                    }

                    weight = myCont.Area;

                    if (weight > totalWeight)
                    {
                        totalWeight = weight;
                    }
                    //  totalWeight = totalWeight + weight;

                    myCont.Clear();

                    double[] sigArr = { 0, 0, 0 };
                    sigArr[0] = (float)dataPoints[r1].XValue;
                    sigArr[1] = (float)dataPoints[r2].XValue;
                    sigArr[2] = weight;
                    //r2_2 = r1;
                    //if (weight > 0.5) { }
                    sigList.Add(sigArr);

                    r2     = 0;
                    weight = 0;
                    r1     = -1;
                }
            }

            //totalWeight = dataPoints.FindMaxByValue().YValues[0];
            // textBox1.Text = totalWeight.ToString();

            //   foreach (double[] sign in sigList)
            //  {
            //    sign[2] = sign[2] / totalWeight;
            //}

            return(sigList);
        }
Ejemplo n.º 39
0
 public abstract void Move(EasingEnum easingEnum, int startTime, int endTime, Gdip.PointF startPoint,
                           Gdip.PointF endPoint);
Ejemplo n.º 40
0
        public override void draw(System.Drawing.Graphics g, System.Drawing.SizeF scale, System.Drawing.PointF start)
        {
            if (Points.Count >= 2)
            {
                RectangleF r = new RectangleF(this.Points[0].X * scale.Width, this.Points[0].Y * scale.Height,
                                              this.Points[1].X * scale.Width, this.Points[1].Y * scale.Height);

                g.FillRectangle(new SolidBrush(this.Color), r);
            }
        }
Ejemplo n.º 41
0
 public static PointF ToEto(this sd.PointF point)
 {
     return(new PointF(point.X, point.Y));
 }
Ejemplo n.º 42
0
        void bg_DoWork(object sender, DoWorkEventArgs e)
        {
            MapInfo info = (MapInfo)e.Argument;

            if (!info.Area.IsEmpty)
            {
                string bigImage = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + Path.DirectorySeparatorChar + "GMap at zoom " + info.Zoom + " - " + info.Type + "-" + DateTime.Now.Ticks + ".png";
                if (!string.IsNullOrEmpty(textBoxSaveAs.Text))
                {
                    bigImage = Path.Combine(Path.GetDirectoryName(textBoxSaveAs.Text), Path.GetFileName(bigImage));
                }

                var smallImage = Path.Combine(Path.GetDirectoryName(bigImage), "layer.png");
                if (!string.IsNullOrEmpty(textBoxSaveAs.Text))
                {
                    smallImage = textBoxSaveAs.Text;
                }

                e.Result = bigImage;

                // current area
                GPoint         topLeftPx     = info.Type.Projection.FromLatLngToPixel(info.Area.LocationTopLeft, info.Zoom);
                GPoint         rightButtomPx = info.Type.Projection.FromLatLngToPixel(info.Area.Bottom, info.Area.Right, info.Zoom);
                GPoint         pxDelta       = new GPoint(rightButtomPx.X - topLeftPx.X, rightButtomPx.Y - topLeftPx.Y);
                GMap.NET.GSize maxOfTiles    = info.Type.Projection.GetTileMatrixMaxXY(info.Zoom);

                int shrinkLoop = 0;

                int padding = info.MakeWorldFile || info.MakeKmz ? 0 : 22;
                {
                    using (Bitmap bmpDestination = new Bitmap((int)(pxDelta.X + padding * 2), (int)(pxDelta.Y + padding * 2)))
                    {
                        using (Graphics gfx = Graphics.FromImage(bmpDestination))
                        {
                            gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            gfx.SmoothingMode     = SmoothingMode.HighQuality;

                            int i = 0;

                            // get tiles & combine into one
                            lock (tileArea)
                            {
                                foreach (var p in tileArea)
                                {
                                    if (bg.CancellationPending)
                                    {
                                        e.Cancel = true;
                                        return;
                                    }

                                    int pc = (int)(((double)++i / tileArea.Count) * 100);
                                    bg.ReportProgress(pc, p);

                                    foreach (var tp in info.Type.Overlays)
                                    {
                                        Exception ex;
                                        GMapImage tile;

                                        // tile number inversion(BottomLeft -> TopLeft) for pergo maps
                                        if (tp.InvertedAxisY)
                                        {
                                            tile = GMaps.Instance.GetImageFrom(tp, new GPoint(p.X, maxOfTiles.Height - p.Y), info.Zoom, out ex) as GMapImage;
                                        }
                                        else // ok
                                        {
                                            tile = GMaps.Instance.GetImageFrom(tp, p, info.Zoom, out ex) as GMapImage;
                                        }

                                        if (tile != null)
                                        {
                                            using (tile)
                                            {
                                                long x = p.X * info.Type.Projection.TileSize.Width - topLeftPx.X + padding;
                                                long y = p.Y * info.Type.Projection.TileSize.Width - topLeftPx.Y + padding;
                                                {
                                                    gfx.DrawImage(tile.Img, x, y, info.Type.Projection.TileSize.Width, info.Type.Projection.TileSize.Height);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            // draw routes
                            {
                                foreach (GMapRoute r in Main.routes.Routes)
                                {
                                    if (r.IsVisible)
                                    {
                                        using (GraphicsPath rp = new GraphicsPath())
                                        {
                                            for (int j = 0; j < r.Points.Count; j++)
                                            {
                                                var    pr = r.Points[j];
                                                GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                                px.Offset(padding, padding);
                                                px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                                GPoint p2 = px;

                                                if (j == 0)
                                                {
                                                    rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                                }
                                                else
                                                {
                                                    System.Drawing.PointF p = rp.GetLastPoint();
                                                    rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                                }
                                            }

                                            if (rp.PointCount > 0)
                                            {
                                                gfx.DrawPath(r.Stroke, rp);
                                            }
                                        }
                                    }
                                }
                            }

                            // draw polygons
                            {
                                foreach (GMapPolygon r in Main.polygons.Polygons)
                                {
                                    if (r.IsVisible)
                                    {
                                        using (GraphicsPath rp = new GraphicsPath())
                                        {
                                            for (int j = 0; j < r.Points.Count; j++)
                                            {
                                                var    pr = r.Points[j];
                                                GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                                px.Offset(padding, padding);
                                                px.Offset(-topLeftPx.X, -topLeftPx.Y);

                                                GPoint p2 = px;

                                                if (j == 0)
                                                {
                                                    rp.AddLine(p2.X, p2.Y, p2.X, p2.Y);
                                                }
                                                else
                                                {
                                                    System.Drawing.PointF p = rp.GetLastPoint();
                                                    rp.AddLine(p.X, p.Y, p2.X, p2.Y);
                                                }
                                            }

                                            if (rp.PointCount > 0)
                                            {
                                                rp.CloseFigure();

                                                gfx.FillPath(r.Fill, rp);

                                                gfx.DrawPath(r.Stroke, rp);
                                            }
                                        }
                                    }
                                }
                            }

                            // draw markers
                            {
                                foreach (GMapMarker r in Main.objects.Markers)
                                {
                                    if (r.IsVisible)
                                    {
                                        var    pr = r.Position;
                                        GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                        px.Offset(padding, padding);
                                        px.Offset(-topLeftPx.X, -topLeftPx.Y);
                                        px.Offset(r.Offset.X, r.Offset.Y);

                                        gfx.ResetTransform();
                                        gfx.TranslateTransform(-r.LocalPosition.X, -r.LocalPosition.Y);
                                        gfx.TranslateTransform((int)px.X, (int)px.Y);

                                        r.OnRender(gfx);
                                    }
                                }

                                // tooltips above
                                foreach (GMapMarker m in Main.objects.Markers)
                                {
                                    if (m.IsVisible && m.ToolTip != null && m.IsVisible)
                                    {
                                        if (!string.IsNullOrEmpty(m.ToolTipText))
                                        {
                                            var    pr = m.Position;
                                            GPoint px = info.Type.Projection.FromLatLngToPixel(pr.Lat, pr.Lng, info.Zoom);

                                            px.Offset(padding, padding);
                                            px.Offset(-topLeftPx.X, -topLeftPx.Y);
                                            px.Offset(m.Offset.X, m.Offset.Y);

                                            gfx.ResetTransform();
                                            gfx.TranslateTransform(-m.LocalPosition.X, -m.LocalPosition.Y);
                                            gfx.TranslateTransform((int)px.X, (int)px.Y);

                                            m.ToolTip.OnRender(gfx);
                                        }
                                    }
                                }
                                gfx.ResetTransform();
                            }

                            // draw info
                            if (!info.MakeWorldFile)
                            {
                                System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
                                {
                                    rect.Location = new System.Drawing.Point(padding, padding);
                                    rect.Size     = new System.Drawing.Size((int)pxDelta.X, (int)pxDelta.Y);
                                }

                                using (Font f = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold))
                                {
                                    // draw bounds & coordinates
                                    using (Pen p = new Pen(Brushes.DimGray, 3))
                                    {
                                        p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;

                                        gfx.DrawRectangle(p, rect);

                                        string topleft = info.Area.LocationTopLeft.ToString();
                                        SizeF  s       = gfx.MeasureString(topleft, f);

                                        gfx.DrawString(topleft, f, p.Brush, rect.X + s.Height / 2, rect.Y + s.Height / 2);

                                        string rightBottom = new PointLatLng(info.Area.Bottom, info.Area.Right).ToString();
                                        SizeF  s2          = gfx.MeasureString(rightBottom, f);

                                        gfx.DrawString(rightBottom, f, p.Brush, rect.Right - s2.Width - s2.Height / 2, rect.Bottom - s2.Height - s2.Height / 2);
                                    }

                                    // draw scale
                                    using (Pen p = new Pen(Brushes.Blue, 1))
                                    {
                                        double rez    = info.Type.Projection.GetGroundResolution(info.Zoom, info.Area.Bottom);
                                        int    px100  = (int)(100.0 / rez);  // 100 meters
                                        int    px1000 = (int)(1000.0 / rez); // 1km

                                        gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px1000, 10);
                                        gfx.DrawRectangle(p, rect.X + 10, rect.Bottom - 20, px100, 10);

                                        string leftBottom = "scale: 100m | 1Km";
                                        SizeF  s          = gfx.MeasureString(leftBottom, f);
                                        gfx.DrawString(leftBottom, f, p.Brush, rect.X + 10, rect.Bottom - s.Height - 20);
                                    }
                                }
                            }
                        }

                        ImageUtilities.SavePng(bigImage, bmpDestination);

                        Image shrinkImage = null;
                        try
                        {
                            shrinkImage = bmpDestination;

                            long size;
                            if (long.TryParse(textBoxSizeFile.Text, out size))
                            {
                                var fileLength = new FileInfo(bigImage).Length;
                                if (fileLength > 0 && (fileLength / 1024 / 1024) > size)
                                {
                                    while (shrinkLoop <= 100)
                                    {
                                        shrinkLoop++;

                                        int nextWidth  = shrinkImage.Width * 80 / 100;
                                        int nextHeight = shrinkImage.Height * 80 / 100;

                                        // Shrink image
                                        shrinkImage = Stuff.FixedSize(shrinkImage, nextWidth, nextHeight);
                                        ImageUtilities.SavePng(smallImage, shrinkImage);

                                        fileLength = new FileInfo(smallImage).Length;
                                        if (fileLength > 0 && (fileLength / 1024 / 1024) < size)
                                        {
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    ImageUtilities.SavePng(smallImage, shrinkImage);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Invalide size - no shrinking.", "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "GMap.NET - Demo.WindowsForms", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        finally
                        {
                            shrinkImage.Dispose();
                        }
                    }
                }

                //The worldfile for the original image is:

                //0.000067897543      // the horizontal size of a pixel in coordinate units (longitude degrees in this case);
                //0.0000000
                //0.0000000
                //-0.0000554613012    // the comparable vertical pixel size in latitude degrees, negative because latitude decreases as you go from top to bottom in the image.
                //-111.743323868834   // longitude of the pixel in the upper-left-hand corner.
                //35.1254392635083    // latitude of the pixel in the upper-left-hand corner.

                // generate world file
                if (info.MakeWorldFile)
                {
                    string wf = Path.ChangeExtension(bigImage, "pgw");
                    using (StreamWriter world = File.CreateText(wf))
                    {
                        world.WriteLine("{0:0.000000000000}", (info.Area.WidthLng / pxDelta.X));
                        world.WriteLine("0.0000000");
                        world.WriteLine("0.0000000");
                        world.WriteLine("{0:0.000000000000}", (-info.Area.HeightLat / pxDelta.Y));
                        world.WriteLine("{0:0.000000000000}", info.Area.Left);
                        world.WriteLine("{0:0.000000000000}", info.Area.Top);
                        world.Close();
                    }

                    wf = Path.ChangeExtension(smallImage, "pgw");
                    using (StreamWriter world = File.CreateText(wf))
                    {
                        world.WriteLine("{0:0.000000000000}", (info.Area.WidthLng / pxDelta.X) * (shrinkLoop > 0 ? Math.Pow(1.25, shrinkLoop) : 1));
                        world.WriteLine("0.0000000");
                        world.WriteLine("0.0000000");
                        world.WriteLine("{0:0.000000000000}", (-info.Area.HeightLat / pxDelta.Y) * (shrinkLoop > 0 ? Math.Pow(1.25, shrinkLoop) : 1));
                        world.WriteLine("{0:0.000000000000}", info.Area.Left);
                        world.WriteLine("{0:0.000000000000}", info.Area.Top);
                        world.Close();
                    }
                }

                if (info.MakeKmz)
                {
                    var kmzFile = Path.GetDirectoryName(bigImage) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(bigImage) + ".kmz";
                    e.Result = kmzFile;

                    using (ZipStorer zip = ZipStorer.Create(kmzFile, "GMap.NET"))
                    {
                        zip.AddFile(ZipStorer.Compression.Store, bigImage, "files/map.jpg", "map");

                        using (var readme = new MemoryStream(
                                   Encoding.UTF8.GetBytes(
                                       string.Format(CultureInfo.InvariantCulture, @"<?xml version=""1.0"" encoding=""UTF-8""?> 
<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">
<GroundOverlay>
	<name>{8}</name>
	<LookAt>
		<longitude>{6}</longitude>
		<latitude>{7}</latitude>
		<altitude>0</altitude>
		<heading>0</heading>
		<tilt>0</tilt>
		<range>69327.55500845652</range>
	</LookAt>
	<color>91ffffff</color>
	<Icon>
		<href>files/map.jpg</href>
	</Icon>
	<gx:LatLonQuad>
		<coordinates>
			{0},{1},0 {2},{3},0 {4},{5},0 {6},{7},0 
		</coordinates>
	</gx:LatLonQuad>
</GroundOverlay>
</kml>", info.Area.Left, info.Area.Bottom,
                                                     info.Area.Right, info.Area.Bottom,
                                                     info.Area.Right, info.Area.Top,
                                                     info.Area.Left, info.Area.Top,
                                                     kmzFile))))
                        {
                            zip.AddStream(ZipStorer.Compression.Store, "doc.kml", readme, DateTime.Now, "kml");
                            zip.Close();
                        }
                    }
                }
            }
        }
Ejemplo n.º 43
0
        private static BaseLabel CreateLabel(FeatureDataRow fdr, Geometry feature, string text, float rotation, int priority, LabelStyle style, MapViewport map, Graphics g, GetLocationMethod _getLocationMethod)
        {
            if (feature == null)
            {
                return(null);
            }

            BaseLabel lbl  = null;
            var       font = style.GetFontForGraphics(g);

            SizeF size = VectorRenderer.SizeOfString(g, text, font);

            if (feature is ILineal)
            {
                if (feature is LineString line)
                {
                    if (style.IsTextOnPath == false)
                    {
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || style.IgnoreLength)
                        {
                            var positiveLineString = PositiveLineString(line, false);
                            var lineStringPath     = LineStringToPath(positiveLineString, map /*, false*/);
                            var rect = lineStringPath.GetBounds();

                            if (style.CollisionDetection && !style.CollisionBuffer.IsEmpty)
                            {
                                var cbx = style.CollisionBuffer.Width;
                                var cby = style.CollisionBuffer.Height;
                                rect.Inflate(2 * cbx, 2 * cby);
                                rect.Offset(-cbx, -cby);
                            }
                            var labelBox = new LabelBox(rect);

                            lbl = new PathLabel(text, lineStringPath, 0, priority, labelBox, style);
                        }
                    }
                    else
                    {
                        //get centriod
                        System.Drawing.PointF position2 = map.WorldToImage(feature.EnvelopeInternal.Centre);
                        lbl = new Label(text, position2, rotation, priority, style);
                        if (size.Width < 0.95 * line.Length / map.PixelWidth || !style.IgnoreLength)
                        {
                            CalculateLabelAroundOnLineString(line, ref lbl, map, g, size);
                        }
                    }
                }
                return(lbl);
            }

            var worldPosition = _getLocationMethod == null
                ? feature.EnvelopeInternal.Centre
                : _getLocationMethod(fdr);

            if (worldPosition == null)
            {
                return(null);
            }

            var position = map.WorldToImage(worldPosition);

            var location = new PointF(
                position.X - size.Width * (short)style.HorizontalAlignment * 0.5f,
                position.Y - size.Height * (short)(2 - (int)style.VerticalAlignment) * 0.5f);

            if (location.X - size.Width > map.Size.Width || location.X + size.Width < 0 ||
                location.Y - size.Height > map.Size.Height || location.Y + size.Height < 0)
            {
                return(null);
            }

            if (!style.CollisionDetection)
            {
                lbl = new Label(text, location, rotation, priority, null, style)
                {
                    LabelPoint = position
                }
            }
            ;
            else
            {
                //Collision detection is enabled so we need to measure the size of the string
                lbl = new Label(text, location, rotation, priority,
                                new LabelBox(location.X - style.CollisionBuffer.Width,
                                             location.Y - style.CollisionBuffer.Height,
                                             size.Width + 2f * style.CollisionBuffer.Width,
                                             size.Height + 2f * style.CollisionBuffer.Height), style)
                {
                    LabelPoint = position
                };
            }

            /*
             * if (feature is LineString)
             * {
             *  var line = feature as LineString;
             *
             *  //Only label feature if it is long enough, or it is definately wanted
             *  if (line.Length / map.PixelSize > size.Width || style.IgnoreLength)
             *  {
             *      CalculateLabelOnLinestring(line, ref lbl, map);
             *  }
             *  else
             *      return null;
             * }
             */
            return(lbl);
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Converts the specified GDI <see cref="GdiPointF"/> to a <see cref="PointF"/>.</summary>
        /// <param name="point">
        /// The GDI <see cref="GdiPointF"/> instance to convert.</param>
        /// <returns>
        /// A new <see cref="PointF"/> instance whose coordinates equal those of the specified
        /// <paramref name="point"/>.</returns>

        public static PointF ToPointF(this GdiPointF point)
        {
            return(new PointF(point.X, point.Y));
        }
Ejemplo n.º 45
0
 public static Point ToEtoPoint(this sd.PointF point)
 {
     return(new Point((int)point.X, (int)point.Y));
 }
Ejemplo n.º 46
0
 protected override void setPosition(System.Drawing.PointF position)
 {
     ImageView.SetX(position.X);
     ImageView.SetY(position.Y);
 }
Ejemplo n.º 47
0
        static void Main(string[] args)
        {
            String      apiKey      = "847e6315f892e21449da5f4077c5104f";
            String      apiSecret   = "BmskojfFyrZVQhkLfNSnRzX-lK8musO6";
            FaceService faceService = new FaceService(apiKey, apiSecret);

            string       filePath     = "D:\\Codes\\datasets\\face_morph\\bbt.jpg";
            DetectResult detectResult = faceService.Detection_DetectImg(filePath);

            Image <Bgr, Byte> srcImg = new Image <Bgr, Byte>(filePath);

            for (int cnt = 0; cnt < detectResult.face.Count; cnt++)
            {
                string       pointFileName = String.Format("D:\\Codes\\datasets\\face_morph\\result_bbt_face_{0}.txt", cnt);
                FileStream   fileStream    = new FileStream(pointFileName, FileMode.Create);
                StreamWriter streamWriter  = new StreamWriter(fileStream);

                Rectangle faceRect = new Rectangle(
                    (int)(detectResult.face[cnt].position.center.x * srcImg.Width / 100 - detectResult.face[cnt].position.width * srcImg.Width * 0.5 / 100),
                    (int)(detectResult.face[cnt].position.center.y * srcImg.Height / 100 - detectResult.face[cnt].position.height * srcImg.Height * 0.5 / 100),
                    (int)detectResult.face[cnt].position.width * srcImg.Width / 100,
                    (int)detectResult.face[cnt].position.height * srcImg.Height / 100);

                Image <Bgr, byte> faceImg = srcImg.GetSubRect(faceRect);

                string fileName = String.Format("D:\\Codes\\datasets\\face_morph\\result_bbt_face_{0}.jpg", cnt);
                faceImg.Save(fileName);

                IList <FaceppSDK.Point> featurePoints = new List <FaceppSDK.Point>();
                //featurePoints.Add(detectResult.face[cnt].position.center);
                FaceppSDK.Point tempPoint1 = new FaceppSDK.Point();
                tempPoint1.x = (detectResult.face[cnt].position.eye_left.x
                                - detectResult.face[cnt].position.center.x) / detectResult.face[cnt].position.width;
                tempPoint1.y = (detectResult.face[cnt].position.eye_left.y
                                - detectResult.face[cnt].position.center.y) / detectResult.face[cnt].position.height;
                featurePoints.Add(tempPoint1);

                FaceppSDK.Point tempPoint2 = new FaceppSDK.Point();
                tempPoint2.x = (detectResult.face[cnt].position.eye_right.x
                                - detectResult.face[cnt].position.center.x) / detectResult.face[cnt].position.width;
                tempPoint2.y = (detectResult.face[cnt].position.eye_right.y
                                - detectResult.face[cnt].position.center.y) / detectResult.face[cnt].position.height;
                featurePoints.Add(tempPoint2);

                FaceppSDK.Point tempPoint3 = new FaceppSDK.Point();
                tempPoint3.x = (detectResult.face[cnt].position.mouth_left.x
                                - detectResult.face[cnt].position.center.x) / detectResult.face[cnt].position.width;
                tempPoint3.y = (detectResult.face[cnt].position.mouth_left.y
                                - detectResult.face[cnt].position.center.y) / detectResult.face[cnt].position.height;
                featurePoints.Add(tempPoint3);

                FaceppSDK.Point tempPoint4 = new FaceppSDK.Point();
                tempPoint4.x = (detectResult.face[cnt].position.mouth_right.x
                                - detectResult.face[cnt].position.center.x) / detectResult.face[cnt].position.width;
                tempPoint4.y = (detectResult.face[cnt].position.mouth_right.y
                                - detectResult.face[cnt].position.center.y) / detectResult.face[cnt].position.height;
                featurePoints.Add(tempPoint4);

                FaceppSDK.Point tempPoint5 = new FaceppSDK.Point();
                tempPoint5.x = (detectResult.face[cnt].position.nose.x
                                - detectResult.face[cnt].position.center.x) / detectResult.face[cnt].position.width;
                tempPoint5.y = (detectResult.face[cnt].position.nose.y
                                - detectResult.face[cnt].position.center.y) / detectResult.face[cnt].position.height;
                featurePoints.Add(tempPoint5);

                foreach (FaceppSDK.Point featurePoint in featurePoints)
                {
                    streamWriter.WriteLine(featurePoint.x.ToString());
                    streamWriter.WriteLine(featurePoint.y.ToString());

                    System.Drawing.PointF point = new System.Drawing.PointF((float)featurePoint.x * srcImg.Width / 100,
                                                                            (float)featurePoint.y * srcImg.Height / 100);
                    Cross2DF cross = new Cross2DF(point, (float)3.0, (float)3.0);
                    srcImg.Draw(cross, new Bgr(0, 255, 0), 3);
                }

                streamWriter.Flush();
                streamWriter.Close();
                fileStream.Close();
                //srcImg.Save("D:\\Codes\\datasets\\face_morph\\result_bbt.jpg");
            }
        }
Ejemplo n.º 48
0
        private bool LineIntersectsLine(System.Drawing.PointF l1p1, System.Drawing.PointF l1p2, System.Drawing.PointF l2p1, System.Drawing.PointF l2p2)
        {
            float q = (l1p1.Y - l2p1.Y) * (l2p2.X - l2p1.X) - (l1p1.X - l2p1.X) * (l2p2.Y - l2p1.Y);
            float d = (l1p2.X - l1p1.X) * (l2p2.Y - l2p1.Y) - (l1p2.Y - l1p1.Y) * (l2p2.X - l2p1.X);

            if (d == 0)
            {
                return(false);
            }

            float r = q / d;

            q = (l1p1.Y - l2p1.Y) * (l1p2.X - l1p1.X) - (l1p1.X - l2p1.X) * (l1p2.Y - l1p1.Y);
            float s = q / d;

            if (r < 0 || r > 1 || s < 0 || s > 1)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 49
0
 public void ProccessMouse(System.Drawing.PointF mousePosition)
 {
     ProccessMouse(mousePosition.X, mousePosition.Y);
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Adds new point to unfinished object.
 /// </summary>
 /// <param name="p"></param>
 public void Add(CanvasPoint p)
 {
     points.Add(p);
 }
Ejemplo n.º 51
0
        static System.Drawing.PointF FindCutPoint(
            System.Drawing.PointF p0, System.Drawing.PointF p1,
            System.Drawing.PointF p2, System.Drawing.PointF p3)
        {
            //find cut point of 2 line
            //y = mx + b
            //from line equation
            //y = mx + b ... (1)
            //from (1)
            //b = y- mx ... (2)
            //----------------------------------
            //line1:
            //y1 = (m1 * x1) + b1 ...(3)
            //line2:
            //y2 = (m2 * x2) + b2 ...(4)
            //----------------------------------
            //from (3),
            //b1 = y1 - (m1 * x1) ...(5)
            //b2 = y2 - (m2 * x2) ...(6)
            //----------------------------------
            //at cutpoint of line1 and line2 => (x1,y1)== (x2,y2)
            //or find (x,y) where (3)==(4)
            //----------------------------------
            //at cutpoint, find x
            // (m1 * x1) + b1 = (m2 * x1) + b2  ...(11), replace x2 with x1
            // (m1 * x1) - (m2 * x1) = b2 - b1  ...(12)
            //  x1 * (m1-m2) = b2 - b1          ...(13)
            //  x1 = (b2-b1)/(m1-m2)            ...(14), now we know x1
            //----------------------------------
            //at cutpoint, find y
            //  y1 = (m1 * x1) + b1 ... (15), replace x1 with value from (14)
            //Ans: (x1,y1)
            //----------------------------------

            double y1diff = p1.Y - p0.Y;
            double x1diff = p1.X - p0.X;


            if (x1diff == 0)
            {
                //90 or 180 degree
                return(new System.Drawing.PointF(p1.X, p2.Y));
            }
            //------------------------------
            //
            //find slope
            double m1 = y1diff / x1diff;
            //from (2) b = y-mx, and (5)
            //so ...
            double b1 = p0.Y - (m1 * p0.X);

            //------------------------------
            double y2diff = p3.Y - p2.Y;
            double x2diff = p3.X - p2.X;
            double m2     = y2diff / x2diff;

            //
            //from (6)
            double b2 = p2.Y - (m2) * p2.X;
            //find cut point

            //check if (m1-m2 !=0)
            double cutx = (b2 - b1) / (m1 - m2); //from  (14)
            double cuty = (m1 * cutx) + b1;      //from (15)

            return(new System.Drawing.PointF((float)cutx, (float)cuty));
        }
Ejemplo n.º 52
0
        private static bool _ProcessControl(System.Drawing.PointF mousePosition, Control control, bool ignore_rect)
        {
            // ignore_rect will call mouse_up & mouse_move in any case.
            var c_location = control.PointToScreen(System.Drawing.Point.Zero);
            var clientRect = new System.Drawing.RectangleF(c_location.X, c_location.Y, control.Width, control.Height);
            var contains   = clientRect.Contains(mousePosition);

            if (contains && (_mouseEvent == MouseEvents.Down) || _mouseEvent == MouseEvents.Up)
            {
                if (control.Parent != null)
                {
                    bool ok             = true;
                    var  clickedControl = _ParentContains(control, mousePosition, control, ref ok);
                    if (clickedControl != null && ok == false)
                    {
                        control = clickedControl;
                    }
                }
            }

            if (ignore_rect || contains)
            {
                var client_mpos = control.PointToClient(mousePosition);
                if (mousePositionChanged)
                {
                    MouseEventArgs m_args = new MouseEventArgs(MouseButtons.None, 0, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseMove(m_args);
                    if (_dragData != null)
                    {
                        _dragndrop = true;
                    }
                }

                if (!contains && _mouseEvent != MouseEvents.Up)
                {
                    return(true);
                }
                switch (_mouseEvent)
                {
                case MouseEvents.Down:
                    MouseEventArgs md_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseDown(md_args);
                    _mouseLastClickControl = control;
                    return(true);

                case MouseEvents.Up:
                    if (_dragndrop)
                    {
                        if (control.AllowDrop)
                        {
                            DataObject    dnd_data = new DataObject(_dragData);
                            DragEventArgs dnd_args = new DragEventArgs(dnd_data, 0, (int)client_mpos.X, (int)client_mpos.Y, DragDropEffects.None, _dragControlEffects);
                            control.RaiseOnDragDrop(dnd_args);
                        }
                        _dragData  = null;
                        _dragndrop = false;
                    }
                    MouseEventArgs mu_args = new MouseEventArgs(_mouseButton, 1, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseUp(mu_args);
                    if (_mouseLastClickControl == control)
                    {
                        control.RaiseOnMouseClick(mu_args);
                    }
                    if (_mouseLastClickControl != null && control != _mouseLastClickControl)
                    {
                        _mouseLastClickControl.RaiseOnMouseUp(mu_args);
                    }
                    return(true);

                case MouseEvents.DoubleClick:
                    MouseEventArgs mdc_args = new MouseEventArgs(_mouseButton, 2, (int)client_mpos.X, (int)client_mpos.Y, 0);
                    control.RaiseOnMouseDoubleClick(mdc_args);
                    return(true);

                case MouseEvents.Wheel:
                    MouseEventArgs mw_args = new MouseEventArgs(MouseButtons.Middle, 0, (int)client_mpos.X, (int)client_mpos.Y, (int)(-_mouseWheelDelta * 4));
                    control.RaiseOnMouseWheel(mw_args);
                    return(true);
                }
            }
            if (!contains)
            {
                control.RaiseOnMouseLeave(null);
            }
            return(false);
        }
Ejemplo n.º 53
0
 public static IS.PointF ToPointF(SD.PointF value, Matrix3x2 matrix)
 {
     return(IS.PointF.Transform(new IS.PointF(value.X, value.Y), matrix));
 }
Ejemplo n.º 54
0
        /// <summary>
        /// NS, 2013-12-02, draw circle inside polygon
        /// </summary>
        /// <param name="g"></param>
        /// <param name="pol"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        /// <param name="clip"></param>
        /// <param name="map"></param>
        /// <param name="circleline"></param>
        /// <param name="drawcircle"></param>
        /// <param name="radius"></param>
        public static void DrawPolygonWithCircle(System.Drawing.Graphics g, IPolygon pol, System.Drawing.Brush brush,
                                                 System.Drawing.Pen pen, bool clip, SharpMap.Map map, System.Drawing.Pen circleline, bool drawcircle, int radius)
        {
            try
            {
                if (pol.Shell == null)
                {
                    return;
                }
                if (pol.Shell.Coordinates.Length > 2)
                {
                    if (drawcircle)
                    {
                        System.Drawing.PointF pp = SharpMap.Utilities.Transform.WorldtoMap(pol.Centroid.Coordinate, map);
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.DrawEllipse(circleline, (pp.X - radius), (pp.Y - radius), radius * 2f, radius * 2f);
                    }

                    //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
                    System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

                    //Add the exterior polygon
                    if (!clip)
                    {
                        gp.AddPolygon(Transform.TransformToImage(pol.Shell, map));
                    }
                    //gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Shell, map), extremeValueLimit));
                    else
                    {
                        gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Shell, map), map.Size.Width, map.Size.Height));
                    }

                    //Add the interior polygons (holes)
                    for (int i = 0; i < pol.Holes.Length; i++)
                    {
                        if (!clip)
                        {
                            gp.AddPolygon(Transform.TransformToImage(pol.Holes[i], map));
                        }
                        //gp.AddPolygon(LimitValues(Transform.TransformToImage(pol.Holes[i], map), extremeValueLimit));
                        else
                        {
                            gp.AddPolygon(clipPolygon(Transform.TransformToImage(pol.Holes[i], map), map.Size.Width, map.Size.Height));
                        }
                    }

                    // Only render inside of polygon if the brush isn't null or isn't transparent
                    if (brush != null && brush != System.Drawing.Brushes.Transparent)
                    {
                        g.FillPath(brush, gp);
                    }
                    // Create an outline if a pen style is available
                    if (pen != null)
                    {
                        g.DrawPath(pen, gp);
                    }
                }
            }
            catch (InvalidOperationException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
            catch (OverflowException e)
            {
                log.WarnFormat("Error during rendering", e);
            }
        }
Ejemplo n.º 55
0
        /// <summary>
        /// Do not use with MOVEX or MOVEY at same time!
        /// </summary>
        public override void Move(EasingType easingEnum, int startTime, int endTime, Gdip.PointF startPoint, Gdip.PointF endPoint)
        {
            if (_movTime.Max == int.MaxValue || endTime >= _movTime.Max)
            {
                _movTime.Max = endTime;
                _x.Target    = endPoint.X;
                _y.Target    = endPoint.Y;
            }

            if (_movTime.Min == int.MinValue || startTime <= _movTime.Min)
            {
                _movTime.Min = startTime;
                _x.Source    = startPoint.X;
                _y.Source    = startPoint.Y;
            }

            float ms = Offset;

            if (!IsFinished && ms <= _movTime.Min)
            {
                _x.RealTimeToSource();
                _y.RealTimeToSource();
            }

            if (!IsFinished && ms >= startTime && ms <= endTime)
            {
                var t = (ms - startTime) / (endTime - startTime);
                _x.RealTime = startPoint.X + (float)easingEnum.Ease(t) * (endPoint.X - startPoint.X);
                _y.RealTime = startPoint.Y + (float)easingEnum.Ease(t) * (endPoint.Y - startPoint.Y);
            }

            if (ms >= _movTime.Max)
            {
                _x.RealTimeToTarget();
                _y.RealTimeToTarget();
            }
        }
Ejemplo n.º 56
0
        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="g">Graphics reference</param>
        /// <param name="LabelPoint">Label placement</param>
        /// <param name="Offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="map">Map reference</param>
        public static void DrawLabel(System.Drawing.Graphics g, System.Drawing.PointF LabelPoint, System.Drawing.PointF Offset, System.Drawing.Font font, System.Drawing.Color forecolor, System.Drawing.Brush backcolor, System.Drawing.Pen halo, float rotation, string text, SharpMap.Map map)
        {
            System.Drawing.SizeF fontSize = g.MeasureString(text, font);    //Calculate the size of the text
            LabelPoint.X += Offset.X; LabelPoint.Y += Offset.Y;             //add label offset
            if (rotation != 0 && rotation != float.NaN)
            {
                g.TranslateTransform(LabelPoint.X, LabelPoint.Y);
                g.RotateTransform(rotation);
                g.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                {
                    g.FillRectangle(backcolor, 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                }
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                {
                    g.DrawPath(halo, path);
                }
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
                g.Transform = map.MapTransform;
            }
            else
            {
                if (backcolor != null && backcolor != System.Drawing.Brushes.Transparent)
                {
                    g.FillRectangle(backcolor, LabelPoint.X, LabelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);
                }

                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

                path.AddString(text, font.FontFamily, (int)font.Style, font.Size, LabelPoint, null);
                if (halo != null)
                {
                    g.DrawPath(halo, path);
                }
                g.FillPath(new System.Drawing.SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
Ejemplo n.º 57
0
        public static IS.Point ToPoint(SD.PointF value, Matrix3x2 matrix)
        {
            var tmp = ToPointF(value, matrix);

            return(new IS.Point((int)tmp.X, (int)tmp.Y));
        }
Ejemplo n.º 58
0
 public static EllipsePolygon ToEllipsePolygon(SD.PointF position, SD.SizeF size, Matrix3x2 matrix)
 {
     return(new EllipsePolygon(ToPointF(position), ToSizeF(size)).Transform(matrix));
 }
Ejemplo n.º 59
0
        static System.Drawing.PointF FindCutPoint(System.Drawing.PointF p0, System.Drawing.PointF p1, System.Drawing.PointF p2, float cutAngle)
        {
            //a line from p0 to p1
            //p2 is any point
            //return p3 -> cutpoint on p0,p1

            //from line equation
            //y = mx + b ... (1)
            //from (1)
            //b = y- mx ... (2)
            //----------------------------------
            //line1:
            //y1 = (m1 * x1) + b1 ...(3)
            //line2:
            //y2 = (m2 * x2) + b2 ...(4)
            //----------------------------------
            //from (3),
            //b1 = y1 - (m1 * x1) ...(5)
            //b2 = y2 - (m2 * x2) ...(6)
            //----------------------------------
            //y1diff = p1.Y-p0.Y  ...(7)
            //x1diff = p1.X-p0.X  ...(8)
            //
            //m1 = (y1diff/x1diff) ...(9)
            //m2 = cutAngle of m1 ...(10)
            //
            //replace value (x1,y1) and (x2,y2)
            //we know b1 and b2
            //----------------------------------
            //at cutpoint of line1 and line2 => (x1,y1)== (x2,y2)
            //or find (x,y) where (3)==(4)
            //----------------------------------
            //at cutpoint, find x
            // (m1 * x1) + b1 = (m2 * x1) + b2  ...(11), replace x2 with x1
            // (m1 * x1) - (m2 * x1) = b2 - b1  ...(12)
            //  x1 * (m1-m2) = b2 - b1          ...(13)
            //  x1 = (b2-b1)/(m1-m2)            ...(14), now we know x1
            //----------------------------------
            //at cutpoint, find y
            //  y1 = (m1 * x1) + b1 ... (15), replace x1 with value from (14)
            //Ans: (x1,y1)
            //----------------------------------

            double y1diff = p1.Y - p0.Y;
            double x1diff = p1.X - p0.X;

            if (x1diff == 0)
            {
                //90 or 180 degree
                return(new System.Drawing.PointF(p1.X, p2.Y));
            }
            //------------------------------
            //
            //find slope
            double m1 = y1diff / x1diff;
            //from (2) b = y-mx, and (5)
            //so ...
            double b1 = p0.Y - (m1 * p0.X);
            //
            //from (10)
            //double invert_m = -(1 / slope_m);
            //double m2 = -1 / m1;   //rotate m1
            //---------------------
            double angle = Math.Atan2(y1diff, x1diff); //rad in degree
                                                       //double m2 = -1 / m1;

            double m2 = cutAngle == 90 ?
                        //short cut
                        (-1 / m1) :
                        //or
                        Math.Tan(
                //radial_angle of original line + radial of cutAngle
                //return new line slope
                Math.Atan2(y1diff, x1diff) +
                DegreesToRadians(cutAngle)); //new m
            //---------------------


            //from (6)
            double b2 = p2.Y - (m2) * p2.X;
            //find cut point

            //check if (m1-m2 !=0)
            double cutx = (b2 - b1) / (m1 - m2); //from  (14)
            double cuty = (m1 * cutx) + b1;      //from (15)

            return(new System.Drawing.PointF((float)cutx, (float)cuty));


            //------
            //at cutpoint of line1 and line2 => (x1,y1)== (x2,y2)
            //or find (x,y) where (3)==(4)
            //-----
            //if (3)==(4)
            //(m1 * x1) + b1 = (m2 * x2) + b2;
            //from given p0 and p1,
            //now we know m1 and b1, ( from (2),  b1 = y1-(m1*x1) )
            //and we now m2 since => it is a 90 degree of m1.
            //and we also know x2, since at the cut point x2 also =x1
            //now we can find b2...
            // (m1 * x1) + b1 = (m2 * x1) + b2  ...(5), replace x2 with x1
            // b2 = (m1 * x1) + b1 - (m2 * x1)  ...(6), move  (m2 * x1)
            // b2 = ((m1 - m2) * x1) + b1       ...(7), we can find b2
            //---------------------------------------------
        }
Ejemplo n.º 60
0
 public static IS.PointF ToPointF(SD.PointF value)
 {
     return(new IS.PointF(value.X, value.Y));
 }