Exemple #1
0
        private System.Drawing.Image Symbol2Picture(object pSymbol, int width, int height)
        {
            if (pSymbol == null || width < 1 || height < 1)
            {
                return(null);
            }
            if (pSymbol is IMarkerSymbol)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbols;
            }
            else if (pSymbol is ILineSymbol)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassLineSymbols;
            }
            else if (pSymbol is IFillSymbol)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassFillSymbols;
            }
            else if (pSymbol is ITextSymbol)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassTextSymbols;
            }
            else if (pSymbol is INorthArrow)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows;
            }
            else if (pSymbol is IScaleBar)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleBars;
            }
            else if (pSymbol is IScaleText)
            {
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassScaleTexts;
            }

            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);

            symbologyStyleClass.RemoveAll();
            IStyleGalleryItem pStyleItem = new ServerStyleGalleryItemClass();

            pStyleItem.Name = "tempSymbol";
            pStyleItem.Item = pSymbol;
            //symbologyStyleClass.AddItem(pStyleItem, 0);
            stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(pStyleItem, width, height);
            if (pSymbol is IScaleBar)
            {
                picture = symbologyStyleClass.PreviewItem(pStyleItem, width * 2, height);
            }
            else if (pSymbol is IScaleText)
            {
                picture = symbologyStyleClass.PreviewItem(pStyleItem, width * 2, height);
            }
            System.Drawing.Image image = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            return(image);
        }
Exemple #2
0
        private void ChangeSymbol(DevComponents.DotNetBar.Controls.ComboBoxEx cmb, Color pColor, esriSymbologyStyleClass styleClass)
        {
            try
            {
                DevComponents.Editors.ComboItem item = cmb.SelectedItem as DevComponents.Editors.ComboItem;
                object obj = item.Tag;
                if (obj == null)
                {
                    return;
                }
                IFrameDecoration pFrameDecoration = (IFrameDecoration)obj;
                IRgbColor        pRgbColor        = new RgbColorClass();
                pRgbColor.Red   = pColor.R;
                pRgbColor.Green = pColor.G;
                pRgbColor.Blue  = pColor.B;

                pFrameDecoration.Color = (IColor)pRgbColor;
                IStyleGalleryItem pItem = new ServerStyleGalleryItemClass();
                pItem.Name = "temp";
                pItem.Item = pFrameDecoration;
                stdole.IPictureDisp  picture;
                System.Drawing.Image image;

                ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(styleClass);
                picture    = symbologyStyleClass.PreviewItem(pItem, cmb.Width - 80, cmb.Height);
                image      = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                item.Image = image;
            }
            catch
            {
            }
        }
Exemple #3
0
        private void InitialColorRamp(esriSymbologyStyleClass styleClass)
        {
            if (m_pRasterRenderer is IRasterStretchColorRampRenderer)
            {
                //得到当前栅格拉伸渲染样式
                IRasterStretchColorRampRenderer rasterStrecthcRenderer = m_pRasterRenderer as IRasterStretchColorRampRenderer;

                //从文件打开渲染库
                string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";
                axSymbologyControl1.LoadStyleFile(sInstall);
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
                pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);

                IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem();
                pStyleGalleryItem.Item = rasterStrecthcRenderer.ColorRamp;
                pSymbolClass.AddItem(pStyleGalleryItem, 0);

                //将渲染库中所有渲染方式添加到列表中
                for (int i = 0; i < pSymbolClass.ItemCount; i++)
                {
                    stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height);
                    Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
                    cmbColorRamp.Items.Add(image);
                }
                if (pSymbolClass.ItemCount > 0)
                {
                    pSymbolClass.SelectItem(0);
                }
                if (cmbColorRamp.Items.Count > 0)
                {
                    cmbColorRamp.SelectedIndex = 0;
                }
            }
        }
