Beispiel #1
0
 private void cboTextType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.m_CanDo)
     {
         this.tabControl1.TabPages.Clear();
         if (this.cboTextType.SelectedIndex == 0)
         {
             this.m_pTextSymbol = new TextSymbolClass();
             TextGeneralControl control  = new TextGeneralControl();
             MaskControl        control2 = new MaskControl();
             TabPage            page     = new TabPage("常规");
             this.tabControl1.TabPages.Add(page);
             control.m_pTextSymbol  = this.m_pTextSymbol;
             control2.m_pMask       = this.m_pTextSymbol as IMask;
             control2.m_pSG         = this.m_pSG;
             control.ValueChanged  += new ValueChangedHandler(this.ValueChanged);
             control2.ValueChanged += new ValueChangedHandler(this.ValueChanged);
             control.Dock           = DockStyle.Fill;
             control2.Dock          = DockStyle.Fill;
             page.Controls.Add(control);
             page = new TabPage("掩模");
             this.tabControl1.TabPages.Add(page);
             page.Controls.Add(control2);
         }
         this.symbolItem1.Symbol = this.m_pTextSymbol as ISymbol;
         this.symbolItem1.Invalidate();
     }
 }
 private void btnSymbolSelector_Click(object sender, EventArgs e)
 {
     try
     {
         ITextSymbol       labelSymbol = m_pScaleBar.LabelSymbol;
         frmSymbolSelector selector    = new frmSymbolSelector();
         if (selector != null)
         {
             selector.SetStyleGallery(this.m_pSG);
             selector.SetSymbol(labelSymbol);
             if (selector.ShowDialog() == DialogResult.OK)
             {
                 labelSymbol             = selector.GetSymbol() as ITextSymbol;
                 m_pScaleBar.LabelSymbol = labelSymbol;
                 this.m_CanDo            = false;
                 this.SetTextSymbol(labelSymbol);
                 this.m_CanDo = true;
                 this.ValueChanged();
             }
         }
     }
     catch
     {
     }
 }
Beispiel #3
0
 public void SetSymbol(ILegendItem item, ISymbol symbol)
 {
     if (item == _symbol && symbol is ITextSymbol)
     {
         _symbol = symbol as ITextSymbol;
     }
 }
