示例#1
0
        private void ChangeSelection()
        {
            if (!(_dsElement is IFeatureSelection) && _class != null)
            {
                return;
            }
            ((IFeatureSelection)_dsElement).ClearSelection();
            IIDSelectionSet selSet = ((FeatureSelection)_dsElement).SelectionSet as IIDSelectionSet;

            if (selSet == null)
            {
                return;
            }

            foreach (DataGridViewRow row in gridView.SelectedRows)
            {
                try
                {
                    selSet.AddID((int)row.Cells[_class.IDFieldName].Value);
                    row.DefaultCellStyle.BackColor = _selectionColor;
                }
                catch
                {
                }
            }

            SetNavigatorCountItemText();

            if (_doc != null && _doc.Application is IMapApplication)
            {
                ((IMapApplication)_doc.Application).RefreshActiveMap(gView.Framework.Carto.DrawPhase.Selection);
            }
            ((IFeatureSelection)_dsElement).FireSelectionChangedEvent();
        }
示例#2
0
            private void RelationTreeNode_Click(object sender, EventArgs e)
            {
                IFeatureSelection target = (this.TableRelation.LeftTable == this.DatasetElement ? this.TableRelation.RightTable : this.TableRelation.LeftTable) as IFeatureSelection;

                if (target == null)
                {
                    return;
                }

                target.ClearSelection();

                if (this.DatasetElement is IFeatureSelection &&
                    ((IFeatureSelection)this.DatasetElement).SelectionSet is IIDSelectionSet)
                {
                    IIDSelectionSet selSet = (IIDSelectionSet)((IFeatureSelection)this.DatasetElement).SelectionSet;
                    if (selSet != null && selSet.IDs != null && selSet.IDs.Count > 0)
                    {
                        string      relationField = this.TableRelation.LeftTable == this.DatasetElement ? this.TableRelation.LeftTableField : this.TableRelation.RightTableField;
                        RowIDFilter filter        = new RowIDFilter(((ITableClass)this.DatasetElement.Class).IDFieldName);
                        filter.IDs       = selSet.IDs;
                        filter.SubFields = relationField;
                        ICursor cursor = ((ITableClass)this.DatasetElement.Class).Search(filter);

                        IRow row = null;
                        while ((row = Next(cursor)) != null)
                        {
                            object val = row[relationField];
                            if (val == null)
                            {
                                continue;
                            }

                            IQueryFilter selFilter = this.TableRelation.LeftTable == this.DatasetElement ? this.TableRelation.GetRightFilter("*", val) : this.TableRelation.GetLeftFilter("*", val);
                            target.Select(selFilter, CombinationMethod.Union);
                        }
                    }
                }

                target.FireSelectionChangedEvent();

                if (_mapDocument != null && _mapDocument.Application is IMapApplication)
                {
                    ((IMapApplication)_mapDocument.Application).RefreshActiveMap(DrawPhase.Selection);
                }
            }
示例#3
0
        internal void StartWorkerThread()
        {
            if (_tabWorker == null || this.Visible == false)
            {
                return;
            }

            gridView.DataSource = null;

            CancelWorkerThread(false);
            ((CancelTracker)_cancelTracker).Reset();

            gridNavigator.BindingSource = null;
            gridSource.DataSource       = null;

            _tabWorker.CleanUp();

            EnableCancelThreadButton(true);
            EnableExecuteButton(true, 1);

            _workerThread          = new Thread(new ParameterizedThreadStart(_tabWorker.Start));
            _workerThread.Priority = ThreadPriority.Lowest;

            if (_viewMode == ViewMode.selected)
            {
                if (_dsElement is IFeatureSelection &&
                    ((IFeatureSelection)_dsElement).SelectionSet is IIDSelectionSet)
                {
                    IIDSelectionSet selSet = (IIDSelectionSet)((IFeatureSelection)_dsElement).SelectionSet;
                    if (selSet != null && selSet.IDs != null)
                    {
                        _workerThread.Start(selSet.IDs);
                    }
                }
            }
            else
            {
                RefreshFilterFields();
                _workerThread.Start(_filter);
            }
        }
示例#4
0
        private void MarkSelectedRows(Color col)
        {
            if (gridView.DataSource == null)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            if (_dsElement is IFeatureSelection && gridSource.DataSource is DataTable)
            {
                IIDSelectionSet selSet = ((IFeatureSelection)_dsElement).SelectionSet as IIDSelectionSet;
                if (selSet != null && selSet.IDs != null)
                {
                    //foreach (int id in selSet.IDs)
                    //{
                    //    try
                    //    {
                    //        //int index = gridSource.Find(_class.IDFieldName, id);
                    //        //DataRow row = ((DataTable)gridSource.DataSource).Select(_class.IDFieldName + "=" + id)[0];
                    //        int index = -1;
                    //        for (int i = 0; i < gridSource.Count; i++)
                    //        {
                    //            if ((int)((DataRowView)gridSource[i])[0] == id)
                    //            {
                    //                index = i;
                    //                break;
                    //            }
                    //        }
                    //        if (index != -1) gridView.Rows[index].DefaultCellStyle.BackColor = col;

                    //        //toolStripStatusLabel1.Text = id.ToString();
                    //    }
                    //    catch
                    //    {
                    //        return;
                    //    }
                    //}


                    List <int> ids = ListOperations <int> .Clone(selSet.IDs);

                    ids.Sort();

                    if (ids.Count != 0)
                    {
                        for (int i = 0; i < gridSource.Count; i++)
                        {
                            if (ids.BinarySearch((int)((DataRowView)gridSource[i])[_class.IDFieldName]) >= 0)
                            {
                                gridView.Rows[i].DefaultCellStyle.BackColor = col;
                                ids.Remove((int)((DataRowView)gridSource[i])[_class.IDFieldName]);
                            }
                        }
                    }
                    else
                    {
                        gridView.ClearSelection();
                    }
                }
            }
            this.Cursor = Cursors.Default;
        }
示例#5
0
 public SelectionCursor(IFeatureClass fc, IIDSelectionSet selSet, string appendToClause)
     : this(fc, selSet)
 {
     _appendToClause = appendToClause;
 }
示例#6
0
 public SelectionCursor(IFeatureClass fc, IIDSelectionSet selSet)
 {
     _pos    = 0;
     _fc     = fc;
     _selSet = selSet;
 }