Exemple #4
0
        //添加GLISTBOX项
        private void addListBoxItem(ISymbol symbol)
        {
            IStyleGallery        styleGallery;
            IStyleGalleryItem    styleGalleryItem;
            IStyleGalleryStorage styleGalleryStorge;

            styleGalleryItem          = new ServerStyleGalleryItemClass();
            styleGalleryItem.Name     = this.txtSymbolName.Text;
            styleGalleryItem.Category = "default";
            object objSymbol = symbol;

            styleGalleryItem.Item = objSymbol;

            styleGallery                  = new ServerStyleGalleryClass();
            styleGalleryStorge            = styleGallery as IStyleGalleryStorage;
            styleGalleryStorge.TargetFile = fileName;

            //IStyleGalleryClass styleGalleryClass = styleGallery.get_Class(CurrentStyleGalleryClassIndex);
            ISymbologyStyleClass pSymbolClass = psymbologyStyleClass;

            pSymbolClass.AddItem(styleGalleryItem, 0);
            pSymbolClass.SelectItem(0);

            stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 20);
            Image     image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
            GridPanel panel = supergrid.PrimaryGrid;
            GridRow   row   = new GridRow(image);

            panel.Rows.Add(row);
            psymbologyStyleClass.RemoveItem(0);
            imagelist.Add(image);
        }
Exemple #5
0
        private void PreviewImage()
        {
            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass);

            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(m_styleGalleryItem, SymbolPictureBox.Width, SymbolPictureBox.Height);
            System.Drawing.Image image   = Image.FromHbitmap(new IntPtr(picture.Handle));
            SymbolPictureBox.Image = image;
        }
Exemple #6
0
        protected void PreviewImage()
        {
            ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
            IPictureDisp         pPicture             = pSymbologyStyleClass.PreviewItem(m_pStyleGalleryItem, picBoxPreview.Width, picBoxPreview.Height);
            Image pImage = Image.FromHbitmap(new IntPtr(pPicture.Handle));

            picBoxPreview.Image = pImage;
        }
        /**
         * @fn GetImageByGiveSymbolAfterSelectItem
         * @date 2013.03.16
         * @author Ge Xizhi
         * @brief 调用边框样式前返回选择样式的图片
         * @param width 图片宽度
         * @param height 图片高度
         * @retval TRUE 成功
         * @retval FALSE 失败
         */
        //选择样式后返回图片
        public Image GetImageByGiveSymbolAfterSelectItem(int width, int height)
        {
            ISymbologyStyleClass symbologyStyleClass = axSymbologyCtlFrame.GetStyleClass(axSymbologyCtlFrame.StyleClass);

            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, height);
            System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            return(image);
        }
        private void PreviewImage(IStyleGalleryItem item)
        {
            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);

            if (symbologyStyleClass.StyleClass == esriSymbologyStyleClass.esriStyleClassScaleBars)
            {
                stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(item, pictureBox1.Width * 2, pictureBox1.Height);
                System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                pictureBox1.Image = image;
            }
            else
            {
                stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(item, pictureBox1.Width, pictureBox1.Height);
                System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                pictureBox1.Image = image;
            }
        }
Exemple #9
0
        /// <summary>
        /// 预览选中符号,使其显示在图片控件中
        /// </summary>
        private void PreviewImage()
        {
            ISymbologyStyleClass pSymbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass);
            IPictureDisp         pPictureDisp         = pSymbologyStyleClass.PreviewItem(currentStyleGalleryItem, PreviewSymbology.Width, PreviewSymbology.Height);

            PreViewImage = Image.FromHbitmap(new System.IntPtr(pPictureDisp.Handle));
            PreviewSymbology.Appearance.Image = PreViewImage;
        }
        // 预览   将 pStyleGalleryItem 反映到 picture 上
        private void PreviewPicture()
        {
            ISymbologyStyleClass pSymbologyStyle = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);

            stdole.IPictureDisp picture = pSymbologyStyle.PreviewItem(pStyleGalleryItem, pictureBox1.Width, pictureBox1.Height);    //建立实例
            Image image = Image.FromHbitmap(new IntPtr(picture.Handle));                                                            //转成 C# 支持的 Image 实例

            pictureBox1.Image = image;
        }
Exemple #11
0
        private void PreviewImage()
        {
            //Get and set the style class
            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);

            //Preview an image of the symbol
            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(m_styleGalleryItem, pictureBox1.Width, pictureBox1.Height);
            System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            pictureBox1.Image = image;
        }