Beispiel #4
0
 public override void DrawTitle()
 {
     try
     {
         IPoint point = new PointClass();
         point.PutCoords((base.LeftUp.X + base.RightUp.X) / 2.0,
                         ((base.RightUp.Y + base.InOutDist) + this.double_2) + base.TitleDist);
         IElement item = new TextElementClass
         {
             Geometry = point
         };
         ITextElement element2 = item as ITextElement;
         element2.Text = base.MapTM;
         IElementProperties2 properties = element2 as IElementProperties2;
         ITextSymbol         symbol     = base.FontStyle(25.0, esriTextHorizontalAlignment.esriTHACenter,
                                                         esriTextVerticalAlignment.esriTVABottom);
         element2.Symbol = symbol;
         properties.Type = "图名";
         this.ilist_0.Add(item);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Beispiel #5
0
        /// <summary>
        /// 设置存储在地图上的注记的字体和大小
        /// </summary>
        /// <param name="map"></param>
        /// <param name="graphicsLayerName"></param>
        /// <param name="fontName">注记字体(此值为""、空白字符或null,则不改变注记字体)</param>
        /// <param name="size">注记大小(此值小于等于0,则不改变注记大小)</param>
        public static void SetAnnotationFontOnMap(this IMap map, string graphicsLayerName, string fontName = null, int size = 0)
        {
            IGraphicsLayer     graphicsLayer    = map.GetGraphicsLayer(graphicsLayerName);
            IGraphicsContainer graphicContainer = graphicsLayer as IGraphicsContainer;
            var txtElements = graphicContainer.GetTextElements();

            foreach (var txtElement in txtElements)
            {
                ITextSymbol txtSymbol = txtElement.Symbol;
                //注意不能使用下面这一句,直接设置txtElement.Symbol.Size = size 是无效的,原因未知
                //txtElement.Symbol.Size = size;

                if (size > 0)
                {
                    txtSymbol.Size = size;
                }

                if (!string.IsNullOrEmpty(fontName) && fontName.Trim() != string.Empty)
                {
                    System.Drawing.Font font     = new System.Drawing.Font(fontName, (float)txtSymbol.Size);
                    IFontDisp           fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as IFontDisp;
                    txtSymbol.Font = fontDisp;
                }
                txtElement.Symbol = txtSymbol;
                graphicContainer.UpdateElement(txtElement as IElement);
            }
        }
Beispiel #6
0
 public void SetObjects(object object_0)
 {
     this.m_FractionTextSymbol = object_0 as IFractionTextElement;
     this.itextSymbol_0        = (this.m_FractionTextSymbol.NumeratorTextSymbol as IClone).Clone() as ITextSymbol;
     this.itextSymbol_1        = (this.m_FractionTextSymbol.DenominatorTextSymbol as IClone).Clone() as ITextSymbol;
     this.ilineSymbol_0        = (this.m_FractionTextSymbol.LineSymbol as IClone).Clone() as ILineSymbol;
 }
        private void DisplayLabel_CheckedChanged(object sender, EventArgs e)
        {
            foreach (Control c in this.Controls)
            {
                c.Enabled = c == DisplayLabel || DisplayLabel.Checked;
            }

            if (m_inUpdate)
            {
                return;
            }

            if (DisplayLabel.Checked)
            {
                if (DisplayLabel.Tag as ITextSymbol != null)
                {
                    this.Item = DisplayLabel.Tag as ITextSymbol;
                }
                if (m_item == null)
                {
                    this.Item = _factory.CreateDefaultTextSymbol();
                }
            }
            else
            {
                DisplayLabel.Tag = m_item;
                this.Item        = null;
            }
        }
        private void btnApply_Click(object sender, EventArgs e)
        {
            IScaleBar mapScaleBar = (m_styleGalleryItem.Item as IScaleBar);

            if (mapScaleBar == null)
            {
                return;
            }

            //设置单位
            int unitIndex = cmbxUnit.SelectedIndex;

            mapScaleBar.Units = (esriUnits)unitIndex;

            //设置文本字体、大小与颜色
            ITextSymbol textSymbol = mapScaleBar.LabelSymbol;

            textSymbol.Font.Name = cmbxTextFont.Text;
            textSymbol.Size      = Convert.ToDouble(cmbxTextSize.Text);
            textSymbol.Color     = ElementPropetyImp.GetRGBColor(btnTextColor.BackColor.R, btnTextColor.BackColor.G, btnTextColor.BackColor.B) as IColor;

            mapScaleBar.LabelSymbol = textSymbol;

            //设置条块大小与颜色
            mapScaleBar.BarHeight = Convert.ToDouble(cmbxSymbolSize.Text);
            mapScaleBar.BarColor  = ElementPropetyImp.GetRGBColor(btnSymbolColor.BackColor.R, btnSymbolColor.BackColor.G, btnSymbolColor.BackColor.B) as IColor;

            PreviewImage();
        }
Beispiel #9
0
 private void InitControl()
 {
     this.m_CanDo = false;
     if (this.m_pTextSymbol == null)
     {
         this.m_pTextSymbol = new TextSymbolClass();
     }
     this.SetColorEdit(this.colorEdit1, this.m_pTextSymbol.Color);
     this.numUpDownSize.Value          = (decimal)this.m_pTextSymbol.Size;
     this.spinEditXOffset.Value        = (decimal)((this.m_pTextSymbol as ISimpleTextSymbol).XOffset * this.m_unit);
     this.spinEditYOffset.Value        = (decimal)((this.m_pTextSymbol as ISimpleTextSymbol).YOffset * this.m_unit);
     this.spinEditAngle.Value          = (decimal)(this.m_pTextSymbol as ISimpleTextSymbol).Angle;
     this.radioGroupHor.SelectedIndex  = (int)this.m_pTextSymbol.HorizontalAlignment;
     this.radioGroupVert.SelectedIndex = (int)this.m_pTextSymbol.VerticalAlignment;
     this.chkVert.Checked = (this.m_pTextSymbol as ICharacterOrientation).CJKCharactersRotation;
     stdole.IFontDisp font = this.m_pTextSymbol.Font;
     this.chkBold.Checked      = font.Bold;
     this.chkItalic.Checked    = font.Italic;
     this.chkUnderline.Checked = font.Underline;
     this.chkStrike.Checked    = font.Strikethrough;
     for (int i = 0; i < this.cboFontName.Properties.Items.Count; i++)
     {
         if (this.m_pTextSymbol.Font.Name == this.cboFontName.Properties.Items[i].ToString())
         {
             this.cboFontName.SelectedIndex = i;
             break;
         }
     }
     this.m_CanDo = true;
 }
Beispiel #10
0
 void ESRI.ArcGIS.esriSystem.IClone.Assign(IClone src)
 {
     if (src is IFractionTextSymbol)
     {
         try
         {
             ITextSymbol         textSymbol         = null;
             ITextSymbol         angle              = null;
             IFractionTextSymbol fractionTextSymbol = src as IFractionTextSymbol;
             this.m_DenominatorText       = fractionTextSymbol.DenominatorText;
             this.m_DenominatorTextSymbol = fractionTextSymbol.DenominatorTextSymbol;
             this.m_NumeratorText         = fractionTextSymbol.DenominatorText;
             this.m_NumeratorTextSymbol   = fractionTextSymbol.NumeratorTextSymbol;
             this.m_LineSymbol            = fractionTextSymbol.LineSymbol;
             textSymbol  = src as ITextSymbol;
             angle       = this;
             angle.Angle = textSymbol.Angle;
             angle.Size  = textSymbol.Size;
             angle.Color = textSymbol.Color;
             angle.HorizontalAlignment = textSymbol.HorizontalAlignment;
             angle.RightToLeft         = textSymbol.RightToLeft;
             angle.Text = textSymbol.Text;
             angle.VerticalAlignment = textSymbol.VerticalAlignment;
             //this.ROP2 = (src as ISymbol).ROP2;
             //this.RotateWithTransform = (src as ISymbolRotation).RotateWithTransform;
             //this.MapLevel = (src as IMapLevel).MapLevel;
         }
         catch
         {
         }
     }
 }
Beispiel #11
0
        /// <summary>
        ///     Add the SMARTMAP text as an ITextElement to the map layout. Place the text on top
        ///     off the black rectangle that was placed in the lower right hand corner between
        ///     the mapframe and the neatline.
        /// </summary>
        public override void addMedfordText()
        {
            CSpatialSubs       oSpatialSubs = new CSpatialSubs();
            IMxDocument        pMxDoc       = (IMxDocument)ArcMap.Document;
            IGraphicsContainer pGC          = (IGraphicsContainer)pMxDoc.PageLayout;

            try
            {
                ITextSymbol  pTextSym  = oSpatialSubs.createTextSymbol(255, 255, 255, (9 * base.YFactor), esriTextHorizontalAlignment.esriTHACenter, esriTextVerticalAlignment.esriTVACenter, "Arial");
                string       sText     = "CITY OF MEDFORD";
                ITextElement pTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC,
                                                                                 pTextSym,
                                                                                 ((base.XFactor * 1.19) * SPrintConst.MapFrame_XMax),
                                                                                 (base.XFactor * SPrintConst.MapFrame_XMax),
                                                                                 (base.YFactor * (SPrintConst.Neatline_YMax - SPrintConst.Logo_Offset)),
                                                                                 (base.YFactor * SPrintConst.Neatline_YMax),
                                                                                 sText);
                pTextSym  = null;
                pTextElem = null;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Errors: CLandscapeLayout:addMedfordText()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                oSpatialSubs.Dispose();
                pMxDoc = null;
                pGC    = null;
            }
        }
Beispiel #12
0
        private void AddLabel(string StrDisplayField)
        {
            pGeoFeatLayer.DisplayAnnotation = false;
            pMapControl.ActiveView.Refresh();

            pGeoFeatLayer.DisplayField = StrDisplayField;

            IAnnotateLayerPropertiesCollection pAnnoProps = null;

            pAnnoProps = pGeoFeatLayer.AnnotationProperties;

            ILineLabelPosition pPosition = null;

            pPosition          = new LineLabelPositionClass();
            pPosition.Parallel = true;
            pPosition.Above    = true;

            ILineLabelPlacementPriorities    pPlacement = new LineLabelPlacementPrioritiesClass();
            IBasicOverposterLayerProperties4 pBasic     = new BasicOverposterLayerPropertiesClass();

            pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasic.LineLabelPlacementPriorities = pPlacement;
            pBasic.LineLabelPosition            = pPosition;
            pBasic.BufferRatio     = 0;
            pBasic.FeatureWeight   = esriBasicOverposterWeight.esriHighWeight;
            pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart;
            //pBasic.PlaceOnlyInsidePolygon = true;//仅在地物内部显示标注  deleted by chulili s20111018 界面上并没有这项设置,这句话应注释掉,否则像是错误

            ILabelEngineLayerProperties pLabelEngine = null;

            pLabelEngine = new LabelEngineLayerPropertiesClass();
            pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties;
            pLabelEngine.Expression = "[" + StrDisplayField + "]";
            ITextSymbol pTextSymbol = null;

            pTextSymbol = pLabelEngine.Symbol;
            System.Drawing.Font pFont = null;
            pFont = LabelText.Font;
            IFontDisp pFontDisp = ESRI.ArcGIS.ADF.Converter.ToStdFont(pFont);

            pTextSymbol.Font = pFontDisp;

            IRgbColor pColor = new RgbColorClass();

            pColor.Red          = Convert.ToInt32(LabelText.ForeColor.R);
            pColor.Green        = Convert.ToInt32(LabelText.ForeColor.G);
            pColor.Blue         = Convert.ToInt32(LabelText.ForeColor.B);
            pTextSymbol.Color   = pColor as IColor;
            pLabelEngine.Symbol = pTextSymbol;

            IAnnotateLayerProperties pAnnoLayerProps = null;

            pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
            pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures;
            pAnnoProps.Clear();

            pAnnoProps.Add(pAnnoLayerProps);
            pGeoFeatLayer.DisplayAnnotation = true;
            pMapControl.ActiveView.Refresh();
        }
        private void CreateLabel(IPoint point)
        {
            // 创建文本
            if (label == null)
            {
                label = _axRenderControl.ObjectManager.CreateLabel();
            }

            label.Text     = "我创建了文本——TestLabel";
            label.Position = point;

            if (textAttribute == null)
            {
                textAttribute = new TextAttribute();
            }

            textAttribute.TextColor = 0xffffff00;
            textAttribute.TextSize  = 20;
            textAttribute.Underline = true;
            textAttribute.Font      = "楷体";

            if (textSymbol == null)
            {
                textSymbol = new TextSymbol();
            }
            textSymbol.TextAttribute  = textAttribute;
            textSymbol.VerticalOffset = 10;
            textSymbol.DrawLine       = true;
            textSymbol.MarginColor    = 0x8800ffff;

            label.TextSymbol = textSymbol;
            _axRenderControl.Camera.FlyToObject(label.Guid, i3dActionCode.i3dActionFlyTo);
        }
Beispiel #14
0
        private void btn_style_Click(object sender, EventArgs e)
        {
            TextFrm child = new TextFrm(pTextelement);

            child.richTextBox1.ReadOnly = true;
            child.ShowDialog();
            ITextSymbol pts  = pTextelement.Symbol;
            string      ziti = "";

            if (pts.Font.Bold)
            {
                ziti = "粗体";
            }
            if (pts.Font.Italic)
            {
                ziti = "倾斜";
            }
            if (pts.Font.Strikethrough)
            {
                ziti = "中划线";
            }
            if (pts.Font.Underline)
            {
                ziti = "下划线";
            }

            ziti          += " " + pts.Font.Size.ToString() + "号 R" + (pts.Color as IRgbColor).Red.ToString() + "G" + (pts.Color as IRgbColor).Green.ToString() + "B" + (pts.Color as IRgbColor).Blue.ToString();
            LabelName.Text = ziti;
        }
Beispiel #15
0
        //创建字体
        private void CreateTextSymbol()
        {
            if (pStyleGalleryItem == null)
            {
                MessageBox.Show("请选择指北针样式", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            pTextSymbol = pStyleGalleryItem.Item as ITextSymbol;

            //颜色
            if (FontColor.SelectedColor != null)
            {
                pTextSymbol.Color = ClsGDBDataCommon.ColorToIColor(FontColor.SelectedColor);;
            }

            //大小
            string pFontString = double.Parse(FontSize.Text).ToString();

            pFont.Size = decimal.Parse(pFontString);

            //字体、
            pFont.Name = this.cmbBoxFontName.Text;

            //风格
            if (toolBtnBold.Checked == true)
            {
                pFont.Bold = true;
            }
            else
            {
                pFont.Bold = false;
            }
            if (toolBtnIntend.Checked == true)
            {
                pFont.Italic = true;
            }
            else
            {
                pFont.Italic = false;
            }
            if (toolBtnUnderline.Checked == true)
            {
                pFont.Underline = true;
            }
            else
            {
                pFont.Underline = false;
            }
            if (toolBtnStrikethrough.Checked == true)
            {
                pFont.Strikethrough = true;
            }
            else
            {
                pFont.Strikethrough = false;
            }

            pTextSymbol.Font = pFont;
        }
Beispiel #16
0
        private void method_3(ITextSymbol itextSymbol_0, Rectangle rectangle_0)
        {
            IPoint point = new ESRI.ArcGIS.Geometry.Point();

            point.X = (double)((rectangle_0.Left + rectangle_0.Right) / 2);
            point.Y = (double)((rectangle_0.Bottom + rectangle_0.Top) / 2);
            if (itextSymbol_0 is ISimpleTextSymbol)
            {
                ISimpleTextSymbol simpleTextSymbol = (ISimpleTextSymbol)itextSymbol_0;
                string            text             = simpleTextSymbol.Text;
                bool clip = simpleTextSymbol.Clip;
                if (text.Length == 0)
                {
                    simpleTextSymbol.Text = "AaBbYyZz";
                }
                simpleTextSymbol.Clip = true;
                ((ISymbol)itextSymbol_0).Draw(point);
                simpleTextSymbol.Text = text;
                simpleTextSymbol.Clip = clip;
            }
            else
            {
                ((ISymbol)itextSymbol_0).Draw(point);
            }
        }
Beispiel #17
0
        void ESRI.ArcGIS.esriSystem.IPersistVariant.Load(IVariantStream Stream)
        {
            int num = 0;

            num = Convert.ToInt32(Stream.Read());
            if (num > 1 | num <= 0)
            {
                throw new Exception("Failed to read from stream");
            }
            this.InitializeMembers();
            if (num == 1)
            {
                this.m_lROP2 = (esriRasterOpCode)Stream.Read();
                this.m_Size  = Convert.ToDouble(Stream.Read());
                this.m_Angle = Convert.ToDouble(Stream.Read());
                this.m_HorizontalAlignment = (esriTextHorizontalAlignment)Stream.Read();
                this.m_VerticalAlignment   = (esriTextVerticalAlignment)Stream.Read();
                this.m_RightToLeft         = Convert.ToBoolean(Stream.Read());
                this.m_Text                  = Convert.ToString(Stream.Read());
                this.m_bRotWithTrans         = Convert.ToBoolean(Stream.Read());
                this.m_lMapLevel             = Convert.ToInt32(Stream.Read());
                this.m_NumeratorText         = Convert.ToString(Stream.Read());
                this.m_DenominatorText       = Convert.ToString(Stream.Read());
                this.m_LineSymbol            = Stream.Read() as ILineSymbol;
                this.m_NumeratorTextSymbol   = Stream.Read() as ITextSymbol;
                this.m_DenominatorTextSymbol = Stream.Read() as ITextSymbol;
            }
        }
 private void btnSymbolSelector_Click(object sender, EventArgs e)
 {
     try
     {
         ITextSymbol       labelSymbol = m_pScaleBar.LabelSymbol;
         frmSymbolSelector selector    = new frmSymbolSelector();
         if (selector != null)
         {
             selector.SetStyleGallery(this.istyleGallery_0);
             selector.SetSymbol(labelSymbol);
             if (selector.ShowDialog() == DialogResult.OK)
             {
                 labelSymbol             = selector.GetSymbol() as ITextSymbol;
                 m_pScaleBar.LabelSymbol = labelSymbol;
                 this.bool_0             = false;
                 this.method_1(labelSymbol);
                 this.bool_0 = true;
                 this.method_4();
             }
         }
     }
     catch
     {
     }
 }
Beispiel #19
0
        public SimpleLabelRenderer()
        {
            _fieldname = _sizeField = _fontField = String.Empty;
            _symbol    = new SimpleTextSymbol();

            _symbolRotation = new SymbolRotation();
        }
Beispiel #20
0
 private void InitializeMembers()
 {
     this.m_lhDC                     = 0;
     this.m_lOldPen                  = 0;
     this.m_lPen                     = 0;
     this.m_lOldBrush                = 0;
     this.m_lBrushTop                = 0;
     this.m_lBrushLeft               = 0;
     this.m_lBrushRight              = 0;
     this.m_dDeviceRadius            = 0;
     this.m_trans                    = null;
     this.m_NumeratorTextSymbol      = new TextSymbol();
     this.m_LineSymbol               = new SimpleLineSymbol();
     this.m_DenominatorTextSymbol    = new TextSymbol();
     this.m_NumeratorText            = "AaBbYyZz";
     this.m_DenominatorText          = "AaBbYyZz";
     this.m_NumeratorTextSymbol.Text = this.m_NumeratorText;
     this.m_NumeratorTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
     this.m_NumeratorTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVABottom;
     this.m_DenominatorTextSymbol.Text = this.m_DenominatorText;
     this.m_DenominatorTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
     this.m_DenominatorTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;
     this.m_lROP2  = esriRasterOpCode.esriROPCopyPen;
     this.m_Angle  = 0;
     this.m_pColor = new RgbColor();
     this.m_pFont  = new StdFont() as IFontDisp;
     this.m_HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
     this.m_RightToLeft         = false;
     this.m_Size = 0;
     this.m_Text = "";
     this.m_VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
     this.m_bRotWithTrans     = true;
 }
Beispiel #21
0
        /// <summary>
        /// Add the mapscale text to the Graphic Container. Places this text under the scale bar.
        /// </summary>
        /// <param name="sMapScale"></param>
        public override void addMapScaleText(string sMapScale)
        {
            CSpatialSubs       oSpatialSubs = new CSpatialSubs();
            IMxDocument        pMxDoc       = (IMxDocument)this.App.Document;
            IGraphicsContainer pGC          = (IGraphicsContainer)pMxDoc.PageLayout;

            IMapSurroundFrame pMSFrame  = null;
            IEnvelope         pEnv      = null;
            ITextSymbol       pTextSym  = null;
            ITextElement      pTextElem = null;

            try
            {
                //Locate the scalebar in the graphics container because we
                //want to put the mapscale right under it.
                //A scalebar is contained within a MapSurroundFrame.
                pGC.Reset();
                IElement pElem = pGC.Next();
                while (pElem != null)
                {
                    if (pElem is IMapSurroundFrame)
                    {
                        pMSFrame = (IMapSurroundFrame)pElem;
                        if (pMSFrame.Object is IScaleBar)
                        {
                            break;  // we got the scalebar
                        }
                    }
                    pElem = pGC.Next();
                }

                pEnv = new EnvelopeClass();
                //get the envelope of the scalebar
                pElem.QueryBounds(pMxDoc.ActiveView.ScreenDisplay, pEnv);

                double xMin = SPrintConst.MapscaleText_XMin * base.XFactor;
                double xMax = SPrintConst.MapscaleText_XMax * base.XFactor;
                double yMax = pEnv.YMin - 0.02;  //this is the min y value of the scalebar envelope - .02
                double yMin = SPrintConst.MapscaleText_YMin * base.YFactor;

                //Set pMapscaleText symbol to the textsymbol
                pTextSym  = oSpatialSubs.createTextSymbol(0, 0, 0, 7 * this.YFactor, esriTextHorizontalAlignment.esriTHALeft, esriTextVerticalAlignment.esriTVATop, "Arial");
                pTextElem = oSpatialSubs.addTextToGraphicsContainer(pGC, pTextSym, xMin, xMax, yMin, yMax, sMapScale);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Errors: CPortraitLayout:addMapScaleText()\r\n" + ex.Message, "Errors occurred", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            finally
            {
                oSpatialSubs.Dispose();
                pMxDoc    = null;
                pGC       = null;
                pMSFrame  = null;
                pEnv      = null;
                pTextSym  = null;
                pTextElem = null;
            }
        }
Beispiel #22
0
 public TextChange(IPageLayoutControlDefault pageLayout, ITextElement textElement)
 {
     InitializeComponent();
     pPageLayout        = pageLayout;
     pTextElement       = textElement;
     pTextSymbol        = pTextElement.Symbol;
     pGraphicsContainer = pageLayout.ActiveView.GraphicsContainer;
 }
 /// <summary>
 /// Applies properties (name, italic, bold, underline) from the characteristics of the specified font
 /// </summary>
 /// <param name="sym"></param>
 /// <param name="f"></param>
 public static void Apply(this ITextSymbol sym, Font f)
 {
     Check.NotNull(sym, "sym"); //NOXLATE
     sym.FontName   = f.Name;
     sym.Italic     = f.Italic.ToString();
     sym.Bold       = f.Bold.ToString();
     sym.Underlined = f.Underline.ToString();
 }
Beispiel #24
0
        public void SetObjects(object object_0)
        {
            this.imapSurroundFrame_0 = object_0 as IMapSurroundFrame;
            this.ilegend_0           = this.imapSurroundFrame_0.MapSurround as ILegend;
            ILegendFormat format = this.ilegend_0.Format;

            this.itextSymbol_0 = format.TitleSymbol;
        }
Beispiel #25
0
 public frmEdit(bool postil)
 {
     InitializeComponent();
     m_pTextSymbol = new TextSymbolClass();
     m_pFillSymbol = new SimpleFillSymbolClass();
     m_pLineSymbol = new SimpleLineSymbolClass();
     canFill       = postil;
 }
Beispiel #26
0
 /// <summary>
 /// Handles the EditValueChanged event of the cmbTxtFont control.
 /// </summary>
 /// <param name="obj">The source of the event.</param>
 /// <param name="eventArgs">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void cmbTxtFont_EditValueChanged(object obj, EventArgs eventArgs)
 {
     this._txtSymble = (this._styleGalleryItem.Item as ITextSymbol);
     stdole.IFontDisp font = this._txtSymble.Font;
     font.Name            = this.cmbTxtFont.EditValue.ToString();
     this._txtSymble.Font = font;
     this.ViewSymble();
 }
Beispiel #27
0
        public void Load(gView.Framework.IO.IPersistStream stream)
        {
            this.Release();

            _textSymbol = stream.Load("textSymbol", null) as ITextSymbol;
            _lineSymbol = stream.Load("lineSymbol", null) as ILineSymbol;
            _capType    = (lineCapType)stream.Load("capType", lineCapType.ArrowLine);
            _format     = (string)stream.Load("format", String.Empty);
        }
Beispiel #28
0
        private IFeatureClass method_1(IFeatureWorkspace ifeatureWorkspace_0, string string_4, double double_0,
                                       ITextSymbol itextSymbol_0, IFields ifields_0)
        {
            IObjectClassDescription  description  = new AnnotationFeatureClassDescriptionClass();
            IFeatureClassDescription description2 = description as IFeatureClassDescription;
            IClone     requiredFields             = description.RequiredFields as IClone;
            IFields    fields = requiredFields.Clone() as IFields;
            IFieldEdit edit   = null;
            int        index  = fields.FindField(description2.ShapeFieldName);

            edit = fields.get_Field(index) as IFieldEdit;
            IGeometryDefEdit      geometryDef    = edit.GeometryDef as IGeometryDefEdit;
            IFeatureWorkspaceAnno anno           = ifeatureWorkspace_0 as IFeatureWorkspaceAnno;
            IGraphicsLayerScale   referenceScale = new GraphicsLayerScaleClass
            {
                ReferenceScale = double_0,
                Units          = esriUnits.esriMeters
            };
            UID instanceCLSID                  = description.InstanceCLSID;
            UID classExtensionCLSID            = description.ClassExtensionCLSID;
            ISymbolCollection symbolCollection = new SymbolCollectionClass();

            symbolCollection.set_Symbol(0, itextSymbol_0 as ISymbol);
            IAnnotateLayerPropertiesCollection2 annoProperties = new AnnotateLayerPropertiesCollectionClass();
            IAnnotateLayerProperties            item           = new LabelEngineLayerPropertiesClass
            {
                Class         = "要素类 1",
                FeatureLinked = false,
                AddUnplacedToGraphicsContainer = false,
                CreateUnplacedElements         = true,
                DisplayAnnotation = true,
                UseOutput         = true
            };
            ILabelEngineLayerProperties properties2 = item as ILabelEngineLayerProperties;

            properties2.Offset   = 0.0;
            properties2.SymbolID = 0;
            properties2.Symbol   = itextSymbol_0;
            annoProperties.Add(item);
            for (int i = 0; i < ifields_0.FieldCount; i++)
            {
                if (fields.FindField(ifields_0.get_Field(i).Name) == -1)
                {
                    (fields as IFieldsEdit).AddField(ifields_0.get_Field(i));
                }
            }
            try
            {
                return(anno.CreateAnnotationClass(string_4, fields, instanceCLSID, classExtensionCLSID,
                                                  description2.ShapeFieldName, "", null, null, annoProperties, referenceScale, symbolCollection, false));
            }
            catch (Exception exception)
            {
                Logger.Current.Error("", exception, "");
            }
            return(null);
        }
Beispiel #29
0
        public override void OnCreate(object hook)
        {
            _context        = hook as IAppContext;
            base.m_caption  = "距离量测";
            base.m_category = "View";
            base.m_bitmap   = Properties.Resources.icon_measure_distance;
            base.m_cursor   =
                new Cursor(base.GetType().Assembly.GetManifestResourceStream("Yutai.Resource.Cursor.Measure.cur"));
            base.m_name    = "View_MeasureLength";
            base._key      = "View_MeasureLength";
            base.m_toolTip = "距离量测";
            base.m_checked = false;
            base.m_enabled = true;
            base._itemType = RibbonItemType.Tool;

            IRgbColor pRgb = new RgbColor() as IRgbColor;

            pRgb.Red   = 200;
            pRgb.Green = 0;
            pRgb.Blue  = 0;

            pSimpleLineSymbol = new SimpleLineSymbolClass()
            {
                Color = pRgb, Width = 1.5, Style = esriSimpleLineStyle.esriSLSSolid
            };
            IRgbColor pRgb2 = new RgbColor() as IRgbColor;

            pRgb2.Red    = 255;
            pRgb2.Green  = 0;
            pRgb2.Blue   = 0;
            pAngleSymbol = new TextSymbolClass()
            {
                Color = pRgb2,
                Size  = 10
            };
            ITextPath         textPath       = new SimpleTextPathClass();
            ISimpleTextSymbol simpleTextPath = (ISimpleTextSymbol)pAngleSymbol;

            simpleTextPath.TextPath            = textPath;
            simpleTextPath.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
            simpleTextPath.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
            simpleTextPath.YOffset             = 3;

            pDistSymbol = new TextSymbolClass()
            {
                Color = pRgb2,
                Size  = 10
            };
            ITextPath textPath2 = new SimpleTextPathClass();

            simpleTextPath                     = (ISimpleTextSymbol)pDistSymbol;
            simpleTextPath.TextPath            = textPath;
            simpleTextPath.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
            simpleTextPath.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;
            simpleTextPath.YOffset             = -3;
        }
 private void SetTextSymbol(ITextSymbol pTextSymbol)
 {
     this.SetColorEdit(this.colorTextSymbol, pTextSymbol.Color);
     stdole.IFontDisp font = pTextSymbol.Font;
     this.chkBold.Checked = font.Bold;
     this.chkItalic.Checked = font.Italic;
     this.chkUnderline.Checked = font.Underline;
     this.cboFontName.Text = font.Name;
     this.cboFontSize.Text = font.Size.ToString();
 }
Beispiel #31
0
 private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
 {
     if (m_BasicOperationTool == "isMeasure")
     {
         m_bInUse = false;
         if (m_pLineSymbol != null)
         {
             IActiveView pActiveView = axMapControl1.ActiveView.FocusMap as IActiveView;
             pActiveView.ScreenDisplay.StartDrawing(pActiveView.ScreenDisplay.hDC, -1);
             pActiveView.ScreenDisplay.SetSymbol(m_pTextSymbol as ISymbol);
             pActiveView.ScreenDisplay.DrawText(m_pTextPoint, m_pTextSymbol.Text);
             pActiveView.ScreenDisplay.SetSymbol(m_pLineSymbol as ISymbol);
             if (m_pLinePolyline.Length > 0)
                 pActiveView.ScreenDisplay.DrawPolyline(m_pLinePolyline);
             pActiveView.ScreenDisplay.FinishDrawing();
             m_pTextSymbol = null;
             m_pTextPoint = null;
             m_pLinePolyline = null;
             m_pLineSymbol = null;
         }
     }
 }
Beispiel #32
0
        public static void RenderPreviewFont(Graphics g, Rectangle size, ITextSymbol item)
        {
            Font font;
            Color? foreground = null;
            Color? background = null;
            string text = string.Empty;
            BackgroundStyleType bgStyle;

            if (item == null || item.FontName == null)
            {
                font = new Font("Arial", 10.0f, FontStyle.Regular); //NOXLATE
                foreground = Color.Black;
                background = Color.White;
                text = Strings.EmptyText;
                bgStyle = BackgroundStyleType.Transparent;
            }
            else
            {
                try { font = new Font(item.FontName, 12); }
                catch { font = new Font("Arial", 12); } //NOXLATE
                try
                {
                    foreground = Utility.ParseHTMLColor(item.ForegroundColor);
                    background = Utility.ParseHTMLColor(item.BackgroundColor);
                }
                catch { }
                bgStyle = item.BackgroundStyle;

                FontStyle fs = FontStyle.Regular;
                if (item.Bold == "true") //NOXLATE
                    fs |= FontStyle.Bold;
                if (item.Italic == "true") //NOXLATE
                    fs |= FontStyle.Italic;
                if (item.Underlined == "true") //NOXLATE
                    fs |= FontStyle.Underline;
                font = new Font(font, fs);

                text = item.Text;
            }

            if (bgStyle == BackgroundStyleType.Ghosted)
            {
                using (System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath())
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    pth.AddString(text, font.FontFamily, (int)font.Style, font.Size * 1.25f, size.Location, StringFormat.GenericDefault);

                    if (background.HasValue)
                    {
                        using (Pen p = new Pen(background.Value, 1.5f))
                            g.DrawPath(p, pth);
                    }

                    if (foreground.HasValue)
                    {
                        using (Brush b = new SolidBrush(foreground.Value))
                            g.FillPath(b, pth);
                    }
                }
            }
            else
            {
                if (bgStyle == BackgroundStyleType.Opaque)
                {
                    SizeF bgSize = g.MeasureString(text, font, new SizeF(size.Width, size.Height));
                    if (background.HasValue)
                    {
                        using (Brush b = new SolidBrush(background.Value))
                            g.FillRectangle(b, new Rectangle(size.Top, size.Left, (int)bgSize.Width, (int)bgSize.Height));
                    }
                }

                if (foreground.HasValue)
                {
                    using (Brush b = new SolidBrush(foreground.Value))
                        g.DrawString(text, font, b, size);
                }
            }
        }
        //���ƣȣ��ԣã�
        public static void HatchDraw(AxMapControl ppAxMapControl, ISimpleLineSymbol pHatchSymMajor, ISimpleLineSymbol pHatchSymMinor, ITextSymbol pTxtSym, IFeatureLayer pFeatLayer, bool bEnds, bool bEndsOnly, double dHatchLen, double dTxtInterval, double dHatchOffset, double dMajorAngle, bool bOverRideMajor, string graphicslayername)
        {
            //����ͼ��ͼ��ΪSEWER TV���ͼ��
            IFeatureCursor pFeatCursor = pFeatLayer.Search(null, true);
            SetGraphicsLayer(ppAxMapControl, pFeatLayer.Name, graphicslayername);
            //����SEWER TV���ͼ��ͼ��
            IGraphicsContainer pGraphicsContainer = ppAxMapControl.ActiveView.FocusMap.ActiveGraphicsLayer as IGraphicsContainer;
            //���ͼ��ͼ��
            pGraphicsContainer.DeleteAllElements();

            IFeature pFeature = pFeatCursor.NextFeature();
            IPolyline pMajorHatchPL = new PolylineClass();
            IPolyline pMinorHatchPL = new PolylineClass();
            IPolyline pPL;
            IMAware pPLM;
            //IMCollection pMColl;
            IGeometryCollection pGeomColl;
            ILineElement pLineElement;
            IElement pElement = null;
            int cnt;
            IPath pPath;
            string txt;
            double txtlen;
            IPath pTxtPath;
            double angle;
            //IPoint pTxtPt;
            ISegmentCollection pSC;
            ISegment pSeg;
            ISegmentM pSegM;
            double m1 = 0;
            //double m2 = 0;
            //IPoint pFromPt;
            //IMarkerSymbol pMSym;
            IMask pMask;
            ITextElement pTextElement;
            ISegmentCollection pSegment;
            ISegmentCollection pPolyline;
            while (pFeature != null)
            {
                pPL = pFeature.Shape as IPolyline;
                pPLM = pPL as IMAware;
                if (pPLM.MAware)
                {
                    if (bEndsOnly)
                    {
                        MakeHatchesEndsOnly(pPL, bEnds, pMajorHatchPL, pMinorHatchPL, dHatchLen, dTxtInterval, dHatchOffset);
                    }
                    else
                    {

                    }
                    // Draw the major hatches if they are lines
                    if (pHatchSymMajor is ILineSymbol)
                    {
                        pLineElement = new LineElementClass();
                        pLineElement.Symbol = pHatchSymMajor;
                        pElement = pLineElement as IElement;
                        pElement.Geometry = pMajorHatchPL as IGeometry;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }
                    // Draw the major hatches if they are markers and the text...
                    pGeomColl = pMajorHatchPL as IGeometryCollection;
                    cnt = pGeomColl.GeometryCount - 1;
                    for (int j = 0; j <= cnt; j++)
                    {
                        pPath = pGeomColl.get_Geometry(j) as IPath;
                        if (bOverRideMajor)
                            angle = dMajorAngle;
                        else
                            angle = GetAngle(pPath) + dMajorAngle;
                        pSC = pPath as ISegmentCollection;
                        pSeg = pSC.get_Segment(0);
                        pSegM = pSeg as ISegmentM;
                        txt = Convert.ToString(Math.Round(m1, 1));
                        txtlen = pTxtSym.Size;
                        angle = GetAngle(pPath as ICurve);
                        if (ShouldFlip(angle))
                        {
                            pTxtPath = MakeTextPath(pPath, txtlen * 2);
                            angle += 180;
                            pTxtSym.RightToLeft = false;
                            pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                            pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;

                        }
                        else
                        {
                            //angle = angle;
                            pTxtPath = MakeTextPath(pPath, txtlen);
                            pTxtSym.RightToLeft = false;
                            pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                            pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                        }
                        pTxtSym.Angle = angle;
                        //Ϊ�ı�����MASK�����û�з��ţ�����Ϊ����
                        pMask = pTxtSym as IMask;
                        pMask.MaskSize = 2;
                        pMask.MaskStyle = esriMaskStyle.esriMSHalo;

                        pTextElement = new TextElementClass();
                        pTextElement.Symbol = pTxtSym;
                        pTextElement.Text = txt + " ";
                        pElement = pTextElement as IElement;

                        pSegment = pTxtPath as ISegmentCollection;
                        pPolyline = new PolylineClass();
                        pPolyline.AddSegmentCollection(pSegment);
                        pElement.Geometry = pPolyline as IGeometry;
                        pGraphicsContainer.AddElement(pElement, 0);
                    }
                }
                pFeature = pFeatCursor.NextFeature();
            }
        }
		private void button1_Click(object sender, System.EventArgs e)
		{
			//Create a new SymbolForm
			Form2 symbolForm = new Form2();

			//Get the IStyleGalleryItem that has been selected in the SymbologyControl
			IStyleGalleryItem styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassTextSymbols);
			if (styleGalleryItem == null) return;
				
			//Set the TextSymbol
			m_textSymbol = (ITextSymbol) styleGalleryItem.Item;

			//Release the SymbolForm
			symbolForm.Dispose();
    
		}
Beispiel #35
0
 private void btnTextSymbol_Click(object sender, EventArgs e)
 {
     ITextElement textElement = new TextElementClass();
     textElement.Symbol = pTextSymbol;
     textElement.Text = "图层名";
     frmTextSymbol frmText = new frmTextSymbol(ref textElement);
     frmText.ShowDialog();
     pTextSymbol = textElement.Symbol; //这里是设置标注的字体样式
 }
Beispiel #36
0
        private void LegendWizard_Load(object sender, EventArgs e)
        {
            if (m_pageLayoutControl.ActiveView.FocusMap == null)
            {
                MessageBox.Show("请先添加地图");
                return;

            }
            #region //点击 添加图例按钮 或在 PageLayoutControl中双击图例时
            if (mapSurroundFrame == null)  //当点击 添加图例按钮 或在 PageLayoutControl中双击图例时 先创建图例 或从地图上获得已经添加的图例;
            {

                //Get the GraphicsContainer
                IGraphicsContainer graphicsContainer = m_pageLayoutControl.GraphicsContainer;
                graphicsContainer.Reset();
                IElementProperties pElementPerties = graphicsContainer.Next() as IElementProperties;
                //Get the MapFrame
                IMapFrame mapFrame = (IMapFrame)graphicsContainer.FindFrame(m_pageLayoutControl.ActiveView.FocusMap);
                if (mapFrame == null) return;
                while (pElementPerties != null) //从地图中获得已有的图例
                {
                    if (pElementPerties.Type == "Map Surround Frame")
                    {
                        pMapSurrounFrame = pElementPerties as IMapSurroundFrame;
                        if (pMapSurrounFrame.MapSurround.Name == "Legend")
                        {
                            m_legend = pMapSurrounFrame.MapSurround as ILegend;
                            break;
                        }
                    }
                    pElementPerties = (IElementProperties)graphicsContainer.Next();
                }
                if (m_legend == null) //当地图中没有添加图例时 创建新图例
                {
                    //Create a legend
                    UID uID = new UIDClass();
                    uID.Value = "esriCarto.Legend";

                    //Create a MapSurroundFrame from the MapFrame
                    mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);

                    if (mapSurroundFrame == null) return;
                    if (mapSurroundFrame.MapSurround == null) return;

                    m_legend = mapSurroundFrame.MapSurround as ILegend;
                }
                else
                {
                    mapSurroundFrame = pMapSurrounFrame;

                }

                UID m_uid = new UIDClass();
                m_uid.Value = "{34C20002-4D3C-11D0-92D8-00805F7C28B0}";
                m_mapLayers = m_mapControl.Map as IMapLayers;
                m_emuLayer = m_mapLayers.get_Layers(m_uid, true);//获取图层
                if (m_emuLayer != null)
                {
                    m_emuLayer.Reset();
                    ILayer m_layer = null;
                    while ((m_layer = m_emuLayer.Next()) != null)
                    {
                        this.listBox1.Items.Add(m_layer.Name);//将图层名添加到图例备选项中
                    }
                }
            }
               #endregion
            else //在双击任意范围打印框中图例时,获得图例,及图层信息;
            {
                if (m_Map == null)
                {
                    MessageBox.Show("请先添加地图!");
                }
                for (int k = 0; k < m_Map.LayerCount; k++)
                {
                    listBox1.Items.Add(m_Map.get_Layer(k).Name.ToString());
                }
                m_legend = mapSurroundFrame .MapSurround as ILegend;
            }
            //以下设置需要用到的变量 及初始化 对话框
            plegendFormat = m_legend.Format as ILegendFormat; //设置图例格式需要用到的

            pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; //初始化图例标签的文本格式

            if (m_legend.Title != null)
                textBox1.Text = m_legend.Title.ToString(); //初始化对话框中的文本框 文本
            else
                textBox1.Text = "Legend";

            this.textBoxWidth.Text = "36";
            this.textBoxHeight.Text = "15";
            IMapSurround mapSurround = m_legend as IMapSurround;
            mapSurroundFrame.MapSurround = mapSurround;
            m_FrameProperties = (IFrameProperties)mapSurroundFrame;
            ISymbolBackground pSymbolBack = m_FrameProperties.Background as ISymbolBackground;
            ISymbolBorder pSymbolBorder = m_FrameProperties.Border as ISymbolBorder;
            ISymbolShadow pSymbolShadow = m_FrameProperties.Shadow as ISymbolShadow;
            if (pSymbolBack !=null )
            this.btnBackGroundColor.BackColor =ColorTranslator.FromOle ( pSymbolBack.FillSymbol.Color.RGB ) ;
            if (pSymbolBorder != null)
            this.btnBolderColor.BackColor = ColorTranslator.FromOle(pSymbolBorder.LineSymbol.Color.RGB);
             if (pSymbolShadow != null)
            this.btnShadowColor.BackColor = ColorTranslator.FromOle(pSymbolShadow.FillSymbol.Color.RGB);
        }
Beispiel #37
0
        private void SetItemInternal(object parent, object item, double previewScale, int themeCategory)
        {
            m_parent = parent;
            m_label = item as ITextSymbol;
            m_point = item as IPointSymbolization2D;
            m_area = item as IAreaSymbolizationFill;
            m_comp = item as ICompositeSymbolization;
            m_w2dsymbol = item as Image;
            this.PreviewScale = previewScale;
            this.ThemeCategory = themeCategory;

            if (item is IEnumerable<IStroke>)
                m_line = new List<IStroke>((IEnumerable<IStroke>)item);
            else
                m_line = null;
        }
Beispiel #38
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            UserControl uc = null;
            if (m_owner.SelectedClass == null)
            {
                MessageBox.Show(Strings.NoFeatureClassAssigned);
                return;
            }
            ILayerStylePreviewable prev = new LayerStylePreviewable(m_owner.EditorService.EditedResourceID,
                                                                    this.PreviewScale,
                                                                    80,
                                                                    40,
                                                                    "PNG", //NOXLATE
                                                                    this.ThemeCategory);

            //TODO: This is obviously a mess and could do with some future cleanup, but the idea here should be
            //easy to understand. Each primitive basic style (that's not a label) has 3 actions.
            // - Commit (When user clicks OK on dialog)
            // - Rollback (When user clicks Cancel on dialog)
            // - Edit Commit (When user invokes refresh)
            //Those that support GETLEGENDIMAGE-based previews will be passed an edit commit action. Invoking the
            //edit commit action will update the session-based layer with this edit-copy rule, allowing for the changes
            //to be reflected when we do the GETLEGENDIMAGE call
            //
            //Labels are exempt as those previews can be sufficiently simulated with System.Drawing API
            var factory = (ILayerElementFactory)m_owner.Editor.GetEditedResource();
            Action commit = null;
            Action rollback = null;
            if (isLabel)
            {
                m_origLabel = m_label;
                m_editLabel = (m_label == null) ? null : (ITextSymbol)m_label.Clone();

                uc = new FontStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId);
                ((FontStyleEditor)uc).Item = m_editLabel;
            }
            else if (isW2dSymbol)
            {
                m_origPoint = m_point;
                m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone();

                var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, m_w2dsymbol, prev);
                uc = pfse;
                pfse.Item = m_editPoint;

                Action editCommit = () =>
                {
                    //We need to update this boolean state
                    var w2d = pfse.W2DSymbolPreviewImage;
                    this.isPoint = (w2d == null);
                    this.isW2dSymbol = (w2d != null);

                    m_editPoint = pfse.Item;
                    ((IPointRule)m_parent).PointSymbolization2D = m_editPoint;

                    m_w2dsymbol = w2d;
                };
                pfse.SetEditCommit(editCommit);
                commit = () =>
                {
                    //We need to update this boolean state
                    var w2d = pfse.W2DSymbolPreviewImage;
                    this.isPoint = (w2d == null);
                    this.isW2dSymbol = (w2d != null);

                    m_point = pfse.Item;
                    ((IPointRule)m_parent).PointSymbolization2D = m_point;

                    m_w2dsymbol = w2d;
                };
                rollback = () =>
                {
                    ((IPointRule)m_parent).PointSymbolization2D = m_origPoint;
                };
            }
            else if (isPoint)
            {
                m_origPoint = m_point;
                m_editPoint = (m_point == null) ? null : (IPointSymbolization2D)m_point.Clone();

                var pfse = new PointFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev);
                uc = pfse;
                pfse.Item = m_editPoint;

                Action editCommit = () =>
                {
                    //We need to update this boolean state
                    var w2d = pfse.W2DSymbolPreviewImage;
                    this.isPoint = (w2d == null);
                    this.isW2dSymbol = (w2d != null);

                    m_editPoint = pfse.Item;
                    ((IPointRule)m_parent).PointSymbolization2D = m_editPoint;

                    m_w2dsymbol = w2d;
                };
                pfse.SetEditCommit(editCommit);
                commit = () =>
                {
                    //We need to update this boolean state
                    var w2d = pfse.W2DSymbolPreviewImage;
                    this.isPoint = (w2d == null);
                    this.isW2dSymbol = (w2d != null);

                    m_point = pfse.Item;
                    ((IPointRule)m_parent).PointSymbolization2D = m_point;

                    m_w2dsymbol = w2d;
                };
                rollback = () =>
                {
                    ((IPointRule)m_parent).PointSymbolization2D = m_origPoint;
                };
            }
            else if (isLine)
            {
                m_origLine = m_line;
                m_editLine = (m_line == null) ? new List<IStroke>() : LayerElementCloningUtil.CloneStrokes(m_line);

                var lfse = new LineFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, factory, prev);
                uc = lfse;
                lfse.Item = m_editLine;

                Action editCommit = () =>
                {
                    m_editLine = lfse.Item;
                    ((ILineRule)m_parent).SetStrokes(m_editLine);
                };
                lfse.SetEditCommit(editCommit);
                commit = () =>
                {
                    m_line = lfse.Item;
                    ((ILineRule)m_parent).SetStrokes(m_line);
                };
                rollback = () =>
                {
                    ((ILineRule)m_parent).SetStrokes(m_origLine);
                };
            }
            else if (isArea)
            {
                m_origArea = m_area;
                m_editArea = (m_area == null) ? null : (IAreaSymbolizationFill)m_area.Clone();

                var afse = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.SelectedClass, m_owner.FeatureSourceId, prev);
                uc = afse;
                afse.Item = m_editArea;

                Action editCommit = () =>
                {
                    m_editArea = afse.Item;
                    ((IAreaRule)m_parent).AreaSymbolization2D = m_editArea;
                };
                commit = () =>
                {
                    m_area = afse.Item;
                    ((IAreaRule)m_parent).AreaSymbolization2D = m_area;
                };
                rollback = () =>
                {
                    ((IAreaRule)m_parent).AreaSymbolization2D = m_origArea;
                };
                afse.SetEditCommit(editCommit);
            }
            else if (isComp)
            {
                var diag = new SymbolInstancesDialog(m_owner.Editor, m_comp, m_owner.SelectedClass, m_owner.GetFdoProvider(), m_owner.FeatureSourceId, prev);
                diag.ShowDialog();
                //HACK: Assume edits made
                Owner.RaiseResourceChanged();
                return;
            }

            if (uc != null)
            {
                EditorTemplateForm dlg = new EditorTemplateForm();
                dlg.ItemPanel.Controls.Add(uc);
                uc.Dock = DockStyle.Fill;
                dlg.RefreshSize();
                var res = dlg.ShowDialog(this);
                if (res == DialogResult.OK)
                {
                    if (commit != null)
                    {
                        commit.Invoke();
                    }

                    if (isLabel)
                    {
                        m_label = ((FontStyleEditor)uc).Item;
                        if (m_parent as IPointRule != null)
                            ((IPointRule)m_parent).Label = m_label;
                        else if (m_parent as ILineRule != null)
                            ((ILineRule)m_parent).Label = m_label;
                        else if (m_parent as IAreaRule != null)
                            ((IAreaRule)m_parent).Label = m_label;

                        if (ItemChanged != null)
                            ItemChanged(m_label, null);
                    }
                    else if (isPoint || isW2dSymbol)
                    {
                        if (ItemChanged != null)
                            ItemChanged(m_point, null);
                    }
                    else if (isLine)
                    {

                        if (ItemChanged != null)
                            ItemChanged(m_line, null);
                    }
                    else if (isArea)
                    {
                        if (ItemChanged != null)
                            ItemChanged(m_area, null);
                    }

                    this.Refresh();
                }
                else if (res == DialogResult.Cancel)
                {
                    if (rollback != null)
                        rollback.Invoke();
                }
            }
        }
