コード例 #1
0
ファイル: Form1.cs プロジェクト: XYT1033/csdn_download
        //GradientFillSymbol
        private void button15_Click(object sender, EventArgs e)
        {
            IGradientFillSymbol   gradientFillSymbol = new GradientFillSymbolClass();
            IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();

            algorithcColorRamp.FromColor          = getRGB(255, 0, 0);
            algorithcColorRamp.ToColor            = getRGB(0, 255, 0);
            algorithcColorRamp.Algorithm          = esriColorRampAlgorithm.esriHSVAlgorithm;
            gradientFillSymbol.ColorRamp          = algorithcColorRamp;
            gradientFillSymbol.GradientAngle      = 45;
            gradientFillSymbol.GradientPercentage = 0.9;
            gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;


            object           Missing         = Type.Missing;
            IPolygon         polygon         = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint           point           = new PointClass();

            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(gradientFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: XYT1033/csdn_download
        //MultilayerFillSymbol
        private void button17_Click(object sender, EventArgs e)
        {
            IMultiLayerFillSymbol multiLayerFillSymbol = new MultiLayerFillSymbolClass();

            IGradientFillSymbol   gradientFillSymbol = new GradientFillSymbolClass();
            IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();

            algorithcColorRamp.FromColor          = getRGB(255, 0, 0);
            algorithcColorRamp.ToColor            = getRGB(0, 255, 0);
            algorithcColorRamp.Algorithm          = esriColorRampAlgorithm.esriHSVAlgorithm;
            gradientFillSymbol.ColorRamp          = algorithcColorRamp;
            gradientFillSymbol.GradientAngle      = 45;
            gradientFillSymbol.GradientPercentage = 0.9;
            gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;

            ICartographicLineSymbol cartoLine = new CartographicLineSymbol();

            cartoLine.Cap   = esriLineCapStyle.esriLCSButt;
            cartoLine.Join  = esriLineJoinStyle.esriLJSMitre;
            cartoLine.Color = getRGB(255, 0, 0);
            cartoLine.Width = 2;
            //Create the LineFillSymbo
            ILineFillSymbol lineFill = new LineFillSymbol();

            lineFill.Angle      = 45;
            lineFill.Separation = 10;
            lineFill.Offset     = 5;
            lineFill.LineSymbol = cartoLine;


            multiLayerFillSymbol.AddLayer(gradientFillSymbol);
            multiLayerFillSymbol.AddLayer(lineFill);

            object           Missing         = Type.Missing;
            IPolygon         polygon         = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint           point           = new PointClass();

            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(multiLayerFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }
コード例 #3
0
 /// <summary>
 /// 创建高级渐变符号
 /// </summary>
 /// <returns>正常:返回符号;异常:null</returns>
 public IGradientFillSymbol CreateAdvancedSymbol()
 {
     try
     {
         //为填充符号创建外框线符号
         IColor pLineColor = new RgbColorClass();
         pLineColor.RGB = 220;
         IGradientFillSymbol pGradientFillSymbol = new GradientFillSymbolClass();
         pGradientFillSymbol.IntervalCount = 1;
         pGradientFillSymbol.Color         = pLineColor;
         //创建一个填充符号
         //ISimpleFillSymbol pSmplFillSymbol = new SimpleFillSymbol();
         //设置填充符号的属性
         // IColor pRgbClr = new RgbColorClass();
         //IFillSymbol pFillSymbol = pSmplFillSymbol;
         //pFillSymbol.Color = pRgbClr;
         //pFillSymbol.Outline = pGradientFillSymbol;
         return(pGradientFillSymbol);
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #4
0
 protected void DrawSymbol(int int_3, System.Drawing.Rectangle rectangle_0, object object_0)
 {
     if (object_0 != null)
     {
         IDisplayTransformation displayTransformation = new DisplayTransformationClass();
         IEnvelope envelope = new EnvelopeClass();
         envelope.PutCoords((double)rectangle_0.Left, (double)rectangle_0.Top, (double)rectangle_0.Right,
                            (double)rectangle_0.Bottom);
         tagRECT tagRECT;
         tagRECT.left   = rectangle_0.Left;
         tagRECT.right  = rectangle_0.Right;
         tagRECT.bottom = rectangle_0.Bottom;
         tagRECT.top    = rectangle_0.Top;
         displayTransformation.set_DeviceFrame(ref tagRECT);
         displayTransformation.Bounds         = envelope;
         displayTransformation.Resolution     = 96.0;
         displayTransformation.ReferenceScale = 1.0;
         displayTransformation.ScaleRatio     = 1.0;
         ISymbol symbol;
         if (object_0 is ISymbol)
         {
             symbol = (ISymbol)object_0;
         }
         else if (object_0 is IColorRamp)
         {
             IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass();
             ILineSymbol         outline            = gradientFillSymbol.Outline;
             outline.Width = 0.0;
             gradientFillSymbol.Outline            = outline;
             gradientFillSymbol.ColorRamp          = (IColorRamp)object_0;
             gradientFillSymbol.GradientAngle      = 180.0;
             gradientFillSymbol.GradientPercentage = 1.0;
             gradientFillSymbol.IntervalCount      = 100;
             gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;
             symbol = (ISymbol)gradientFillSymbol;
         }
         else if (object_0 is IColor)
         {
             symbol = (ISymbol) new ColorSymbolClass
             {
                 Color = (IColor)object_0
             };
         }
         else if (object_0 is IAreaPatch)
         {
             symbol = new SimpleFillSymbolClass();
             IRgbColor rgbColor = new RgbColorClass();
             rgbColor.Red   = 227;
             rgbColor.Green = 236;
             rgbColor.Blue  = 19;
             ((IFillSymbol)symbol).Color = rgbColor;
         }
         else if (object_0 is ILinePatch)
         {
             symbol = new SimpleLineSymbolClass();
         }
         else
         {
             if (object_0 is INorthArrow)
             {
                 IDisplay display = new ScreenDisplayClass();
                 display.StartDrawing(int_3, 0);
                 display.DisplayTransformation = displayTransformation;
                 ((IMapSurround)object_0).Draw(display, null, envelope);
                 display.FinishDrawing();
                 ((IMapSurround)object_0).Refresh();
                 return;
             }
             if (object_0 is IMapSurround)
             {
                 IDisplay display = new ScreenDisplayClass();
                 display.StartDrawing(int_3, 0);
                 display.DisplayTransformation = displayTransformation;
                 IEnvelope envelope2 = new EnvelopeClass();
                 envelope2.PutCoords((double)(rectangle_0.Left + 5), (double)(rectangle_0.Top + 5),
                                     (double)(rectangle_0.Right - 5), (double)(rectangle_0.Bottom - 5));
                 ((IMapSurround)object_0).QueryBounds(display, envelope, envelope2);
                 bool flag;
                 ((IMapSurround)object_0).FitToBounds(display, envelope2, out flag);
                 ((IMapSurround)object_0).Draw(display, null, envelope2);
                 display.FinishDrawing();
                 ((IMapSurround)object_0).Refresh();
                 return;
             }
             if (object_0 is IBackground)
             {
                 IDisplay display = new ScreenDisplayClass();
                 display.StartDrawing(int_3, 0);
                 display.DisplayTransformation = displayTransformation;
                 IGeometry geometry = ((IBackground)object_0).GetGeometry(display, envelope);
                 ((IBackground)object_0).Draw(display, geometry);
                 display.FinishDrawing();
                 return;
             }
             if (object_0 is IShadow)
             {
                 IDisplay display = new ScreenDisplayClass();
                 display.StartDrawing(int_3, 0);
                 display.DisplayTransformation = displayTransformation;
                 double horizontalSpacing = ((IShadow)object_0).HorizontalSpacing;
                 double verticalSpacing   = ((IShadow)object_0).VerticalSpacing;
                 ((IShadow)object_0).HorizontalSpacing = 0.0;
                 ((IShadow)object_0).VerticalSpacing   = 0.0;
                 IGeometry geometry = ((IShadow)object_0).GetGeometry(display, envelope);
                 ((IShadow)object_0).Draw(display, geometry);
                 ((IShadow)object_0).HorizontalSpacing = horizontalSpacing;
                 ((IShadow)object_0).VerticalSpacing   = verticalSpacing;
                 display.FinishDrawing();
                 return;
             }
             if (object_0 is IBorder)
             {
                 IDisplay display = new ScreenDisplayClass();
                 display.StartDrawing(int_3, 0);
                 display.DisplayTransformation = displayTransformation;
                 IPointCollection pointCollection = new PolylineClass();
                 object           value           = System.Reflection.Missing.Value;
                 IPoint           point           = new PointClass();
                 point.PutCoords((double)(rectangle_0.X + 4), (double)rectangle_0.Top);
                 pointCollection.AddPoint(point, ref value, ref value);
                 point.PutCoords((double)(rectangle_0.X + 4), (double)rectangle_0.Bottom);
                 pointCollection.AddPoint(point, ref value, ref value);
                 point.PutCoords((double)(rectangle_0.Right - 4), (double)rectangle_0.Bottom);
                 pointCollection.AddPoint(point, ref value, ref value);
                 IGeometry geometry = ((IBorder)object_0).GetGeometry(display, (IGeometry)pointCollection);
                 ((IBorder)object_0).Draw(display, geometry);
                 display.FinishDrawing();
                 return;
             }
             return;
         }
         if (symbol is IPictureFillSymbol || symbol is IPictureLineSymbol)
         {
             symbol.SetupDC(int_3, null);
         }
         else
         {
             symbol.SetupDC(int_3, displayTransformation);
         }
         if (object_0 is IPatch)
         {
             this.method_3(symbol, (IPatch)object_0, rectangle_0);
         }
         else if (symbol is IMarkerSymbol)
         {
             this.method_2((IMarkerSymbol)symbol, rectangle_0);
         }
         else if (symbol is ILineSymbol)
         {
             this.method_4((ILineSymbol)symbol, rectangle_0);
         }
         else if (symbol is IFillSymbol)
         {
             this.method_5((IFillSymbol)symbol, rectangle_0);
         }
         else if (symbol is ITextSymbol)
         {
             this.method_7((ITextSymbol)symbol, rectangle_0);
         }
         symbol.ResetDC();
     }
 }
コード例 #5
0
 protected void DrawSymbol(int int_3, Rectangle rectangle_0, object object_0)
 {
     if (object_0 != null)
     {
         tagRECT grect;
         ISymbol symbol;
         IDisplayTransformation transformation = new DisplayTransformationClass();
         IEnvelope bounds = new EnvelopeClass();
         bounds.PutCoords((double)rectangle_0.Left, (double)rectangle_0.Top, (double)rectangle_0.Right,
                          (double)rectangle_0.Bottom);
         grect.left   = rectangle_0.Left;
         grect.right  = rectangle_0.Right;
         grect.bottom = rectangle_0.Bottom;
         grect.top    = rectangle_0.Top;
         transformation.set_DeviceFrame(ref grect);
         transformation.Bounds         = bounds;
         transformation.Resolution     = 96.0;
         transformation.ReferenceScale = 1.0;
         transformation.ScaleRatio     = 1.0;
         if (object_0 is ISymbol)
         {
             symbol = object_0 as ISymbol;
         }
         else if (object_0 is IColorRamp)
         {
             IGradientFillSymbol symbol2 = new GradientFillSymbolClass();
             ILineSymbol         outline = symbol2.Outline;
             outline.Width              = 0.0;
             symbol2.Outline            = outline;
             symbol2.ColorRamp          = object_0 as IColorRamp;
             symbol2.GradientAngle      = 180.0;
             symbol2.GradientPercentage = 1.0;
             symbol2.IntervalCount      = 100;
             symbol2.Style              = esriGradientFillStyle.esriGFSLinear;
             symbol = (ISymbol)symbol2;
         }
         else if (object_0 is IColor)
         {
             IColorSymbol symbol4 = new ColorSymbolClass
             {
                 Color = object_0 as IColor
             };
             symbol = (ISymbol)symbol4;
         }
         else if (object_0 is IAreaPatch)
         {
             symbol = new SimpleFillSymbolClass();
             IRgbColor color = new RgbColorClass
             {
                 Red   = 227,
                 Green = 236,
                 Blue  = 19
             };
             ((IFillSymbol)symbol).Color = color;
         }
         else
         {
             if (!(object_0 is ILinePatch))
             {
                 IDisplay display;
                 if (object_0 is INorthArrow)
                 {
                     display = new ScreenDisplayClass();
                     display.StartDrawing(int_3, 0);
                     display.DisplayTransformation = transformation;
                     ((IMapSurround)object_0).Draw(display, null, bounds);
                     display.FinishDrawing();
                     ((IMapSurround)object_0).Refresh();
                 }
                 else if (object_0 is IMapSurround)
                 {
                     bool flag;
                     display = new ScreenDisplayClass();
                     display.StartDrawing(int_3, 0);
                     display.DisplayTransformation = transformation;
                     IEnvelope newBounds = new EnvelopeClass();
                     newBounds.PutCoords((double)(rectangle_0.Left + 5), (double)(rectangle_0.Top + 5),
                                         (double)(rectangle_0.Right - 5), (double)(rectangle_0.Bottom - 5));
                     ((IMapSurround)object_0).QueryBounds(display, bounds, newBounds);
                     ((IMapSurround)object_0).FitToBounds(display, newBounds, out flag);
                     ((IMapSurround)object_0).Draw(display, null, newBounds);
                     display.FinishDrawing();
                     ((IMapSurround)object_0).Refresh();
                 }
                 else
                 {
                     IGeometry geometry;
                     if (object_0 is IBackground)
                     {
                         display = new ScreenDisplayClass();
                         display.StartDrawing(int_3, 0);
                         display.DisplayTransformation = transformation;
                         geometry = ((IBackground)object_0).GetGeometry(display, bounds);
                         ((IBackground)object_0).Draw(display, geometry);
                         display.FinishDrawing();
                     }
                     else if (object_0 is IShadow)
                     {
                         display = new ScreenDisplayClass();
                         display.StartDrawing(int_3, 0);
                         display.DisplayTransformation = transformation;
                         double horizontalSpacing = ((IShadow)object_0).HorizontalSpacing;
                         double verticalSpacing   = ((IShadow)object_0).VerticalSpacing;
                         ((IShadow)object_0).HorizontalSpacing = 0.0;
                         ((IShadow)object_0).VerticalSpacing   = 0.0;
                         geometry = ((IShadow)object_0).GetGeometry(display, bounds);
                         ((IShadow)object_0).Draw(display, geometry);
                         ((IShadow)object_0).HorizontalSpacing = horizontalSpacing;
                         ((IShadow)object_0).VerticalSpacing   = verticalSpacing;
                         display.FinishDrawing();
                     }
                     else if (object_0 is IBorder)
                     {
                         display = new ScreenDisplayClass();
                         display.StartDrawing(int_3, 0);
                         display.DisplayTransformation = transformation;
                         IPointCollection points  = new PolylineClass();
                         object           before  = Missing.Value;
                         IPoint           inPoint = new PointClass();
                         inPoint.PutCoords((double)(rectangle_0.X + 4), (double)rectangle_0.Top);
                         points.AddPoint(inPoint, ref before, ref before);
                         inPoint.PutCoords((double)(rectangle_0.X + 4), (double)rectangle_0.Bottom);
                         points.AddPoint(inPoint, ref before, ref before);
                         inPoint.PutCoords((double)(rectangle_0.Right - 4), (double)rectangle_0.Bottom);
                         points.AddPoint(inPoint, ref before, ref before);
                         geometry = ((IBorder)object_0).GetGeometry(display, (IGeometry)points);
                         ((IBorder)object_0).Draw(display, geometry);
                         display.FinishDrawing();
                     }
                 }
                 return;
             }
             symbol = new SimpleLineSymbolClass();
         }
         if ((symbol is IPictureFillSymbol) || (symbol is IPictureLineSymbol))
         {
             symbol.SetupDC(int_3, null);
         }
         else
         {
             symbol.SetupDC(int_3, transformation);
         }
         if (object_0 is IPatch)
         {
             this.method_3(symbol, (IPatch)object_0, rectangle_0);
         }
         else if (symbol is IMarkerSymbol)
         {
             this.method_2((IMarkerSymbol)symbol, rectangle_0);
         }
         else if (symbol is ILineSymbol)
         {
             this.method_4((ILineSymbol)symbol, rectangle_0);
         }
         else if (symbol is IFillSymbol)
         {
             this.method_5((IFillSymbol)symbol, rectangle_0);
         }
         else if (symbol is ITextSymbol)
         {
             this.method_7((ITextSymbol)symbol, rectangle_0);
         }
         symbol.ResetDC();
     }
 }