Exemple #12
0
        private void ShowPreviewImage()
        {
            //Get and set the style class
            ISymbologyStyleClass symbologyStyleClass = this._axSymCtrl.GetStyleClass(_axSymCtrl.StyleClass);

            //Preview an image of the symbol
            stdole.IPictureDisp   picture = symbologyStyleClass.PreviewItem(this._styleGalleryItem, (int)PreviewImage.Width, (int)PreviewImage.Height);
            System.Drawing.Bitmap bitmap  = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            PreviewImage.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
        }
Exemple #13
0
 /// <summary>
 /// Views the symble.
 /// </summary>
 private void ViewSymble()
 {
     if (this._styleGalleryItem != null)
     {
         ISymbologyStyleClass styleClass  = this.axSymbologyControl1.GetStyleClass(this.axSymbologyControl1.StyleClass);
         stdole.IPictureDisp  pictureDisp = styleClass.PreviewItem(this._styleGalleryItem, this.pictureEdit.Width, this.pictureEdit.Height);
         Image image = Image.FromHbitmap(new IntPtr(pictureDisp.Handle));
         this.pictureEdit.Image = image;
     }
 }
Exemple #14
0
        private void FrmSymboloTin_Load(object sender, EventArgs e)
        {
            string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyControl1.LoadStyleFile(sInstall);
            axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
            pSymbolClass = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);



            /* *********************************
            * 生成色度带
            * *********************************/

            for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++)
            {
                stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbcolor.Width, cmbcolor.Height);
                Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
                cmbcolor.Items.Add(image);
            }

            if (cmbcolor.Items.Count > 0)
            {
                cmbcolor.SelectedIndex = 0;
            }

            /* *********************************
            * 初始化gridview及颜色控件
            * *********************************/

            if (pTLayer.GetRenderer(0).GetType().Name == "TinFaceRendererClass" || pTLayer.GetRenderer(0).Name == "Faces")
            {
                treeshow.SelectedIndex = 1;
                ITinSingleSymbolRenderer pTinrenderer = pTLayer.GetRenderer(0) as ITinSingleSymbolRenderer;
                ISimpleFillSymbol        psymbol      = new SimpleFillSymbolClass();
                psymbol = pTinrenderer.Symbol as ISimpleFillSymbol;
                btncolor.SelectedColor = ClsGDBDataCommon.IColorToColor(psymbol.Color);
                istrue = true;
            }
            else if (pTLayer.GetRenderer(0).Name == "Elevation" || pTLayer.GetRenderer(0).Name == "Edge types")
            {
                treeshow.SelectedIndex = 0;
                btncolor.SelectedColor = System.Drawing.Color.Green;
                for (int j = 0; j < pTLayer.RendererCount; j++)
                {
                    if (pTLayer.GetRenderer(j).Name == "Elevation")
                    {
                        ptinColorRampRenderer = pTLayer.GetRenderer(j) as ITinColorRampRenderer;
                        break;
                    }
                }
                cmbclasses.SelectedIndex = ptinColorRampRenderer.BreakCount - 1;
                initialupdatagrid();
            }
        }
Exemple #15
0
        //预览样式
        private void PreviewImage()
        {
            //Get and set the style class
            ISymbologyStyleClass symbologyStyleClass = axSymbologyCtlLegendItem.GetStyleClass(axSymbologyCtlLegendItem.StyleClass);

            //Preview an image of the symbol
            stdole.IPictureDisp  pPicpture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, ImagePreview.Width, ImagePreview.Height);
            System.Drawing.Image pImage    = System.Drawing.Image.FromHbitmap(new System.IntPtr(pPicpture.Handle));

            ImagePreview.Image = pImage;
        }
        /// <summary>
        /// 预览当前元素对象
        /// </summary>
        private void PreviewImage()
        {
            //获得样式类
            ISymbologyStyleClass symbolgyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);

            //symbolPictureBox.Size = new System.Drawing.Size((int)GetTextSizeFromItem(m_styleGalleryItem.Item), (int)GetTextSizeFromItem(m_styleGalleryItem.Item));
            //symbolPictureBox.Location = new System.Drawing.Point((symbolPictureBox.Parent.Width - symbolPictureBox.Width) / 2 , 20);
            stdole.IPictureDisp  picture = symbolgyStyleClass.PreviewItem(m_styleGalleryItem, symbolPictureBox.Width, symbolPictureBox.Height);
            System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));

            symbolPictureBox.Image = image;
        }
