private void comboBoxEdit_SelectedIndexChanged(object sender, EventArgs e)
 {
     BulidGeometryNetworkHelper.Weight selectedItem =
         this.comboBoxEdit.SelectedItem as BulidGeometryNetworkHelper.Weight;
     this.listView1.Items.Clear();
     if (selectedItem != null)
     {
         int num = 0;
         for (int i = 0; i < BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps.Count; i++)
         {
             BulidGeometryNetworkHelper.FeatureClassWrap wrap =
                 BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps[i] as
                 BulidGeometryNetworkHelper.FeatureClassWrap;
             if (wrap.IsUse)
             {
                 num++;
             }
         }
         int      num3  = this.comboBoxEdit.SelectedIndex * num;
         string[] items = new string[2];
         for (int j = num3; j < (num3 + num); j++)
         {
             BulidGeometryNetworkHelper.WeightAssociation association =
                 this.ilist_0[j] as BulidGeometryNetworkHelper.WeightAssociation;
             items[0] = association.featureClassName;
             items[1] = association.fieldName;
             ListViewItem item = new ListViewItem(items)
             {
                 Tag = association
             };
             this.listView1.Items.Add(item);
         }
     }
 }
 public void Init()
 {
     for (int i = 0; i < BulidGeometryNetworkHelper.BulidGNHelper.Weights.Count; i++)
     {
         BulidGeometryNetworkHelper.Weight item =
             BulidGeometryNetworkHelper.BulidGNHelper.Weights[i] as BulidGeometryNetworkHelper.Weight;
         this.comboBoxEdit.Properties.Items.Add(item);
         for (int j = 0; j < BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps.Count; j++)
         {
             BulidGeometryNetworkHelper.FeatureClassWrap wrap =
                 BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps[j] as
                 BulidGeometryNetworkHelper.FeatureClassWrap;
             if (wrap.IsUse)
             {
                 BulidGeometryNetworkHelper.WeightAssociation association = new BulidGeometryNetworkHelper.
                                                                            WeightAssociation
                 {
                     networkWeightName = item.networkWeightName,
                     featureClassName  = (wrap.FeatureClass as IDataset).Name,
                     fieldName         = "<无>"
                 };
                 this.ilist_0.Add(association);
             }
         }
     }
     if (this.comboBoxEdit.Properties.Items.Count > 0)
     {
         this.comboBoxEdit.SelectedIndex = 0;
     }
     BulidGeometryNetworkHelper.BulidGNHelper.WeightAssociations.Clear();
 }
Exemple #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         BulidGeometryNetworkHelper.Weight tag =
             this.listView1.SelectedItems[0].Tag as BulidGeometryNetworkHelper.Weight;
         if (tag != null)
         {
             BulidGeometryNetworkHelper.BulidGNHelper.Weights.Remove(tag);
         }
         this.listView1.Items.RemoveAt(this.listView1.SelectedIndices[0]);
     }
 }
Exemple #4
0
        private void comboBox_0_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!this.bool_1)
            {
                int selectedIndex = this.comboBox_0.SelectedIndex;
                if (selectedIndex >= 0)
                {
                    string text = this.comboBox_0.Text;
                    int    num1 = this.comboBox_0.SelectedIndex;
                    this.listViewItem_0.SubItems[1].Text = text;
                    BulidGeometryNetworkHelper.Weight tag = this.listViewItem_0.Tag as BulidGeometryNetworkHelper.Weight;
                    switch (this.comboBox_0.SelectedIndex)
                    {
                    case 0:
                        tag.weightType = esriWeightType.esriWTInteger;
                        break;

                    case 1:
                        tag.weightType = esriWeightType.esriWTSingle;
                        break;

                    case 2:
                        tag.weightType = esriWeightType.esriWTDouble;
                        break;

                    case 3:
                        tag.weightType = esriWeightType.esriWTBitGate;
                        break;
                    }
                    if (selectedIndex == 3)
                    {
                        this.listViewItem_0.SubItems.Add("1");
                        if (tag != null)
                        {
                            tag.bitGateSize = 1;
                        }
                    }
                    else if (this.listViewItem_0.SubItems.Count == 3)
                    {
                        this.listViewItem_0.SubItems.RemoveAt(2);
                    }
                }
                this.comboBox_0.Hide();
            }
        }
