// Summary: // Object selection event listener (function). // It will set DataTable's IsSelected property according to // object's selection state. // Remarks: // (1) The IsSelected property is dynamically injected into // DataTable when object data is read from database. // See ReadRawData() function in the // IS3.Core.Serialization.DbDataLoader class for more information. // (2) The DataTable is used to display object data in // the datagrid (class IS3DataGrid). When IsSelected property // is set to true, it will be displayed as selected state // in the datagrid. // public void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { if (sender == this) { return; } if (e.addedObjs != null) { setObjSelectionState(e.addedObjs, true); } if (e.removedObjs != null) { setObjSelectionState(e.removedObjs, false); } }
//视图对象选择监听事件 void _inputView_objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { //设置segmenglining listbox数据源 _selectedSLsDict = _prj.getSelectedObjs(_structureDomain, "SegmentLining"); List<DGObject> _sls = new List<DGObject>(); foreach (var item in _selectedSLsDict.Values) { foreach (var obj in item) { _sls.Add(obj); } } if (_sls != null && _sls.Count() > 0) SLLB.ItemsSource = _sls; }
// Summary: // Object selection event listener. public void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { // get current selected objects Dictionary<string, IEnumerable<DGObject>> selectedObjsDict = Globals.project.getSelectedObjs(); // process added objs if (e.addedObjs != null) { foreach (string key in e.addedObjs.Keys) { if (selectedObjsDict.ContainsKey(key)) { IEnumerable<DGObject> objs = selectedObjsDict[key]; List<DGObject> objlist = objs.ToList(); IEnumerable<DGObject> objsToBeAdded = e.addedObjs[key]; foreach (var obj in objsToBeAdded) { if (objlist.Contains(obj)) continue; else objlist.Add(obj); } selectedObjsDict[key] = objlist.AsEnumerable(); } else selectedObjsDict.Add(key, e.addedObjs[key]); } } // process removed objects if (e.removedObjs != null) { foreach (string key in e.removedObjs.Keys) { if (selectedObjsDict.ContainsKey(key)) { IEnumerable<DGObject> objs = selectedObjsDict[key]; List<DGObject> objlist = objs.ToList(); IEnumerable<DGObject> objsToBeRemoved = e.removedObjs[key]; foreach (var obj in objsToBeRemoved) objlist.Remove(obj); selectedObjsDict[key] = objlist.AsEnumerable(); } } } _saved = selectedObjsDict; // refreshTextView(selectedObjsDict); refreshTableView(selectedObjsDict); refreshChartView(selectedObjsDict); }
void _inputView_objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { // fill borehole combobox if (_prj == null) return; _selectedBhsDict = _prj.getSelectedObjs(_geologyDomain, "Borehole"); List<DGObject> _bhs = new List<DGObject>(); foreach (var item in _selectedBhsDict.Values) { foreach (var obj in item) { _bhs.Add(obj); } } if (_bhs != null && _bhs.Count() > 0) { BoreholeCB.ItemsSource = _bhs; BoreholeCB.SelectedIndex = 0; } // fill tunnel listbox if(RB1.IsChecked.Value) { _selectedTunnelsDict = _prj.getSelectedObjs(_structureDomain, "Tunnel"); List<Tuple<DGObject, string>> _tunnels = new List<Tuple<DGObject, string>>(); foreach (var item in _selectedTunnelsDict.Values) { foreach (var obj in item) { _tunnels.Add(new Tuple<DGObject, string>(obj,obj.name)); } } if (_tunnels != null && _tunnels.Count() > 0) { LineLB.ItemsSource = _tunnels; LineLB.SelectedIndex = LineLB.Items.Count - 1; } } }
void _inputView_objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { _selectedTunnelsDict = _prj.getSelectedObjs(_structureDomain, "Tunnel"); List<DGObject> _tunnels = new List<DGObject>(); foreach (var item in _selectedTunnelsDict.Values) { foreach (var obj in item) { _tunnels.Add(obj); } } if (_tunnels != null && _tunnels.Count() > 0) LineLB.ItemsSource = _tunnels; }
public async void selectByRect() { if (Globals.isThreadUnsafe()) { Globals.application.Dispatcher.Invoke(new Action(()=> { selectByRect(); })); return; } Geometry geom = await _mapView.Editor.RequestShapeAsync(DrawShape.Rectangle); if (_srEMap != null) geom = GeometryEngine.Project(geom, _srEMap); IGeometry rect = IS3GeometryEngine.fromGeometry(geom); ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs(); args.addedObjs = new Dictionary<string, IEnumerable<DGObject>>(); foreach (Layer layer in _map.Layers) { IGraphicsLayer gLayer = layer as IGraphicsLayer; if (!isLayerSelectable(gLayer)) continue; List<DGObject> objs = gLayer.selectObjectsByRect(rect); if (objs.Count > 0) args.addedObjs.Add(gLayer.ID, objs); } if (objSelectionChangedTrigger != null) objSelectionChangedTrigger(this, args); }
// Summary: // Object selection event listener (function). // It will highlight selected objects and unhighlight // deselected objects. public void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { if (sender == this) return; if (e.addedObjs != null) { foreach (string layerID in e.addedObjs.Keys) highlightObjects(e.addedObjs[layerID], layerID, true); } if (e.removedObjs != null) { foreach (string layerID in e.removedObjs.Keys) highlightObjects(e.removedObjs[layerID], layerID, false); } }
public async Task<bool> selectByPoint(Point screenPoint) { bool success = false; DGObject obj = null; IS3GraphicsLayer gLayer = null; foreach (Layer layer in _map.Layers) { gLayer = layer as IS3GraphicsLayer; if (!isLayerSelectable(gLayer)) continue; obj = await gLayer.selectObjectByPoint(screenPoint, mapView); if (obj != null) { break; } } if (obj != null && objSelectionChangedTrigger != null) { ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs(); args.addedObjs = new Dictionary<string, IEnumerable<DGObject>>(); List<DGObject> objs = new List<DGObject>(); objs.Add(obj); args.addedObjs.Add(gLayer.ID, objs); objSelectionChangedTrigger(this, args); success = true; } return success; }
public void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { }
protected override void OnKeyUp(KeyEventArgs e) { if (e.Key == Key.Escape) { if (_prj != null) { // trigger object selection changed event Dictionary<string, IEnumerable<DGObject>> selectedObjs = _prj.getSelectedObjs(); if (objSelectionChangedTrigger != null) { ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs(); args.removedObjs = selectedObjs; _isEscTriggered = true; objSelectionChangedTrigger(this, args); _isEscTriggered = false; } } // clear selections in all views in case graphics all not cleared. foreach (IView view in views) { if (view.layers != null) { foreach (var layer in view.layers) layer.highlightAll(false); } } } else if (e.Key == Key.Delete) { //RemoveDrawingObjects(); } else if (e.Key == Key.N && System.Windows.Input.Keyboard.Modifiers == ModifierKeys.Control) { // Ctrl+N } base.OnKeyUp(e); }
// Summary: // Object selection event listener (function). // It will broadcast the event to views and datagrid. public void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e) { if (objSelectionChangedTrigger != null) objSelectionChangedTrigger(sender, e); }
void DGObjectDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Handles selection changed event triggered by user input only. // Selection changed event will also be triggered in // situations like DGObjectDataGrid.ItemsSource = IEnumerable<>, // but we don't want to handle the event in such conditions. // This can be differentiated by the IsKeyboardFocusWithin property. if (MyDataGrid.IsKeyboardFocusWithin == false || _isEscTriggered) return; // Trigger a ObjSelectionChangedEvent event // DataView dataView = MyDataGrid.DGObjectDataGrid.ItemsSource as DataView; if (dataView == null) return; DataTable dataTable = dataView.Table; DataSet dataSet = dataTable.DataSet; if (dataSet == null) return; if (!_prj.dataSetIndex.ContainsKey(dataSet)) return; DGObjects objs = _prj.dataSetIndex[dataSet]; string layerName = objs.definition.GISLayerName; IList addedItems = e.AddedItems; IList removedItems = e.RemovedItems; List<DGObject> addedObjs = new List<DGObject>(); List<DGObject> removedObjs = new List<DGObject>(); foreach (DataRowView drv in addedItems) { DataRow dr = drv.Row; if (objs.rowView2Obj.ContainsKey(dr)) { DGObject obj = objs.rowView2Obj[dr]; addedObjs.Add(obj); } } foreach (DataRowView drv in removedItems) { DataRow dr = drv.Row; if (objs.rowView2Obj.ContainsKey(dr)) { DGObject obj = objs.rowView2Obj[dr]; removedObjs.Add(obj); } } if (objSelectionChangedTrigger != null) { Dictionary<string, IEnumerable<DGObject>> addedObjsDict = null; Dictionary<string, IEnumerable<DGObject>> removedObjsDict = null; if (addedObjs.Count > 0) { addedObjsDict = new Dictionary<string, IEnumerable<DGObject>>(); addedObjsDict[layerName] = addedObjs; } if (removedObjs.Count > 0) { removedObjsDict = new Dictionary<string, IEnumerable<DGObject>>(); removedObjsDict[layerName] = removedObjs; } ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs(); args.addedObjs = addedObjsDict; args.removedObjs = removedObjsDict; objSelectionChangedListener(sender, args); } }