Exemple #17
0
        /**
         * @fn GetImageByGiveSymbolAfterSelectItem
         * @date 2013.03.16
         * @author Ge Xizhi
         * @brief 调用背景样式前返回选择样式的图片
         * @param width 图片宽度
         * @param height 图片高度
         * @retval TRUE 成功
         * @retval FALSE 失败
         */

        //选择样式后返回图片
        public Image GetImageByGiveSymbolAfterSelectItem(int width, int height)
        {
            if (pStyleGalleryItem == null)
            {
                MessageBox.Show("请选择背景式", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            ISymbologyStyleClass symbologyStyleClass = axSymbologyCtlFrame.GetStyleClass(axSymbologyCtlFrame.StyleClass);

            //Preview an image of the symbol
            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, height);
            System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            return(image);
        }
Exemple #18
0
        /// <summary>
        /// 在图片框中预览符号样式
        /// </summary>
        /// <param name="symbologyCtrl">符号控件</param>
        /// <param name="styleGalleryItem">符号样式</param>
        /// <param name="pictureBox">图片框</param>
        public static void PreviewImage(AxSymbologyControl symbologyCtrl, IStyleGalleryItem styleGalleryItem,
                                        PictureBox pictureBox)
        {
            //获取符号样式类
            ISymbologyStyleClass symbologyStyleClass = symbologyCtrl.GetStyleClass(symbologyCtrl.StyleClass);

            //获取符号图片
            stdole.IPictureDisp picture = symbologyStyleClass.PreviewItem(styleGalleryItem, pictureBox.Width,
                                                                          pictureBox.Height);
            Image image = Image.FromHbitmap(new IntPtr(picture.Handle));

            pictureBox.Image = image;
        }
Exemple #19
0
        //返回样式图片
        public void GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass styleClass, ISymbol symbol)
        {
            axSymbologyControl.StyleClass = styleClass;
            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(styleClass);

            IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem();

            styleGalleryItem.Item = symbol;

            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(styleGalleryItem, ImagePreview.Width, ImagePreview.Height);
            System.Drawing.Image pImage  = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            ImagePreview.Image = pImage;
        }
Exemple #20
0
        //选择样式前返回面图片
        public Image GetImageByGiveAreaSymbolBeforeSelectItem(esriSymbologyStyleClass styleClass, IAreaPatch symbol, int width, int height)
        {
            axSymbologyCtlFrame.StyleClass = styleClass;
            ISymbologyStyleClass symbologyStyleClass = axSymbologyCtlFrame.GetStyleClass(styleClass);

            IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem();

            styleGalleryItem.Item = symbol;
            symbologyStyleClass.AddItem(styleGalleryItem, 0);
            symbologyStyleClass.SelectItem(0);
            stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, height);
            System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
            return(image);
        }
