Exemplo n.º 1
0
        private IGeometryRender GetGeoRender(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }
            IGeometryRender result       = null;
            double          heightOffset = 0.0;
            string          value        = node.Attributes["HeightStyle"].Value;
            object          obj          = node.Attributes["HeightOffset"];

            if (obj != null)
            {
                heightOffset = double.Parse(node.Attributes["HeightOffset"].Value);
            }
            string value2 = node.Attributes["GroupField"].Value;
            string value3 = node.Attributes["RenderType"].Value;

            if (value3 == gviRenderType.gviRenderSimple.ToString())
            {
                ISimpleGeometryRender simpleGeometryRender = new SimpleGeometryRenderClass();
                XmlNode xmlNode = node.SelectSingleNode("GeometrySymbol");
                if (xmlNode != null)
                {
                    string value4 = xmlNode.Attributes["GeometryType"].Value;
                    simpleGeometryRender.Symbol = this.GetGeometrySymbol(value4, xmlNode);
                }
                if (value == gviHeightStyle.gviHeightAbsolute.ToString())
                {
                    simpleGeometryRender.HeightStyle = gviHeightStyle.gviHeightAbsolute;
                }
                else
                {
                    simpleGeometryRender.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                }
                simpleGeometryRender.HeightOffset     = heightOffset;
                simpleGeometryRender.RenderGroupField = value2;
                result = simpleGeometryRender;
            }
            else
            {
                XmlNodeList xmlNodeList = node.SelectNodes("ValueMap/RenderScheme");
                if (xmlNodeList != null && xmlNodeList.Count > 0)
                {
                    IValueMapGeometryRender valueMapGeometryRender = new ValueMapGeometryRenderClass();
                    foreach (XmlNode xmlNode2 in xmlNodeList)
                    {
                        IGeometryRenderScheme geometryRenderScheme = new GeometryRenderSchemeClass();
                        XmlNode xmlNode3 = xmlNode2.SelectSingleNode("RenderRule");
                        if (xmlNode3 != null)
                        {
                            string value5 = xmlNode3.Attributes["RuleType"].Value;
                            string value6 = xmlNode3.Attributes["LookUpField"].Value;
                            if (value5 == gviRenderRuleType.gviRenderRuleUniqueValues.ToString())
                            {
                                IUniqueValuesRenderRule uniqueValuesRenderRule = new UniqueValuesRenderRuleClass();
                                uniqueValuesRenderRule.LookUpField = value6;
                                if (xmlNode3.Attributes["UniqueValue"] != null)
                                {
                                    string value7 = xmlNode3.Attributes["UniqueValue"].Value;
                                    uniqueValuesRenderRule.AddValue(value7);
                                }
                                geometryRenderScheme.AddRule(uniqueValuesRenderRule);
                            }
                            else
                            {
                                IRangeRenderRule rangeRenderRule = new RangeRenderRuleClass();
                                string           value8          = xmlNode3.Attributes["IncludeMax"].Value;
                                string           value9          = xmlNode3.Attributes["IncludeMin"].Value;
                                string           value10         = xmlNode3.Attributes["MaxValue"].Value;
                                string           value11         = xmlNode3.Attributes["MinValue"].Value;
                                rangeRenderRule.LookUpField = value6;
                                rangeRenderRule.IncludeMax  = (value8.ToLower() == "true");
                                rangeRenderRule.IncludeMin  = (value9.ToLower() == "true");
                                rangeRenderRule.MaxValue    = double.Parse(value10);
                                rangeRenderRule.MinValue    = double.Parse(value11);
                                geometryRenderScheme.AddRule(rangeRenderRule);
                            }
                        }
                        XmlNode xmlNode4 = xmlNode2.SelectSingleNode("GeometrySymbol");
                        if (xmlNode4 != null)
                        {
                            string          value12        = xmlNode4.Attributes["GeometryType"].Value;
                            IGeometrySymbol geometrySymbol = this.GetGeometrySymbol(value12, xmlNode4);
                            geometryRenderScheme.Symbol = geometrySymbol;
                        }
                        if (value == gviHeightStyle.gviHeightAbsolute.ToString())
                        {
                            valueMapGeometryRender.HeightStyle = gviHeightStyle.gviHeightAbsolute;
                        }
                        else
                        {
                            valueMapGeometryRender.HeightStyle = gviHeightStyle.gviHeightOnTerrain;
                        }
                        valueMapGeometryRender.HeightOffset     = heightOffset;
                        valueMapGeometryRender.RenderGroupField = value2;
                        valueMapGeometryRender.AddScheme(geometryRenderScheme);
                    }
                    result = valueMapGeometryRender;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void btnApply_Click(object sender, System.EventArgs e)
        {
            string script = this.txtScript.Text.Trim();

            if (script != "")
            {
                IGeometryRender render = selectedLayer.GetGeometryRender();
                if (render != null)
                {
                    if (render.RenderType == gviRenderType.gviRenderSimple)
                    {
                        ISimpleGeometryRender simpleRender = render as ISimpleGeometryRender;
                        IGeometrySymbol       geoSymbol    = simpleRender.Symbol;
                        geoSymbol.Script    = script;
                        simpleRender.Symbol = geoSymbol;
                        if (!selectedLayer.SetGeometryRender(simpleRender))
                        {
                            MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                        }
                    }
                }
                else
                {
                    ISimpleGeometryRender simpleRender = new SimpleGeometryRender();
                    switch (type)
                    {
                    case LayerType.ModelPoint:
                    {
                        IModelPointSymbol mps = new ModelPointSymbol();
                        mps.Script          = script;
                        simpleRender.Symbol = mps;
                    }
                    break;

                    case LayerType.Polyline:
                    {
                        ICurveSymbol cs = new CurveSymbol();
                        cs.Script           = script;
                        simpleRender.Symbol = cs;
                    }
                    break;

                    case LayerType.Point:
                    {
                        if (script.Contains("<ImageName>"))
                        {
                            IImagePointSymbol ips = new ImagePointSymbol();
                            ips.Script          = script;
                            simpleRender.Symbol = ips;
                        }
                        else
                        {
                            ISimplePointSymbol sps = new SimplePointSymbol();
                            sps.Script          = script;
                            simpleRender.Symbol = sps;
                        }
                    }
                    break;

                    case LayerType.Polygon:
                    {
                        if (script.Contains("<Height>"))
                        {
                            IPolygon3DSymbol p3s = new Polygon3DSymbol();
                            p3s.Script          = script;
                            simpleRender.Symbol = p3s;
                        }
                        else
                        {
                            ISurfaceSymbol ss = new SurfaceSymbol();
                            ss.Script           = script;
                            simpleRender.Symbol = ss;
                        }
                    }
                    break;
                    }
                    if (!selectedLayer.SetGeometryRender(simpleRender))
                    {
                        MessageBox.Show("错误码为:" + this.axRenderControl1.GetLastError());
                    }
                }
            }
            else
            {
                selectedLayer.SetGeometryRender(null);
            }
        }
Exemplo n.º 3
0
        private IGeometrySymbol GetGeometrySymbol(string GeoType, XmlNode symbolNode)
        {
            IGeometrySymbol result = null;

            if (GeoType != null)
            {
                if (!(GeoType == "ModelPoint"))
                {
                    if (!(GeoType == "PointCloud"))
                    {
                        if (!(GeoType == "SimplePoint"))
                        {
                            if (!(GeoType == "ImagePoint"))
                            {
                                if (!(GeoType == "Polyline"))
                                {
                                    if (GeoType == "Polygon")
                                    {
                                        result = new SurfaceSymbolClass
                                        {
                                            Color          = uint.Parse(symbolNode.Attributes["FillColor"].Value),
                                            EnableLight    = bool.Parse(symbolNode.Attributes["EnableLight"].Value),
                                            BoundarySymbol =
                                            {
                                                Color     = uint.Parse(symbolNode.Attributes["Color"].Value),
                                                Width     = float.Parse(symbolNode.Attributes["Width"].Value),
                                                ImageName = symbolNode.Attributes["ImageName"].Value
                                            }
                                        };
                                    }
                                }
                                else
                                {
                                    ICurveSymbol curveSymbol = new CurveSymbolClass();
                                    curveSymbol.Color     = uint.Parse(symbolNode.Attributes["Color"].Value);
                                    curveSymbol.Width     = float.Parse(symbolNode.Attributes["Width"].Value);
                                    curveSymbol.ImageName = symbolNode.Attributes["ImageName"].Value;
                                    if (symbolNode.Attributes["RepeatLength"] != null)
                                    {
                                        curveSymbol.RepeatLength = float.Parse(symbolNode.Attributes["RepeatLength"].Value);
                                    }
                                    result = curveSymbol;
                                }
                            }
                            else
                            {
                                result = new ImagePointSymbolClass
                                {
                                    Size      = int.Parse(symbolNode.Attributes["Size"].Value),
                                    Alignment = (gviPivotAlignment)System.Enum.Parse(typeof(gviPivotAlignment), symbolNode.Attributes["Alignment"].Value),
                                    ImageName = Path.Combine(System.Windows.Forms.Application.StartupPath + @"\..\Image\" + symbolNode.Attributes["ImageName"].Value)
                                };
                            }
                        }
                        else
                        {
                            result = new SimplePointSymbolClass
                            {
                                Size      = int.Parse(symbolNode.Attributes["Size"].Value),
                                Alignment = (gviPivotAlignment)System.Enum.Parse(typeof(gviPivotAlignment), symbolNode.Attributes["Alignment"].Value),
                                FillColor = uint.Parse(symbolNode.Attributes["FillColor"].Value),
                                Style     = (gviSimplePointStyle)System.Enum.Parse(typeof(gviSimplePointStyle), symbolNode.Attributes["Style"].Value)
                            };
                        }
                    }
                    else
                    {
                        result = new PointCloudSymbolClass
                        {
                            Color       = uint.Parse(symbolNode.Attributes["Color"].Value),
                            EnableColor = symbolNode.Attributes["EnableColor"].Value.ToLower() == "true",
                            Size        = int.Parse(symbolNode.Attributes["Size"].Value)
                        };
                    }
                }
                else
                {
                    IModelPointSymbol modelPointSymbol = new ModelPointSymbolClass();
                    modelPointSymbol.Color       = uint.Parse(symbolNode.Attributes["Color"].Value);
                    modelPointSymbol.EnableColor = (symbolNode.Attributes["EnableColor"].Value.ToLower() == "true");
                    XmlAttribute xmlAttribute = symbolNode.Attributes["EnableTexture"];
                    if (xmlAttribute != null)
                    {
                        modelPointSymbol.EnableTexture = (xmlAttribute.Value.ToLower() == "true");
                    }
                    result = modelPointSymbol;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            myListNode item = (myListNode)this.listView1.GetItemAt(e.X, e.Y);

            if (item == null)
            {
                return;
            }

            cbCOMProperties.Items.Clear();
            selectedLayer = item.layer;
            IGeometryRender render = selectedLayer.GetGeometryRender();

            if (render != null)
            {
                if (render.RenderType == gviRenderType.gviRenderSimple)
                {
                    IGeometrySymbol geoSymbol = (render as ISimpleGeometryRender).Symbol;
                    txtScript.Text = geoSymbol.Script;

                    switch (geoSymbol.SymbolType)
                    {
                    case gviGeometrySymbolType.gviGeoSymbolPoint:
                    {
                        cbCOMProperties.Items.Add("Size");
                        cbCOMProperties.Items.Add("FillColor");
                    }
                    break;

                    case gviGeometrySymbolType.gviGeoSymbolModelPoint:
                    {
                        cbCOMProperties.Items.Add("Color");
                    }
                    break;

                    case gviGeometrySymbolType.gviGeoSymbolImagePoint:
                    {
                        cbCOMProperties.Items.Add("Size");
                        cbCOMProperties.Items.Add("ImageName");
                    }
                    break;

                    case gviGeometrySymbolType.gviGeoSymbolCurve:
                    {
                        cbCOMProperties.Items.Add("Color");
                        cbCOMProperties.Items.Add("ImageName");
                        cbCOMProperties.Items.Add("RepeatLength");
                        cbCOMProperties.Items.Add("Width");
                    }
                    break;

                    case gviGeometrySymbolType.gviGeoSymbolSurface:
                    {
                        cbCOMProperties.Items.Add("Color");
                    }
                    break;

                    case gviGeometrySymbolType.gviGeoSymbol3DPolygon:
                    {
                        cbCOMProperties.Items.Add("Color");
                        cbCOMProperties.Items.Add("Height");
                    }
                    break;
                    }
                }
            }
            else
            {
                switch (item.type)
                {
                case LayerType.ModelPoint:
                {
                    cbCOMProperties.Items.Add("Color");
                }
                break;

                case LayerType.Polyline:
                {
                    cbCOMProperties.Items.Add("Color");
                    cbCOMProperties.Items.Add("ImageName");
                    cbCOMProperties.Items.Add("RepeatLength");
                    cbCOMProperties.Items.Add("Width");
                }
                break;

                case LayerType.Point:
                {
                    cbCOMProperties.Items.Add("Size");
                    cbCOMProperties.Items.Add("FillColor");
                    cbCOMProperties.Items.Add("ImageName");
                }
                break;

                case LayerType.Polygon:
                {
                    cbCOMProperties.Items.Add("Color");
                    cbCOMProperties.Items.Add("Height");
                }
                break;
                }
            }

            cbFields.Items.Clear();
            IFeatureClass fc = null;

            try
            {
                foreach (System.Guid guid in fcGuidMap.Keys)
                {
                    if (guid.Equals(selectedLayer.FeatureClassId))
                    {
                        fc = fcGuidMap[guid] as IFeatureClass;
                    }
                }

                IFieldInfoCollection fields = fc.GetFields();
                for (int i = 0; i < fields.Count; i++)
                {
                    IFieldInfo field = fields.Get(i);
                    if (field.FieldType == gviFieldType.gviFieldGeometry || field.FieldType == gviFieldType.gviFieldBlob)
                    {
                        continue;
                    }
                    cbFields.Items.Add(field.Name);
                }
            }
            catch (System.Exception ex)
            {
            }

            type = item.type;
        }