public bool Execute(EditorForm form) { bool flag = false; vector = form.GetStorage(); for (int i = vector.Count() - 1; i >= 0; i--) { if (vector[i].IsSelected()) { if (vector[i].IsSticky() || vector[i].IsSticked()) { List <Observer> list = vector[i].GetObservers(); for (int j = list.Count - 1; j > 0; j--) { ((Figure)list[j]).RemoveObserver(vector[i]); } if (vector[i].IsSticked()) { vector[i].ChangeSticked(false); } } flag = true; shapes.Add(vector[i]); vector.RemoveAt(i); } } return(flag); }
public void Unexecute() { for (int i = 0; i < groups.Count; i++) { for (int j = 0; j < groups[i].Count(); j++) { for (int k = vector.Count() - 1; k >= 0; k--) { if (vector[k] == groups[i][j]) { vector[k].ChangeGrouped(true); vector.RemoveAt(k); } } } vector.Add(groups[i]); } for (int i = 0; i < vector.Count(); i++) { if (vector[i].IsSticky()) { for (int j = 0; j < vector.Count(); j++) { if (vector[j].IsToStick(vector[i]) && !vector[j].IsSticked() && (i != j)) { vector[j].ChangeSticked(true); vector[j].AddObserver(vector[i]); vector[i].AddObserver(vector[j]); } } } } }
public bool Execute(EditorForm form) { bool flag = false; vector = form.GetStorage(); Group newGroup = new Group(); newGroup.ChangeSelected(true); bool stickyGroup = false; for (int i = 0; i < vector.Count(); i++) { if (vector[i].IsSticky() && vector[i].IsSelected()) { stickyGroup = true; break; } } for (int i = vector.Count() - 1; i >= 0; i--) { if (vector[i].IsSelected()) { vector[i].ChangeGrouped(true); if (stickyGroup && !vector[i].IsSticky()) { not_sticky.Add(vector[i]); } if (vector[i].IsSticky() || vector[i].IsSticked()) { List <Observer> list = vector[i].GetObservers(); for (int j = list.Count - 1; j > 0; j--) { ((Figure)list[j]).RemoveObserver(vector[i]); } } colors.Add(vector[i].GetColor()); vector[i].ChangeColor(Color.Green); newGroup.Add(vector[i]); vector.RemoveAt(i); } } if (newGroup.Count() != 0) { flag = true; if (stickyGroup) { newGroup.ChangeSticky(true); } vector.Add(newGroup); group = newGroup; } return(flag); }
public bool Execute(EditorForm form) { bool flag = false; vector = form.GetStorage(); for (int i = vector.Count() - 1; i >= 0; i--) { if ((vector[i] is Group) && vector[i].IsSelected()) { flag = true; groups.Add((Group)vector[i]); if (vector[i].IsSticky() || vector[i].IsSticked()) { List <Observer> list = vector[i].GetObservers(); for (int j = 1; j < list.Count; j++) { ((Figure)list[j]).RemoveObserver(vector[i]); } } if (vector[i].IsSticked()) { vector[i].ChangeSticked(false); } for (int j = 0; j < ((Group)vector[i]).Count(); j++) { ((Group)vector[i])[j].ChangeGrouped(false); if (((Group)vector[i])[j] is Group) { for (int k = 0; k < ((Group)((Group)vector[i])[j]).Count(); k++) { ((Group)((Group)vector[i])[j])[k].ChangeGrouped(true); } } vector.Add(((Group)vector[i])[j]); } vector.RemoveAt(i); } } return(flag); }