Exemple #21
0
        //预览
        private void PreviewImage()
        {
            try
            {
                //Get and set the style class
                ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(axSymbologyControl.StyleClass);

                //Preview an image of the symbol
                stdole.IPictureDisp  pPicpture = symbologyStyleClass.PreviewItem(StyleGalleryItem, ImagePreview.Width, ImagePreview.Height);
                System.Drawing.Image pImage    = System.Drawing.Image.FromHbitmap(new System.IntPtr(pPicpture.Handle));

                ImagePreview.Image = pImage;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #22
0
        //添加GLISTBOX项
        private void addListBoxItem(ISymbol symbol)
        {
            IStyleGallery        styleGallery;
            IStyleGalleryItem    styleGalleryItem;
            IStyleGalleryStorage styleGalleryStorge;

            styleGalleryItem          = new ServerStyleGalleryItemClass();
            styleGalleryItem.Name     = this.txtSymbolName.Text;
            styleGalleryItem.Category = "default";
            object objSymbol = symbol;

            styleGalleryItem.Item = objSymbol;

            styleGallery                  = new ServerStyleGalleryClass();
            styleGalleryStorge            = styleGallery as IStyleGalleryStorage;
            styleGalleryStorge.TargetFile = fileName;

            ISymbologyStyleClass pSymbolClass = psymbologyStyleClass;

            pSymbolClass.AddItem(styleGalleryItem, 0);
            pSymbolClass.SelectItem(0);
            Image image = null;

            if (symbol is IMarker3DSymbol)
            {
                IMarker3DSymbol mar3dsym = symbol as IMarker3DSymbol;
                stdole.IPicture pic      = mar3dsym.Thumbnail;
                image = Image.FromHbitmap(new System.IntPtr(pic.Handle));
            }
            else
            {
                stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(styleGalleryItem, 140, 15);
                image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
            }

            GridPanel panel = supergrid.PrimaryGrid;
            GridRow   row   = new GridRow(image);

            panel.Rows.Add(row);
            psymbologyStyleClass.RemoveItem(0);
            imagelist.Add(image);
            Symbollist.Add(symbol);
        }
Exemple #23
0
        private void PreViewCustom(DevComponents.DotNetBar.Controls.ComboBoxEx cmb, object item, esriSymbologyStyleClass styleClass)
        {
            IStyleGalleryItem pStyleItem = new ServerStyleGalleryItemClass();

            pStyleItem.Name = "Custom";
            pStyleItem.Item = item;
            stdole.IPictureDisp  picture;
            System.Drawing.Image image;

            ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(styleClass);

            picture = symbologyStyleClass.PreviewItem(pStyleItem, cmb.Width - 80, cmb.Height);
            image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));

            DevComponents.Editors.ComboItem valueItem;
            valueItem       = new DevComponents.Editors.ComboItem();
            valueItem.Text  = "Custom";
            valueItem.Tag   = item;
            valueItem.Image = image;
            cmb.Items.Add(valueItem);
            cmb.SelectedIndex = cmb.Items.Count - 1;
        }
