コード例 #1
0
        // 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);
            }
        }
コード例 #2
0
        // Summary:
        //     Select objects by geometry
        // Remarks:
        //     The function selects graphics at first,
        //     then it returns the corresponding DGObjects as a list.
        //     If a graphic has no corresponding DGObject, it will
        //     still be in a selected state.
        public List <DGObject> selectObjectsByRect(IGeometry geom)
        {
            Esri.ArcGISRuntime.Geometry.Geometry rect = geom
                                                        as Esri.ArcGISRuntime.Geometry.Geometry;

            foreach (Graphic g in graphics)
            {
                if (!GeometryEngine.Contains(rect, g.Geometry))
                {
                    continue;
                }

                IGraphic ig = g as IGraphic;
                // make sure all graphics with the name is selected.
                if (_graphic2Objs != null &&
                    _graphic2Objs.ContainsKey(ig))
                {
                    DGObject           obj = _graphic2Objs[ig];
                    IGraphicCollection gc  = _obj2Graphics[obj];
                    foreach (IGraphic item in gc)
                    {
                        item.IsSelected = true;
                    }
                }
                else
                {
                    g.IsSelected = true;
                }
            }
            List <DGObject> objs = getHighlightedObjects();

            return(objs);
        }
コード例 #3
0
        //添加对象事件处理
        //例如MonProject、MonGroup之类,
        //添加Tree,添加Obj
        //返回tree,返回Obj,更新
        public async void DGObjectListener(object sender, DGObject model)
        {
            if (menuItem.Tag.ToString() == "Common")
            {
                TreeDefinition def = await CommonRepo.AddProjectTree(Globals.project.projectID, _domain, menuBase.TargetObjType, model.ID, 0);

                _treeDefinitions.Add(def);
            }
            else
            {
                TreeDefinition item = DomainTreeView.SelectedItem as TreeDefinition;
                TreeDefinition def  = await CommonRepo.AddProjectTree(Globals.project.projectID, _domain, menuBase.TargetObjType, model.ID, item.ID);

                if (item.Chillds == null)
                {
                    item.Chillds = new ObservableCollection <TreeDefinition>();
                }
                item.Chillds.Add(def);
            }
            Domain domain = Globals.project.getDomain(_domain);

            domain.objectsDefinitions = await CommonRepo.GetObjectsDefinition(Globals.project.projectID, domain.name);

            domain.DGObjectsList = new List <DGObjects>();
            foreach (ObjectsDefinition definition in domain.objectsDefinitions)
            {
                domain.DGObjectsList.Add(new DGObjects()
                {
                    parent = domain, definition = definition,
                });
            }
            commonPropertyWin.DGObjectHandler -= DGObjectListener;
            commonPropertyWin.Close();
        }
コード例 #4
0
        private async void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            var  obj  = iS3Property.GetInstance(_domain, _objType);
            Type type = iS3Property.GetType(_domain, _objType);

            foreach (PropertyDef def in _propertyDefs)
            {
                PropertyInfo info = type.GetProperty(def.key); //获取指定名称的属性
                if (TBDict.ContainsKey(def.id))
                {
                    string value = TBDict[def.id].Text.ToString();
                    if (!info.PropertyType.IsGenericType)
                    {
                        //非泛型
                        info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, info.PropertyType), null);
                    }
                    else
                    {
                        //泛型Nullable<>
                        Type genericTypeDefinition = info.PropertyType.GetGenericTypeDefinition();
                        if (genericTypeDefinition == typeof(Nullable <>))
                        {
                            info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, Nullable.GetUnderlyingType(info.PropertyType)), null);
                        }
                    }
                }
            }
            DGObject _obj = await RepositoryForClient.Create(obj as DGObject, _domain, _objType);

            if (DGObjectHandler != null)
            {
                DGObjectHandler(this, _obj);
            }
            this.Close();
        }
コード例 #5
0
        /// <summary>Mouse button has been pressed</summary>
        private void OnMouseButtonPress(object o, ButtonPressEventArgs args)
        {
            // Get the point clicked by the mouse.
            PointD clickPoint = new PointD(args.Event.X, args.Event.Y);

            // Delselect existing object
            if (selectedObject != null)
                selectedObject.Selected = false;

            // Look through nodes for the click point
            selectedObject = Nodes.FindLast(node => node.HitTest(clickPoint));

            // If not found, look through arcs for the click point
            if (selectedObject == null)
                selectedObject = Arcs.FindLast(arc => arc.HitTest(clickPoint));

            // If found object, select it.
            if (selectedObject != null)
            {
                selectedObject.Selected = true;
                mouseDown = true;
                lastPos = clickPoint;
            }

            // Redraw area.
            (o as DrawingArea).QueueDraw();
        }
