Example #1
0
        private MouseAction GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent, out TreeChartPerson person)
        {
            var result = MouseAction.maNone;

            person = null;

            Point mpt = GetImageRelativeLocation(e.Location);
            int   aX  = mpt.X;
            int   aY  = mpt.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meDown)
                    {
                        result = MouseAction.maSelect;
                        break;
                    }
                    else if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meUp)
                    {
                        result = MouseAction.maProperties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        result = MouseAction.maHighlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Buttons == MouseButtons.Primary && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.maExpand;
                    break;
                }
            }

            if (result == MouseAction.maNone && person == null)
            {
                if (e.Buttons == MouseButtons.Alternate && mouseEvent == MouseEvent.meDown)
                {
                    result = MouseAction.maDrag;
                }
            }

            return(result);
        }
Example #2
0
        private MouseActionRet GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent)
        {
            MouseAction     action = MouseAction.maNone;
            TreeChartPerson person = null;

            ExtPoint offsets = fModel.GetOffsets();
            int      aX      = e.X - offsets.X;
            int      aY      = e.Y - offsets.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown)
                    {
                        action = MouseAction.maSelect;
                        break;
                    }
                    else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp)
                    {
                        action = MouseAction.maProperties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        action = MouseAction.maHighlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    action = MouseAction.maExpand;
                    break;
                }
            }

            if (action == MouseAction.maNone && person == null)
            {
                if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown)
                {
                    action = MouseAction.maDrag;
                }
            }

            return(new MouseActionRet(action, person));
        }
Example #3
0
        public void Test_TreeChartModel()
        {
            using (var model = new TreeChartModel())
            {
                Assert.IsNotNull(model);

                model.Base = fBase;
                Assert.AreEqual(fBase, model.Base);

                model.BranchDistance = TreeChartModel.DEF_BRANCH_DISTANCE;
                Assert.AreEqual(TreeChartModel.DEF_BRANCH_DISTANCE, model.BranchDistance);

                model.CertaintyIndex = true;
                Assert.AreEqual(true, model.CertaintyIndex);

                model.DepthLimit = 8;
                Assert.AreEqual(8, model.DepthLimit);

                model.DepthLimit = 8;
                Assert.AreEqual(8, model.DepthLimit);

                Assert.IsNotNull(model.Filter);

                model.HighlightedPerson = null;
                Assert.AreEqual(null, model.HighlightedPerson);

                Assert.AreEqual(0, model.ImageHeight);
                Assert.AreEqual(0, model.ImageWidth);

                model.KinRoot = null;
                Assert.AreEqual(null, model.KinRoot);

                model.Kind = TreeChartKind.ckAncestors;
                Assert.AreEqual(TreeChartKind.ckAncestors, model.Kind);

                model.Margins = 15;
                Assert.AreEqual(15, model.Margins);

                Assert.IsNull(model.Options);

                model.PathDebug = true;
                Assert.AreEqual(true, model.PathDebug);

                Assert.IsNotNull(model.Persons);

                Assert.IsNotNull(model.PreparedIndividuals);

                Assert.IsNull(model.Root);

                model.Scale = 1.3f;
                Assert.AreEqual(1.3f, model.Scale);

                model.Scale = 0.1f;
                Assert.AreEqual(0.5f, model.Scale);

                model.Scale = 1.7f;
                Assert.AreEqual(1.5f, model.Scale);

                Assert.Throws(typeof(ArgumentNullException), () => { model.DoFilter(null); });

                Assert.IsNull(model.FindPersonByCoords(0, 0));

                Assert.AreEqual(ExtRect.Create(0, -18, 15, -2), TreeChartModel.GetExpanderRect(ExtRect.Create(0, 0, 0, 0)));
                Assert.AreEqual(ExtRect.Create(-8, -18, 7, -2), TreeChartModel.GetPersonExpandRect(ExtRect.Create(0, 0, 0, 0)));

                ExtRect rt = model.VisibleArea;
                Assert.IsTrue(rt.IsEmpty());
            }
        }
Example #4
0
        private MouseAction GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent, out TreeChartPerson person)
        {
            var result = MouseAction.None;

            person = null;

            ExtPoint offsets = fModel.GetOffsets();
            int      aX      = e.X - offsets.X;
            int      aY      = e.Y - offsets.Y;

            int num = fModel.Persons.Count;

            for (int i = 0; i < num; i++)
            {
                TreeChartPerson p      = fModel.Persons[i];
                ExtRect         persRt = p.Rect;

                if (persRt.Contains(aX, aY))
                {
                    person = p;

                    if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown)
                    {
                        result = MouseAction.Select;
                        break;
                    }
                    else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp)
                    {
                        result = MouseAction.Properties;
                        break;
                    }
                    else if (mouseEvent == MouseEvent.meMove)
                    {
                        result = MouseAction.Highlight;
                        break;
                    }
                }

                ExtRect expRt = TreeChartModel.GetExpanderRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.Expand;
                    break;
                }

                expRt = TreeChartModel.GetPersonExpandRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.PersonExpand;
                    break;
                }

                ExtRect infoRt = TreeChartModel.GetInfoRect(persRt);
                if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && infoRt.Contains(aX, aY))
                {
                    person = p;
                    result = MouseAction.Info;
                    break;
                }
            }

            if (result == MouseAction.None && person == null)
            {
                if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown)
                {
                    result = MouseAction.Drag;
                }
            }

            return(result);
        }