Exemple #24
0
        //选择样式前返回图片
        public Image GetImageByGiveSymbolBeforeSelectItem(esriSymbologyStyleClass styleClass, ISymbol symbol, int width, int height)
        {
            try
            {
                axSymbologyControl.StyleClass = styleClass;
                ISymbologyStyleClass symbologyStyleClass = axSymbologyControl.GetStyleClass(styleClass);

                IStyleGalleryItem styleGalleryItem = new ServerStyleGalleryItem();

                styleGalleryItem.Item = symbol;
                //// styleGalleryItem.Name = "DefaultSymbol";
                symbologyStyleClass.AddItem(styleGalleryItem, 0);
                symbologyStyleClass.SelectItem(0);
                stdole.IPictureDisp  picture = symbologyStyleClass.PreviewItem(pStyleGalleryItem, width, height);
                System.Drawing.Image image   = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                return(image);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
                return(null);
            }
        }
        private void RasterRenderer_Load(object sender, EventArgs e)
        {
            IRasterBandCollection bands = rasterLayer.Raster as IRasterBandCollection;
            List <string>         bds   = new List <string>();

            for (int i = 0; i < bands.Count; i++)
            {
                bds.Add(bands.Item(i).Bandname);
            }
            cbSelectedBand.DataSource = bds;
            try
            {
                axSymbologyControl1.LoadStyleFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\ESRI\\ESRI.ServerStyle");
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
                symbol = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);
                cbColorRamp.DrawMode      = DrawMode.OwnerDrawFixed;
                cbColorRamp.DropDownStyle = ComboBoxStyle.DropDownList;//这是最关键的一步

                for (int i = 0; i < symbol.get_ItemCount(symbol); i++)
                {
                    stdole.IPictureDisp picture = symbol.PreviewItem(symbol.GetItem(i), cbColorRamp.Width, cbColorRamp.Height);
                    Image image = Image.FromHbitmap(new IntPtr(picture.Handle));
                    cbColorRamp.Items.Add(image);
                }
            }
            catch
            {
                if (lang == Language.Chinese)
                {
                    MessageBox.Show("色带加载失败!");
                }
                else if (lang == Language.English)
                {
                    MessageBox.Show("Loading color ribbons failed!");
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// 获取要色方案集合
        /// </summary>
        /// <param name="width">色带图片的宽度</param>
        /// <param name="height">色带图片的高度</param>
        /// <param name="category">色带的类型</param>
        /// <returns></returns>
        public List <ColorItem> GetColorScheme(int width, int height, string category)
        {
            string sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime");

            if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改
            {
                sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime");
            }
            if (sInstall == "")
            {
                sInstall = ModuleCommon.ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime");
            }   //added by chulili 2012-11-13  end
            m_SymbologyControl.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle");

            ISymbologyStyleClass styleClass = m_SymbologyControl.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);
            int count = styleClass.get_ItemCount("");

            List <ColorItem> colorScheme = new List <ColorItem>();

            for (int i = 0; i < count; i++)
            {
                IStyleGalleryItem pItem = styleClass.GetItem(i);
                if (category.Contains(pItem.Category))
                {
                    stdole.IPictureDisp picture = styleClass.PreviewItem(pItem, width, height);
                    Image     image             = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                    ColorItem colorItem         = new ColorItem();
                    colorItem.ColorImage = image;
                    colorItem.Name       = pItem.Name;
                    colorItem.ColorRamp  = pItem.Item as IColorRamp;
                    colorScheme.Add(colorItem);
                }
            }

            return(colorScheme);
        }
Exemple #27
0
        private void SetUI(IElement pElement)
        {
            tabProperty.Tabs["tabFrame"].Visible = false;
            chkRatio.Checked = m_pBoundProp.FixedAspectRatio;
            if (pElement is IMarkerElement)
            {
                //panelLine.Visible = false;
                //panelPoly.Visible = false;
                panelText.Visible = false;
                picLine.Visible   = false;
                picPoly.Visible   = false;
                picPoint.Visible  = true;

                btnLine.Visible  = false;
                btnPoint.Visible = true;
                btnPoly.Visible  = false;

                picArrow.Visible     = false;
                picScale.Visible     = false;
                picScaleText.Visible = false;

                btnArrow.Visible     = false;
                btnScale.Visible     = false;
                btnScaleText.Visible = false;
                //panelPoint.Visible = true;
                //panelPoint.BringToFront ();
                picPoint.BringToFront();
                tabProperty.Tabs["tabArea"].Visible = false;
                chkRatio.Enabled = false;
            }
            else if (pElement is ILineElement)
            {
                panelText.Visible = false;
                picLine.Visible   = true;
                picPoly.Visible   = false;
                picPoint.Visible  = false;

                btnLine.Visible  = true;
                btnPoint.Visible = false;
                btnPoly.Visible  = false;

                picArrow.Visible     = false;
                picScale.Visible     = false;
                picScaleText.Visible = false;

                btnArrow.Visible     = false;
                btnScale.Visible     = false;
                btnScaleText.Visible = false;

                picLine.BringToFront();
                tabProperty.Tabs["tabArea"].Visible = false;
                chkRatio.Enabled = true;
            }
            else if (pElement is IFillShapeElement)
            {
                panelText.Visible = false;
                picLine.Visible   = false;
                picPoly.Visible   = true;
                picPoint.Visible  = false;

                btnLine.Visible  = false;
                btnPoint.Visible = false;
                btnPoly.Visible  = true;

                picArrow.Visible     = false;
                picScale.Visible     = false;
                picScaleText.Visible = false;

                btnArrow.Visible     = false;
                btnScale.Visible     = false;
                btnScaleText.Visible = false;

                picPoly.BringToFront();
                chkRatio.Enabled = true;
            }
            else if (pElement is ITextElement)
            {
                panelText.Visible = true;
                picLine.Visible   = false;
                picPoly.Visible   = false;
                picPoint.Visible  = false;

                btnLine.Visible  = false;
                btnPoint.Visible = false;
                btnPoly.Visible  = false;

                picArrow.Visible     = false;
                picScale.Visible     = false;
                picScaleText.Visible = false;

                btnArrow.Visible     = false;
                btnScale.Visible     = false;
                btnScaleText.Visible = false;

                panelText.BringToFront();
                tabProperty.Tabs["tabArea"].Visible = false;
                chkRatio.Enabled = false;
            }
            else if (pElement is IInkGraphic)
            {
                tabProperty.Tabs["tabArea"].Visible   = false;
                tabProperty.Tabs["tabSymbol"].Visible = false;
            }

            if (pElement is IFrameElement)
            {
                tabProperty.Tabs["tabArea"].Visible   = false;
                tabProperty.Tabs["tabSymbol"].Visible = false;
                //判断指北针,比例尺,比例文本
                IMapSurroundFrame pMapSurroundFrame = pElement as IMapSurroundFrame;
                if (pMapSurroundFrame != null)
                {
                    IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                    if (pMapSurround != null)
                    {
                        tabProperty.Tabs["tabSymbol"].Visible = true;
                        panelText.Visible = false;
                        if (pMapSurround is INorthArrow)
                        {
                            panelText.Visible = false;
                            picLine.Visible   = false;
                            picPoly.Visible   = false;
                            picPoint.Visible  = false;

                            btnLine.Visible  = false;
                            btnPoint.Visible = false;
                            btnPoly.Visible  = false;

                            picArrow.Visible     = true;
                            picScale.Visible     = false;
                            picScaleText.Visible = false;

                            btnArrow.Visible     = true;
                            btnScale.Visible     = false;
                            btnScaleText.Visible = false;

                            picArrow.BringToFront();
                            chkRatio.Enabled = true;
                        }
                        else if (pMapSurround is IScaleBar)
                        {
                            panelText.Visible = false;
                            picLine.Visible   = false;
                            picPoly.Visible   = false;
                            picPoint.Visible  = false;

                            btnLine.Visible  = false;
                            btnPoint.Visible = false;
                            btnPoly.Visible  = false;

                            picArrow.Visible     = false;
                            picScale.Visible     = true;
                            picScaleText.Visible = false;

                            btnArrow.Visible     = false;
                            btnScale.Visible     = true;
                            btnScaleText.Visible = false;

                            picScale.BringToFront();
                            chkRatio.Enabled = true;
                        }
                        else if (pMapSurround is IScaleText)
                        {
                            panelText.Visible = false;
                            picLine.Visible   = false;
                            picPoly.Visible   = false;
                            picPoint.Visible  = false;

                            btnLine.Visible  = false;
                            btnPoint.Visible = false;
                            btnPoly.Visible  = false;

                            picArrow.Visible     = false;
                            picScale.Visible     = false;
                            picScaleText.Visible = true;

                            btnArrow.Visible     = false;
                            btnScale.Visible     = false;
                            btnScaleText.Visible = true;

                            picScaleText.BringToFront();
                            chkRatio.Enabled = true;
                        }
                    }
                }
                else if (pElement is IMapFrame)
                {
                    tabProperty.Tabs["tabFrame"].Visible = true;
                }
                //初始化窗体
                //Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ESRI\\CoreRuntime", true);
                //if (rk == null) return;

                //string sInstall = (string)rk.GetValue("InstallDir");
                string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime");
                if (sInstall == "") //added by chulili 2012-11-13 平台由ArcGIS9.3换成ArcGIS10,相应的注册表路径要修改
                {
                    sInstall = ReadRegistry("SOFTWARE\\ESRI\\Engine10.0\\CoreRuntime");
                }
                if (sInstall == "")
                {
                    sInstall = ReadRegistry("SOFTWARE\\ESRI\\Desktop10.0\\CoreRuntime");
                }   //added by chulili 2012-11-13  end
                if (sInstall == "")
                {
                    MessageBox.Show("系统没有安装Engine Runtime", "提示");
                    return;
                }

                string sPath = sInstall + "\\Styles\\ESRI.ServerStyle";

                axSymbologyControl1.Clear();
                axSymbologyControl1.LoadStyleFile(sPath);

                //添加边框符号
                IStyleGalleryItem               pItem;
                stdole.IPictureDisp             picture;
                System.Drawing.Image            image;
                DevComponents.Editors.ComboItem valueItem;
                int i = 0;

                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBorders;
                ISymbologyStyleClass symbologyStyleClass = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
                int cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory);
                cmbBorder.Items.Clear();
                cmbBorder.Items.Add("<None>");
                for (i = 0; i < cnt; i++)
                {
                    pItem           = symbologyStyleClass.GetItem(i);
                    picture         = symbologyStyleClass.PreviewItem(pItem, cmbBorder.Width - 80, cmbBorder.Height);
                    image           = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                    valueItem       = new DevComponents.Editors.ComboItem();
                    valueItem.Text  = pItem.Name;
                    valueItem.Tag   = pItem.Item;
                    valueItem.Image = image;
                    cmbBorder.Items.Add(valueItem);
                }

                //添加背景符号
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBackgrounds;
                symbologyStyleClass            = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
                cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory);
                cmbBack.Items.Clear();
                cmbBack.Items.Add("<None>");
                for (i = 0; i < cnt; i++)
                {
                    pItem           = symbologyStyleClass.GetItem(i);
                    picture         = symbologyStyleClass.PreviewItem(pItem, cmbBack.Width - 80, cmbBack.Height);
                    image           = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                    valueItem       = new DevComponents.Editors.ComboItem();
                    valueItem.Text  = pItem.Name;
                    valueItem.Tag   = pItem.Item;
                    valueItem.Image = image;
                    cmbBack.Items.Add(valueItem);
                }

                //添加阴影符号
                axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassShadows;
                symbologyStyleClass            = axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
                cnt = symbologyStyleClass.get_ItemCount(symbologyStyleClass.StyleCategory);
                cmbShadow.Items.Clear();
                cmbShadow.Items.Add("<None>");
                for (i = 0; i < cnt; i++)
                {
                    pItem           = symbologyStyleClass.GetItem(i);
                    picture         = symbologyStyleClass.PreviewItem(pItem, cmbShadow.Width - 80, cmbShadow.Height);
                    image           = System.Drawing.Image.FromHbitmap(new System.IntPtr(picture.Handle));
                    valueItem       = new DevComponents.Editors.ComboItem();
                    valueItem.Text  = pItem.Name;
                    valueItem.Tag   = pItem.Item;
                    valueItem.Image = image;
                    cmbShadow.Items.Add(valueItem);
                }
            }
        }
