Esempio n. 1
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);
        }
Esempio n. 2
0
        public bool ShowFlowDirection(int flowDir, out IRenderModelPoint rpt)
        {
            rpt = null;
            if (base._rowInfo == null)
            {
                return(false);
            }

            string str = Application.StartupPath + @"\..\Resource\Images\FlowDirection";

            if (!Directory.Exists(str))
            {
                return(false);
            }
            IImage _imgFlowImg = DrawGeometry.resFactory.CreateImageFromFile(str);

            _imgFlowImg.FrameInterval = 50;

            IPolyline        path        = null;
            IPipeSection     pipeSection = null;
            string           name        = "FlowDirection";
            IDrawDynamicFlow flow        = null;
            IModelPoint      mp          = null;

            try
            {
                IModel    model;
                IModel    model2;
                IPoint    pointValue = null;
                IPolyline polyline2  = null;
                polyline2 = base._geoGroup[1] as IPolyline;
                if ((polyline2 == null) || (polyline2.PointCount < 2))
                {
                    return(false);
                }
                path = polyline2.Clone() as IPolyline;
                for (int i = 0; i < path.PointCount; i++)
                {
                    pointValue = path.GetPoint(i);
                    if (pointValue != null)
                    {
                        pointValue.Z += this.OffsetZ;
                        path.UpdatePoint(i, pointValue);
                    }
                }

                pipeSection = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0);

                flow = ParamModelFactory.Instance.CreateGeometryDraw(ModelType.DynamicFlow, Guid.NewGuid().ToString()) as IDrawDynamicFlow;
                flow.SetParameter(pipeSection, path, flowDir);
                flow.SetTextureRender(new string[] { name });
                if (!flow.Draw(out mp, out model, out model2))
                {
                    return(false);
                }

                #region 需要runtime授权
                IFeatureDataSet  iFeatureDataSet = DF3DPipeCreateApp.App.TempLib.OpenFeatureDataset("FeatureDataSet");
                IResourceManager manager         = iFeatureDataSet as IResourceManager;
                if (!manager.ModelExist(mp.ModelName))
                {
                    manager.AddModel(mp.ModelName, model, null);
                }
                if (!manager.ImageExist(name))
                {
                    manager.AddImage(name, _imgFlowImg);
                }
                #endregion

                IModelPointSymbol symbol = new ModelPointSymbolClass();
                symbol.SetResourceDataSet(iFeatureDataSet);
                symbol.Color       = uint.MaxValue;
                symbol.EnableColor = true;
                mp.ModelEnvelope   = model.Envelope;
                rpt = DrawGeometry.Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, DrawGeometry.Ocx.ProjectTree.RootID);

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }