Пример #1
0
        private void StartPaintTrace()
        {
            TasksPanel.CreateGraphics().Clear(Color.White);
            foreach (TaskUI tk in TasksPanel.Controls)
            {
                foreach (NetPoint np in tk.Task.Connections)
                {
                    TaskUI link = null;
                    foreach (TaskUI tik in TasksPanel.Controls)
                    {
                        if (tik.Task == np)
                        {
                            link = tik;
                            break;
                        }
                    }
                    if (link == null)
                    {
                        continue;
                    }
                    Graphics g = TasksPanel.CreateGraphics();
                    Pen      p = new Pen(Color.Black, 3);
                    g.DrawLine(p, tk.APoint, link.APoint);

                    Point center = new Point((tk.APoint.X + link.APoint.X) / 2, (tk.APoint.Y + link.APoint.Y) / 2);
                    AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5);
                    p.CustomEndCap = bigArrow;
                    g.DrawLine(p, tk.APoint, center);
                }
            }
            DrawShortPath();
        }
Пример #2
0
        private void DrawShortPath()
        {
            if (way == null)
            {
                return;
            }
            Graphics      g  = TasksPanel.CreateGraphics();
            Pen           p  = new Pen(Color.Red, 5);
            List <TaskUI> tk = new List <TaskUI>();

            foreach (NetPoint np in way)
            {
                foreach (TaskUI tik in TasksPanel.Controls)
                {
                    if (tik.Task == np)
                    {
                        tk.Add(tik);
                        break;
                    }
                }
            }
            for (int i = 0; i < tk.Count - 1; i++)
            {
                g.DrawLine(p, tk[i].APoint, tk[i + 1].APoint);
                Point center = new Point((tk[i].APoint.X + tk[i + 1].APoint.X) / 2, (tk[i].APoint.Y + tk[i + 1].APoint.Y) / 2);
                AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5);
                p.CustomEndCap = bigArrow;
                g.DrawLine(p, tk[i].APoint, center);
            }
        }
Пример #3
0
        /// <summary>
        /// Обработчик события изменения данных внутри NetPoint для дальнейшей перерисовки панели.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RedrawTasks(object sender, EventArgs e)
        {
            Graphics gr = TasksPanel.CreateGraphics();

            gr.Clear(Color.White);
            gr.Dispose();
            StartPaintTrace();
        }