Beispiel #1
0
        // 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)
            {
                //old
                //foreach (string layerID in e.addedObjs.Keys)
                //    highlightObjects(e.addedObjs[layerID], layerID, true);
                foreach (string objDef in e.addedObjs.Keys)
                {
                    highlightObjects(e.addedObjs[objDef], e.addedObjs[objDef].FirstOrDefault().parent.definition.GISLayerName, true);
                }
            }
            if (e.removedObjs != null)
            {
                //old
                //foreach (string layerID in e.removedObjs.Keys)
                //    highlightObjects(e.removedObjs[layerID], layerID, false);

                foreach (string objDef in e.removedObjs.Keys)
                {
                    highlightObjects(e.removedObjs[objDef], e.removedObjs[objDef].FirstOrDefault().parent.definition.GISLayerName, false);
                }
            }
        }
Beispiel #2
0
 public void SelectObjByName(string message)
 {
     try
     {
         string   nameInfo = message.Split(',')[0];
         bool     _state   = (message.Split(',')[1].ToUpper()) == "TRUE" ? true : false;
         DGObject obj      = TurnNameToObj(nameInfo);
         if (obj != null && objSelectionChangedTrigger != null)
         {
             ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs();
             if (_state)
             {
                 args.addedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                 List <DGObject> objs = new List <DGObject>()
                 {
                     obj
                 };
                 args.addedObjs.Add(obj.parent.definition.GISLayerName, objs);
             }
             else
             {
                 args.removedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                 List <DGObject> objs = new List <DGObject>()
                 {
                     obj
                 };
                 args.removedObjs.Add(obj.parent.definition.GISLayerName, objs);
             }
             objSelectionChangedTrigger(this, args);
         }
     }
     catch { }
 }
        // Summary:
        //     Object selection event listener (function).
        //     It will broadcast the event to views and datagrid.
        public async void objSelectionChangedListener(object sender,
                                                      ObjSelectionChangedEventArgs e)
        {
            //  get detail information of obj from server
            //
            Dictionary <string, IEnumerable <DGObject> > detailDict = new Dictionary <string, IEnumerable <DGObject> >();

            if (e.addedObjs != null)
            {
                foreach (string key in e.addedObjs.Keys)
                {
                    List <DGObject>        tempList = new List <DGObject>();
                    IEnumerable <DGObject> objs     = e.addedObjs[key];
                    List <DGObject>        objlist  = objs.ToList();
                    DGObjects dGObjects             = Globals.project.objsDefIndex[key];

                    List <DGObject> detailObjList = new List <DGObject>();
                    foreach (DGObject _obj in objlist)
                    {
                        DGObject obj = await _obj.parent.QueryObjByID(_obj.ID);

                        tempList.Add(obj);
                    }
                    detailDict[key] = tempList.AsEnumerable();
                }
            }
            e.addedObjs = detailDict;

            // Distribution the objselectionchanged events
            //
            if (objSelectionChangedTrigger != null)
            {
                objSelectionChangedTrigger(sender, e);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 // 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);
     }
 }
        private void objSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e)
        {
            if (view == null)
            {
                view = Globals.mainframe.getViewByID("DemoLineChart");
                holder.Children.Add(view as UserControl);
            }
            MonPoint mp = e.addedObjs.Values.FirstOrDefault().FirstOrDefault() as MonPoint;

            view.SetData(string.Format("测点{0}监测曲线", mp.Name),
                         mp.readingsDict.Values.FirstOrDefault().ToList(),
                         "time", "value", "", mp.Name);
        }
Beispiel #7
0
        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)
                {
                    //old
                    // args.addedObjs.Add(gLayer.ID, objs);
                    args.addedObjs.Add(objs.FirstOrDefault().parent.definition.Name, objs);
                }
            }

            if (objSelectionChangedTrigger != null)
            {
                objSelectionChangedTrigger(this, args);
            }
        }
