Beispiel #1
0
        private void ShowWind_Click(object sender, EventArgs e)
        {
            ILayer        pLayer        = MainMap.get_Layer(0);
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            int indexDir   = pFeatureClass.Fields.FindField("Dir");
            int indexSpeed = pFeatureClass.Fields.FindField("Speed");

            ISymbol          pSymbol          = AOUtil.FetchSymbol("dir");
            IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
            ISimpleRenderer  pSimpleRenderer  = pGeoFeatureLayer.Renderer as ISimpleRenderer;

            pSimpleRenderer.Symbol = pSymbol;

            IRotationRenderer pRotationRender = pSimpleRenderer as IRotationRenderer;

            pRotationRender.RotationField = "dir";

            ISizeRenderer pSizeRender = pSimpleRenderer as ISizeRenderer;

            pSizeRender.SizeRendererExpression = "[Speed]";
            pSizeRender.SizeRendererFlags      = 1;

            MainMap.Refresh();
        }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            string FieldName = cbx_Field.SelectedItem.ToString();

            if (FieldName == "None")
            {
                MessageBox.Show("不可用字段,请选择其它图层"); return;
            }
            IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)m_FeatureLayer;

            pGeoFeatureLayer.ScaleSymbols = true;
            ITable  pTable  = (ITable)pGeoFeatureLayer;
            ICursor pCursor = pTable.Search(null, true);

            IDataStatistics pDataStatistics = new DataStatisticsClass();

            pDataStatistics.Cursor = pCursor;
            //Set statistical field
            pDataStatistics.Field = FieldName;
            //Get the result of statistics
            IStatisticsResults pStatisticsResult = pDataStatistics.Statistics;

            if (pStatisticsResult == null)
            {
                MessageBox.Show("Failed to gather stats on the feature class");
                return;
            }

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
            // pFillSymbol.Color = m_BackGroundColor;


            IMarkerSymbol pCharaterMarkerS = new CharacterMarkerSymbolClass();

            pCharaterMarkerS       = (IMarkerSymbol)m_StyleGallertItem.Item;
            pCharaterMarkerS.Size  = (int)numericUpDown1.Value;
            pCharaterMarkerS.Color = m_BackGroundColor;

            IProportionalSymbolRenderer pProportionalSymbolR = new ProportionalSymbolRendererClass();

            pProportionalSymbolR.ValueUnit            = esriUnits.esriUnknownUnits;
            pProportionalSymbolR.Field                = FieldName;
            pProportionalSymbolR.FlanneryCompensation = false;
            pProportionalSymbolR.MinDataValue         = pStatisticsResult.Minimum;
            pProportionalSymbolR.MaxDataValue         = pStatisticsResult.Maximum;
            pProportionalSymbolR.BackgroundSymbol     = pFillSymbol;
            pProportionalSymbolR.MinSymbol            = (ISymbol)pCharaterMarkerS;
            pProportionalSymbolR.LegendSymbolCount    = 5;
            pProportionalSymbolR.CreateLegendSymbols();

            IRotationRenderer pRotationRenderer = (IRotationRenderer)pProportionalSymbolR;

            pRotationRenderer.RotationField = FieldName;
            pRotationRenderer.RotationType  = esriSymbolRotationType.esriRotateSymbolGeographic;
            //Set the states layer renderer to the proportional symbol renderer and refresh the display
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pProportionalSymbolR;

            m_MapControl.ActiveView.ContentsChanged();
            m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
		public void InitRenderer(IMultivariateRenderer pMultiRend)
		{
			// copy properties from the form to the renderer

			if (chkShapePattern.CheckState == System.Windows.Forms.CheckState.Checked)
				pMultiRend.ShapePatternRend = m_pShapePatternRend;
			else
				pMultiRend.ShapePatternRend = null;

			if (chkColor.CheckState == System.Windows.Forms.CheckState.Checked)
			{
				pMultiRend.ColorRend1 = m_pColorRend1;
				pMultiRend.ColorRend2 = m_pColorRend2;
				pMultiRend.ColorCombinationMethod = m_eColorCombinationMethod;
			}
			else
			{
				pMultiRend.ColorRend1 = null;
				pMultiRend.ColorRend2 = null;
				pMultiRend.ColorCombinationMethod = EColorCombinationType.enuCIELabMatrix; // default (?)
			}

			if (chkSize.CheckState == System.Windows.Forms.CheckState.Checked)
				pMultiRend.SizeRend = m_pSizeRend;
			else
				pMultiRend.SizeRend = null;

			IRotationRenderer pRotRend = null;
			IRotationRenderer pFormRotRend = null;
			pRotRend = pMultiRend as IRotationRenderer;
			if (chkRotation.CheckState == System.Windows.Forms.CheckState.Checked)
			{
				pFormRotRend = m_pRend as IRotationRenderer;
				pRotRend.RotationField = pFormRotRend.RotationField;
				pRotRend.RotationType = pFormRotRend.RotationType;
			}
			else
			{
				pRotRend.RotationField = "";
				pRotRend.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic; // default (?)
			}

            //ITransparencyRenderer pTransRend = null;
            //ITransparencyRenderer pFormTransRend = null;
            //pTransRend = pMultiRend as ITransparencyRenderer;
            //if (chkTransparency.CheckState == System.Windows.Forms.CheckState.Checked)
            //{
            //    pFormTransRend = m_pRend as ITransparencyRenderer;
            //    pTransRend.TransparencyField = pFormTransRend.TransparencyField;
            //}
            //else
            //    pTransRend.TransparencyField = "";


		}
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the buttonMakeLayer control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void buttonMakeLayer_Click(object sender, EventArgs e)
        {
            IFeatureClass featureClass = this.PhotoTable.ToFeatureClass();

            if (this.MxDocument != null && featureClass != null)
            {
                IFeatureLayer layer = new FeatureLayerClass();
                layer.Name         = "GPS Photos    -     " + DateTime.Now.ToString();
                layer.FeatureClass = featureClass;

                // set the hotlink to the FullPath field
                IHotlinkContainer hotlink = (IHotlinkContainer)layer;
                hotlink.HotlinkField = "FullPath";
                hotlink.HotlinkType  = esriHyperlinkType.esriHyperlinkTypeURL;

                IHTMLPopupInfo htmlPopupInfo = (IHTMLPopupInfo)layer;
                htmlPopupInfo.HTMLPopupEnabled = true;

                string xsl = this.ReadDefaultXSLT();

                if (!string.IsNullOrEmpty(xsl))
                {
                    htmlPopupInfo.HTMLPresentationStyle = esriHTMLPopupStyle.esriHTMLPopupStyleXSLStylesheet;
                    htmlPopupInfo.HTMLXSLStylesheet     = xsl;
                }
                else
                {
                    htmlPopupInfo.HTMLPresentationStyle = esriHTMLPopupStyle.esriHTMLPopupStyleTwoColumnTable;
                }

                IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)layer;
                ISimpleRenderer  renderer        = new SimpleRendererClass();
                renderer.Label  = "Photo Locations";
                renderer.Symbol = this.GetGPSPhotoSymbol();

                IRotationRenderer rotationRenderer = (IRotationRenderer)renderer;
                rotationRenderer.RotationField = "MagneticNorth";
                rotationRenderer.RotationType  = esriSymbolRotationType.esriRotateSymbolGeographic;

                geoFeatureLayer.Renderer = (IFeatureRenderer)renderer;

                this.MxDocument.FocusMap.AddLayer((ILayer)layer);
                this.MxDocument.UpdateContents();

                this.Close();
            }
        }
