Пример #1
0
        private void exportGeometryRenderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string        nodeName  = selectNode.Text;
            myListNode    node      = selectNode as myListNode;
            IFeatureLayer layer     = node.layer;
            string        renderStr = layer.GetGeometryRender().AsXml();

            SaveFileDialog sd = new SaveFileDialog();

            sd.AddExtension     = true;
            sd.DefaultExt       = "xml";
            sd.Filter           = "XML文件|*.xml";
            sd.RestoreDirectory = true;
            if (sd.ShowDialog() == DialogResult.OK)
            {
                String final = sd.FileName;
                if (sd.FileName.LastIndexOf(".xml") == -1)
                {
                    final = String.Format("{0}.xml", sd.FileName);
                }
                System.IO.File.WriteAllText(final, renderStr);
                MessageBox.Show("导出成功");
            }
        }
Пример #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);
            }
        }
Пример #3
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;
        }