Beispiel #39
0
 public void SetItem(object parent, ITextSymbol label, double previewScale, int themeCategory)
 {
     isLabel = true;
     SetItemInternal(parent, label, previewScale, themeCategory);
 }
Beispiel #40
0
        private void DisplayLabel_CheckedChanged(object sender, EventArgs e)
        {
            foreach (Control c in this.Controls)
                c.Enabled = c == DisplayLabel || DisplayLabel.Checked;

            if (m_inUpdate)
                return;

            if (DisplayLabel.Checked)
            {
                if (DisplayLabel.Tag as ITextSymbol != null)
                    this.Item = DisplayLabel.Tag as ITextSymbol;
                if (m_item == null)
                    this.Item = _factory.CreateDefaultTextSymbol();
            }
            else
            {
                DisplayLabel.Tag = m_item;
                this.Item = null;
            }
        }
Beispiel #41
0
 private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
 {
     IActiveView pActiveView = axMapControl1.ActiveView.FocusMap as IActiveView;
     IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
     object Missing = Type.Missing;
     switch (m_BasicOperationTool)
     {
         case "isMeasure":
             if (!m_bInUse)
                 break;
             bool bFirstTime = false;
             if (m_pLineSymbol == null)
                 bFirstTime = true;
             pActiveView.ScreenDisplay.StartDrawing(pActiveView.ScreenDisplay.hDC, -1);
             if (bFirstTime == true)
             {
                 IRgbColor pRgbColor = new RgbColorClass();
                 m_pLineSymbol = new SimpleLineSymbolClass();
                 m_pLineSymbol.Width = 2;
                 pRgbColor.Red = 223;
                 pRgbColor.Green = 223;
                 pRgbColor.Blue = 223;
                 m_pLineSymbol.Color = pRgbColor;
                 ISymbol pSymbol = m_pLineSymbol as ISymbol;
                 pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen;
                 //�����ı�����
                 m_pTextSymbol = new TextSymbolClass();
                 m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                 m_pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                 m_pTextSymbol.Size = 16;
                 pSymbol = m_pTextSymbol as ISymbol;
                 stdole.IFontDisp fnt = (stdole.IFontDisp)new stdole.StdFontClass();
                 fnt.Name = "Arial";
                 fnt.Size = Convert.ToDecimal(20);
                 m_pTextSymbol.Font = fnt;
                 pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen;
                 //�������Ի��ı�
                 m_pTextPoint = new PointClass();
             }
             else
             {
                 pActiveView.ScreenDisplay.SetSymbol(m_pTextSymbol as ISymbol);
                 pActiveView.ScreenDisplay.DrawText(m_pTextPoint, m_pTextSymbol.Text);
                 pActiveView.ScreenDisplay.SetSymbol(m_pLineSymbol as ISymbol);
                 if (m_pLinePolyline.Length > 0)
                     pActiveView.ScreenDisplay.DrawPolyline(m_pLinePolyline);
             }
             //����㵽�յ�֮������߲������ı��ĽǶ�
             ILine pLine = new LineClass();
             pLine.PutCoords(m_pStartPoint, pPoint);
             double angle = pLine.Angle;
             angle = angle * (180 / 3.1415926);
             if ((angle > 90) || (angle < 180))
                 angle = angle + 180;
             if ((angle < 0) || (angle > -90))
                 angle = angle - 180;
             if ((angle < -90) || (angle > -180))
                 angle = angle - 180;
             if (angle > 180)
                 angle = angle - 180;
             //Ϊ�˻����ı�������ı��ľ��룬�ǶȺ͵�
             double deltaX = pPoint.X - m_pStartPoint.X;
             double deltaY = pPoint.Y - m_pStartPoint.Y;
             m_pTextPoint.X = m_pStartPoint.X + deltaX / 2;
             m_pTextPoint.Y = m_pStartPoint.Y + deltaY / 2;
             m_pTextSymbol.Angle = angle;
             int distance = Convert.ToInt32(Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY)));
             m_pTextSymbol.Text = "[" + distance.ToString() + "]";
             //�����ı�
             pActiveView.ScreenDisplay.SetSymbol(m_pTextSymbol as ISymbol);
             pActiveView.ScreenDisplay.DrawText(m_pTextPoint, m_pTextSymbol.Text);
             //��ö����
             IPolyline pPolyline = new PolylineClass();
             ISegmentCollection pSegColl = pPolyline as ISegmentCollection;
             pSegColl.AddSegment(pLine as ISegment, ref Missing, ref Missing);
             m_pLinePolyline = GetSmashedLine(pActiveView.ScreenDisplay, m_pTextSymbol as ISymbol, m_pTextPoint, pPolyline);
             //���ƶ����
             pActiveView.ScreenDisplay.SetSymbol(m_pLineSymbol as ISymbol);
             if (m_pLinePolyline.Length > 0)
             {
                 pActiveView.ScreenDisplay.DrawPolyline(m_pLinePolyline);
             }
             pActiveView.ScreenDisplay.FinishDrawing();
             break;
     }
 }