Exemple #5
0
 private void comboBox_1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!this.bool_1)
     {
         int selectedIndex = this.comboBox_1.SelectedIndex;
         if (selectedIndex >= 0)
         {
             string text = this.comboBox_1.Text;
             this.listViewItem_0.SubItems[2].Text = text;
             BulidGeometryNetworkHelper.Weight tag = this.listViewItem_0.Tag as BulidGeometryNetworkHelper.Weight;
             if (tag != null)
             {
                 tag.bitGateSize = selectedIndex + 1;
             }
         }
         this.comboBox_1.Hide();
     }
 }
Exemple #6
0
 private void textBox_0_LostFocus(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         this.bool_0 = false;
         this.textBox_0.Hide();
     }
     else
     {
         if (this.listViewItem_0 != null)
         {
             BulidGeometryNetworkHelper.Weight tag;
             bool flag;
             int  num;
             BulidGeometryNetworkHelper.Weight weight2;
             if (this.listViewItem_0.Tag != null)
             {
                 tag  = this.listViewItem_0.Tag as BulidGeometryNetworkHelper.Weight;
                 flag = true;
                 for (num = 0; num < BulidGeometryNetworkHelper.BulidGNHelper.Weights.Count; num++)
                 {
                     weight2 =
                         BulidGeometryNetworkHelper.BulidGNHelper.Weights[num] as
                         BulidGeometryNetworkHelper.Weight;
                     if ((tag != weight2) && (weight2.networkWeightName == tag.networkWeightName))
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (flag)
                 {
                     tag.networkWeightName = this.textBox_0.Text;
                     if (this.listViewItem_0.SubItems[0].Text != this.textBox_0.Text)
                     {
                         this.listViewItem_0.SubItems[0].Text = this.textBox_0.Text;
                         if (this.listViewItem_0.SubItems.Count == 1)
                         {
                             this.listViewItem_0.SubItems.Add("");
                         }
                     }
                 }
             }
             else
             {
                 tag = new BulidGeometryNetworkHelper.Weight
                 {
                     networkWeightName = this.textBox_0.Text,
                     weightType        = esriWeightType.esriWTNull
                 };
                 flag = true;
                 for (num = 0; num < BulidGeometryNetworkHelper.BulidGNHelper.Weights.Count; num++)
                 {
                     weight2 =
                         BulidGeometryNetworkHelper.BulidGNHelper.Weights[num] as
                         BulidGeometryNetworkHelper.Weight;
                     if (weight2.networkWeightName == tag.networkWeightName)
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (flag)
                 {
                     this.listViewItem_0.Tag = tag;
                     BulidGeometryNetworkHelper.BulidGNHelper.Weights.Add(tag);
                     if (this.listViewItem_0.SubItems[0].Text != this.textBox_0.Text)
                     {
                         this.listViewItem_0.SubItems[0].Text = this.textBox_0.Text;
                         if (this.listViewItem_0.SubItems.Count == 1)
                         {
                             this.listViewItem_0.SubItems.Add("");
                         }
                     }
                 }
             }
         }
         this.bool_0 = true;
         this.textBox_0.Hide();
     }
 }
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.comboBox_0.Items.Clear();
            this.comboBox_0.Items.Add("<无>");
            if (this.listView1.SelectedItems.Count > 0)
            {
                IFeatureClass class2 = this.method_0(this.listView1.SelectedItems[0].Text);
                if (class2 != null)
                {
                    BulidGeometryNetworkHelper.Weight selectedItem =
                        this.comboBoxEdit.SelectedItem as BulidGeometryNetworkHelper.Weight;
                    if (selectedItem != null)
                    {
                        esriFieldType esriFieldTypeOID = esriFieldType.esriFieldTypeOID;
                        switch (selectedItem.weightType)
                        {
                        case esriWeightType.esriWTBitGate:
                        case esriWeightType.esriWTInteger:
                            esriFieldTypeOID = esriFieldType.esriFieldTypeInteger;
                            break;

                        case esriWeightType.esriWTSingle:
                            esriFieldTypeOID = esriFieldType.esriFieldTypeSingle;
                            break;

                        case esriWeightType.esriWTDouble:
                            esriFieldTypeOID = esriFieldType.esriFieldTypeDouble;
                            break;
                        }
                        IFields fields = class2.Fields;
                        for (int i = 0; i < fields.FieldCount; i++)
                        {
                            IField field = fields.get_Field(i);
                            if (((((field.Type != esriFieldType.esriFieldTypeOID) &&
                                   (field.Type != esriFieldType.esriFieldTypeGeometry)) &&
                                  ((field.Type != esriFieldType.esriFieldTypeGUID) &&
                                   (field.Type != esriFieldType.esriFieldTypeGlobalID))) &&
                                 (field.Type != esriFieldType.esriFieldTypeRaster)) &&
                                (field.Type != esriFieldType.esriFieldTypeString))
                            {
                                if ((esriFieldTypeOID == esriFieldType.esriFieldTypeSingle) &&
                                    (esriFieldTypeOID == field.Type))
                                {
                                    this.comboBox_0.Items.Add(field.AliasName);
                                }
                                else if (esriFieldTypeOID == esriFieldType.esriFieldTypeDouble)
                                {
                                    if ((field.Type == esriFieldType.esriFieldTypeDouble) ||
                                        (field.Type == esriFieldType.esriFieldTypeSingle))
                                    {
                                        this.comboBox_0.Items.Add(field.AliasName);
                                    }
                                }
                                else if ((esriFieldTypeOID == esriFieldType.esriFieldTypeInteger) &&
                                         ((field.Type == esriFieldType.esriFieldTypeSmallInteger) ||
                                          (field.Type == esriFieldType.esriFieldTypeInteger)))
                                {
                                    this.comboBox_0.Items.Add(field.AliasName);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #8
0
        public IGeometricNetwork CreateGeometricNetwork(IFeatureDataset ifeatureDataset_1)
        {
            int i;
            IGeometricNetwork geometricNetworkByName;

            try
            {
                INetworkCollection  ifeatureDataset1      = ifeatureDataset_1 as INetworkCollection;
                INetworkLoader      networkLoader         = this.NetworkLoader;
                INetworkLoader2     preserveEnabledValues = networkLoader as INetworkLoader2;
                INetworkLoaderProps networkLoaderProp     = networkLoader as INetworkLoaderProps;
                networkLoader.FeatureDatasetName = ifeatureDataset_1.FullName as IFeatureDatasetName as IDatasetName;
                networkLoader.NetworkName        = this.Name;
                UID uIDClass                = new UIDClass();
                UID gUIDSIMPLEEDGECLSID     = new UIDClass();
                UID gUIDSIMPLEJUNCTIONCLSID = new UIDClass();
                uIDClass.Value                = this.GUID_COMPLEXEDGE_CLSID;
                gUIDSIMPLEEDGECLSID.Value     = this.GUID_SIMPLEEDGE_CLSID;
                gUIDSIMPLEJUNCTIONCLSID.Value = this.GUID_SIMPLEJUNCTION_CLSID;
                if (!this.IsSnap)
                {
                    networkLoader.SnapTolerance = preserveEnabledValues.MinSnapTolerance;
                }
                else
                {
                    networkLoader.SnapTolerance = this.SnapTolerance;
                }
                for (i = 0; i < this.Weights.Count; i++)
                {
                    BulidGeometryNetworkHelper.Weight item = this.Weights[i] as BulidGeometryNetworkHelper.Weight;
                    networkLoader.AddWeight(item.networkWeightName, item.weightType, item.bitGateSize);
                }
                bool flag  = true;
                bool flag1 = false;
                for (i = 0; i < this.FeatureClassWraps.Count; i++)
                {
                    BulidGeometryNetworkHelper.FeatureClassWrap featureClassWrap =
                        this.FeatureClassWraps[i] as BulidGeometryNetworkHelper.FeatureClassWrap;
                    if (featureClassWrap.IsUse)
                    {
                        flag = true;
                        IDataset featureClass = featureClassWrap.FeatureClass as IDataset;
                        esriNetworkLoaderFeatureClassCheck _esriNetworkLoaderFeatureClassCheck =
                            preserveEnabledValues.CanUseFeatureClass(featureClass.Name);
                        esriNetworkLoaderFeatureClassCheck _esriNetworkLoaderFeatureClassCheck1 =
                            _esriNetworkLoaderFeatureClassCheck;
                        if (_esriNetworkLoaderFeatureClassCheck1 ==
                            esriNetworkLoaderFeatureClassCheck.esriNLFCCUnknownError)
                        {
                            MessageBox.Show(string.Concat(featureClass.Name, " 未知错误"));
                            flag = false;
                        }
                        else
                        {
                            switch (_esriNetworkLoaderFeatureClassCheck1)
                            {
                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInTerrain:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已用在三角网中"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCIsCompressedReadOnly:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "是压缩只读要素类"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInTopology:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已用在拓扑中"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCRegisteredAsVersioned:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已注册版本"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInvalidShapeType:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "不是点或线几何要素"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInvalidFeatureType:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "是无效要素类型"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInAnotherNetwork:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已在其它网络中使用"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCCannotOpen:
                            {
                                MessageBox.Show(string.Concat("无法打开", featureClass.Name));
                                flag = false;
                                break;
                            }
                            }
                        }
                        if (flag &&
                            _esriNetworkLoaderFeatureClassCheck == esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
                        {
                            preserveEnabledValues.PreserveEnabledValues = this.PreserveEnabledValues;
                            esriNetworkLoaderFieldCheck _esriNetworkLoaderFieldCheck =
                                preserveEnabledValues.CheckEnabledDisabledField(featureClass.Name,
                                                                                networkLoaderProp.DefaultEnabledField);
                            if (_esriNetworkLoaderFieldCheck == esriNetworkLoaderFieldCheck.esriNLFCUnknownError)
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, ": (ENABLED 字段)- 产生未知错误."));
                                flag = false;
                            }
                            else
                            {
                                switch (_esriNetworkLoaderFieldCheck)
                                {
                                case esriNetworkLoaderFieldCheck.esriNLFCInvalidDomain:
                                {
                                    MessageBox.Show(string.Concat(featureClass.Name, ": ENABLED字段有无效域值."));
                                    flag = false;
                                    break;
                                }

                                case esriNetworkLoaderFieldCheck.esriNLFCInvalidType:
                                {
                                    MessageBox.Show(string.Concat(featureClass.Name, ": ENABLED字段有无效类型"));
                                    flag = false;
                                    break;
                                }

                                case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
                                {
                                    try
                                    {
                                        networkLoader.PutEnabledDisabledFieldName(featureClass.Name,
                                                                                  networkLoaderProp.DefaultEnabledField);
                                        break;
                                    }
                                    catch (Exception exception)
                                    {
                                        Logger.Current.Error("", exception, "");
                                        break;
                                    }
                                    break;
                                }
                                }
                            }
                            if (flag)
                            {
                                esriNetworkClassAncillaryRole _esriNetworkClassAncillaryRole =
                                    esriNetworkClassAncillaryRole.esriNCARNone;
                                if (featureClassWrap.GeometryType == esriGeometryType.esriGeometryPoint &&
                                    featureClassWrap.IsUse)
                                {
                                    _esriNetworkClassAncillaryRole = esriNetworkClassAncillaryRole.esriNCARSourceSink;
                                }
                                esriFeatureType featureType = featureClassWrap.FeatureType;
                                if (featureType == esriFeatureType.esriFTSimpleJunction)
                                {
                                    switch (_esriNetworkClassAncillaryRole)
                                    {
                                    case esriNetworkClassAncillaryRole.esriNCARNone:
                                    {
                                        break;
                                    }

                                    case esriNetworkClassAncillaryRole.esriNCARSourceSink:
                                    {
                                        _esriNetworkLoaderFieldCheck =
                                            preserveEnabledValues.CheckAncillaryRoleField(featureClass.Name,
                                                                                          networkLoaderProp.DefaultAncillaryRoleField);
                                        if (_esriNetworkLoaderFieldCheck ==
                                            esriNetworkLoaderFieldCheck.esriNLFCUnknownError)
                                        {
                                            MessageBox.Show(string.Concat(featureClass.Name,
                                                                          ": (ROLE Field)- An unknown error was encountered."));
                                            geometricNetworkByName = null;
                                            return(geometricNetworkByName);
                                        }
                                        else
                                        {
                                            switch (_esriNetworkLoaderFieldCheck)
                                            {
                                            case esriNetworkLoaderFieldCheck.esriNLFCInvalidDomain:
                                            {
                                                MessageBox.Show(string.Concat(featureClass.Name,
                                                                              ": ROLE字段有无效域值."));
                                                geometricNetworkByName = null;
                                                return(geometricNetworkByName);
                                            }

                                            case esriNetworkLoaderFieldCheck.esriNLFCInvalidType:
                                            {
                                                MessageBox.Show(string.Concat(featureClass.Name,
                                                                              ": ROLE字段有无效类型."));
                                                geometricNetworkByName = null;
                                                return(geometricNetworkByName);
                                            }

                                            case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
                                            {
                                                try
                                                {
                                                    networkLoader.PutAncillaryRole(featureClass.Name,
                                                                                   esriNetworkClassAncillaryRole.esriNCARSourceSink,
                                                                                   networkLoaderProp.DefaultAncillaryRoleField);
                                                    break;
                                                }
                                                catch
                                                {
                                                    break;
                                                }
                                                break;
                                            }

                                            default:
                                            {
                                                break;
                                            }
                                            }
                                        }
                                        break;
                                    }

                                    default:
                                    {
                                        goto case esriNetworkClassAncillaryRole.esriNCARNone;
                                    }
                                    }
                                }
                                try
                                {
                                    switch (featureType)
                                    {
                                    case esriFeatureType.esriFTSimpleJunction:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTSimpleJunction, gUIDSIMPLEJUNCTIONCLSID,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    case esriFeatureType.esriFTSimpleEdge:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTSimpleEdge, gUIDSIMPLEEDGECLSID,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    case esriFeatureType.esriFTComplexJunction:
                                    {
                                        flag1 = true;
                                        break;
                                    }

                                    case esriFeatureType.esriFTComplexEdge:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTComplexEdge, uIDClass,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    default:
                                    {
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }
                                    }
                                }
                                catch (COMException cOMException1)
                                {
                                    COMException cOMException = cOMException1;
                                    if (cOMException.ErrorCode != -2147220462)
                                    {
                                        MessageBox.Show(cOMException.Message);
                                    }
                                    else
                                    {
                                        MessageBox.Show(string.Concat("要素类[", featureClass.Name, "]无法添加到几何网络中!"));
                                    }
                                }
                                catch (Exception exception1)
                                {
                                    MessageBox.Show(exception1.Message);
                                }
                            }
                        }
                    }
                }
                if (flag1)
                {
                    for (i = 0; i < this.WeightAssociations.Count; i++)
                    {
                        BulidGeometryNetworkHelper.WeightAssociation weightAssociation =
                            this.WeightAssociations[i] as BulidGeometryNetworkHelper.WeightAssociation;
                        preserveEnabledValues.AddWeightAssociation(weightAssociation.networkWeightName,
                                                                   weightAssociation.featureClassName, weightAssociation.fieldName);
                    }
                    preserveEnabledValues.ConfigurationKeyword  = this.ConfigurationKeyword;
                    preserveEnabledValues.PreserveEnabledValues = this.PreserveEnabledValues;
                    networkLoader.LoadNetwork();
                    geometricNetworkByName = ifeatureDataset1.GeometricNetworkByName[this.Name];
                }
                else
                {
                    geometricNetworkByName = null;
                }
            }
            catch (Exception exception2)
            {
                MessageBox.Show(exception2.Message);
                geometricNetworkByName = null;
                return(geometricNetworkByName);
            }
            return(geometricNetworkByName);
        }