//
        // CONSTRUCTOR
        //
        public TabbedDocumentTopologyRule(Topology topology) {
            InitializeComponent();

            this.topologyRuleModel1.Topology = topology;
            this.topologyRuleModel1.OpenModel();
            this.TabText = string.Format("{0} {1}", topology.Name, "(Rules)");
            this.TabImage = this.topologyRuleModel1.Icon;
        }
        //
        // CONSTRUCTOR
        //
        public TabbedDocumentTopology(Topology topology) {
            InitializeComponent();

            this.topologyModel1.Topology = topology;
            this.topologyModel1.OpenModel();
            this.TabText = topology.Name;
            this.TabImage = this.topologyModel1.Icon;
        }
예제 #3
0
        //
        // PUBLIC METHODS
        //
        public override void OpenModel(string filename) {
            // Exit if FileName is invalid
            if (string.IsNullOrEmpty(filename)) { return; }

            // Exit if File does not exist
            if (!File.Exists(filename)) { return; }

            // Open XML Workspace
            XPathDocument document = null;
            try {
                document = new XPathDocument(filename, XmlSpace.None);
            }
            catch (XmlException ex) {
                MessageBox.Show(
                    "The XML file failed to load. Please select 'View > Exceptions' to view a detailed explanation.",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);

                // Add Exception
                ExceptionDialog.HandleException(ex);
            }
            if (document == null) { return; }

            // Get XPathNavigator (IXPathNavigable::CreateNavigator)
            XPathNavigator navigator = document.CreateNavigator();

            // Get <esri:Workspace>
            if (!navigator.MoveToFirstChild()) {
                MessageBox.Show(
                    "This file is not a valid ESRI xml workspace document",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return;
            }

            // Check Node Name
            if (navigator.Name != "esri:Workspace") {
                MessageBox.Show(
                    "This file is not a valid ESRI xml workspace document",
                    Resources.TEXT_APPLICATION,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                return;
            }

            // Create Xml Namespace Manager
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(navigator.NameTable);
            namespaceManager.AddNamespace(Xml._XSI, Xml.XMLSCHEMAINSTANCE);

            // Suspend Model
            this.Suspend();
            this.SuspendEvents = true;
            if (ModelSettings.Default.EnableUndoRedo) {
                this.UndoList.Suspend();
            }

            // Select Domains
            XPathNodeIterator iteratorDomain = navigator.Select("WorkspaceDefinition/Domains/Domain");

            // Add Domains
            while (iteratorDomain.MoveNext()) {
                XPathNavigator domain = iteratorDomain.Current;
                XPathNavigator type = domain.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                switch (type.Value) {
                    case Xml._RANGEDOMAIN:
                        DomainRange domainRange = new DomainRange(domain);
                        this.Shapes.Add(this.Shapes.CreateKey(), domainRange);
                        break;
                    case Xml._CODEDVALUEDOMAIN:
                        DomainCodedValue domainCodedValue = new DomainCodedValue(domain);
                        this.Shapes.Add(this.Shapes.CreateKey(), domainCodedValue);
                        break;
                }
            }

            // Select Root DataElements
            XPathNodeIterator iteratorDataElement = navigator.Select("WorkspaceDefinition/DatasetDefinitions/DataElement");
            while (iteratorDataElement.MoveNext()) {
                XPathNavigator dataElement = iteratorDataElement.Current;
                XPathNavigator type = dataElement.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                switch (type.Value) {
                    case Xml._DEFEATUREDATASET:
                        // Create FeatureDataset
                        FeatureDataset featureDataset = new FeatureDataset(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), featureDataset);

                        // Loop for Child DataElements
                        XPathNodeIterator iteratorDataElement2 = dataElement.Select("Children/DataElement");
                        while (iteratorDataElement2.MoveNext()) {
                            XPathNavigator dataElement2 = iteratorDataElement2.Current;
                            XPathNavigator type2 = dataElement2.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                            switch (type2.Value) {
                                case Xml._DEFEATURECLASS:
                                    // Create FeatureClass
                                    FeatureClass featureClass2 = new FeatureClass(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), featureClass2);

                                    // Create Link to FeatureDataset
                                    Link link1 = new Link(featureDataset, featureClass2);
                                    link1.BorderColor = ModelSettings.Default.EnabledLines;
                                    link1.BorderStyle = DashStyle.Solid;
                                    link1.BorderWidth = 1f;
                                    link1.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link1);

                                    // Add Subtypes
                                    this.AddSubtypes(featureClass2, dataElement2);

                                    break;
                                case Xml._DEGEOMETRICNETWORK:
                                    // Create GeometricNetwork
                                    GeometricNetwork geometricNetwork = new GeometricNetwork(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), geometricNetwork);

                                    // Create Link to FeatureDataset
                                    Link link2 = new Link(featureDataset, geometricNetwork);
                                    link2.BorderColor = ModelSettings.Default.EnabledLines;
                                    link2.BorderStyle = DashStyle.Solid;
                                    link2.BorderWidth = 1f;
                                    link2.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link2);

                                    break;
                                case Xml._DERELATIONSHIPCLASS:
                                    // Create Relationship
                                    RelationshipClass relationshipClass = new RelationshipClass(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), relationshipClass);

                                    // Create Link to FeatureDataset
                                    Link link3 = new Link(featureDataset, relationshipClass);
                                    link3.BorderColor = ModelSettings.Default.EnabledLines;
                                    link3.BorderStyle = DashStyle.Solid;
                                    link3.BorderWidth = 1f;
                                    link3.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link3);

                                    break;
                                case Xml._DETOPOLOGY:
                                    // Create Topology
                                    Topology topology = new Topology(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), topology);

                                    // Create Link to FeatureDataset
                                    Link link4 = new Link(featureDataset, topology);
                                    link4.BorderColor = ModelSettings.Default.EnabledLines;
                                    link4.BorderStyle = DashStyle.Solid;
                                    link4.BorderWidth = 1f;
                                    link4.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link4);

                                    break;
                                case Xml._DENETWORKDATASET:
                                    // Create Network Dataset
                                    Network network = new Network(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), network);

                                    // Create Link to FeatureDataset
                                    Link link5 = new Link(featureDataset, network);
                                    link5.BorderColor = ModelSettings.Default.EnabledLines;
                                    link5.BorderStyle = DashStyle.Solid;
                                    link5.BorderWidth = 1f;
                                    link5.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link5);

                                    break;
                                case Xml._DETERRAIN:
                                    // Create Network Dataset
                                    Terrain terrain = new Terrain(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), terrain);

                                    // Create Link to FeatureDataset
                                    Link link6 = new Link(featureDataset, terrain);
                                    link6.BorderColor = ModelSettings.Default.EnabledLines;
                                    link6.BorderStyle = DashStyle.Solid;
                                    link6.BorderWidth = 1f;
                                    link6.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link6);

                                    break;
                            }
                        }

                        break;
                    case Xml._DEFEATURECLASS:
                        // Create FeatureClass
                        FeatureClass featureClass = new FeatureClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), featureClass);

                        // Add Subtypes
                        this.AddSubtypes(featureClass, dataElement);

                        break;
                    case Xml._DETABLE:
                        // Create Table
                        ObjectClass objectClass = new ObjectClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), objectClass);

                        // Add Subtypes
                        this.AddSubtypes(objectClass, dataElement);

                        break;
                    case Xml._DERASTERCATALOG:
                        // Create Table
                        RasterCatalog rasterCatalog = new RasterCatalog(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), rasterCatalog);

                        break;
                    case Xml._DERELATIONSHIPCLASS:
                        // Create Relationship
                        RelationshipClass relationshipClass2 = new RelationshipClass(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), relationshipClass2);

                        break;
                    case Xml._DERASTERDATASET:
                        // Create RasterDataset
                        RasterDataset rasterDataset = new RasterDataset(dataElement);
                        this.Shapes.Add(this.Shapes.CreateKey(), rasterDataset);

                        // Loop for Child DataElements
                        XPathNodeIterator iteratorDataElement3 = dataElement.Select("Children/DataElement");
                        while (iteratorDataElement3.MoveNext()) {
                            XPathNavigator dataElement2 = iteratorDataElement3.Current;
                            XPathNavigator type2 = dataElement2.SelectSingleNode(Xml._XSITYPE, namespaceManager);
                            switch (type2.Value) {
                                case Xml._DERASTERBAND:
                                    // Create FeatureClass
                                    RasterBand rasterBand = new RasterBand(dataElement2);
                                    this.Shapes.Add(this.Shapes.CreateKey(), rasterBand);

                                    // Create Link to FeatureDataset
                                    Link link = new Link(rasterDataset, rasterBand);
                                    link.BorderColor = ModelSettings.Default.EnabledLines;
                                    link.BorderStyle = DashStyle.Solid;
                                    link.BorderWidth = 1f;
                                    link.End.Marker.BorderColor = ModelSettings.Default.EnabledLines;
                                    this.Lines.Add(this.Lines.CreateKey(), link);

                                    break;
                            }
                        }

                        break;
                }
            }

            // <esri:Workspace><WorkspaceDefinition><Metadata><XmlDoc>
            XPathNavigator navigatorMetadata = navigator.SelectSingleNode("WorkspaceDefinition/Metadata/XmlDoc");
            if (navigatorMetadata != null) {
                this._metadata = navigatorMetadata.Value;
            }

            // <WorkspaceType>
            XPathNavigator navigatorWorkspaceType = navigator.SelectSingleNode("WorkspaceDefinition/WorkspaceType");
            if (navigatorWorkspaceType != null) {
                this._workspaceType = (esriWorkspaceType)Enum.Parse(typeof(esriWorkspaceType), navigatorWorkspaceType.Value, true);
            }

            // <Version>
            XPathNavigator navigatorVersion = navigator.SelectSingleNode("WorkspaceDefinition/Version");
            if (navigatorVersion != null) {
                this._version = navigatorVersion.Value;
            }

            // Close XML Document
            document = null;

            // Perform Layout
            this.ExecuteLayout(typeof(HierarchicalLayout), true);

            // Resume and Refresh Model
            if (ModelSettings.Default.EnableUndoRedo) {
                this.UndoList.Resume();
            }
            this.SuspendEvents = false;
            this.Resume();
            this.Refresh();

            // Make Dirty
            this._dirty = true;
        }
예제 #4
0
 public Topology(Topology prototype) : base(prototype) {
     if (prototype.Extent != null) {
         this._extent = prototype.Extent.Clone() as Extent;
     }
     if (prototype.SpatialReference != null) {
         this._spatialReference = prototype.SpatialReference.Clone() as SpatialReference;
     }
     this._clusterTolerance = prototype.ClusterTolerance;
     this._zClusterTolerance = prototype.ZClusterTolerance;
     this._maxGeneratedErrorCount = prototype.MaxGeneratedErrorCount;
     this._topologyRules = new List<TopologyRule>();
     foreach (TopologyRule topologyRule in prototype.TopologyRules) {
         this._topologyRules.Add((TopologyRule)topologyRule.Clone());
     }
 }