public override void AddControlToTop(ICoatingScheduleLogic newLogic) { if (newLogic.GetType() == typeof(CoatingScheduleShift)) { CoatingScheduleShift newController = (CoatingScheduleShift)newLogic; bool foundLineMatch = false; for (Int32 index = 0; !foundLineMatch && index < ChildrenLogic.Count; index++) { var shift = ChildrenLogic[index]; if (newController.CoatingLine == shift.CoatingLine) { foundLineMatch = true; shift.AddControlToTop(newController); } } } else if (ChildrenLogic.Count > 0) { var foundShift = ChildrenLogic.FirstOrDefault( shift => shift.CoatingLine == newLogic.CoatingLine); if (foundShift != null) { foundShift.AddControlToTop(newLogic); } } }
public override void SwapChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent) { if (lastParent.GetType() == typeof(CoatingScheduleLine)) { Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleLine)lastParent); if (indexOfParent > 0) // if not at the top { lastParent.RemoveLogic(upChild); ChildrenLogic[indexOfParent - 1].AddControlToBottom(upChild); } else if (indexOfParent == 0) { ParentLogic.SwapChildUp(upChild, this); } else { throw new Exception("Invoking object not a member of current object"); } } else { throw new Exception("Call received by a non-child control."); } }
public override void SwapChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent) { if (lastParent.GetType() == typeof(CoatingScheduleDay)) { Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent); if (indexOfParent > 0) // if not at the top { lastParent.RemoveLogic(upChild); ChildrenLogic[indexOfParent - 1].AddControlToBottom(upChild); } else if (indexOfParent == 0) { //must add back the child ICoatingScheduleLogic child = ChildrenLogic[0]; ICoatingScheduleLogic child2 = child.ChildrenLogic[0]; ICoatingScheduleLogic child3 = child2.ChildrenLogic.First(x => x.CoatingLine == upChild.CoatingLine); child3.AddLogic(upChild); } else { throw new Exception("Invoking object not a member of current object"); } } else { throw new Exception("Call received by a non-child control."); } }
public override void AddControlToBottom(ICoatingScheduleLogic upChild) { if (upChild.GetType() == typeof(CoatingScheduleShift)) { CoatingScheduleShift newController = (CoatingScheduleShift)upChild; bool foundLineMatch = false; for (Int32 index = 0; !foundLineMatch && index < ChildrenLogic.Count; index++) { var shift = ChildrenLogic[index]; if (newController.CoatingLine == shift.CoatingLine) { foundLineMatch = true; shift.AddControlToBottom(newController); } } } else if (ChildrenLogic.Count > 0) { var foundShift = ChildrenLogic.Last( shift => shift.CoatingLine == upChild.CoatingLine); if (foundShift != null) { foundShift.AddControlToBottom(upChild); } } }
public override void SwapChildDown(ICoatingScheduleLogic downChild, ICoatingScheduleLogic lastParent) { if (lastParent.GetType() == typeof(CoatingScheduleDay)) { Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent); if (indexOfParent < ChildrenLogic.Count - 1) // if not at the bottom { lastParent.RemoveLogic(downChild); ChildrenLogic[indexOfParent + 1].AddControlToTop(downChild); } else if (indexOfParent == ChildrenLogic.Count - 1) { //must add back the child var day = ChildrenLogic.Last(); var line = day.ChildrenLogic.Last(); var shift = line.ChildrenLogic.First(x => x.CoatingLine == downChild.CoatingLine); shift.AddControlToBottom(downChild); } else { throw new Exception("Invoking object not a member of current object"); } } else { throw new Exception("Call received by a non-child control."); } }
public static ProductControlBase CreateControl(ICoatingScheduleLogic logic) { ProductControlBase newControl = null; if (logic.GetType() == typeof(CoatingScheduleProduct)) { newControl = ProductControl.CreateControl(logic); } else if (logic.GetType() == typeof(CoatingScheduleNote)) { newControl = ProductNoteControl.CreateControl(logic); } else { throw new Exception("Cannot create class from passed logic."); } return(newControl); }
public override void PushUpChildren(ICoatingScheduleLogic upChild) { if (upChild.GetType() == typeof(CoatingScheduleProduct)) { var shifts = ChildrenLogic.Where(x => x.CoatingLine == ((CoatingScheduleProduct)upChild).CoatingLine); foreach (var shift in shifts) { shift.PushUpChildren(upChild); } } }
public override void PushChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent) { if (lastParent.GetType() == typeof(CoatingScheduleDay)) { Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent); for (Int32 i = indexOfParent; i >= 0; --i) { ChildrenLogic[i].PushUpChildren(upChild); } } }
public override void PushChildDown(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent) { if (lastParent.GetType() == typeof(CoatingScheduleDay)) { Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent); Int32 dayCount = ChildrenLogic.Count; for (Int32 i = dayCount - 1; i >= indexOfParent; --i) { ChildrenLogic[i].PushDownChildren(upChild); } } }
public override bool ChildIsTop(ICoatingScheduleLogic child) { bool isTop = false; if (child.GetType() == typeof(CoatingScheduleDay) && ChildrenLogic.Count > 0) { isTop = ChildrenLogic.First() == (CoatingScheduleDay)child; } else { throw new Exception("Child not contained within class."); } return(isTop); }
public override void RemoveLogic(ICoatingScheduleLogic child) { if (child.GetType() == typeof(CoatingScheduleLine)) { ChildrenLogic.Remove((CoatingScheduleLine)child); Control.RemoveControl(child.Control); } else { foreach (var logic in ChildrenLogic) { logic.RemoveLogic(child); } } }
public override void AddControlToBottom(ICoatingScheduleLogic upChild) { if (upChild.GetType() == typeof(CoatingScheduleLine)) // if child type, add to list { AddLogic(upChild); } else if (ChildrenLogic.Count > 0) // if not child type, but this logic has children, try to have them add { ChildrenLogic.Last().AddControlToBottom(upChild); } else // if no children, create one and add new control to bottom { AddLogic(); ChildrenLogic[0].AddControlToBottom(upChild); } }
public override void AddControlToTop(ICoatingScheduleLogic newController) { CoatingScheduleLine newLogic; if (newController != null) { if (newController.GetType() == typeof(CoatingScheduleLine)) { newLogic = (CoatingScheduleLine)newController; newLogic.Shift = GetNextShift(); ChildrenLogic.Add(newLogic); newLogic.Connect(this); Control.AddControlToTop(newLogic); newLogic.AddLogic(); } else if (ChildrenLogic.Count > 0) { ChildrenLogic[0].AddControlToTop(newController); } else { newLogic = new CoatingScheduleLine(); newLogic.Date = Date; newLogic.Shift = GetNextShift(); ChildrenLogic.Add(newLogic); newLogic.Connect(this); Control.AddControlToTop(newLogic); newLogic.AddLogic(); newLogic.AddControlToTop(newController); } } else { newLogic = new CoatingScheduleLine(); newLogic.Date = Date; newLogic.Shift = GetNextShift(); ChildrenLogic.Add(newLogic); newLogic.Connect(this); Control.AddControlToTop(newLogic); newLogic.AddLogic(); } }
public override void AddControlToTop(ICoatingScheduleLogic newLogic) { if (newLogic.GetType() == typeof(CoatingScheduleDay)) // if child type, add to list { AddControlToTop(newLogic); } else if (ChildrenLogic.Count > 0) // if not child type, but this logic has children, try to have them add { ChildrenLogic.Last().AddControlToTop(newLogic); } else // if no children, create one and add new control to bottom { AddLogic(); ChildrenLogic[0].AddControlToTop(newLogic); } UpdateDateText(); }
public override bool ChildIsTop(ICoatingScheduleLogic child) { bool isTop = false; if (child.GetType() == typeof(CoatingScheduleLine) && ChildrenLogic.Count > 0) { isTop = ChildrenLogic.First() == (CoatingScheduleLine)child; if (isTop) { isTop = ParentLogic.ChildIsTop(this); } } else { throw new Exception("Child is not contained in this class."); } return(isTop); }