Ejemplo n.º 1
0
        public horizontal_line(DestinationAlgorithms _dest_alg, double startY, int count, int id, List <int> to_id)
        {
            this._dest_alg = _dest_alg;
            this.startY    = startY;
            this.id        = id;
            this.to_id     = to_id;
            this.sub_interval_horizontal = (_dest_alg.interval_horizontal - 20) / (count);
            endX                           = 50;
            LineHorizontal                 = new Line();
            LineHorizontal.Stroke          = Brushes.Blue;
            LineHorizontal.StrokeThickness = 1;
            ((Line)LineHorizontal).X1      = 50;
            ((Line)LineHorizontal).Y1      = startY;
            ((Line)LineHorizontal).X2      = 9950;
            ((Line)LineHorizontal).Y2      = startY;

            _dest_alg.LinesHorizontal.Add(this);
            label_horizontal = new Label();
            label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center;
            label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center;
            label_horizontal.FontSize   = 12;
            label_horizontal.Content    = id.ToString();
            label_horizontal.Width      = 30;
            label_horizontal.FontWeight = FontWeights.Bold;

            _dest_alg.GantCanvas.Children.Add(LineHorizontal);
            _dest_alg.GantCanvas.Children.Add(label_horizontal);
            Canvas.SetZIndex(LineHorizontal, 0);
            Canvas.SetZIndex(label_horizontal, 2);

            Canvas.SetLeft(label_horizontal, 25);
            Canvas.SetTop(label_horizontal, startY - 15);

            if (sub_interval_horizontal >= 20)
            {
                startY -= sub_interval_horizontal;
            }
            else
            {
                startY -= 20;
            }
            for (int i = 0; i < to_id.Count; i++)
            {
                sub_line horiz_line = new sub_line(_dest_alg, this, startY, id, to_id[i]);
                startY -= sub_interval_horizontal;
            }
        }
Ejemplo n.º 2
0
        public horizontal_line(DestinationAlgorithms _dest_alg, double startY, int count, int id, List<int> to_id)
        {
            this._dest_alg = _dest_alg;
            this.startY = startY;
            this.id = id;
            this.to_id = to_id;
            this.sub_interval_horizontal = (_dest_alg.interval_horizontal-20) / (count);
            endX = 50;
            LineHorizontal = new Line();
            LineHorizontal.Stroke = Brushes.Blue;
            LineHorizontal.StrokeThickness = 1;
            ((Line)LineHorizontal).X1 = 50;
            ((Line)LineHorizontal).Y1 = startY;
            ((Line)LineHorizontal).X2 = 9950;
            ((Line)LineHorizontal).Y2 = startY;

            _dest_alg.LinesHorizontal.Add(this);
            label_horizontal = new Label();
            label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center;
            label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center;
            label_horizontal.FontSize = 12;
            label_horizontal.Content = id.ToString();
            label_horizontal.Width = 30;
            label_horizontal.FontWeight = FontWeights.Bold;

            _dest_alg.GantCanvas.Children.Add(LineHorizontal);
            _dest_alg.GantCanvas.Children.Add(label_horizontal);
            Canvas.SetZIndex(LineHorizontal, 0);
            Canvas.SetZIndex(label_horizontal, 2);

            Canvas.SetLeft(label_horizontal, 25);
            Canvas.SetTop(label_horizontal, startY - 15);

            if (sub_interval_horizontal >= 20)
                startY -= sub_interval_horizontal;
            else
                startY -= 20;
            for (int i = 0; i < to_id.Count; i++)
            {                
                sub_line horiz_line = new sub_line(_dest_alg, this, startY, id, to_id[i]);
                startY -= sub_interval_horizontal;
            }
        }
