protected override void OnTick(double delta) { if (m_IsAnimated) { PolygonElement polygon1 = m_PolygonElement1; PolygonElement polygon2 = m_PolygonElement2; double x, y; for (int i = 0; i < 6; i++) { x = polygon1.GetXn(i); y = polygon1.GetYn(i); MovePoint(ref x, ref y, ref m_dx1[i], ref m_dy1[i]); polygon1.SetXn(i, x); polygon1.SetYn(i, y); x = polygon2.GetXn(i); y = polygon2.GetYn(i); MovePoint(ref x, ref y, ref m_dx2[i], ref m_dy2[i]); polygon2.SetXn(i, x); polygon2.SetYn(i, y); NormalizePoint(i); } Refresh(); } base.OnTick(delta); }
public override void OnDblClick() { if (this.inewPolygonFeedback_0 != null) { IPolygon geometry = this.inewPolygonFeedback_0.Stop(); this.inewPolygonFeedback_0 = null; IElement element = new PolygonElement { Geometry = geometry }; INewElementOperation operation = new NewElementOperation { ActiveView = this._context.ActiveView, Element = element, ContainHook = this.method_0() }; this._context.OperationStack.Do(operation); //if (this._context.Hook is IApplication) //{ // if ((this._context.Hook as IApplication).ContainerHook != null) // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).ContainerHook); // } // else // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).Hook); // } //} //else //{ // DocumentManager.DocumentChanged(this._context.Hook); //} } }
protected override void OnPaint(GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.None; PolygonElement polygon = m_PolygonElement; if (!polygon.IsModified) { //TEST return; } polygon.close(m_CloseCheckBox.IsChecked); PolylineGeometry poly = new PolylineGeometry(polygon.Polygon, true, m_CloseCheckBox.IsChecked); BSplineGeometry bspline = new BSplineGeometry(poly); bspline.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; SinglePathTransform tcurve = new SinglePathTransform(); tcurve.PreserveXScale = m_PreserveXScaleCheckBox.IsChecked; if (m_FixedLenCheckBox.IsChecked) { tcurve.BaseLength = 1120; } tcurve.AddPath(bspline); GeometryTransformer ftrans = new GeometryTransformer(GetCurveTransformedTextGeometry(tcurve.TotalLength).Item1, tcurve); if (m_FillCheckBox.IsChecked) { Brush brush = m_TextBrush; // Irrlicht Renderer can't render smoothed gradients now if (graphics.RenderSystemName.Contains(Graphics.RSN_Irrlicht)) { if (m_TextBrush_Irrlicht == null) { m_TextBrush_Irrlicht = new SolidColorBrush(Color.Yellow); } brush = m_TextBrush_Irrlicht; } graphics.FillGeometry(brush, ftrans); } if (m_OutlineCheckBox.IsChecked) { graphics.DrawGeometry(m_FillCheckBox.IsChecked ? Color.Red : Color.White, ftrans, m_OutlineThicknessSlider.Value); } graphics.DrawGeometry(m_BSplinePen, bspline); base.OnPaint(e); }
private void AddPolygonElement(IGeometry geo, IActiveView pAV) { IElement pElem = new PolygonElement(); pElem.Geometry = geo; ISimpleFillSymbol pSFSym = new SimpleFillSymbol(); Color color = ColorTranslator.FromHtml(SystemInfo.Instance.FillColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; pSFSym.Color = pColor; pSFSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; ISimpleLineSymbol pSLSym = new SimpleLineSymbol(); pSLSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLSym.Width = 1; pSLSym.Color = pColor; pSFSym.Outline = pSLSym; IFillShapeElement pElemFillShp = pElem as IFillShapeElement; pElemFillShp.Symbol = pSFSym; pGraphicsContainer = pAV as IGraphicsContainer; pGraphicsContainer.AddElement(pElem, 0); }
private void OnOnDoubleClick(int button, int shift, int i, int i1, double mapX, double mapY) { if (button == 2) { return; } if (_polygonFeedback == null) { return; } IPoint point = new PointClass(); point.PutCoords(mapX, mapY); _polygonFeedback.AddPoint(point); _polygon = _polygonFeedback.Stop(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10); simpleFillSymbolClass.Color = (rgbColorClass); IElement element = new PolygonElement(); element.Geometry = _polygon; ((IFillShapeElement)element).Symbol = simpleFillSymbolClass; _graphicsContainer.DeleteAllElements(); _graphicsContainer.AddElement(element, 100); _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); OnDrawCompleteEvent(); //_polygon = null; _polygonFeedback = null; }
public void createPointBuffer() { // ITopologicalOperator ===> IGeometry as ITopologicalOperator IGeometry geometry = axMapControl1.TrackLine(); // IRubberBand ---- 橡皮筋 ITopologicalOperator topoOper = geometry as ITopologicalOperator; IPolygon geoPolygon = topoOper.Buffer(1) as IPolygon; // IElement // 创建符号 ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; //pSimpleLineSymbol.Color = GetRGBColor(46, 24, 63);// Common.GetRGBColor(46, 24, 63); ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol(); //pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145); pSimpleFillSymbol.Outline = pSimpleLineSymbol; // 创建Element并赋值图形和符号 IFillShapeElement pPolygonElement = new PolygonElement() as IFillShapeElement; IElement pElement = (IElement)pPolygonElement; pElement.Geometry = geoPolygon; pPolygonElement.Symbol = pSimpleFillSymbol; // 添加到IGraphicsContainer容器 IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map; pGraphicsContainer.AddElement((IElement)pPolygonElement, 0); axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void button2_Click(object sender, EventArgs e) { IActiveView pIActiveView = pmapcontrol.Map as IActiveView; IGraphicsContainer pIGraphicsContainer = pIActiveView.GraphicsContainer; pIGraphicsContainer.DeleteAllElements(); IFeatureLayer pIFeatureLayer = pmapcontrol.get_Layer(0) as IFeatureLayer; IFeatureCursor pIFeatureCursor = pIFeatureLayer.FeatureClass.Search(null, false); IFeature pfeature = pIFeatureCursor.NextFeature(); while (pfeature != null) { ITopologicalOperator pITopologicalOperator = pfeature.Shape as ITopologicalOperator; IPolygon pPolygon = pITopologicalOperator.Buffer(double.Parse(textBox1.Text)) as IPolygon; IElement pIElement = new PolygonElement(); pIElement.Geometry = pPolygon; pIGraphicsContainer.AddElement(pIElement, 0); pfeature = pIFeatureCursor.NextFeature(); } pmapcontrol.Refresh(); this.Close(); }
public void createDrawPolygon() { // 创建图形 IPolygon pPolygon = new Polygon() as IPolygon; IRubberBand pRubberBand = new RubberPolygon(); pPolygon = (IPolygon)pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null); // 创建符号 ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; //pSimpleLineSymbol.Color = GetRGBColor(46, 24, 63);// Common.GetRGBColor(46, 24, 63); ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol(); //pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145); pSimpleFillSymbol.Outline = pSimpleLineSymbol; // 创建Element并赋值图形和符号 IFillShapeElement pPolygonElement = new PolygonElement() as IFillShapeElement; IElement pElement = (IElement)pPolygonElement; pElement.Geometry = pPolygon; pPolygonElement.Symbol = pSimpleFillSymbol; // 添加到IGraphicsContainer容器 IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map; pGraphicsContainer.AddElement((IElement)pPolygonElement, 0); axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
//private PointF ControlLocationToImage(PointF p) //{ // PointF point = new PointF(); // point.X = (float)(p.X - imageLocationRectF.X) / ImageScale; // point.Y = (float)(p.Y - imageLocationRectF.Y) / ImageScale; // return point; //} //private PointF ControlLocationToImage(Point p) //{ // PointF point = new PointF(); // point.X = (float)((float)p.X - imageLocationRectF.X) / ImageScale; // point.Y = (float)((float)p.Y - imageLocationRectF.Y) / ImageScale; // return point; //} //private PointF ImageLocationToControl(PointF p) //{ // Point point = new Point(); // point.X = (int)(p.X*ImageScale + imageLocationRectF.X); // point.Y = (int)(p.Y * ImageScale + imageLocationRectF.Y); // return point; //} #endregion #region 标事件 private void LvImageView_MouseClick(object sender, MouseEventArgs e) { PointF p = Coordinate.CoordinateTransport(e.Location, Coordinate.BaseCoornidate, imageElement.coordinate); if (ImageViewState == ImageViewState.Draw)//绘制模式 { if (e.Button == MouseButtons.Left) { this.SelectElement(this.drawingElement); if (MouseState == MouseState.Idle) { MouseState = MouseState.Operating; drawingElement.Visible = true; } //如果添加了最后一个点 if (drawingElement.AddKeyPoint(p)) { MouseState = MouseState.Idle; this.ElementCreateEventHandler(drawingElement);//触发事件 if (this.ContinuousDraw) { CreateElement(this.DrawingElementType); } else { drawingElement = null; this.ImageViewState = ImageViewState.Normal; } } } else if (e.Button == MouseButtons.Right) { if (drawingElement is PolygonElement) { PolygonElement polygon = drawingElement as PolygonElement; if (polygon.Complete()) { MouseState = MouseState.Idle; this.ElementCreateEventHandler(drawingElement); if (this.ContinuousDraw) { CreateElement(this.DrawingElementType); } else { drawingElement = null; this.ImageViewState = ImageViewState.Normal; } } else { MouseState = MouseState.Idle; this.drawingElement = null; } } } this.Refresh(); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Geometry m_PolygonElement = new PolygonElement(6, 5.0); AddElement(m_PolygonElement); InitPoly(); }
/// <summary> /// 生成缓冲区 /// </summary> /// <param name="pGeometry"></param> /// <returns></returns> public IPolygon GenerateBuffer(IGeometry pGeometry, float Radius) { IGraphicsContainer pGraphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)mapControl.Map; ITopologicalOperator pTopoOp = default(ITopologicalOperator); //拓扑接口,用来根据选择的对象和输入的距离产生缓冲区 IElement pElement = default(IElement); IGeometry geoBuffer = null; if ((pGeometry != null)) { pTopoOp = pGeometry as ITopologicalOperator; IPolygonElement pPolygonElement = new PolygonElement() as IPolygonElement; //PolygonElement pElement = pPolygonElement as IElement; //Generate Buffer geoBuffer = pTopoOp.Buffer((double)Radius) as IGeometry; pElement.Geometry = geoBuffer; //Get the IRGBColor interface IRgbColor pColor = default(IRgbColor); pColor = new RgbColor(); //Set the color properties pColor.RGB = 255; pColor.Transparency = 255; //Get the ILine symbol interface ILineSymbol pOutline = default(ILineSymbol); pOutline = new SimpleLineSymbol(); //Set the line symbol properties pOutline.Width = 2; pOutline.Color = pColor; //Set the color properties pColor = new RgbColor(); pColor.RGB = 255; pColor.Transparency = 0; //Get the IFillSymbol properties IFillSymbol pFillSymbol = new SimpleFillSymbol(); //Set the fill symbol properties pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline; //QI for IFillShapeElement interface through the IElement interface IFillShapeElement pFillShapeElement = pElement as IFillShapeElement; //Set the symbol property pFillShapeElement.Symbol = pFillSymbol; object obj = pFillSymbol as object; //this.axMapControl1.DrawShape(pElement.Geometry,ref obj ); pGraphicsContainer.AddElement(pFillShapeElement as IElement, 0); } mapControl.Refresh(); return(geoBuffer as IPolygon); }
public void AddPolypon(PolygonElement polygon) { polygon.ParentCoordinate = imageElement.coordinate; polygon.ParentElement = imageElement; elements.Add(polygon); baseElements.Add(polygon); for (int i = 0; i < polygon.keyPointList.Count; i++) { baseElements.Add(polygon.keyPointList[i].tractionPoint); } baseElements.Sort(); }
void NormalizePoint(int i) { PolygonElement polygon1 = m_PolygonElement1; PolygonElement polygon2 = m_PolygonElement2; double d = MathHelper.Distance(polygon1.GetXn(i), polygon1.GetYn(i), polygon2.GetXn(i), polygon2.GetYn(i)); double k = 20 * System.Math.Sqrt(2) * 3; if (d > k) { polygon2.SetXn(i, polygon1.GetXn(i) + (polygon2.GetXn(i) - polygon1.GetXn(i)) * k / d); polygon2.SetYn(i, polygon1.GetYn(i) + (polygon2.GetYn(i) - polygon1.GetYn(i)) * k / d); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Transformation Type rbBilinear.Select(); groupBox_TransformationType.SelectionChanged += new GwenEventHandler(groupBox_TransformationType_SelectionChanged); // update groupBox_TransformationType location DrawingPanel_Resize(null, EventArgs.Empty); // m_PolygonElement = new PolygonElement(4, 5.0); m_PolygonElement.Color = Color.FromArgb(200, Color.Yellow); m_PolygonElement.LineWidth = 2; m_DrawingPanel.AddElement(m_PolygonElement); // m_SVGPath = new SVGPath(); m_x = m_DrawingPanel.ClientWidth / 2; m_y = m_DrawingPanel.ClientHeight / 2; m_EllipsePen = new Pen(Color.LightGreen, 3); m_EllipseBrush = new SolidColorBrush(ColorR.FromArgb(0.4, 0.5, 0.3, 0.0)); try { LoadSVG("AltData/SVG/lion.svg"); } catch (SVGException) { //TEMP message(.ToString(e.Message)); return; } }
void InitPoly() { int dx = (ClientRectangle.Width - 2 * InternalOffset) / 5; int dy = (ClientRectangle.Height - 2 * InternalOffset) / 5; PolygonElement polygon = m_PolygonElement1; int x = ClientRectangle.Left + InternalOffset; int y = ClientRectangle.Top + InternalOffset; int k1 = 30; int k2 = 20; polygon.SetXn(0, x + k1); polygon.SetYn(0, y - k1); polygon.SetXn(1, (x += dx) + k1 + k2); polygon.SetYn(1, (y += dy) - k1 - k2); polygon.SetXn(2, (x += dx) + k1 - k2); polygon.SetYn(2, (y += dy) - k1 + k2); polygon.SetXn(3, (x += dx) + k1 + k2); polygon.SetYn(3, (y += dy) - k1 - k2); polygon.SetXn(4, (x += dx) + k1 - k2); polygon.SetYn(4, (y += dy) - k1 + k2); polygon.SetXn(5, (x += dx) + k1); polygon.SetYn(5, (y += dy) - k1); polygon = m_PolygonElement2; x = ClientRectangle.Left + InternalOffset; y = ClientRectangle.Top + InternalOffset; polygon.SetXn(0, x - k1); polygon.SetYn(0, y + k1); polygon.SetXn(1, (x += dx) - k1 + k2); polygon.SetYn(1, (y += dy) + k1 - k2); polygon.SetXn(2, (x += dx) - k1 - k2); polygon.SetYn(2, (y += dy) + k1 + k2); polygon.SetXn(3, (x += dx) - k1 + k2); polygon.SetYn(3, (y += dy) + k1 - k2); polygon.SetXn(4, (x += dx) - k1 - k2); polygon.SetYn(4, (y += dy) + k1 + k2); polygon.SetXn(5, (x += dx) - k1); polygon.SetYn(5, (y += dy) + k1); }
public static void NewPolygonElement(IMap pMap, IPolygon pPolygon) { IActiveView pActiveView = pMap as IActiveView; IGraphicsContainer activeView = (IGraphicsContainer)pActiveView; RubberPolygon rubberPolygonClass = new RubberPolygon(); ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); simpleLineSymbolClass.Color = (rgbColorClass); simpleLineSymbolClass.Width = (8); simpleLineSymbolClass.Style = (esriSimpleLineStyle)(2); PolygonElement polygonElementClass = new PolygonElement(); polygonElementClass.Geometry = (pPolygon); activeView.AddElement(polygonElementClass, 0); pActiveView.PartialRefresh((esriViewDrawPhase)8, null, null); }
protected override void OnTick(double delta) { if (m_IsAnimated) { PolygonElement polygon = m_PolygonElement; double x, y; for (int i = 0; i < 6; i++) { x = polygon.GetXn(i); y = polygon.GetYn(i); MovePoint(ref x, ref y, ref m_dx[i], ref m_dy[i]); polygon.SetXn(i, x); polygon.SetYn(i, y); } Refresh(); } base.OnTick(delta); }
protected override void OnPaint(GUI.PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; PolygonElement polygon = m_PolygonElement; polygon.close(m_CloseCheckBox.IsChecked); PolylineGeometry poly = new PolylineGeometry(polygon.Polygon, true, m_CloseCheckBox.IsChecked); BSplineGeometry bspline = new BSplineGeometry(poly); bspline.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; e.Graphics.DrawGeometry(m_BSplinePen, bspline); base.OnPaint(e); }
void InitPoly() { int dx = (ClientRectangle.Width - 2 * InternalOffset) / 5; int dy = (ClientRectangle.Height - 2 * InternalOffset) / 5; PolygonElement polygon = m_PolygonElement; int x = ClientRectangle.Left + InternalOffset; int y = ClientRectangle.Top + InternalOffset; polygon.SetXn(0, x); polygon.SetYn(0, y); polygon.SetXn(1, (x += dx) + 20); polygon.SetYn(1, (y += dy) - 20); polygon.SetXn(2, (x += dx) - 20); polygon.SetYn(2, (y += dy) + 20); polygon.SetXn(3, (x += dx) + 20); polygon.SetYn(3, (y += dy) - 20); polygon.SetXn(4, (x += dx) - 20); polygon.SetYn(4, (y += dy) + 20); polygon.SetXn(5, (x += dx)); polygon.SetYn(5, (y += dy)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Graphics m_BSplinePen = new Pen(Color.Maroon, 2); m_TextBrush = //Brushes.White; new LinearGradientBrush(Point.Zero, new Point(Width, Height), Color.Red, Color.LawnGreen); // Geometry m_PolygonElement1 = new PolygonElement(6, 5.0); m_PolygonElement1.close(false); AddElement(m_PolygonElement1); m_PolygonElement2 = new PolygonElement(6, 5.0); m_PolygonElement2.close(false); AddElement(m_PolygonElement2); InitPoly(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); TextUpperBaseLine = true; // Graphics m_BSplinePen = new Pen(Color.FromArgb(150, 170, 50, 20), 2); m_TextBrush = //Brushes.White; new LinearGradientBrush(Point.Zero, new Point(Width, Height), Color.Yellow, Color.Cyan); // Geometry m_PolygonElement = new PolygonElement(6, 5.0); AddElement(m_PolygonElement); InitPoly(); // start animation m_AnimateCheckBox.IsChecked = true; }
void InitPoly() { PolygonElement polygon = m_PolygonElement; int offset = 100; int quad = System.Math.Min(ClientRectangle.Width, ClientRectangle.Height); int x = ClientRectangle.X + (ClientRectangle.Width - quad) / 2; int y = ClientRectangle.Y + (ClientRectangle.Height - quad) / 2; if (m_PolygonFlip) { polygon.SetXn(0, x + offset); polygon.SetYn(0, y + quad - offset); polygon.SetXn(1, x + quad - offset); polygon.SetYn(1, y + quad - offset); polygon.SetXn(2, x + quad - offset); polygon.SetYn(2, y + offset); polygon.SetXn(3, x + offset); polygon.SetYn(3, y + offset); } else { polygon.SetXn(0, x + offset); polygon.SetYn(0, y + offset); polygon.SetXn(1, x + quad - offset); polygon.SetYn(1, y + offset); polygon.SetXn(2, x + quad - offset); polygon.SetYn(2, y + quad - offset); polygon.SetXn(3, x + offset); polygon.SetYn(3, y + quad - offset); } polygon.SetXn(4, x + quad / 2); polygon.SetYn(4, y + quad / 2); polygon.SetXn(5, x + quad / 2); polygon.SetYn(5, y + quad / 1.5); }
public static void NewPolygonElementTran(IMap pMap, IPolygon pPolygon, bool bRefresh) { IActiveView pActiveView = pMap as IActiveView; IGraphicsContainer activeView = (IGraphicsContainer)pActiveView; RubberPolygon rubberPolygonClass = new RubberPolygon(); ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); rgbColorClass.Transparency = (1); IRgbColor rgbColor = new RgbColor(); rgbColor.Red = (255); rgbColor.Green = (0); rgbColor.Blue = (0); rgbColor.Transparency = (1); simpleLineSymbolClass.Color = (rgbColorClass); simpleLineSymbolClass.Width = (8); simpleLineSymbolClass.Style = esriSimpleLineStyle.esriSLSSolid; ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10); simpleFillSymbolClass.Color = (rgbColorClass); simpleFillSymbolClass.Color.Transparency = (1); IElement polygonElementClass = new PolygonElement(); polygonElementClass.Geometry = (pPolygon); (polygonElementClass as IFillShapeElement).Symbol = (simpleFillSymbolClass); activeView.AddElement(polygonElementClass, 0); if (bRefresh) { pActiveView.Refresh(); } }
/// <summary> /// 添加图元 /// </summary> /// <param name="pGeometry"></param> /// <param name="pActiveView"></param> /// <param name="pSymbol"></param> /// <param name="key"></param> /// <returns></returns> public IElement AddElement(IGeometry pGeometry, ISymbol pSymbol, string key) { try { IActiveView pActiveView = mapControl.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; IElement pElement = null; ILineElement pLineElement = null; IFillShapeElement pFillShapeElement = null; IMarkerElement pMarkerElement = null; ICircleElement pCircleElement = null; IElementProperties pElmentProperties = null; switch (pGeometry.GeometryType) { case esriGeometryType.esriGeometryEnvelope: { pElement = new RectangleElement(); pElement.Geometry = pGeometry; pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol; break; } case esriGeometryType.esriGeometryPolyline: { pElement = new LineElement(); pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement; pLineElement.Symbol = (ILineSymbol)pSymbol; break; } case esriGeometryType.esriGeometryLine: { pElement = new LineElement(); pElement.Geometry = pGeometry; pLineElement = (ILineElement)pElement; pLineElement.Symbol = (ILineSymbol)pSymbol; break; } case esriGeometryType.esriGeometryPolygon: { pElement = new PolygonElement(); pElement.Geometry = pGeometry; pFillShapeElement = (IFillShapeElement)pElement; pFillShapeElement.Symbol = (IFillSymbol)pSymbol; break; } case esriGeometryType.esriGeometryMultipoint: case esriGeometryType.esriGeometryPoint: { pElement = new MarkerElement(); pElement.Geometry = pGeometry; pMarkerElement = (IMarkerElement)pElement; pMarkerElement.Symbol = (IMarkerSymbol)pSymbol; break; } case esriGeometryType.esriGeometryCircularArc: { pElement = new CircleElement(); pElement.Geometry = pGeometry; pCircleElement = (ICircleElement)pElement; break; } default: pElement = null; break; } if (pElement != null) { pElmentProperties = pElement as IElementProperties; pElmentProperties.Name = key; pGraphicsContainer.AddElement(pElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, pGeometry.Envelope); return(pElement); } else { return(null); } } catch (Exception ex) { return(null); } }
/// <summary> /// 连接表 /// </summary> public IElement CreateJionTab(IActiveView pAV, IPoint Leftdown) { IGroupElement groupElementClass = new GroupElement() as IGroupElement; (groupElementClass as IElementProperties).Name = "接图表"; (groupElementClass as IElementProperties).Type = "接图表"; ILineSymbol lineSymbol = null; double num = this.height / 3; double num1 = this.width / 3; double num2 = 0.3; object missing = System.Type.Missing; IElement lineElementClass = new LineElement(); IElement element = new LineElement(); IElement lineElementClass1 = new LineElement(); IElement element1 = new LineElement(); IElement lineElementClass2 = new LineElement(); IPolyline polylineClass = new Polyline() as IPolyline; IPolyline polyline = new Polyline() as IPolyline; IPolyline polylineClass1 = new Polyline() as IPolyline; IPolyline polyline1 = new Polyline() as IPolyline; IPolyline polylineClass2 = new Polyline() as IPolyline; IPointCollection pointCollection = polylineClass as IPointCollection; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); IPoint point = new ESRI.ArcGIS.Geometry.Point(); IPoint pointClass1 = new ESRI.ArcGIS.Geometry.Point(); IPoint point1 = new ESRI.ArcGIS.Geometry.Point(); try { lineSymbol = this.LineSymbol; (lineElementClass as ILineElement).Symbol = lineSymbol; (element as ILineElement).Symbol = lineSymbol; (lineElementClass1 as ILineElement).Symbol = lineSymbol; (element1 as ILineElement).Symbol = lineSymbol; (lineElementClass2 as ILineElement).Symbol = lineSymbol; point.PutCoords(Leftdown.X, Leftdown.Y + num2); pointClass.PutCoords(Leftdown.X, Leftdown.Y + num2 + this.height); pointClass1.PutCoords(Leftdown.X + this.width, Leftdown.Y + num2); point1.PutCoords(Leftdown.X + this.width, Leftdown.Y + num2 + this.height); pointCollection.AddPoint(pointClass, ref missing, ref missing); pointCollection.AddPoint(point, ref missing, ref missing); pointCollection.AddPoint(pointClass1, ref missing, ref missing); pointCollection.AddPoint(point1, ref missing, ref missing); pointCollection.AddPoint(pointClass, ref missing, ref missing); lineElementClass.Geometry = polylineClass; groupElementClass.AddElement(lineElementClass); IPoint pointClass2 = new ESRI.ArcGIS.Geometry.Point(); IPoint point2 = new ESRI.ArcGIS.Geometry.Point(); pointClass2.PutCoords(pointClass.X, pointClass.Y - num); point2.PutCoords(point1.X, point1.Y - num); pointCollection = polyline as IPointCollection; pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointCollection.AddPoint(point2, ref missing, ref missing); element.Geometry = polyline; groupElementClass.AddElement(element); pointClass2.PutCoords(pointClass.X, pointClass.Y - num * 2); point2.PutCoords(point1.X, point1.Y - num * 2); pointCollection = polylineClass1 as IPointCollection; pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointCollection.AddPoint(point2, ref missing, ref missing); lineElementClass1.Geometry = polylineClass1; groupElementClass.AddElement(lineElementClass1); pointClass2.PutCoords(pointClass.X + num1, pointClass.Y); point2.PutCoords(pointClass.X + num1, point.Y); pointCollection = polyline1 as IPointCollection; pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointCollection.AddPoint(point2, ref missing, ref missing); element1.Geometry = polyline1; groupElementClass.AddElement(element1); pointClass2.PutCoords(pointClass.X + num1 * 2, pointClass.Y); point2.PutCoords(pointClass.X + num1 * 2, point.Y); pointCollection = polylineClass2 as IPointCollection; pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointCollection.AddPoint(point2, ref missing, ref missing); lineElementClass2.Geometry = polylineClass2; groupElementClass.AddElement(lineElementClass2); IPolygon polygonClass = new Polygon() as IPolygon; IElement polygonElementClass = new PolygonElement(); IPolygonElement polygonElement = polygonElementClass as IPolygonElement; ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); IFillShapeElement fillShapeElement = polygonElement as IFillShapeElement; IRgbColor rgbColorClass = new RgbColor() { Red = 0, Green = 0, Blue = 0 }; simpleFillSymbolClass.Outline = this.LineSymbol; simpleFillSymbolClass.Color = rgbColorClass; simpleFillSymbolClass.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal; fillShapeElement.Symbol = simpleFillSymbolClass; pointCollection = polygonClass as IPointCollection; pointClass2.PutCoords(pointClass.X + num1, pointClass.Y - num); pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointClass2.PutCoords(pointClass.X + num1 * 2, pointClass.Y - num); pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointClass2.PutCoords(pointClass.X + num1 * 2, pointClass.Y - num * 2); pointCollection.AddPoint(pointClass2, ref missing, ref missing); pointClass2.PutCoords(pointClass.X + num1, pointClass.Y - num * 2); pointCollection.AddPoint(pointClass2, ref missing, ref missing); polygonClass.Close(); polygonElementClass.Geometry = polygonClass; groupElementClass.AddElement(polygonElementClass); IEnvelope envelope = polygonClass.Envelope; IEnvelope envelopeClass = new Envelope() as IEnvelope; this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row1Col1Text, pointClass.X + num1 / 2, pointClass.Y - num / 2, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[0] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row1Col2Text, pointClass.X + 1.5 * num1, pointClass.Y - 0.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[1] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row1Col3Text, pointClass.X + 2.5 * num1, pointClass.Y - 0.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[2] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row2Col1Text, pointClass.X + num1 / 2, pointClass.Y - 1.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[3] as IElement); this.m_pTextElementList.Add(null); this.m_pTextElementAdd.Add(false); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row2Col3Text, pointClass.X + 2.5 * num1, pointClass.Y - 1.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[5] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row3Col1Text, pointClass.X + num1 / 2, pointClass.Y - 2.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[6] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row3Col2Text, pointClass.X + 1.5 * num1, pointClass.Y - 2.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[7] as IElement); this.m_pTextElementList.Add( this.CreateJionTabTextElement(pAV, this.Row3Col3Text, pointClass.X + 2.5 * num1, pointClass.Y - 2.5 * num, envelope) as ITextElement); this.m_pTextElementAdd.Add(true); groupElementClass.AddElement(this.m_pTextElementList[8] as IElement); } catch (Exception exception) { } this.m_pGroupElement = groupElementClass as IElement; return(this.m_pGroupElement); }
protected void createPdfButton_Click(object sender, EventArgs e) { // Get the server IP and port String serverIP = textBoxServerIP.Text; uint serverPort = uint.Parse(textBoxServerPort.Text); // Create a PDF document Document pdfDocument = new Document(serverIP, serverPort); // Set optional service password if (textBoxServicePassword.Text.Length > 0) { pdfDocument.ServicePassword = textBoxServicePassword.Text; } // Set license key received after purchase to use the converter in licensed mode // Leave it not set to use the converter in demo mode pdfDocument.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="; // The titles font used to mark various sections of the PDF document PdfFont titleFont = new PdfFont("Times New Roman", 12, true); titleFont.Bold = true; // Create a PDF page in PDF document PdfPage pdfPage = pdfDocument.AddPage(); // Line Elements // Add section title TextElement titleTextElement = new TextElement(5, 5, "Line Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfPage.AddElement(titleTextElement); // Add a line with default properties LineElement lineElement = new LineElement(0, 0, 50, 0); pdfDocument.AddElement(lineElement, 10); // Add a bold line LineElement boldLineElement = new LineElement(0, 0, 50, 0); boldLineElement.LineStyle.LineWidth = 3; pdfDocument.AddElement(boldLineElement, 10, true, false, 0, true, false); // Add dotted line LineElement dottedLineElement = new LineElement(0, 0, 50, 0); dottedLineElement.LineStyle.LineDashStyle = LineDashStyle.Dot; dottedLineElement.ForeColor = RgbColor.Green; pdfDocument.AddElement(dottedLineElement, 10, true, false, 0, true, false); // Add a dashed line LineElement dashedLineElement = new LineElement(0, 0, 50, 0); dashedLineElement.LineStyle.LineDashStyle = LineDashStyle.Dash; dashedLineElement.ForeColor = RgbColor.Green; pdfDocument.AddElement(dashedLineElement, 10, true, false, 0, true, false); // Add a dash-dot-dot line LineElement dashDotDotLineElement = new LineElement(0, 0, 50, 0); dashDotDotLineElement.LineStyle.LineDashStyle = LineDashStyle.DashDotDot; dashDotDotLineElement.ForeColor = RgbColor.Green; pdfDocument.AddElement(dashDotDotLineElement, 10, true, false, 0, true, false); // Add a bold line with rounded cap style LineElement roundCapBoldLine = new LineElement(0, 0, 50, 0); roundCapBoldLine.LineStyle.LineWidth = 5; roundCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.RoundCap; roundCapBoldLine.ForeColor = RgbColor.Blue; pdfDocument.AddElement(roundCapBoldLine, 10, true, false, 0, true, false); // Add a bold line with projecting square cap style LineElement projectingSquareCapBoldLine = new LineElement(0, 0, 50, 0); projectingSquareCapBoldLine.LineStyle.LineWidth = 5; projectingSquareCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.ProjectingSquareCap; projectingSquareCapBoldLine.ForeColor = RgbColor.Blue; pdfDocument.AddElement(projectingSquareCapBoldLine, 10, true, false, 0, true, false); // Add a bold line with projecting butt cap style LineElement buttCapBoldLine = new LineElement(0, 0, 50, 0); buttCapBoldLine.LineStyle.LineWidth = 5; buttCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.ButtCap; buttCapBoldLine.ForeColor = RgbColor.Blue; pdfDocument.AddElement(buttCapBoldLine, 10, true, false, 0, true, false); // Line Join Styles // Add section title titleTextElement = new TextElement(0, 0, "Line Join and Cap Styles", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Add graphic path with miter join line style PathElement miterJoinPath = new PathElement(new PointFloat(0, 50)); // Add path lines miterJoinPath.AddLineSegment(new PointFloat(25, 0)); miterJoinPath.AddLineSegment(new PointFloat(50, 50)); // Set path style miterJoinPath.LineStyle.LineWidth = 5; miterJoinPath.LineStyle.LineCapStyle = LineCapStyle.ProjectingSquareCap; miterJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; miterJoinPath.ForeColor = RgbColor.Coral; pdfDocument.AddElement(miterJoinPath, 5, false, 10, true); // Add graphic path with round join line style PathElement roundJoinPath = new PathElement(new PointFloat(0, 50)); // Add path lines roundJoinPath.AddLineSegment(new PointFloat(25, 0)); roundJoinPath.AddLineSegment(new PointFloat(50, 50)); // Set path style roundJoinPath.LineStyle.LineWidth = 5; roundJoinPath.LineStyle.LineCapStyle = LineCapStyle.RoundCap; roundJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; roundJoinPath.ForeColor = RgbColor.Coral; pdfDocument.AddElement(roundJoinPath, 20, true, false, 0, true, false); // Add graphic path with bevel join line style PathElement bevelJoinPath = new PathElement(new PointFloat(0, 50)); // Add lines to path bevelJoinPath.AddLineSegment(new PointFloat(25, 0)); bevelJoinPath.AddLineSegment(new PointFloat(50, 50)); // Set path style bevelJoinPath.LineStyle.LineWidth = 5; bevelJoinPath.LineStyle.LineCapStyle = LineCapStyle.ButtCap; bevelJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.BevelJoin; bevelJoinPath.ForeColor = RgbColor.Coral; // Add element to document pdfDocument.AddElement(bevelJoinPath, 20, true, false, 0, true, false); // Add a polygon with miter join line style PointFloat[] polygonPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(25, 0), new PointFloat(50, 50) }; PolygonElement miterJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style miterJoinPolygon.LineStyle.LineWidth = 5; miterJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; miterJoinPolygon.ForeColor = RgbColor.Green; miterJoinPolygon.BackColor = RgbColor.AliceBlue; pdfDocument.AddElement(miterJoinPolygon, 20, true, false, 0, true, false); // Add a polygon with round join line style polygonPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(25, 0), new PointFloat(50, 50) }; PolygonElement roundJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style roundJoinPolygon.LineStyle.LineWidth = 5; roundJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; roundJoinPolygon.ForeColor = RgbColor.Green; roundJoinPolygon.BackColor = RgbColor.Blue; pdfDocument.AddElement(roundJoinPolygon, 20, true, false, 0, true, false); // Add a polygon with bevel join line style polygonPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(25, 0), new PointFloat(50, 50) }; PolygonElement bevelJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style bevelJoinPolygon.LineStyle.LineWidth = 5; bevelJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.BevelJoin; bevelJoinPolygon.ForeColor = RgbColor.Green; bevelJoinPolygon.BackColor = RgbColor.Blue; pdfDocument.AddElement(bevelJoinPolygon, 20, true, false, 0, true, false); // Add a Graphics Path Element // Add section title titleTextElement = new TextElement(0, 0, "Path Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Create the path PathElement graphicsPath = new PathElement(new PointFloat(0, 0)); // Add line and Bezier curve segments graphicsPath.AddLineSegment(new PointFloat(50, 50)); graphicsPath.AddBezierCurveSegment(new PointFloat(100, 0), new PointFloat(200, 100), new PointFloat(250, 50)); graphicsPath.AddLineSegment(new PointFloat(300, 0)); // Close path graphicsPath.ClosePath = true; // Set path style graphicsPath.LineStyle.LineWidth = 3; graphicsPath.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; graphicsPath.LineStyle.LineCapStyle = LineCapStyle.RoundCap; graphicsPath.ForeColor = RgbColor.Green; //graphicsPath.BackColor = Color.Green; graphicsPath.Gradient = new GradientColor(GradientDirection.Vertical, RgbColor.LightGreen, RgbColor.Blue); // Add element to document pdfDocument.AddElement(graphicsPath, 5, false, 10, true); // Add Circle Elements // Add section title titleTextElement = new TextElement(0, 0, "Circle Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Add a Circle Element with default settings CircleElement circleElement = new CircleElement(30, 30, 30); pdfDocument.AddElement(circleElement, 10); // Add dotted circle element CircleElement dottedCircleElement = new CircleElement(30, 30, 30); dottedCircleElement.ForeColor = RgbColor.Green; dottedCircleElement.LineStyle.LineDashStyle = LineDashStyle.Dot; pdfDocument.AddElement(dottedCircleElement, 10, true, false, 0, true, false); // Add a disc CircleElement discElement = new CircleElement(30, 30, 30); discElement.ForeColor = RgbColor.Green; discElement.BackColor = RgbColor.LightGray; pdfDocument.AddElement(discElement, 10, true, false, 0, true, false); // Add disc with bold border CircleElement discWithBoldBorder = new CircleElement(30, 30, 30); discWithBoldBorder.LineStyle.LineWidth = 5; discWithBoldBorder.BackColor = RgbColor.Coral; discWithBoldBorder.ForeColor = RgbColor.Blue; pdfDocument.AddElement(discWithBoldBorder, 10, true, false, 0, true, false); // Add colored disc with bold border for (int i = 30; i > 0; i = i - 3) { CircleElement coloredDisc = new CircleElement(30, 30, i); coloredDisc.LineStyle.LineWidth = 3; switch ((i / 3) % 7) { case 0: coloredDisc.BackColor = RgbColor.Red; break; case 1: coloredDisc.BackColor = RgbColor.Orange; break; case 2: coloredDisc.BackColor = RgbColor.Yellow; break; case 3: coloredDisc.BackColor = RgbColor.Green; break; case 4: coloredDisc.BackColor = RgbColor.Blue; break; case 5: coloredDisc.BackColor = RgbColor.Indigo; break; case 6: coloredDisc.BackColor = RgbColor.Violet; break; default: break; } if (i == 30) { pdfDocument.AddElement(coloredDisc, 10, true, false, 0, true, false); } else { pdfDocument.AddElement(coloredDisc, 3, true, true, 3, true, false); } } // Add a doughnut CircleElement exteriorNoBorderDisc = new CircleElement(30, 30, 30); exteriorNoBorderDisc.BackColor = RgbColor.Coral; pdfDocument.AddElement(exteriorNoBorderDisc, 40, true, false, -30, true, false); CircleElement interiorNoBorderDisc = new CircleElement(30, 30, 15); interiorNoBorderDisc.BackColor = RgbColor.White; pdfDocument.AddElement(interiorNoBorderDisc, 15, true, true, 15, true, false); // Add a simple disc CircleElement simpleDisc = new CircleElement(30, 30, 30); simpleDisc.BackColor = RgbColor.Green; pdfDocument.AddElement(simpleDisc, 25, true, false, -15, true, false); // Add Ellipse Elements // Add section title titleTextElement = new TextElement(0, 0, "Ellipse Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Add an Ellipse Element with default settings EllipseElement ellipseElement = new EllipseElement(50, 30, 50, 30); pdfDocument.AddElement(ellipseElement, 5, false, 10, true); // Add an Ellipse Element with background color and line color EllipseElement ellipseWithBackgroundAndBorder = new EllipseElement(50, 30, 50, 30); ellipseWithBackgroundAndBorder.BackColor = RgbColor.LightGray; ellipseWithBackgroundAndBorder.ForeColor = RgbColor.Green; pdfDocument.AddElement(ellipseWithBackgroundAndBorder, 10, true, false, 0, true, false); // Create an ellipse from multiple Ellipse Arc Elements EllipseArcElement ellipseArcElement1 = new EllipseArcElement(0, 0, 100, 60, 0, 100); ellipseArcElement1.ForeColor = RgbColor.Coral; ellipseArcElement1.LineStyle.LineWidth = 3; pdfDocument.AddElement(ellipseArcElement1, 10, true, false, 0, true, false); EllipseArcElement ellipseArcElement2 = new EllipseArcElement(0, 0, 100, 60, 100, 100); ellipseArcElement2.ForeColor = RgbColor.Blue; ellipseArcElement2.LineStyle.LineWidth = 3; pdfDocument.AddElement(ellipseArcElement2, 0, true, true, 0, true, false); EllipseArcElement ellipseArcElement3 = new EllipseArcElement(0, 0, 100, 60, 180, 100); ellipseArcElement3.ForeColor = RgbColor.Green; ellipseArcElement3.LineStyle.LineWidth = 3; pdfDocument.AddElement(ellipseArcElement3, 0, true, true, 0, true, false); EllipseArcElement ellipseArcElement4 = new EllipseArcElement(0, 0, 100, 60, 270, 100); ellipseArcElement4.ForeColor = RgbColor.Violet; ellipseArcElement4.LineStyle.LineWidth = 3; pdfDocument.AddElement(ellipseArcElement4, 0, true, true, 0, true, false); // Create an ellipse from multiple Ellipse Slice Elements EllipseSliceElement ellipseSliceElement1 = new EllipseSliceElement(0, 0, 100, 60, 0, 90); ellipseSliceElement1.BackColor = RgbColor.Coral; pdfDocument.AddElement(ellipseSliceElement1, 10, true, false, 0, true, false); EllipseSliceElement ellipseSliceElement2 = new EllipseSliceElement(0, 0, 100, 60, 90, 90); ellipseSliceElement2.BackColor = RgbColor.Blue; pdfDocument.AddElement(ellipseSliceElement2, 0, true, true, 0, true, false); EllipseSliceElement ellipseSliceElement3 = new EllipseSliceElement(0, 0, 100, 60, 180, 90); ellipseSliceElement3.BackColor = RgbColor.Green; pdfDocument.AddElement(ellipseSliceElement3, 0, true, true, 0, true, false); EllipseSliceElement ellipseSliceElement4 = new EllipseSliceElement(0, 0, 100, 60, 270, 90); ellipseSliceElement4.BackColor = RgbColor.Violet; pdfDocument.AddElement(ellipseSliceElement4, 0, true, true, 0, true, false); // Add an Ellipse Element with background EllipseElement ellipseWithBackground = new EllipseElement(0, 0, 50, 30); ellipseWithBackground.BackColor = RgbColor.Green; pdfDocument.AddElement(ellipseWithBackground, 10, true, false, 0, true, false); // Add Rectangle Elements // Add section title titleTextElement = new TextElement(0, 0, "Rectangle Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Add a Rectangle Element with default settings RectangleElement rectangleElement = new RectangleElement(0, 0, 100, 60); pdfDocument.AddElement(rectangleElement, 10); // Add a Rectangle Element with background color and dotted line RectangleElement rectangleElementWithDottedLine = new RectangleElement(0, 0, 100, 60); rectangleElementWithDottedLine.BackColor = RgbColor.LightGray; rectangleElementWithDottedLine.ForeColor = RgbColor.Green; rectangleElementWithDottedLine.LineStyle.LineDashStyle = LineDashStyle.Dot; pdfDocument.AddElement(rectangleElementWithDottedLine, 10, true, false, 0, true, false); // Add a Rectangle Element with background color without border RectangleElement rectangleElementWithoutBorder = new RectangleElement(0, 0, 100, 60); rectangleElementWithoutBorder.BackColor = RgbColor.Green; pdfDocument.AddElement(rectangleElementWithoutBorder, 10, true, false, 0, true, false); // Add a Rectangle Element with background color, bold border line and rounded corners RectangleElement rectangleElementWithRoundedCorners = new RectangleElement(0, 0, 100, 60); rectangleElementWithRoundedCorners.BackColor = RgbColor.Coral; rectangleElementWithRoundedCorners.ForeColor = RgbColor.Blue; rectangleElementWithRoundedCorners.LineStyle.LineWidth = 5; rectangleElementWithRoundedCorners.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; pdfDocument.AddElement(rectangleElementWithRoundedCorners, 10, true, false, 0, true, false); // Add Polygon Elements // Add section title titleTextElement = new TextElement(0, 0, "Polygon Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); PointFloat[] polygonElementPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(50, 0), new PointFloat(100, 50), new PointFloat(50, 100) }; // Add a Polygon Element with default settings PolygonElement polygonElement = new PolygonElement(polygonElementPoints); pdfDocument.AddElement(polygonElement, 10); polygonElementPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(50, 0), new PointFloat(100, 50), new PointFloat(50, 100) }; // Add a Polygon Element with background color and border polygonElement = new PolygonElement(polygonElementPoints); polygonElement.BackColor = RgbColor.LightGray; polygonElement.ForeColor = RgbColor.Green; polygonElement.LineStyle.LineDashStyle = LineDashStyle.Dot; pdfDocument.AddElement(polygonElement, 10, true, false, 0, true, false); polygonElementPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(50, 0), new PointFloat(100, 50), new PointFloat(50, 100) }; // Add a Polygon Element with background color polygonElement = new PolygonElement(polygonElementPoints); polygonElement.BackColor = RgbColor.Green; pdfDocument.AddElement(polygonElement, 10, true, false, 0, true, false); PointFloat[] polyFillPoints = new PointFloat[] { new PointFloat(0, 50), new PointFloat(50, 0), new PointFloat(100, 50), new PointFloat(50, 100) }; // Add a Polygon Element with background color and rounded line joins PolygonElement polygonElementWithBackgruondColorAndBorder = new PolygonElement(polyFillPoints); polygonElementWithBackgruondColorAndBorder.ForeColor = RgbColor.Blue; polygonElementWithBackgruondColorAndBorder.BackColor = RgbColor.Coral; polygonElementWithBackgruondColorAndBorder.LineStyle.LineWidth = 5; polygonElementWithBackgruondColorAndBorder.LineStyle.LineCapStyle = LineCapStyle.RoundCap; polygonElementWithBackgruondColorAndBorder.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; pdfDocument.AddElement(polygonElementWithBackgruondColorAndBorder, 10, true, false, 0, true, false); // Add Bezier Curve Elements // Add section title titleTextElement = new TextElement(0, 0, "Bezier Curve Elements", titleFont); titleTextElement.ForeColor = RgbColor.Black; pdfDocument.AddElement(titleTextElement, 5, false, 10, true); // Add a Bezier Curve Element with normal style BezierCurveElement bezierCurveElement = new BezierCurveElement(0, 50, 50, 0, 100, 100, 150, 50); bezierCurveElement.ForeColor = RgbColor.Blue; bezierCurveElement.LineStyle.LineWidth = 3; pdfDocument.AddElement(bezierCurveElement, 10); // Add a Bezier Curve Element with dotted line using the controlling points above bezierCurveElement = new BezierCurveElement(0, 50, 50, 0, 100, 100, 150, 50); bezierCurveElement.ForeColor = RgbColor.Green; bezierCurveElement.LineStyle.LineDashStyle = LineDashStyle.Dot; bezierCurveElement.LineStyle.LineWidth = 1; pdfDocument.AddElement(bezierCurveElement, 30, true, false, 0, true, false); // Mark the points controlling the Bezier curve CircleElement controlPoint1 = new CircleElement(0, 0, 10); controlPoint1.BackColor = RgbColor.Violet; controlPoint1.Opacity = 75; pdfDocument.AddElement(controlPoint1, -10, true, true, 40, true, false); CircleElement controlPoint2 = new CircleElement(0, 0, 10); controlPoint2.BackColor = RgbColor.Violet; pdfDocument.AddElement(controlPoint2, 50, true, true, -50, true, false); CircleElement controlPoint3 = new CircleElement(0, 0, 10); controlPoint3.BackColor = RgbColor.Violet; pdfDocument.AddElement(controlPoint3, 50, true, true, 100, true, false); CircleElement controlPoint4 = new CircleElement(0, 0, 10); controlPoint4.BackColor = RgbColor.Violet; pdfDocument.AddElement(controlPoint4, 50, true, true, -50, true, false); // Save the PDF document in a memory buffer byte[] outPdfBuffer = pdfDocument.Save(); // Send the PDF as response to browser // Set response content type Response.AddHeader("Content-Type", "application/pdf"); // Instruct the browser to open the PDF file as an attachment or inline Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Graphic_Elements.pdf; size={0}", outPdfBuffer.Length.ToString())); // Write the PDF document buffer to HTTP response Response.BinaryWrite(outPdfBuffer); // End the HTTP response and stop the current page processing Response.End(); }
public void AddGraphic(IScene iscene_0, IGeometry igeometry_0, ISymbol isymbol_0, bool bool_1, bool bool_2, string string_0) { if (!igeometry_0.IsEmpty) { IGraphicsLayer basicGraphicsLayer = iscene_0.BasicGraphicsLayer; IElement element = null; esriGeometryType geometryType = igeometry_0.GeometryType; switch (geometryType) { case esriGeometryType.esriGeometryPoint: { element = new MarkerElement(); IMarkerElement markerElement = element as IMarkerElement; if (isymbol_0 != null) { markerElement.Symbol = (isymbol_0 as IMarkerSymbol); } else { markerElement.Symbol = new SimpleMarkerSymbol(); } break; } case esriGeometryType.esriGeometryMultipoint: break; case esriGeometryType.esriGeometryPolyline: { element = new LineElement(); ILineElement lineElement = element as ILineElement; if (isymbol_0 != null) { lineElement.Symbol = (isymbol_0 as ILineSymbol); } else { lineElement.Symbol = new SimpleLineSymbol(); } break; } case esriGeometryType.esriGeometryPolygon: { element = new PolygonElement(); IFillShapeElement fillShapeElement = element as IFillShapeElement; if (isymbol_0 != null) { fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } else { fillShapeElement.Symbol = new SimpleFillSymbol(); } break; } default: if (geometryType == esriGeometryType.esriGeometryMultiPatch) { element = new MultiPatchElement(); IFillShapeElement fillShapeElement = element as IFillShapeElement; if (isymbol_0 != null) { fillShapeElement.Symbol = (isymbol_0 as IFillSymbol); } else { fillShapeElement.Symbol = new SimpleFillSymbol(); } } break; } if (element != null) { element.Geometry = igeometry_0; if (string_0.Length > 0) { IElementProperties elementProperties = element as IElementProperties; elementProperties.Name = string_0; } IGraphicsContainer3D graphicsContainer3D = basicGraphicsLayer as IGraphicsContainer3D; graphicsContainer3D.AddElement(element); IGraphicsSelection graphicsSelection = graphicsContainer3D as IGraphicsSelection; if (bool_2) { if (!bool_1) { graphicsSelection.UnselectAllElements(); } graphicsSelection.SelectElement(element); } iscene_0.SceneGraph.RefreshViewers(); } } }
protected override void OnPaint(GUI.PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.PixelOffsetMode = PixelOffsetMode.None; // Polygon1 PolygonElement polygon1 = m_PolygonElement1; PolylineGeometry path1 = new PolylineGeometry(polygon1.Polygon, true, false); BSplineGeometry bspline1 = new BSplineGeometry(path1); bspline1.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; // Polygon2 PolygonElement polygon2 = m_PolygonElement2; PolylineGeometry path2 = new PolylineGeometry(polygon2.Polygon, true, false); BSplineGeometry bspline2 = new BSplineGeometry(path2); bspline1.InterpolationStep = 1.0 / m_PointsNumberSlider.Value; DoublePathTransform tcurve = new DoublePathTransform(); tcurve.PreserveXScale = m_PreserveXScaleCheckBox.IsChecked; if (m_FixedLenCheckBox.IsChecked) { tcurve.BaseLength = 1140.0; } tcurve.AddPaths(bspline1, bspline2); Tuple <Geometry, double> geometry = GetCurveTransformedTextGeometry(tcurve.TotalLength1); tcurve.BaseHeight = FontAscentInPixels + geometry.Item2 + 3; GeometryTransformer ftrans = new GeometryTransformer(geometry.Item1, tcurve); if (m_FillCheckBox.IsChecked) { Brush brush = m_TextBrush; // Irrlicht Renderer can't render smoothed gradients now if (graphics.RenderSystemName.Contains(Graphics.RSN_Irrlicht)) { if (m_TextBrush_Irrlicht == null) { m_TextBrush_Irrlicht = new SolidColorBrush(Color.LawnGreen); } brush = m_TextBrush_Irrlicht; } graphics.FillGeometry(brush, ftrans); } if (m_OutlineCheckBox.IsChecked) { graphics.DrawGeometry(Color.White, ftrans, m_OutlineThicknessSlider.Value); } graphics.DrawGeometry(m_BSplinePen, bspline1); graphics.DrawGeometry(m_BSplinePen, bspline2); base.OnPaint(e); }
//显示临时数据 public void showGraphics(IGeometry pBufferGeo) { IGraphicsContainer pGraphicsContainer = Global.mainmap.Map as IGraphicsContainer; //定义容器 //pFeature = pEnumFeature.Next(); //遍历要素 //if (pFeature == null) //若不存在要素,则推出循环 // break; //pGeometry = pFeature.Shape; //获取要素的Geometry //ITopologicalOperator pTopoOperator = pGeometry as ITopologicalOperator; //QI到拓扑操作 //IGeometry pBufferGeo = pTopoOperator.Buffer(2); //缓冲区分析 IElement pElement = new PolygonElement(); pElement.Geometry = pBufferGeo; //获取得到的缓冲区 pGraphicsContainer.AddElement(pElement, 0); //显示缓冲区 //Global.mainmap IMap pMap = Global.mainmap.Map; IActiveView pActiveView; pActiveView = pMap as IActiveView; pActiveView.Refresh(); }
private void DelVertexNode(IPoint pPnt) { try { IFeatureLayer pFeaturelayer = m_EngineEditLayers.TargetLayer; IActiveView pActiveView = m_activeView; IPoint pPoint = pPnt; if (pFeaturelayer.FeatureClass == null) { return; } //如果不是面状地物则退出 if (pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryEnvelope && pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon && pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryLine && pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline) { return; } IGeometry pGeo = null; IFeature pSelFeature = null; pSelFeature = EditVertexClass.GetSelectedFeature(pFeaturelayer); //是否有选中的几何体 if (pSelFeature == null) { return; } pGeo = pSelFeature.ShapeCopy; double pSrchDis = 0; double pHitDis = 0; pSrchDis = pActiveView.Extent.Width / 200; pPoint.Z = 0; int pIndex = 0; IElement pElement = null; IHitTest pHtTest = null; bool pBoolHitTest = false; IPoint pPtHit = null; IPointCollection pPointCol = null; IPolygon pPolygon = null; IPolyline pPyline = null; bool bRightZSide = true; int pInt = 0; m_EngineEditor.StartOperation(); //删除面状要素的节点 if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon || pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryEnvelope) { pElement = new PolygonElement(); pElement.Geometry = pSelFeature.Shape; IPolygon pPoly = null; pPoly = pElement.Geometry as IPolygon; pHtTest = pPoly as IHitTest; pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex, pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide); if (pBoolHitTest == false) { return; } EditVertexClass.pHitPnt = pPtHit; pPointCol = pSelFeature.ShapeCopy as IPointCollection; //如果多边形的节点只有3个则不能再删除了 if (pPointCol.PointCount <= 4) { MessageBox.Show("多边形的节点至少需要3个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //顶点删除 pPointCol.RemovePoints(pIndex, 1); pPolygon = pPointCol as IPolygon; pPolygon.Close(); pSelFeature.Shape = pPolygon; pSelFeature.Store(); } //删除线状要素的节点 else if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline || pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryLine) { pElement = new LineElement(); pElement.Geometry = pSelFeature.Shape; IPolyline pPolyLine = default(IPolyline); pPolyLine = pElement.Geometry as IPolyline; pHtTest = pPolyLine as IHitTest; pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex, pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide); if (pBoolHitTest == false) { return; } EditVertexClass.pHitPnt = pPtHit; pPointCol = pSelFeature.ShapeCopy as IPointCollection; //如果Polyline节点只有2个则不能再删除了 if (pPointCol.PointCount <= 2) { MessageBox.Show("线的节点至少需要2个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //顶点删除 pPointCol.RemovePoints(pIndex, 1); pPyline = pPointCol as IPolyline; pSelFeature.Shape = pPyline; pSelFeature.Store(); } //与选中点坐标相同的节点都删除 for (int i = 0; i <= pPointCol.PointCount - 1; i++) { if (i > pPointCol.PointCount - 1) { break; } if (pPointCol.get_Point(i).X == pPoint.X & pPointCol.get_Point(i).Y == pPoint.Y) { pPointCol.RemovePoints(i, 1); i = i - 1; } } //停止编辑 m_EngineEditor.StopOperation("DelVertexTool"); //显示顶点 EditVertexClass.ShowAllVertex(pFeaturelayer); m_activeView.Refresh(); } catch (Exception ex) { m_activeView.Refresh(); } }
protected void createPdfButton_Click(object sender, EventArgs e) { // Create a PDF document Document pdfDocument = new Document(); // Set license key received after purchase to use the converter in licensed mode // Leave it not set to use the converter in demo mode pdfDocument.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="; try { // The result of adding elements to PDF document AddElementResult addElementResult = null; // The titles font used to mark various sections of the PDF document PdfFont titleFont = pdfDocument.AddFont(new Font("Times New Roman", 12, FontStyle.Bold, GraphicsUnit.Point)); // The position on X anf Y axes where to add the next element float yLocation = 5; float xLocation = 5; // Create a PDF page in PDF document PdfPage pdfPage = pdfDocument.AddPage(); // Line Elements // Add section title TextElement titleTextElement = new TextElement(xLocation, yLocation, "Line Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add a line with default properties LineElement lineElement = new LineElement(xLocation, yLocation, xLocation + 50, yLocation); addElementResult = pdfPage.AddElement(lineElement); // Add a bold line LineElement boldLineElement = new LineElement(xLocation + 60, yLocation, xLocation + 110, yLocation); boldLineElement.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(boldLineElement); // Add dotted line LineElement dottedLineElement = new LineElement(xLocation + 120, yLocation, xLocation + 170, yLocation); dottedLineElement.LineStyle.LineDashStyle = LineDashStyle.Dot; dottedLineElement.ForeColor = Color.Green; addElementResult = pdfPage.AddElement(dottedLineElement); // Add a dashed line LineElement dashedLineElement = new LineElement(xLocation + 180, yLocation, xLocation + 230, yLocation); dashedLineElement.LineStyle.LineDashStyle = LineDashStyle.Dash; dashedLineElement.ForeColor = Color.Green; addElementResult = pdfPage.AddElement(dashedLineElement); // Add a dash-dot-dot line LineElement dashDotDotLineElement = new LineElement(xLocation + 240, yLocation, xLocation + 290, yLocation); dashDotDotLineElement.LineStyle.LineDashStyle = LineDashStyle.DashDotDot; dashDotDotLineElement.ForeColor = Color.Green; addElementResult = pdfPage.AddElement(dashDotDotLineElement); // Add a bold line with rounded cap style LineElement roundCapBoldLine = new LineElement(xLocation + 300, yLocation, xLocation + 350, yLocation); roundCapBoldLine.LineStyle.LineWidth = 5; roundCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.RoundCap; roundCapBoldLine.ForeColor = Color.Blue; addElementResult = pdfPage.AddElement(roundCapBoldLine); // Add a bold line with projecting square cap style LineElement projectingSquareCapBoldLine = new LineElement(xLocation + 360, yLocation, xLocation + 410, yLocation); projectingSquareCapBoldLine.LineStyle.LineWidth = 5; projectingSquareCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.ProjectingSquareCap; projectingSquareCapBoldLine.ForeColor = Color.Blue; addElementResult = pdfPage.AddElement(projectingSquareCapBoldLine); // Add a bold line with projecting butt cap style LineElement buttCapBoldLine = new LineElement(xLocation + 420, yLocation, xLocation + 470, yLocation); buttCapBoldLine.LineStyle.LineWidth = 5; buttCapBoldLine.LineStyle.LineCapStyle = LineCapStyle.ButtCap; buttCapBoldLine.ForeColor = Color.Blue; addElementResult = pdfPage.AddElement(buttCapBoldLine); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Line Join Styles // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Line Join and Cap Styles", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add graphic path with miter join line style PathElement miterJoinPath = new PathElement(new PointF(xLocation, yLocation + 50)); // Add path lines miterJoinPath.AddLineSegment(new PointF(xLocation + 25, yLocation)); miterJoinPath.AddLineSegment(new PointF(xLocation + 50, yLocation + 50)); // Set path style miterJoinPath.LineStyle.LineWidth = 5; miterJoinPath.LineStyle.LineCapStyle = LineCapStyle.ProjectingSquareCap; miterJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; miterJoinPath.ForeColor = Color.Coral; addElementResult = pdfPage.AddElement(miterJoinPath); // Add graphic path with round join line style PathElement roundJoinPath = new PathElement(new PointF(xLocation + 70, yLocation + 50)); // Add path lines roundJoinPath.AddLineSegment(new PointF(xLocation + 95, yLocation)); roundJoinPath.AddLineSegment(new PointF(xLocation + 120, yLocation + 50)); // Set path style roundJoinPath.LineStyle.LineWidth = 5; roundJoinPath.LineStyle.LineCapStyle = LineCapStyle.RoundCap; roundJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; roundJoinPath.ForeColor = Color.Coral; addElementResult = pdfPage.AddElement(roundJoinPath); // Add graphic path with bevel join line style PathElement bevelJoinPath = new PathElement(new PointF(xLocation + 140, yLocation + 50)); // Add lines to path bevelJoinPath.AddLineSegment(new PointF(xLocation + 165, yLocation)); bevelJoinPath.AddLineSegment(new PointF(xLocation + 190, yLocation + 50)); // Set path style bevelJoinPath.LineStyle.LineWidth = 5; bevelJoinPath.LineStyle.LineCapStyle = LineCapStyle.ButtCap; bevelJoinPath.LineStyle.LineJoinStyle = LineJoinStyle.BevelJoin; bevelJoinPath.ForeColor = Color.Coral; // Add element to document addElementResult = pdfPage.AddElement(bevelJoinPath); // Add a polygon with miter join line style PointF[] polygonPoints = new PointF[] { new PointF(xLocation + 210, yLocation + 50), new PointF(xLocation + 235, yLocation), new PointF(xLocation + 260, yLocation + 50) }; PolygonElement miterJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style miterJoinPolygon.LineStyle.LineWidth = 5; miterJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; miterJoinPolygon.ForeColor = Color.Green; miterJoinPolygon.BackColor = Color.AliceBlue; addElementResult = pdfPage.AddElement(miterJoinPolygon); // Add a polygon with round join line style polygonPoints = new PointF[] { new PointF(xLocation + 280, yLocation + 50), new PointF(xLocation + 305, yLocation), new PointF(xLocation + 330, yLocation + 50) }; PolygonElement roundJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style roundJoinPolygon.LineStyle.LineWidth = 5; roundJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; roundJoinPolygon.ForeColor = Color.Green; roundJoinPolygon.BackColor = Color.Blue; addElementResult = pdfPage.AddElement(roundJoinPolygon); // Add a polygon with bevel join line style polygonPoints = new PointF[] { new PointF(xLocation + 350, yLocation + 50), new PointF(xLocation + 375, yLocation), new PointF(xLocation + 400, yLocation + 50) }; PolygonElement bevelJoinPolygon = new PolygonElement(polygonPoints); // Set polygon style bevelJoinPolygon.LineStyle.LineWidth = 5; bevelJoinPolygon.LineStyle.LineJoinStyle = LineJoinStyle.BevelJoin; bevelJoinPolygon.ForeColor = Color.Green; bevelJoinPolygon.BackColor = Color.Blue; addElementResult = pdfPage.AddElement(bevelJoinPolygon); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add a Graphics Path Element // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Path Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Create the path PathElement graphicsPath = new PathElement(new PointF(xLocation, yLocation)); // Add line and Bezier curve segments graphicsPath.AddLineSegment(new PointF(xLocation + 50, yLocation + 50)); graphicsPath.AddBezierCurveSegment(new PointF(xLocation + 100, yLocation), new PointF(xLocation + 200, yLocation + 100), new PointF(xLocation + 250, yLocation + 50)); graphicsPath.AddLineSegment(new PointF(xLocation + 300, yLocation)); // Close path graphicsPath.ClosePath = true; // Set path style graphicsPath.LineStyle.LineWidth = 3; graphicsPath.LineStyle.LineJoinStyle = LineJoinStyle.MiterJoin; graphicsPath.LineStyle.LineCapStyle = LineCapStyle.RoundCap; graphicsPath.ForeColor = Color.Green; //graphicsPath.BackColor = Color.Green; graphicsPath.Gradient = new GradientColor(GradientDirection.Vertical, System.Drawing.Color.LightGreen, System.Drawing.Color.Blue); // Add element to document addElementResult = pdfPage.AddElement(graphicsPath); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add Circle Elements // Add section title xLocation -= 5; yLocation -= 10; titleTextElement = new TextElement(xLocation, yLocation, "Circle Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add a Circle Element with default settings CircleElement circleElement = new CircleElement(xLocation + 30, yLocation + 30, 30); addElementResult = pdfPage.AddElement(circleElement); // Add dotted circle element CircleElement dottedCircleElement = new CircleElement(xLocation + 100, yLocation + 30, 30); dottedCircleElement.ForeColor = Color.Green; dottedCircleElement.LineStyle.LineDashStyle = LineDashStyle.Dot; addElementResult = pdfPage.AddElement(dottedCircleElement); // Add a disc CircleElement discElement = new CircleElement(xLocation + 170, yLocation + 30, 30); discElement.ForeColor = Color.Green; discElement.BackColor = Color.LightGray; addElementResult = pdfPage.AddElement(discElement); // Add disc with bold border CircleElement discWithBoldBorder = new CircleElement(xLocation + 240, yLocation + 30, 30); discWithBoldBorder.LineStyle.LineWidth = 5; discWithBoldBorder.BackColor = Color.Coral; discWithBoldBorder.ForeColor = Color.Blue; addElementResult = pdfPage.AddElement(discWithBoldBorder); // Add colored disc with bold border for (int i = 30; i >= 0; i = i - 3) { CircleElement coloredDisc = new CircleElement(xLocation + 310, yLocation + 30, i == 0 ? 1 : i); coloredDisc.LineStyle.LineWidth = 3; switch ((i / 3) % 7) { case 0: coloredDisc.BackColor = Color.Red; break; case 1: coloredDisc.BackColor = Color.Orange; break; case 2: coloredDisc.BackColor = Color.Yellow; break; case 3: coloredDisc.BackColor = Color.Green; break; case 4: coloredDisc.BackColor = Color.Blue; break; case 5: coloredDisc.BackColor = Color.Indigo; break; case 6: coloredDisc.BackColor = Color.Violet; break; default: break; } addElementResult = pdfPage.AddElement(coloredDisc); } // Add a doughnut CircleElement exteriorNoBorderDisc = new CircleElement(xLocation + 380, yLocation + 30, 30); exteriorNoBorderDisc.BackColor = Color.Coral; addElementResult = pdfPage.AddElement(exteriorNoBorderDisc); CircleElement interiorNoBorderDisc = new CircleElement(xLocation + 380, yLocation + 30, 15); interiorNoBorderDisc.BackColor = Color.White; pdfPage.AddElement(interiorNoBorderDisc); // Add a simple disc CircleElement simpleDisc = new CircleElement(xLocation + 450, yLocation + 30, 30); simpleDisc.BackColor = Color.Green; addElementResult = pdfPage.AddElement(simpleDisc); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add Ellipse Elements // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Ellipse Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add an Ellipse Element with default settings EllipseElement ellipseElement = new EllipseElement(xLocation + 50, yLocation + 30, 50, 30); addElementResult = pdfPage.AddElement(ellipseElement); // Add an Ellipse Element with background color and line color EllipseElement ellipseWithBackgroundAndBorder = new EllipseElement(xLocation + 160, yLocation + 30, 50, 30); ellipseWithBackgroundAndBorder.BackColor = Color.LightGray; ellipseWithBackgroundAndBorder.ForeColor = Color.Green; addElementResult = pdfPage.AddElement(ellipseWithBackgroundAndBorder); // Create an ellipse from multiple Ellipse Arc Elements EllipseArcElement ellipseArcElement1 = new EllipseArcElement(xLocation + 220, yLocation, 100, 60, 0, 100); ellipseArcElement1.ForeColor = Color.Coral; ellipseArcElement1.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(ellipseArcElement1); EllipseArcElement ellipseArcElement2 = new EllipseArcElement(xLocation + 220, yLocation, 100, 60, 100, 100); ellipseArcElement2.ForeColor = Color.Blue; ellipseArcElement2.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(ellipseArcElement2); EllipseArcElement ellipseArcElement3 = new EllipseArcElement(xLocation + 220, yLocation, 100, 60, 180, 100); ellipseArcElement3.ForeColor = Color.Green; ellipseArcElement3.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(ellipseArcElement3); EllipseArcElement ellipseArcElement4 = new EllipseArcElement(xLocation + 220, yLocation, 100, 60, 270, 100); ellipseArcElement4.ForeColor = Color.Violet; ellipseArcElement4.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(ellipseArcElement4); // Create an ellipse from multiple Ellipse Slice Elements EllipseSliceElement ellipseSliceElement1 = new EllipseSliceElement(xLocation + 330, yLocation, 100, 60, 0, 90); ellipseSliceElement1.BackColor = Color.Coral; addElementResult = pdfPage.AddElement(ellipseSliceElement1); EllipseSliceElement ellipseSliceElement2 = new EllipseSliceElement(xLocation + 330, yLocation, 100, 60, 90, 90); ellipseSliceElement2.BackColor = Color.Blue; addElementResult = pdfPage.AddElement(ellipseSliceElement2); EllipseSliceElement ellipseSliceElement3 = new EllipseSliceElement(xLocation + 330, yLocation, 100, 60, 180, 90); ellipseSliceElement3.BackColor = Color.Green; addElementResult = pdfPage.AddElement(ellipseSliceElement3); EllipseSliceElement ellipseSliceElement4 = new EllipseSliceElement(xLocation + 330, yLocation, 100, 60, 270, 90); ellipseSliceElement4.BackColor = Color.Violet; addElementResult = pdfPage.AddElement(ellipseSliceElement4); // Add an Ellipse Element with background EllipseElement ellipseWithBackground = new EllipseElement(xLocation + 490, yLocation + 30, 50, 30); ellipseWithBackground.BackColor = Color.Green; addElementResult = pdfPage.AddElement(ellipseWithBackground); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add Rectangle Elements // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Rectangle Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add a Rectangle Element with default settings RectangleElement rectangleElement = new RectangleElement(xLocation, yLocation, 100, 60); addElementResult = pdfPage.AddElement(rectangleElement); // Add a Rectangle Element with background color and dotted line RectangleElement rectangleElementWithDottedLine = new RectangleElement(xLocation + 110, yLocation, 100, 60); rectangleElementWithDottedLine.BackColor = Color.LightGray; rectangleElementWithDottedLine.ForeColor = Color.Green; rectangleElementWithDottedLine.LineStyle.LineDashStyle = LineDashStyle.Dot; addElementResult = pdfPage.AddElement(rectangleElementWithDottedLine); // Add a Rectangle Element with background color without border RectangleElement rectangleElementWithoutBorder = new RectangleElement(xLocation + 220, yLocation, 100, 60); rectangleElementWithoutBorder.BackColor = Color.Green; addElementResult = pdfPage.AddElement(rectangleElementWithoutBorder); // Add a Rectangle Element with background color, bold border line and rounded corners RectangleElement rectangleElementWithRoundedCorners = new RectangleElement(xLocation + 330, yLocation, 100, 60); rectangleElementWithRoundedCorners.BackColor = Color.Coral; rectangleElementWithRoundedCorners.ForeColor = Color.Blue; rectangleElementWithRoundedCorners.LineStyle.LineWidth = 5; rectangleElementWithRoundedCorners.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; addElementResult = pdfPage.AddElement(rectangleElementWithRoundedCorners); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add Polygon Elements // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Polygon Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; PointF[] polygonElementPoints = new PointF[] { new PointF(xLocation, yLocation + 50), new PointF(xLocation + 50, yLocation), new PointF(xLocation + 100, yLocation + 50), new PointF(xLocation + 50, yLocation + 100) }; // Add a Polygon Element with default settings PolygonElement polygonElement = new PolygonElement(polygonElementPoints); addElementResult = pdfPage.AddElement(polygonElement); polygonElementPoints = new PointF[] { new PointF(xLocation + 110, yLocation + 50), new PointF(xLocation + 160, yLocation), new PointF(xLocation + 210, yLocation + 50), new PointF(xLocation + 160, yLocation + 100) }; // Add a Polygon Element with background color and border polygonElement = new PolygonElement(polygonElementPoints); polygonElement.BackColor = Color.LightGray; polygonElement.ForeColor = Color.Green; polygonElement.LineStyle.LineDashStyle = LineDashStyle.Dot; addElementResult = pdfPage.AddElement(polygonElement); polygonElementPoints = new PointF[] { new PointF(xLocation + 220, yLocation + 50), new PointF(xLocation + 270, yLocation), new PointF(xLocation + 320, yLocation + 50), new PointF(xLocation + 270, yLocation + 100) }; // Add a Polygon Element with background color polygonElement = new PolygonElement(polygonElementPoints); polygonElement.BackColor = Color.Green; addElementResult = pdfPage.AddElement(polygonElement); PointF[] polyFillPoints = new PointF[] { new PointF(xLocation + 330, yLocation + 50), new PointF(xLocation + 380, yLocation), new PointF(xLocation + 430, yLocation + 50), new PointF(xLocation + 380, yLocation + 100) }; // Add a Polygon Element with background color and rounded line joins PolygonElement polygonElementWithBackgruondColorAndBorder = new PolygonElement(polyFillPoints); polygonElementWithBackgruondColorAndBorder.ForeColor = Color.Blue; polygonElementWithBackgruondColorAndBorder.BackColor = Color.Coral; polygonElementWithBackgruondColorAndBorder.LineStyle.LineWidth = 5; polygonElementWithBackgruondColorAndBorder.LineStyle.LineCapStyle = LineCapStyle.RoundCap; polygonElementWithBackgruondColorAndBorder.LineStyle.LineJoinStyle = LineJoinStyle.RoundJoin; addElementResult = pdfPage.AddElement(polygonElementWithBackgruondColorAndBorder); yLocation = addElementResult.EndPageBounds.Bottom + 3; pdfPage = addElementResult.EndPdfPage; // Add Bezier Curve Elements // Add section title xLocation -= 5; yLocation += 10; titleTextElement = new TextElement(xLocation, yLocation, "Bezier Curve Elements", titleFont); titleTextElement.ForeColor = Color.Black; addElementResult = pdfPage.AddElement(titleTextElement); yLocation = addElementResult.EndPageBounds.Bottom + 10; xLocation += 5; pdfPage = addElementResult.EndPdfPage; // Add a Bezier Curve Element with normal style BezierCurveElement bezierCurveElement = new BezierCurveElement(xLocation, yLocation + 50, xLocation + 50, yLocation, xLocation + 100, yLocation + 100, xLocation + 150, yLocation + 50); bezierCurveElement.ForeColor = Color.Blue; bezierCurveElement.LineStyle.LineWidth = 3; addElementResult = pdfPage.AddElement(bezierCurveElement); // Mark the points controlling the Bezier curve CircleElement controlPoint1 = new CircleElement(xLocation + 200, yLocation + 50, 2); controlPoint1.BackColor = Color.Violet; pdfPage.AddElement(controlPoint1); CircleElement controlPoint2 = new CircleElement(xLocation + 250, yLocation, 2); controlPoint2.BackColor = Color.Violet; pdfPage.AddElement(controlPoint2); CircleElement controlPoint3 = new CircleElement(xLocation + 300, yLocation + 100, 2); controlPoint3.BackColor = Color.Violet; pdfPage.AddElement(controlPoint3); CircleElement controlPoint4 = new CircleElement(xLocation + 350, yLocation + 50, 2); controlPoint4.BackColor = Color.Violet; pdfPage.AddElement(controlPoint4); // Add a Bezier Curve Element with dotted line using the controlling points above bezierCurveElement = new BezierCurveElement(controlPoint1.X, controlPoint1.Y, controlPoint2.X, controlPoint2.Y, controlPoint3.X, controlPoint3.Y, controlPoint4.X, controlPoint4.Y); bezierCurveElement.ForeColor = Color.Green; bezierCurveElement.LineStyle.LineDashStyle = LineDashStyle.Dot; bezierCurveElement.LineStyle.LineWidth = 1; addElementResult = pdfPage.AddElement(bezierCurveElement); // Save the PDF document in a memory buffer byte[] outPdfBuffer = pdfDocument.Save(); // Send the PDF as response to browser // Set response content type Response.AddHeader("Content-Type", "application/pdf"); // Instruct the browser to open the PDF file as an attachment or inline Response.AddHeader("Content-Disposition", String.Format("attachment; filename=Graphic_Elements.pdf; size={0}", outPdfBuffer.Length.ToString())); // Write the PDF document buffer to HTTP response Response.BinaryWrite(outPdfBuffer); // End the HTTP response and stop the current page processing Response.End(); } finally { // Close the PDF document pdfDocument.Close(); } }