Beispiel #5
0
        /// <summary>
        /// 清空地图要素选集
        /// </summary>
        /// <param name="pEditor">当前编辑接口</param>
        /// <returns>无效区域(需要重绘)</returns>
        //public static IInvalidArea3 ClearSelection(IEditor pEditor)
        //{
        //    IInvalidArea3 pInvalidArea = new InvalidAreaClass();
        //    pInvalidArea.Display = pEditor.Display;
        //    IEnumFeature pEnum = (IEnumFeature)pEditor.Map.FeatureSelection;
        //    IFeature pFeature = null;
        //    while ((pFeature = pEnum.Next()) != null) { pInvalidArea.Add(pFeature); }
        //    pEditor.Map.ClearSelection();
        //    return pInvalidArea;
        //}

        /// <summary>
        /// 设置旋转要素所在图层的旋转字段,建议使用mxd设置
        /// </summary>
        /// <param name="sRotationField">字段</param>
        public static void SetRotateRenderer(string sRotationField)
        {
            IEnumLayer    pEnumLayer = GeoDbUtils.GetFeatureLayers(true);
            IFeatureLayer pfLayer    = null;

            while ((pfLayer = (IFeatureLayer)pEnumLayer.Next()) != null)
            {
                IFeatureClass pfClass = pfLayer.FeatureClass;
                if (pfClass != null && pfClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    if (pfClass.FindField(sRotationField) != -1)
                    {
                        IGeoFeatureLayer  pGeofLayer   = (IGeoFeatureLayer)pfLayer;
                        IRotationRenderer pRotRenderer = (IRotationRenderer)pGeofLayer.Renderer;
                        pRotRenderer.RotationField = sRotationField;
                        pRotRenderer.RotationType  = esriSymbolRotationType.esriRotateSymbolArithmetic;
                    }
                }
            }
        }
        //*********************************************************************************
        //** 函 数 名:FunReadRotation
        //** 输    入:
        //** 输    出:
        //** 功能描述:读取RotationRenderer
        //** 全局变量:
        //** 调用模块:
        //*********************************************************************************
        private void FunReadRotation()
        {
            IFeatureRenderer pRenderer;
            IGeoFeatureLayer pGeoFeatureLayer;

            pGeoFeatureLayer   = (IGeoFeatureLayer)m_FeatureLayer;
            pRenderer          = pGeoFeatureLayer.Renderer;
            m_RotationRenderer = (IRotationRenderer)pRenderer;

            if (m_RotationRenderer != null)
            {
                try
                {
                    if (m_RotationRenderer.RotationField != "")
                    {
                        this.CmbField.Text = m_RotationRenderer.RotationField;
                    }
                    else
                    {
                        this.CmbField.Text = "<无>";
                    }

                    if (m_RotationRenderer.RotationField == esriSymbolRotationType.esriRotateSymbolGeographic.ToString())
                    {
                        this.rdoGeographic.Checked = true;
                    }
                    else
                    {
                        this.rdoMath.Checked = true;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
		public void InitControls(IMultivariateRenderer pMultiRend, IMap pMap, IGeoFeatureLayer pGeoLayer)
		{
			// copy properties from the renderer and map to the form

			m_eColorCombinationMethod = pMultiRend.ColorCombinationMethod;
			m_pShapePatternRend = pMultiRend.ShapePatternRend;
			m_pColorRend1 = pMultiRend.ColorRend1;
			m_pColorRend2 = pMultiRend.ColorRend2;
			m_pSizeRend = pMultiRend.SizeRend;

			if (m_pShapePatternRend != null)
			{
				chkShapePattern.CheckState = System.Windows.Forms.CheckState.Checked;
				cboShapePattern.Enabled = true;
			}

			if (m_eColorCombinationMethod == EColorCombinationType.enuComponents)
			{
				radComponents.Checked = true;
				radCombination.Checked = false;
				UpdateColorComb();

			}
			else
			{
                //disabled
                //radComponents.Checked = false;
                //radCombination.Checked = true;

                radComponents.Checked = true;
                radCombination.Checked = false;
				UpdateColorComb();

			}

			if (m_pColorRend1 != null)
			{
				chkColor.CheckState = System.Windows.Forms.CheckState.Checked;
				radComponents.Enabled = true;
                //disabled
                //radCombination.Enabled = true;
                radCombination.Enabled = false;

			}
			if (m_pSizeRend != null)
			{
				chkSize.CheckState = System.Windows.Forms.CheckState.Checked;
				cboSize1.Enabled = true;
			}

			IRotationRenderer pRotRend = null;
			pRotRend = pMultiRend as IRotationRenderer;
			if (pRotRend.RotationField != "")
			{
				chkRotation.CheckState = System.Windows.Forms.CheckState.Checked;
				butRotation.Enabled = true;
			}

            //ITransparencyRenderer pTransRend = null;
            //pTransRend = pMultiRend as ITransparencyRenderer;
            //if (pTransRend.TransparencyField != "")
            //{
            //    chkTransparency.CheckState = System.Windows.Forms.CheckState.Checked;
            //    butTransparency.Enabled = true;
            //}

			m_pMap = pMap;
			m_pCurrentLayer = pGeoLayer;
			m_pRend = pMultiRend as IFeatureRenderer; // we need this object to support the root transparency dialogs

			m_PageIsDirty = false;
		}