Exemple #28
0
        /// <summary>
        /// 初始化与拉伸相关控件
        /// </summary>
        private void initstreach()
        {
            string sInstall = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\Style\ESRI.ServerStyle";

            axSymbologyControl1.LoadStyleFile(sInstall);
            axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps;
            pSymbolClass           = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassColorRamps);
            pRasterRender          = pRLayer.Renderer;
            pRasterRenderColorRamp = pRasterRender as IRasterRendererColorRamp;
            //生成色度带
            if (pRasterRender is IRasterStretchColorRampRenderer)
            {
                IStyleGalleryItem pStyleGalleryItem = new ServerStyleGalleryItem();
                pStyleGalleryItem.Item = pRasterRenderColorRamp.ColorRamp;
                pSymbolClass.AddItem(pStyleGalleryItem, 0);
                pSymbolClass.SelectItem(0);
            }
            for (int i = 0; i < pSymbolClass.get_ItemCount(pSymbolClass.StyleCategory); i++)
            {
                stdole.IPictureDisp pPicture = pSymbolClass.PreviewItem(pSymbolClass.GetItem(i), cmbColorRamp.Width, cmbColorRamp.Height);
                Image image = Image.FromHbitmap(new System.IntPtr(pPicture.Handle));
                cmbColorRamp.Items.Add(image);
            }

            if (cmbColorRamp.Items.Count > 0)
            {
                cmbColorRamp.SelectedIndex = 0;
            }
            //判断拉伸方式和拉伸波段
            if (pRasterRender is IRasterStretchColorRampRenderer)
            {
                pSCRampRender  = pRasterRender as IRasterStretchColorRampRenderer;
                pRasterStretch = pRasterRender as IRasterStretch;
                int bandindex = pSCRampRender.BandIndex;
                cmbBand.SelectedIndex = bandindex;
                if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_Custom)
                {
                    cmbStreach.SelectedIndex = 1;
                }
                else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum)
                {
                    cmbStreach.SelectedIndex = 2;
                }
                else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations)
                {
                    cmbStreach.SelectedIndex = 3;
                }
                else if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_HistogramEqualize)
                {
                    cmbStreach.SelectedIndex = 4;
                }
                else
                {
                    cmbStreach.SelectedIndex = 0;
                }

                lblminstr.Text = pSCRampRender.LabelLow;
                lblmaxstr.Text = pSCRampRender.LabelHigh;
                txtmin.Text    = pSCRampRender.LabelLow;
                txtmax.Text    = pSCRampRender.LabelHigh;
                if (pRasterStretch.StretchType == esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum)
                {
                    txtmax.Visible = true;
                    txtmin.Visible = false;
                }
            }
            else
            {
                cmbBand.SelectedIndex    = 0;
                cmbStreach.SelectedIndex = 0;
            }
            isminmax = true;
        }