Line with specific angle

المشرف العام

Administrator
طاقم الإدارة
I've created a line by mouse click event when I click on the second point I need two lines at an angle of 28 degrees from the first line how should I do it?.

IPoint point1; IPoint point2;

protected override void OnMouseDown(MouseEventArgs arg) { IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument; IGraphicsContainer gContiner = mxdoc.FocusMap as IGraphicsContainer; IDisplayTransformation dispTransformation = mxdoc.ActiveView.ScreenDisplay.DisplayTransformation; if (point1 == null) { point1 = dispTransformation.ToMapPoint(arg.X, arg.Y); IRgbColor color = new RgbColorClass(); color.Red = 0; color.Blue = 255; color.Green = 0; IRgbColor outlineColor = new RgbColorClass(); outlineColor.Red = 0; outlineColor.Blue = 255; outlineColor.Green = 0; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineSize = 1.5; simpleMarkerSymbol.OutlineColor = outlineColor; simpleMarkerSymbol.Size = 9; if (arg.Button == System.Windows.Forms.MouseButtons.Left) { simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; } else if (arg.Button == System.Windows.Forms.MouseButtons.Right) { simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; } IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; IElement element = (IElement)markerElement; element.Geometry = point1; gContiner.AddElement(element, 0); mxdoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } else if (point2 == null) { point2 = dispTransformation.ToMapPoint(arg.X, arg.Y); IRgbColor colortarget = new RgbColorClass(); colortarget.Red = 255; colortarget.Blue = 0; colortarget.Green = 0; IRgbColor outlineColortarget = new RgbColorClass(); outlineColortarget.Red = 0; outlineColortarget.Blue = 255; outlineColortarget.Green = 0; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = colortarget; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineSize = 1.5; simpleMarkerSymbol.OutlineColor = outlineColortarget; simpleMarkerSymbol.Size = 9; if (arg.Button == System.Windows.Forms.MouseButtons.Left) { simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; } else if (arg.Button == System.Windows.Forms.MouseButtons.Right) { simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; } IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; IElement element = (IElement)markerElement; element.Geometry = point2; gContiner.AddElement(element, 0); mxdoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } else { // IPolyline polyline = new PolylineClass(); IPointCollection pointColl = polyline as IPointCollection; pointColl.AddPoint(point1); pointColl.AddPoint(point2); pointColl.AddPoint(point3); IRgbColor color = new RgbColorClass(); color.Red = 0; color.Blue = 0; color.Green = 255; // Create a line symbol ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Width = 3; // Create a line element, this is the graphic that will get added to container IElement element = new LineElement(); element.Geometry = polyline; ILineElement lineElement; lineElement = element as ILineElement; lineElement.Symbol = simpleLineSymbol; gContiner.AddElement(element, 0); mxdoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }

أكثر...
 
أعلى