Exemplo n.º 1
0
 //添加样式按钮
 private void btnadd_Click(object sender, EventArgs e)
 {
     if (cboBoxLineType.SelectedIndex == 0)//简单线
     {
         ISimpleLineSymbol pSimpleLineSymbol = CreateSimpleLineSymbol();
         pStyleGalleryItem.Item = pSimpleLineSymbol;
         addListBoxItem();
         PreviewImage();
     }
     else if (cboBoxLineType.SelectedIndex == 5) //点状线
     {
         IMarkerLineSymbol pMarkerLineSymbol = CreateMarkerLineSymbol();
         pStyleGalleryItem.Item = pMarkerLineSymbol;
         addListBoxItem();
         PreviewImage();
     }
 }
Exemplo n.º 2
0
        private ISymbol SetColorOfUnknownSymbol(IClone ClonedSymbol, IColor Color)
        {
            ISymbol tempSetColorOfUnknownSymbol = null;

            //
            // This function takes an IClone interface, works out the underlying coclass
            // (which should be some kind of symbol) and then sets the Color property
            // according to the passed in color.
            //
            tempSetColorOfUnknownSymbol = null;
            if (ClonedSymbol == null)
            {
                return(tempSetColorOfUnknownSymbol);
            }
            //
            // Here we figure out which kind of symbol we have. For the simple symbol
            // types, simply setting the color property is OK. However, more complex
            // symbol types require further investigation.
            //
            IFillSymbol          FillSymbol          = null;
            IMarkerFillSymbol    MarkerFillSymbol    = null;
            IMarkerSymbol        MarkerSymbol_A      = null;
            ILineFillSymbol      LineFillSymbol      = null;
            ILineSymbol          LineSymbol          = null;
            IPictureFillSymbol   PictureFillSymbol   = null;
            IMarkerSymbol        MarkerSymbol_B      = null;
            IPictureMarkerSymbol PictureMarkerSymbol = null;
            IMarkerLineSymbol    MarkerLineSymbol    = null;
            IMarkerSymbol        MarkerSymbol_C      = null;
            ILineSymbol          LineSymbol_B        = null;

            if (ClonedSymbol is ISymbol)
            {
                //
                // Check for Fill symbols.
                //
                if (ClonedSymbol is IFillSymbol)
                {
                    //
                    // Check for SimpleFillSymbols or MultiLevelFillSymbols.
                    //
                    if ((ClonedSymbol is ISimpleFillSymbol) | (ClonedSymbol is IMultiLayerFillSymbol))
                    {
                        FillSymbol = (IFillSymbol)ClonedSymbol;
                        //
                        // Here we simply change the color of the Fill.
                        //
                        FillSymbol.Color            = Color;
                        tempSetColorOfUnknownSymbol = (ISymbol)FillSymbol;
                        //
                        // Check for MarkerFillSymbols.
                        //
                    }
                    else if (ClonedSymbol is IMarkerFillSymbol)
                    {
                        MarkerFillSymbol = (IMarkerFillSymbol)ClonedSymbol;
                        //
                        // Here we change the color of the MarkerSymbol.
                        //
                        MarkerSymbol_A = (IMarkerSymbol)SetColorOfUnknownSymbol((IClone)MarkerFillSymbol.MarkerSymbol, Color);
                        MarkerFillSymbol.MarkerSymbol = MarkerSymbol_A;
                        tempSetColorOfUnknownSymbol   = (ISymbol)MarkerFillSymbol;
                        //
                        // Check for LineFillSymbols.
                        //
                    }
                    else if (ClonedSymbol is ILineFillSymbol)
                    {
                        LineFillSymbol = (ILineFillSymbol)ClonedSymbol;
                        //
                        // Here we change the color of the LineSymbol.
                        //
                        LineSymbol = (ILineSymbol)SetColorOfUnknownSymbol((IClone)LineFillSymbol.LineSymbol, Color);
                        LineFillSymbol.LineSymbol   = LineSymbol;
                        tempSetColorOfUnknownSymbol = (ISymbol)LineFillSymbol;
                        //
                        // Check for PictureFillSymbols.
                        //
                    }
                    else if (ClonedSymbol is IPictureFillSymbol)
                    {
                        PictureFillSymbol = (IPictureFillSymbol)ClonedSymbol;
                        //
                        // Here we simply change the color of the BackgroundColor.
                        //
                        PictureFillSymbol.BackgroundColor = Color;
                        tempSetColorOfUnknownSymbol       = (ISymbol)PictureFillSymbol;
                    }
                    //
                    // Check for Marker symbols.
                    //
                }
                else if (ClonedSymbol is IMarkerSymbol)
                {
                    //
                    // Check for SimpleMarkerSymbols, ArrowMarkerSymbols or
                    // CharacterMarkerSymbols.
                    //
                    if ((ClonedSymbol is IMultiLayerMarkerSymbol) | (ClonedSymbol is ISimpleMarkerSymbol) | (ClonedSymbol is IArrowMarkerSymbol) | (ClonedSymbol is ICharacterMarkerSymbol))
                    {
                        MarkerSymbol_B = (IMarkerSymbol)ClonedSymbol;
                        //
                        // For these types, we simply change the color property.
                        //
                        MarkerSymbol_B.Color        = Color;
                        tempSetColorOfUnknownSymbol = (ISymbol)MarkerSymbol_B;
                        //
                        // Check for PictureMarkerSymbols.
                        //
                    }
                    else if (ClonedSymbol is IPictureMarkerSymbol)
                    {
                        PictureMarkerSymbol = (IPictureMarkerSymbol)ClonedSymbol;
                        //
                        // Here we change the BackgroundColor property.
                        //
                        PictureMarkerSymbol.Color   = Color;
                        tempSetColorOfUnknownSymbol = (ISymbol)PictureMarkerSymbol;
                    }
                    //
                    // Check for Line symbols.
                    //
                }
                else if (ClonedSymbol is ILineSymbol)
                {
                    //
                    // Check for MarkerLine symbols.
                    //
                    if (ClonedSymbol is IMarkerLineSymbol)
                    {
                        MarkerLineSymbol = (IMarkerLineSymbol)ClonedSymbol;
                        //
                        // Here we change the color of the MarkerSymbol.
                        //
                        MarkerSymbol_C = (IMarkerSymbol)SetColorOfUnknownSymbol((IClone)MarkerLineSymbol.MarkerSymbol, Color);
                        MarkerLineSymbol.MarkerSymbol = MarkerSymbol_C;
                        tempSetColorOfUnknownSymbol   = (ISymbol)MarkerLineSymbol;
                        //
                        // Check for other Line symbols.
                        //
                    }
                    else if ((ClonedSymbol is ISimpleLineSymbol) | (ClonedSymbol is IHashLineSymbol) | (ClonedSymbol is ICartographicLineSymbol))
                    {
                        LineSymbol_B                = (ILineSymbol)ClonedSymbol;
                        LineSymbol_B.Color          = Color;
                        tempSetColorOfUnknownSymbol = (ISymbol)LineSymbol_B;
                    }
                }
            }

            return(tempSetColorOfUnknownSymbol);
        }