Ejemplo n.º 1
0
        private void ShowRefs()
        {
            List <Tuple <bool, string> > param = new List <Tuple <bool, string> >(showRefs.Count);

            foreach (KeyValuePair <Class, bool> kvp in showRefs)
            {
                param.Add(new Tuple <bool, string>(kvp.Value, kvp.Key.Name));
            }

            SelectWindow w = new SelectWindow((IReadOnlyList <Tuple <bool, string> >)param)
            {
                Title = "Show references"
            };

            w.ShowDialog();

            List <bool> result = w.Result;

            if (result == null)
            {
                return;
            }

            for (int i = 0; i < result.Count; ++i)
            {
                showRefs[profile.Classes[param[i].Item2]] = result[i];
            }

            Redraw();
        }
Ejemplo n.º 2
0
        private void Deselect()
        {
            if (selectedNodes.Count <= 0)
            {
                return;
            }

            List <Tuple <bool, string> > param = new List <Tuple <bool, string> >(selectedNodes.Count);

            foreach (Node n in selectedNodes)
            {
                param.Add(new Tuple <bool, string>(true, n.Instance.GetProperty("mRID") + " : " + n.Instance.Class.Name));
            }

            SelectWindow w = new SelectWindow(param)
            {
                Title = "Deselect"
            };

            w.ShowDialog();
            List <bool> result = w.Result;

            if (result == null)
            {
                return;
            }

            bool change = false;

            int i = 0;

            foreach (bool keep in result)
            {
                if (keep)
                {
                    ++i;
                    continue;
                }

                selectedNodes[i].Selected = false;
                selectedNodes.RemoveAt(i);
                change = true;
            }

            if (change)
            {
                Redraw();
            }
        }
Ejemplo n.º 3
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!loaded)
            {
                return;
            }

            List <Node> ns = HitTest(e.GetPosition(canvas));

            if (ns.Count <= 0)
            {
                return;
            }

            if (ns.Count == 1)
            {
                Node n = ns[0];

                if (n.Selected = !n.Selected)
                {
                    selectedNodes.Add(n);
                }
                else
                {
                    selectedNodes.Remove(n);
                }

                Redraw();
                return;
            }

            List <Tuple <bool, string> > param = new List <Tuple <bool, string> >(ns.Count);

            foreach (Node n in ns)
            {
                param.Add(new Tuple <bool, string>(n.Selected, n.Instance.GetProperty("mRID") + " : " + n.Instance.Class.Name));
            }

            SelectWindow w = new SelectWindow(param)
            {
                Title = "Select"
            };

            w.ShowDialog();

            List <bool> result = w.Result;

            if (result == null)
            {
                return;
            }

            bool change = false;

            for (int i = 0; i < ns.Count; ++i)
            {
                Node n = ns[i];

                if (result[i])
                {
                    if (!n.Selected)
                    {
                        n.Selected = true;
                        selectedNodes.Add(n);
                        change = true;
                    }
                }
                else
                {
                    if (n.Selected)
                    {
                        n.Selected = false;
                        selectedNodes.Remove(n);
                        change = true;
                    }
                }
            }

            if (change)
            {
                Redraw();
            }
        }