Exemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (!(lstRelates.SelectedItem is TableRelationItem))
            {
                return;
            }

            ITableRelation relation = ((TableRelationItem)lstRelates.SelectedItem).TableRelation;

            AddTableRelationDialog dlg = new AddTableRelationDialog(_mapDocument, _layer);

            dlg.TableRelation = relation;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ITableRelation newRelation = dlg.TableRelation;
                if (newRelation != null && newRelation.LeftTable != null && newRelation.RightTable != null)
                {
                    _mapDocument.TableRelations.Remove(relation);
                    _mapDocument.TableRelations.Add(newRelation);

                    if (relation.LeftTable != null && relation.RightTable != null)
                    {
                        relation.LeftTable.FirePropertyChanged();
                        relation.RightTable.FirePropertyChanged();
                    }

                    newRelation.LeftTable.FirePropertyChanged();
                    newRelation.RightTable.FirePropertyChanged();

                    FillList();
                }
            }
        }
Exemplo n.º 2
0
        private void treeObjects_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node is RelationTreeNode)
            {
                IFeatureCursor   cursor = null;
                RelationTreeNode rtn    = (RelationTreeNode)e.Node;

                try
                {
                    rtn.Nodes.Clear();
                    FeatureTreeNode ftn = (FeatureTreeNode)rtn.Parent;

                    ITableRelation relation = rtn.TableRelation;
                    ILayer         target   = null;
                    if (relation.LeftTable == ftn.Layer && ftn.Feature[relation.LeftTableField] != null)
                    {
                        target = relation.RightTable as ILayer;
                        cursor = relation.GetRightRows(TargetFields(target), ftn.Feature[relation.LeftTableField]) as IFeatureCursor;
                    }
                    else if (relation.RightTable == ftn.Layer)
                    {
                        target = relation.LeftTable as ILayer;
                        cursor = relation.GetLeftRows(TargetFields(target), ftn.Feature[relation.RightTableField]) as IFeatureCursor;
                    }
                    if (cursor == null || target == null)
                    {
                        return;
                    }

                    string primaryDisplayField = String.Empty;
                    if (target is IFeatureLayer && ((IFeatureLayer)target).Fields.PrimaryDisplayField != null)
                    {
                        primaryDisplayField = ((IFeatureLayer)target).Fields.PrimaryDisplayField.name;
                    }

                    IFeature feature = null;
                    while ((feature = cursor.NextFeature) != null)
                    {
                        rtn.Nodes.Add(new FeatureTreeNode(_doc, feature,
                                                          _doc.FocusMap.Display.SpatialReference,
                                                          target,
                                                          (target is IFeatureLayer ? ((IFeatureLayer)target).Fields.PrimaryDisplayField.name : String.Empty),
                                                          1));
                    }
                }
                finally
                {
                    if (cursor != null)
                    {
                        cursor.Dispose();
                    }
                    if (rtn.Nodes.Count == 0)
                    {
                        rtn.Nodes.Add(new TreeNode());
                        rtn.Collapse();
                    }
                }
            }
        }
        public SelectionRelationTreeNode(ITableRelation tableRelation, IDatasetElement element)
        {
            this.TableRelation  = tableRelation;
            this.DatasetElement = element;

            IDatasetElement target = (tableRelation.LeftTable == element) ? tableRelation.RightTable : tableRelation.LeftTable;

            base.Text       = tableRelation.RelationName + " (" + target.Title + ")";
            base.ImageIndex = 0;
        }
Exemplo n.º 4
0
            public RelationTreeNode(IMapDocument mapDocument, ITableRelation tableRelation, IDatasetElement element)
            {
                _mapDocument        = mapDocument;
                this.TableRelation  = tableRelation;
                this.DatasetElement = element;

                IDatasetElement target = (tableRelation.LeftTable == element) ? tableRelation.RightTable : tableRelation.LeftTable;

                base.Text = tableRelation.RelationName + " (" + target.Title + ")";

                base.Click += new EventHandler(RelationTreeNode_Click);
            }
Exemplo n.º 5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddTableRelationDialog dlg = new AddTableRelationDialog(_mapDocument, _layer);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ITableRelation relation = dlg.TableRelation;
                if (relation != null && relation.LeftTable != null && relation.RightTable != null)
                {
                    _mapDocument.TableRelations.Add(relation);

                    relation.LeftTable.FirePropertyChanged();
                    relation.RightTable.FirePropertyChanged();

                    FillList();
                }
            }
        }
        public ITable GetChildTable(ITableRelation relation)
        {
            string tableName;

            if (_data.ActualProperties.ContainsKey(relation.ChildTableName))
            {
                return(new JsonSchemaTable(relation.ChildTableName, null, _provider, _data.ActualProperties[relation.ChildTableName]));
            }
            else if (_provider.AliasDictionary.TryGetValue(relation.ChildTableName, out tableName))
            {
                return(new JsonSchemaTable(relation.ChildTableName, null, _provider, _data.ActualProperties[tableName]));
            }
            else
            {
                _provider.Logger.Warn(LogCategory.DataProvider, "JSON: Property {0} not found in schema.", new object[] { relation.ChildTableName });
                return(null);
            }
        }
Exemplo n.º 7
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (!(lstRelates.SelectedItem is TableRelationItem))
            {
                return;
            }

            ITableRelation relation = ((TableRelationItem)lstRelates.SelectedItem).TableRelation;

            if (relation != null)
            {
                _mapDocument.TableRelations.Remove(relation);
                if (relation.LeftTable != null)
                {
                    relation.LeftTable.FirePropertyChanged();
                }
                if (relation.RightTable != null)
                {
                    relation.RightTable.FirePropertyChanged();
                }
            }
            FillList();
        }
Exemplo n.º 8
0
 public virtual ITableRow GetParentRow(ITableRelation relation)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
 public virtual ITable GetChildTable(ITableRelation relation)
 {
     throw new NotImplementedException();
 }