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]); } if (!isDuplex) _sub_line_duplex = LinesHorizontal.Find(x => x.id.Equals(_sub_line.to_id)). SubLinesHorizontal.Find(x => x.to_id.Equals(_sub_line.from_id)); 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); for (int u = 0; u < list_sub_duplex.Count; u++) if (SubWorkList[m].end_y == list_sub_duplex[u].posY) if (!isDuplex) try { _dict_sub_work.Add(SubWorkList[m], SubWorkList[m].end_x); } catch (Exception ex) { } } _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); if (horiz_line.SubLinesHorizontal.Count + list_sub_duplex.Count <= countLinks) 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; } else { 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; } } } }
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; } } } }