Beispiel #8
0
        //视图对象选择监听事件
        void _inputView_objSelectionChangedListener(object sender,
                                                    ObjSelectionChangedEventArgs e)
        {
            //设置MonPoint listbox数据源
            _selectedMonsDict = _prj.getSelectedObjs(_MonitorDomain, "MonPoint");
            List <DGObject> _mons = new List <DGObject>();

            foreach (var item in _selectedMonsDict.Values)
            {
                foreach (var obj in item)
                {
                    _mons.Add(obj);
                }
            }
            if (_mons != null && _mons.Count() > 0)
            {
                SLLB.ItemsSource = _mons;
            }
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        //视图对象选择监听事件
        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;
            }
        }
        private void DGObjectDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DGObjectDataGrid.IsKeyboardFocusWithin == false)
            {
                return;
            }
            List <DGObject> addedObjs   = new List <DGObject>();
            List <DGObject> removedObjs = new List <DGObject>();
            DGObject        selectOne   = DGObjectDataGrid.SelectedItem as DGObject;

            //select the selected one
            if ((_lastObj != null) && (_lastObj.Name == selectOne.Name))
            {
                return;
            }
            addedObjs.Add(selectOne);
            if (_lastObj != null)
            {
                removedObjs.Add(_lastObj);
            }
            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[selectOne.parent.definition.Name] = addedObjs;
                }
                if (removedObjs.Count > 0)
                {
                    removedObjsDict = new Dictionary <string, IEnumerable <DGObject> >();
                    removedObjsDict[_lastObj.parent.definition.Name] = removedObjs;
                }
                ObjSelectionChangedEventArgs args =
                    new ObjSelectionChangedEventArgs();
                args.addedObjs   = addedObjsDict;
                args.removedObjs = removedObjsDict;
                objSelectionChangedTrigger(this, args);
            }
            _lastObj = selectOne;
        }
 public void ObjSelectionChangedListener(object sender, ObjSelectionChangedEventArgs e)
 {
     if (LastObjList == null)
     {
         return;
     }
     //if (e.addedObjs != null)
     //{
     //    foreach (string key in e.addedObjs.Keys)
     //    {
     //        foreach (DGObject obj in e.addedObjs[key])
     //        {
     //            foreach (var data in LastObjList)
     //            {
     //                if ((data as DGObject).Name == obj.Name)
     //                {
     //                    (data as DGObject).IsSelected = true;
     //                }
     //            }
     //        }
     //    }
     //}
     //if (e.removedObjs != null)
     //{
     //    foreach (string key in e.removedObjs.Keys)
     //    {
     //        foreach (DGObject obj in e.removedObjs[key])
     //        {
     //            foreach (var data in LastObjList)
     //            {
     //                if ((data as DGObject).Name == obj.Name)
     //                {
     //                    (data as DGObject).IsSelected = false;
     //                }
     //            }
     //        }
     //    }
     //}
 }
Beispiel #13
0
        // 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);
                }
            }
        }
Beispiel #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _u3dPlayerControl_UnityCall(object sender, AxUnityWebPlayerAXLib._DUnityWebPlayerAXEvents_OnExternalCallEvent e)
        {
            try
            {
                string   message = e.value;
                string[] list    = message.Split('"');
                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i].StartsWith("@"))
                    {
                        iS3UnityMessage myMessage = MessageConverter.DeSerializeMessage(list[i]);
                        switch (myMessage.type)
                        {
                        case MessageType.SendUnityLayer:
                            break;

                        case MessageType.SetObjSelectState:
                            SetObjSelectStateMessage _message = myMessage as SetObjSelectStateMessage;
                            string   _path      = _message.path;
                            int      id         = int.Parse(_path.Split('/')[_path.Split('/').Length - 1]);
                            bool     isSelected = _message.iSSelected;
                            DGObject obj        = null;
                            foreach (string key in prj.objsLayerIndex.Keys)
                            {
                                DGObjects objs = prj.objsLayerIndex[key];
                                if ((objs.definition.Has3D) && (_path.StartsWith(objs.definition.Layer3DName)))
                                {
                                    foreach (DGObject _obj in objs.values)
                                    {
                                        if (_obj.fullName == id.ToString())
                                        {
                                            obj = _obj;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (obj != null && objSelectionChangedTrigger != null)
                            {
                                ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs();
                                if (isSelected)
                                {
                                    args.addedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                                    List <DGObject> objs = new List <DGObject>()
                                    {
                                        obj
                                    };
                                    args.addedObjs.Add(obj.parent.definition.GISLayerName, objs);
                                }
                                else
                                {
                                    args.removedObjs = new Dictionary <string, IEnumerable <DGObject> >();
                                    List <DGObject> objs = new List <DGObject>()
                                    {
                                        obj
                                    };
                                    args.removedObjs.Add(obj.parent.definition.GISLayerName, objs);
                                }
                                objSelectionChangedTrigger(this, args);
                            }
                            break;

                        case MessageType.SetObjShowState:
                            break;

                        default: break;
                        }
                    }
                }
            }
            catch { }
        }
Beispiel #15
0
        // 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)
                        {
                            int findIndex = -1;
                            // use ID to find the old one
                            for (int i = 0; i < objlist.Count; i++)
                            {
                                if (objlist[i].ID == obj.ID)
                                {
                                    findIndex = i;
                                }
                            }
                            if (findIndex == -1)
                            {
                                objlist.Add(obj);
                            }
                            else
                            {
                                objlist[findIndex] = 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)
                        {
                            //delete,use ID relate
                            objlist.Remove(objlist.Where(x => x.ID == obj.ID).FirstOrDefault());
                        }

                        selectedObjsDict[key] = objlist.AsEnumerable();
                    }
                }
            }

            _saved = selectedObjsDict;

            //
            refreshTextView(selectedObjsDict);
            //refreshTableView(selectedObjsDict);
            refreshChartView(selectedObjsDict);
        }
Beispiel #16
0
        async Task FindDetail()
        {
            List <DGObject> addedObjs   = new List <DGObject>();
            List <DGObject> removedObjs = new List <DGObject>();

            DGObject           selectOne  = MyDataGrid.DGObjectDataGrid.SelectedItem as DGObject;
            DGObjectRepository repository = DGObjectRepository.Instance(
                "SHML12", nowTree.RefDomainName, nowTree.Name);
            DGObject obj = await repository.Retrieve(selectOne.id);

            addedObjs.Add(obj);
            if (lastOne != null)
            {
                removedObjs.Add(lastOne);
            }
            lastOne = selectOne;
            string layerName = "Default";

            //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;


            //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(this, args);
            }
        }
Beispiel #17
0
        // 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);
        }
Beispiel #18
0
        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);
            }
        }