Esempio n. 1
0
        /// <summary>
        /// Ковертирует узел декартового дерева в узел для отрисовки на форме
        /// </summary>
        /// <param name="node">Узел декартового дерева</param>
        /// <param name="startY">Высота рисования узла</param>
        /// <param name="startX">Начало области рисования узла</param>
        /// <param name="endX">Конец области рисования узла</param>
        /// <returns></returns>
        private NodeDrawer GetNodeDrawer(NodeOfCartesianTree <TNode, TValue> node, int startY, int startX, int endX)
        {
            NodeDrawer nodeDrawer = new NodeDrawer()
            {
                StartY            = startY,
                StartX            = startX,
                EndX              = endX,
                Text              = node.ToString(),
                Size              = Size,
                PenBorder         = (Pen)PenBorder.Clone(),
                BrushFont         = (Brush)BrushFont.Clone(),
                MinSizeForOutText = Size,
                Font              = Font
            };

            return(nodeDrawer);
        }
Esempio n. 2
0
        /// <summary>
        /// Отрисовывает следующее изменение
        /// </summary>
        public void NextEventInLog()
        {
            if (indexLogs >= Logs.Count)
            {
                return;
            }
            else
            {
                switch (Logs[indexLogs].LogEvent)
                {
                case LogTreapEvent.StartSplite:
                {
                    ClearActive();
                    NodeDrawer nodeDrawer = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    nodeDrawer.PenBorder.Color = activeColor;
                    prevActive.Enqueue(nodeDrawer);
                    break;
                }

                case LogTreapEvent.EndSplite:
                {
                    prevActive.Clear();
                    NodeDrawer nodeDrawer = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    nodeDrawer.PenBorder.Color = PenBorder.Color;
                    break;
                }

                case LogTreapEvent.RemoveEdge:
                {
                    NodeDrawer nodeDrawer = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    nodeDrawer.Arrow = null;
                    break;
                }

                case LogTreapEvent.AddedEdge:
                {
                    NodeDrawer nodeFrom = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    NodeDrawer nodeTo   = FindNodeDrawer(Logs[indexLogs].Nodes[1]);
                    nodeFrom.PenBorder.Color = activeColor;
                    nodeTo.Arrow             = new ArrowDrawer(nodeFrom.Rect, nodeTo.Rect)
                    {
                        Pen           = (Pen)PenArrow.Clone(),
                        LengthPointer = nodeTo.Size / 3,
                    };
                    break;
                }

                case LogTreapEvent.StartMerge:
                {
                    ClearActive();
                    NodeDrawer nodeLeft  = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    NodeDrawer nodeRight = FindNodeDrawer(Logs[indexLogs].Nodes[1]);
                    nodeLeft.PenBorder.Color  = activeColor;
                    nodeRight.PenBorder.Color = activeColor;
                    prevActive.Enqueue(nodeLeft);
                    prevActive.Enqueue(nodeRight);
                    break;
                }

                case LogTreapEvent.EndMerge:
                {
                    prevActive.Clear();
                    NodeDrawer nodeLeft  = FindNodeDrawer(Logs[indexLogs].Nodes[0]);
                    NodeDrawer nodeRight = FindNodeDrawer(Logs[indexLogs].Nodes[1]);
                    nodeLeft.PenBorder.Color  = PenBorder.Color;
                    nodeRight.PenBorder.Color = PenBorder.Color;
                    break;
                }
                }
                Draw();
                indexLogs++;
            }
        }