Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        private void Node_OnMove(NodeViewMoveEventArgs e)
        {
            var node      = e.NodeView;
            int nDiameter = Configuration.ms_nGraphNodeRadius * 2 + 1;

            for (int i = 0; i < Nodes.Count; i++)
            {
                if (Nodes[i] == node)
                {
                    continue;
                }

                int distance = GraphicComputing.CalcDistance(
                    e.MovedPosition.X - Nodes[i].Location.X,
                    e.MovedPosition.Y - Nodes[i].Location.Y
                    );
                if (distance <= nDiameter)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Обработчик перемещения мыши по узлу
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NodeGraph_MouseMove(object sender, MouseEventArgs e)
        {
            if (!m_bIsPressed)
            {
                return;
            }

            var newPosition = new Point(
                Location.X - (m_pCapturePoint.X - e.X),
                Location.Y - (m_pCapturePoint.Y - e.Y)
                );
            var moveArgs = new NodeViewMoveEventArgs(this, newPosition);

            OnMove?.Invoke(moveArgs);

            if (moveArgs.Cancel)
            {
                return;
            }

            Location = moveArgs.MovedPosition;
            Parent.Refresh();
        }