Ejemplo n.º 3
0
        public void DrawSubWorks(int alg, int j, int need_proc_id, List <work_view> dependWorkList)
        {
            double          start_sub_point  = 0;
            List <sub_line> list_sub_duplex  = new List <sub_line>();
            sub_line        _sub_line_duplex = LinesHorizontal[0].SubLinesHorizontal[0];
            horizontal_line horiz_line       = LinesHorizontal[0];
            sub_line        _sub_line        = LinesHorizontal[0].SubLinesHorizontal[0];

            if (alg == 4)
            {
                for (int i = 0; i < dependWorkList.Count; i++)
                {
                    if (dependWorkList[i].end_x > start_sub_point)
                    {
                        start_sub_point = dependWorkList[i].end_x;
                    }
                }
            }

            for (int k = 0; k < dependWorkList.Count; k++)
            {
                list_sub_duplex.Clear();
                if (alg == 6 || alg == 5)
                {
                    start_sub_point = dependWorkList[k].end_x;
                }

                if (dependWorkList[k].proc_id != need_proc_id)
                {
                    NodeMinList(dependWorkList[k].proc_id, need_proc_id);
                    double start_sub_point_next = start_sub_point;
                    for (int i = 0; i < node_min_list.Count - 1; i++)
                    {
                        if (node_min_list.Count <= 2)
                        {
                            horiz_line = LinesHorizontal.Find(x => x.id.Equals(dependWorkList[k].proc_id));
                            _sub_line  = horiz_line.SubLinesHorizontal.Find(x => x.to_id.Equals(need_proc_id));
                        }
                        else
                        {
                            horiz_line = LinesHorizontal.Find(x => x.id.Equals(node_min_list[i]));
                            _sub_line  = horiz_line.SubLinesHorizontal.Find(x => x.to_id.Equals(node_min_list[i + 1]));
                        }

                        double weight = edge_weight[new KeyValuePair <int, int>(dependWorkList[k].rect_id, TopListNew[j].id)] *
                                        interval_vertical;

                        for (int m = 0; m < LinesHorizontal.Count; m++)
                        {
                            if (LinesHorizontal[m] != horiz_line)
                            {
                                for (int tt = 0; tt < horiz_line.SubLinesHorizontal.Count; tt++)
                                {
                                    for (int u = 0; u < LinesHorizontal[m].SubLinesHorizontal.Count; u++)
                                    {
                                        if (                                                                                               //LinesHorizontal[m].SubLinesHorizontal[u].to_id == horiz_line.id || //LinesHorizontal[m].SubLinesHorizontal[u].from_id == horiz_line.id ||
                                            (LinesHorizontal[m].SubLinesHorizontal[u].to_id == horiz_line.SubLinesHorizontal[tt].to_id ||
                                             LinesHorizontal[m].SubLinesHorizontal[u].from_id == horiz_line.SubLinesHorizontal[tt].to_id)) // &&
                                        {
                                            list_sub_duplex.Add(LinesHorizontal[m].SubLinesHorizontal[u]);
                                        }
                                    }
                                }
                            }
                        }

                        List <sub_work_view> _sub_work_new = new List <sub_work_view>();
                        Dictionary <sub_work_view, double> _dict_sub_work = new Dictionary <sub_work_view, double>();

                        for (int m = 0; m < SubWorkList.Count; m++)
                        {
                            if (SubWorkList[m].end_y == _sub_line.posY)
                            {
                                _dict_sub_work.Add(SubWorkList[m], SubWorkList[m].end_x);
                            }
                        }

                        _dict_sub_work = _dict_sub_work.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

                        foreach (var n_c in _dict_sub_work)
                        {
                            _sub_work_new.Add(n_c.Key);
                        }

                        List <sub_work_view> _sub_work_other_links             = new List <sub_work_view>();
                        Dictionary <sub_work_view, double> _dict_sub_work_link = new Dictionary <sub_work_view, double>();

                        for (int s = 0; s < horiz_line.SubLinesHorizontal.Count; s++)
                        {
                            if (horiz_line.SubLinesHorizontal[s].to_id != _sub_line.to_id)
                            {
                                for (int l = 0; l < SubWorkList.Count; l++)
                                {
                                    if (SubWorkList[l].end_y == horiz_line.SubLinesHorizontal[s].posY)
                                    {
                                        _dict_sub_work_link.Add(SubWorkList[l], SubWorkList[l].end_x);
                                    }
                                }
                            }
                        }

                        for (int m = 0; m < SubWorkList.Count; m++)
                        {
                            for (int u = 0; u < list_sub_duplex.Count; u++)
                            {
                                if (SubWorkList[m].end_y == list_sub_duplex[u].posY)
                                {
                                    try
                                    {
                                        _dict_sub_work_link.Add(SubWorkList[m], SubWorkList[m].end_x);
                                    }
                                    catch (Exception ex) { }
                                }
                            }
                        }


                        _dict_sub_work_link = _dict_sub_work_link.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);

                        foreach (var n_c in _dict_sub_work_link)
                        {
                            _sub_work_other_links.Add(n_c.Key);
                        }
                        List <sub_work_view> _sub_work_test_links = _sub_work_other_links;

                        for (int lol = 0; lol < SubWorkList.Count; lol++)
                        {
                            for (int m = 0; m < _sub_work_new.Count; m++)
                            {
                                double other_sub_start_x = _sub_work_new[m].end_x - _sub_work_new[m].rect_width;

                                if ((start_sub_point_next < other_sub_start_x && (start_sub_point_next + weight) > other_sub_start_x) ||
                                    (start_sub_point_next < _sub_work_new[m].end_x && (start_sub_point_next + weight) > other_sub_start_x) ||
                                    start_sub_point_next == other_sub_start_x || (start_sub_point_next + weight == _sub_work_new[m].end_x))
                                {
                                    start_sub_point_next = _sub_work_new[m].end_x;
                                }

                                start_sub_point_next = ShiftLinks(_sub_work_other_links, start_sub_point_next, weight);
                            }
                        }

                        if (_sub_work_new.Count == 0)
                        {
                            start_sub_point_next = ShiftLinks(_sub_work_other_links, start_sub_point_next, weight);
                        }


                        sub_work_view _sub_work = new sub_work_view(this, dependWorkList[k].rect_id, TopListNew[j].id,
                                                                    weight, start_sub_point_next, _sub_line.posY - 10, maxSubID() + 1);

                        start_sub_point_next += weight;
                    }
                }
            }
        }