コード例 #1
0
        /// <summary>
        /// Returns true if any the mouse at the given point has moved from the previous treeNode panel to the new
        /// </summary>
        public static bool MovedTest(NodePanel old, NodePanel current, Point p)
        {
            bool changed = false;

            if (current == null && old == null)
            {
                // no change
            }
            else if (old == null)
            {
                //  old was not set and current is not null so changed
                changed = true;
            }
            else if (current == null)
            {
                // old was set but current is no longer
                changed = true;
            }
            else
            {
                // old and new set
                changed = !old.HitTest(p);  // current is different from previous
            }

            return(changed);
        }
コード例 #2
0
        void TypePanelMouseClick(object sender, MouseEventArgs e)
        {
            if (Controller.Enabled)
            {
                NodePanel nodePanel = _layout.LocatePanel(e.Location);

                if (nodePanel != null)
                {
                    Controller.SelectNode(nodePanel.TreeNode);

                    if (e.Button == MouseButtons.Right)
                    {
                        if (Controller.ContextMenuIsVisible)
                        {
                            Controller.HideContextMenu();
                            Invalidate();
                        }
                        else
                        {
                            Controller.ShowContextMenu(PointToScreen(e.Location));
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void MatrixPanelMouseClick(object sender, MouseEventArgs e)
        {
            if (Controller.Enabled)
            {
                NodePanel providerNodePanel = _hLayout.LocatePanel(e.Location);
                NodePanel consumerNodePanel = _vLayout.LocatePanel(e.Location);

                if (providerNodePanel != null && consumerNodePanel != null)
                {
                    Controller.SelectProviderNode(providerNodePanel.TreeNode);
                    Controller.SelectConsumerNode(consumerNodePanel.TreeNode);

                    if (e.Button == MouseButtons.Right)
                    {
                        if (Controller.ContextMenuIsVisible)
                        {
                            Controller.HideContextMenu();
                            Invalidate();
                        }
                        else
                        {
                            Controller.ShowContextMenu(PointToScreen(e.Location));
                        }
                    }
                }
            }
        }
コード例 #4
0
        void DoTooltipAfterMouseMove(NodePanel hCurrent, NodePanel vCurrent)
        {
            try
            {
                _ttTimer.Stop();

                if (hCurrent == null && vCurrent == null)
                {
                    return;
                }

                if (hCurrent != null && vCurrent != null)
                {
                    if (hCurrent.TreeNode == null)
                    {
                        // header
                        _tooltip.SetToolTip(this, TooltipString(vCurrent.TreeNode.NodeValue));
                    }
                    else // _matrix
                    {
                        if (vCurrent.TreeNode == hCurrent.TreeNode)
                        {
                            _tooltip.SetToolTip(this, TooltipString(vCurrent.TreeNode.NodeValue));
                        }
                        else
                        {
                            Relation rel = Controller.GetRelation(vCurrent.TreeNode.NodeValue, hCurrent.TreeNode.NodeValue);

                            int weight = 0;

                            if (rel != null)
                            {
                                weight = rel.Weight;
                            }

                            _tooltip.SetToolTip(this,
                                                "Consumer: " + TooltipString(vCurrent.TreeNode.NodeValue) +
                                                Environment.NewLine +
                                                "Provider: " + TooltipString(hCurrent.TreeNode.NodeValue) +
                                                Environment.NewLine +
                                                "Weight: " + weight);
                        }
                    }
                }
                else
                {
                    _tooltip.SetToolTip(this, String.Empty);
                }

                Invalidate();
                _tooltip.Active = true;
                _ttTimer.Start();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace);
            }
        }
コード例 #5
0
        public NodePanel LocatePanel(Point p)
        {
            NodePanel panel = null;

            for (int i = 0; i < _layout.Count && panel == null; i++)
            {
                if (_layout[i].HitTest(p))
                {
                    panel = _layout[i];
                }
            }

            return(panel);
        }
コード例 #6
0
        void DoTooltipAfterMouseMove(Point p)
        {
            NodePanel current = _layout.LocatePanel(p);

            if (LayoutHelper.MovedTest(_nodePanel, current, p))
            {
                _ttTimer.Stop();

                if (current == null)
                {
                    return;
                }

                Controller.SetCurrentModules(current.TreeNode, Controller.ConsumerTreeNode);

                _nodePanel = current;
                _tooltip.SetToolTip(this, TooltipString(current.TreeNode.NodeValue));
                _tooltip.Active = true;
                _ttTimer.Start();
            }
        }
コード例 #7
0
        private void MatrixPanelMouseMove(object sender, MouseEventArgs e)
        {
            try

            {
                // TODO review null values etc

                if (Controller.Enabled)
                {
                    NodePanel hCurrent = _hLayout.LocatePanel(e.Location);
                    NodePanel vCurrent = _vLayout.LocatePanel(e.Location);

                    //if ( HasMouseMovedCell( e.Location, hCurrent, vCurrent ) )

                    //if ( Controller.RowNode != hCurrent.TreeNode || Controller.ColNode != vCurrent.TreeNode )
                    if ((hCurrent?.TreeNode != null && Controller.ProviderTreeNode != hCurrent.TreeNode) ||
                        (vCurrent?.TreeNode != null && Controller.ConsumerTreeNode != vCurrent.TreeNode))
                    {
                        //_vPanel = vCurrent;
                        //_hPanel = hCurrent;

                        // change in position
                        //Controller.ProviderModule = (hCurrent == null ) ? null : hCurrent.TreeNode.NodeValue;
                        //Controller.ConsumerModule = (vCurrent == null ) ? null : vCurrent.TreeNode.NodeValue;

                        Controller.SetCurrentModules(
                            hCurrent?.TreeNode,
                            vCurrent?.TreeNode);

                        DoTooltipAfterMouseMove(hCurrent, vCurrent);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
コード例 #8
0
 public void Add(NodePanel panel)
 {
     _layout.Add(panel);
 }