コード例 #6
0
ファイル: IS3View.cs プロジェクト: linxy5326/iS3-Desktop
        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);
        }
コード例 #7
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 { }
 }
コード例 #8
0
ファイル: IS3Layer.cs プロジェクト: lzkqcc/iS3-V2.0-Client
        public int highlightObject(DGObject obj, bool on = true)
        {
            int count = 0;

            if (_obj2Graphics != null)
            {
                KeyValuePair <DGObject, IGraphicCollection> result = _obj2Graphics.Where(x => x.Key.Name == obj.Name).FirstOrDefault();
                if (result.Key != null)
                {
                    IGraphicCollection gc = result.Value;
                    foreach (IGraphic g in gc)
                    {
                        if (g.IsSelected != on)
                        {
                            g.IsSelected = on;
                        }
                        count++;
                    }
                }
            }
            //old
            //if (_obj2Graphics != null &&
            //    _obj2Graphics.ContainsKey(obj))
            //{
            //    IGraphicCollection gc = _obj2Graphics[obj];
            //    foreach (IGraphic g in gc)
            //    {
            //        if (g.IsSelected != on)
            //            g.IsSelected = on;
            //    }
            //}
            return(count);
        }
コード例 #9
0
ファイル: IS3View2D.cs プロジェクト: flyong/iS3-Transplant
        async Task showDefaultMapTip(System.Windows.Point screenPoint, MapPoint mapPoint)
        {
            if (_isHitTesting)
            {
                return;
            }
            try
            {
                _isHitTesting = true;
                DGObject         obj    = null;
                IS3GraphicsLayer gLayer = null;
                for (int i = _map.Layers.Count - 1; i >= 0; i--)
                {
                    Layer layer = _map.Layers[i];
                    gLayer = layer as IS3GraphicsLayer;
                    if (!isLayerSelectable(gLayer))
                    {
                        continue;
                    }
                    obj = await gLayer.hitTestAsync(screenPoint, mapView);

                    if (obj != null)
                    {
                        break;
                    }
                }
                //foreach (Layer layer in _map.Layers)
                //{
                //    gLayer = layer as IS3GraphicsLayer;
                //    if (!isLayerSelectable(gLayer))
                //        continue;
                //    obj = await gLayer.hitTestAsync(screenPoint, mapView);
                //    if (obj != null)
                //    {
                //        break;
                //    }
                //}
                if (obj != null)
                {
                    //_mapTip.className.Text = obj.GetType().Name;
                    _mapTip.DataContext = obj;
                    _mapTip.Visibility  = System.Windows.Visibility.Visible;
                    MapView.SetViewOverlayAnchor(_mapTip, mapPoint);
                }
                else
                {
                    _mapTip.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            catch
            {
                _mapTip.Visibility = System.Windows.Visibility.Collapsed;
            }
            finally
            {
                _isHitTesting = false;
            }
        }
コード例 #10
0
        public string TurnObjToName(DGObject obj)
        {
            string result = obj.name;

            result = obj.parent.definition.Name + "+" + result;
            result = obj.parent.parent.name + "+" + result;
            result = Globals.project.projDef.ID + "+" + result;
            return(result);
        }
コード例 #11
0
        // Summary:
        //     Hit test by screen point
        public async Task <DGObject> hitTestAsync(
            System.Windows.Point screenPoint,
            Esri.ArcGISRuntime.Controls.MapView mapView)
        {
            Graphic g = await HitTestAsync(mapView, screenPoint);

            DGObject obj = getObject(g as IGraphic);

            return(obj);
        }
コード例 #12
0
        private void largeWindowButton_Click(object sender, RoutedEventArgs e)
        {
            if (_saved == null || _saved.Count != 1)
            {
                return;
            }
            IEnumerable <DGObject> objs = _saved.Values.First();
            string   names    = string.Empty;
            DGObject firstObj = objs.First();

            foreach (DGObject obj in objs)
            {
                names += obj.Name + ",";
            }

            Window window = new Window();

            window.Width        = SystemParameters.PrimaryScreenWidth / 2;
            window.Height       = SystemParameters.PrimaryScreenHeight / 2;
            window.Owner        = App.Current.MainWindow;
            window.WindowState  = WindowState.Maximized;
            window.Title        = "Monitoring data chart: " + names;
            window.SizeChanged += (o, args) =>
            {
                List <FrameworkElement> chartViews = firstObj.chartViews(objs,
                                                                         window.ActualWidth, window.ActualHeight - 40.0);

                TabControl tabControl = new TabControl();
                foreach (var chart in chartViews)
                {
                    TabItem item = new TabItem();
                    item.Header = chart.Name;
                    tabControl.Items.Add(item);
                    item.Content = chart;
                }

                if (_tabControlSaved == null)
                {
                    tabControl.SelectedIndex = chartViewHolder.SelectedIndex;
                }
                else
                {
                    tabControl.SelectedIndex = _tabControlSaved.SelectedIndex;
                }
                _tabControlSaved = tabControl;      // save it to temporary var

                Grid grid = new Grid();
                grid.Children.Add(tabControl);
                window.Content = grid;
            };
            window.Show();
        }
コード例 #13
0
        public void highlightObject(DGObject obj, bool on = true)
        {
            if (obj == null || obj.parent == null || (obj.parent.definition.Has3D == false))
            {
                return;
            }

            SetObjSelectStateMessage message = new SetObjSelectStateMessage();

            message.path       = obj.parent.definition.Layer3DName + "/" + obj.fullName;
            message.iSSelected = on;
            ExcuteCommand(message);
        }
コード例 #14
0
        public async Task SetDGObjectShow(DGObject _obj)
        {
            DGObject obj = await RepositoryForClient.RetrieveObj(_obj);

            string             domainName = _obj.parent.parent.name;
            string             objType    = _obj.parent.definition.Type;
            Extensions         extensions = DllImport.domainExtension[domainName];
            DGObjectViewConfig dw         = extensions.treeItems().Where(x => x.objType == objType).FirstOrDefault();
            IDGObjectView      view       = dw.func();

            view.SetObjContent(obj);
            CommonWindow.GetInstance(view.ChartView()).Show();
        }
コード例 #15
0
        public EngineeringMap SetIt(DGObject model)
        {
            //try
            //{
            //    init();
            //}
            //catch (Exception ex)
            //{

            //}
            return(new Core.Model.EngineeringMap()
            {
                LocalTileFileNameStr = "CONC_" + model.ID.ToString() + ".unity3d",
            });
        }
コード例 #16
0
ファイル: IS3View2D.cs プロジェクト: flyong/iS3-Transplant
        public void highlightObject(DGObject obj, bool on = true)
        {
            if (obj == null || obj.parent == null)
            {
                return;
            }
            string         layerID = obj.parent.definition.GISLayerName;
            IGraphicsLayer gLayer  = _map.Layers[layerID] as IGraphicsLayer;

            if (gLayer == null)
            {
                return;
            }
            gLayer.highlightObject(obj, on);
        }
コード例 #17
0
        // Summary:
        //     Get selected objects
        // Remarks:
        //     The function checke IsSelected property of graphics at first,
        //     and then return the corresponding DGObject.
        //     The graphic is ignored if it has no related DGObjects.
        public List <DGObject> getHighlightedObjects()
        {
            HashSet <DGObject> objs = new HashSet <DGObject>();

            foreach (IGraphic g in selectedGraphics)
            {
                if (_graphic2Objs != null &&
                    _graphic2Objs.ContainsKey(g))
                {
                    DGObject obj = _graphic2Objs[g];
                    objs.Add(obj);
                }
            }
            return(objs.ToList());
        }
コード例 #18
0
 public IGraphicCollection getGraphics(DGObject obj)
 {
     if (_obj2Graphics == null)
     {
         return(null);
     }
     if (_obj2Graphics.ContainsKey(obj))
     {
         return(_obj2Graphics[obj]);
     }
     else
     {
         return(null);
     }
 }
コード例 #19
0
        public static async Task <DGObject> Create(DGObject _obj)
        {
            Type     type = iS3Property.GetType(_obj.parent.parent.name, _obj.parent.definition.Type);
            Type     myGenericClassType = typeof(RepositoryForClient <>);
            DGObject obj  = new DGObject();
            var      tt   = Activator.CreateInstance(myGenericClassType.MakeGenericType(new Type[] { type }));
            var      task = myGenericClassType.MakeGenericType(new Type[] { type }).
                            GetMethod("Create", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).
                            Invoke(tt, new object[] { Globals.project.projectID, _obj }) as Task;
            await task;

            obj        = task.GetType().GetProperty("Result").GetValue(task, null) as DGObject;
            obj.parent = _obj.parent;
            return(obj);
        }
コード例 #20
0
        public static async Task <int> Delete(DGObject _obj, string domainName, string objType)
        {
            Type type = iS3Property.GetType(domainName, objType);
            Type myGenericClassType = typeof(RepositoryForClient <>);

            var tt   = Activator.CreateInstance(myGenericClassType.MakeGenericType(new Type[] { type }));
            var task = myGenericClassType.MakeGenericType(new Type[] { type }).
                       GetMethod("DeleteModel", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).
                       Invoke(tt, new object[] { _obj, domainName, objType }) as Task;
            await task;
            int   result = int.Parse(task.GetType().GetProperty("Result").GetValue(task, null).ToString());

            //obj.Parent = _obj.Parent;
            return(result);
        }
コード例 #21
0
ファイル: IS3Layer.cs プロジェクト: flyong/iS3-Transplant
        public int highlightObject(DGObject obj, bool on = true)
        {
            if (_obj2Graphics == null)
            {
                return(0);
            }
            int count = 0;
            //foreach (IGraphic g in graphics)
            //{
            //    if (g.Attributes.ContainsKey("Name"))
            //    {
            //        string name = g.Attributes["Name"] as string;
            //        if (name == obj.name)
            //        {
            //            if (g.IsSelected != on)
            //                g.IsSelected = on;
            //        }
            //    }
            //}
            DGObject getobj = GetObjByID(obj.ID);

            if (_obj2Graphics != null && getobj != null &&
                _obj2Graphics.ContainsKey(getobj))
            {
                IGraphicCollection gc = _obj2Graphics[getobj];
                foreach (IGraphic g in gc)
                {
                    if (g.IsSelected != on)
                    {
                        g.IsSelected = on;
                    }
                }
            }
            return(count);

            //int count = 0;
            //if (_obj2Graphics != null &&
            //    _obj2Graphics.ContainsKey(obj))
            //{
            //    IGraphicCollection gc = _obj2Graphics[obj];
            //    foreach (IGraphic g in gc)
            //    {
            //        if (g.IsSelected != on)
            //            g.IsSelected = on;
            //    }
            //}
            //return count;
        }
コード例 #22
0
        private async void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            DGObject obj = DGObjectDataGrid.SelectedItem as DGObject;

            try
            {
                int result = await RepositoryForClient.Delete(obj, domainName, objTypeName);

                if (result > 0)
                {
                    await GetData(lastObj);
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #23
0
        // Read object (i.e., Name list) from the specified table.
        // REQUIREMENT:
        //      1. The specified table must have a 'Name' column.
        //
        public virtual bool ReadDGObjects(DGObjects objs, string tableNameSQL,
                                          string defNamesSQL, string orderSQL, string conditionSQL)
        {
            ReadRawData(objs, tableNameSQL, orderSQL, conditionSQL);

            DataTable table = objs.rawDataSet.Tables[0];

            foreach (DataRow row in table.Rows)
            {
                DGObject dgObj = new DGObject(row);

                try
                {
                    if (table.Columns.Contains("ID"))
                    {
                        dgObj.id = Convert.ToInt32(row["ID"]);
                    }

                    if (table.Columns.Contains("Name"))
                    {
                        dgObj.name = Convert.ToString(row["Name"]);
                    }

                    if (table.Columns.Contains("FullName"))
                    {
                        dgObj.fullName = ReadString(row, "FullName");
                    }

                    if (table.Columns.Contains("Description"))
                    {
                        dgObj.description = ReadString(row, "Description");
                    }

                    dgObj.shape = ReadShape(row);
                }
                catch (FormatException ex)
                {
                    string str = ex.ToString();
                    ErrorReport.Report(str);
                    continue;
                }
                objs[dgObj.id.ToString() + ":" + dgObj.name] = dgObj;
            }

            return(true);
        }
コード例 #24
0
        public T getObjectById <T>(int id) where T : DGObject
        {
            string klassName = typeof(T).Name;
            string name      = domain.objsDefinitions.Values.FirstOrDefault((d) => d.Type == klassName).Name;

            domain.loadObjects(name);
            DGObjects objs = domain[name];

            if (!objs.containsKey(id))
            {
                return(default(T));
            }

            DGObject obj = objs[id];

            return((T)obj);
        }
コード例 #25
0
 public DGObject TurnNameToObj(string nameInfo)
 {
     try
     {
         string[] nameList    = nameInfo.Split('+');
         string   projectName = nameList[0];
         string   domainName  = nameList[1];
         string   objDefName  = nameList[2];
         string   objName     = nameList[3];
         DGObject obj         = Globals.project.domains[domainName].objsContainer[objDefName][objName];
         return(obj);
     }
     catch
     {
         return(null);
     }
 }
コード例 #26
0
        // Summary:
        //     Select objects by point
        // Remarks:
        //     The function selects graphics at first,
        //     then it returns the corresponding DGObject.
        //     If a graphic has no corresponding DGObject, it will
        //     still be in a selected state.
        //     The selected object will be highlighted.
        public async Task <DGObject> selectObjectByPoint(
            System.Windows.Point screenPoint,
            Esri.ArcGISRuntime.Controls.MapView mapView)
        {
            Graphic g = await HitTestAsync(mapView, screenPoint);

            if (g != null)
            {
                g.IsSelected = true;
            }
            DGObject obj = getObject(g as IGraphic);

            if (obj != null)
            {
                highlightObject(obj, true);
            }
            return(obj);
        }
コード例 #27
0
        public int highlightObject(DGObject obj, bool on = true)
        {
            int count = 0;

            if (_obj2Graphics != null &&
                _obj2Graphics.ContainsKey(obj))
            {
                IGraphicCollection gc = _obj2Graphics[obj];
                foreach (IGraphic g in gc)
                {
                    if (g.IsSelected != on)
                    {
                        g.IsSelected = on;
                    }
                }
            }
            return(count);
        }
コード例 #28
0
ファイル: IS3View2D.cs プロジェクト: flyong/iS3-Transplant
        public async Task <bool> selectByPoint(System.Windows.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;
            //    }
            //}
            for (int i = _map.Layers.Count - 1; i >= 0; i--)
            {
                Layer layer = _map.Layers[i];
                gLayer = layer as IS3GraphicsLayer;
                if (!isLayerSelectable(gLayer))
                {
                    continue;
                }
                obj = await gLayer.selectObjectByPoint(screenPoint, mapView);

                if (obj != null)
                {
                    break;
                }
            }
            if (obj != null && ObjSelectionChangedHandler != null)
            {
                ObjSelectionChangedEvent args = new ObjSelectionChangedEvent();
                args.addObjs = new Dictionary <string, List <DGObject> >();
                List <DGObject> objs = new List <DGObject>();
                objs.Add(obj);
                args.addObjs.Add(obj.parent.definition.Name, objs);
                ObjSelectionChangedHandler(this, args);
                success = true;
            }
            return(success);
        }
コード例 #29
0
ファイル: DirectedGraphView.cs プロジェクト: shenyczz/ApsimX
        /// <summary>Mouse button has been released</summary>
        private void OnMouseButtonRelease(object o, ButtonReleaseEventArgs args)
        {
            try
            {
                args.RetVal = true;
                mouseDown   = false;

                if (args.Event.Button == 1)
                {
                    if (isDragging)
                    {
                        OnGraphObjectMoved?.Invoke(this, new ObjectMovedArgs(SelectedObject));
                    }
                    else
                    {
                        PointD clickPoint = new PointD(args.Event.X, args.Event.Y);
                        // Look through nodes for the click point
                        DGObject clickedObject = nodes.FindLast(node => node.HitTest(clickPoint));

                        // If not found, look through arcs for the click point
                        if (clickedObject == null)
                        {
                            clickedObject = arcs.FindLast(arc => arc.HitTest(clickPoint));
                        }

                        if (clickedObject == null)
                        {
                            UnSelect();
                        }
                        //else
                        //{
                        //    clickedObject.Selected = true;
                        //    OnGraphObjectSelected?.Invoke(this, new GraphObjectSelectedArgs(clickedObject, null));
                        //}
                    }
                }
                isDragging = false;
                CheckSizing();
            }
            catch (Exception err)
            {
                ShowError(err);
            }
        }
コード例 #30
0
        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;
        }