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.");
            }
        }
Exemple #2
0
        public void AddControlToBottom(ICoatingScheduleLogic logic)
        {
            ProductControlBase newControl = ProductControlBase.CreateControl(logic);

            ProductControls.Add(newControl);
            logic.Connect(newControl);
            newControl.Connect(this);
        }
Exemple #3
0
 public ShiftControl(ICoatingScheduleLogic logic)
 {
     ProductControls = new ObservableCollection <ProductControlBase>();
     InitializeComponent();
     ShiftListView.ItemsSource = ProductControls;
     ShiftListView.DataContext = typeof(ProductControlBase);
     this.DataContext          = logic;
 }
        public void AddControlToBottom(ICoatingScheduleLogic logic)
        {
            DayControl newDay = new DayControl();

            DayControls.Add(newDay);
            logic.Connect(newDay);
            newDay.Connect(this);
        }
        public void AddControlToTop(ICoatingScheduleLogic logic)
        {
            DayControl newDay = new DayControl();

            DayControls.Insert(0, newDay);
            logic.Connect(newDay);
            newDay.Connect(this);
        }
Exemple #6
0
        private ProductControl(ICoatingScheduleLogic logic)
        {
            Product = logic as CoatingScheduleProduct;
            InitializeComponent();
            CbbBarcode.SelectionChanged += CbbBarcode_SelectionChanged;
            DataContext = logic;

            SetMachineRef();
        }
Exemple #7
0
        public override void PushUpChildren(ICoatingScheduleLogic upChild)
        {
            Int32 lineCount = ChildrenLogic.Count;

            for (Int32 index = 0; index < lineCount; index++)
            {
                var line = ChildrenLogic[index];
                line.PushUpChildren(upChild);
            }
        }
Exemple #8
0
        public void AddControlToTop(ICoatingScheduleLogic logic)
        {
            ProductControlBase newControl = ProductControlBase.CreateControl(logic);

            if (newControl != null)
            {
                ProductControls.Insert(0, newControl);
                logic.Connect(newControl);
                newControl.Connect(this);
            }
        }
Exemple #9
0
 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 LineControl(ICoatingScheduleLogic logic)
        {
            ShiftControls = new ObservableCollection <ShiftControl>();

            InitializeComponent();
            ShiftListView.ItemsSource = ShiftControls;
            ShiftBox.ItemsSource      = ShiftHandler.CoatingInstance.Shifts;
            DataContext = logic;

            UpdateControlData();
        }
        public void AddControlToBottom(ICoatingScheduleLogic logic)
        {
            ShiftControl newControl = new ShiftControl(logic)
            {
                VerticalAlignment = VerticalAlignment.Top
            };

            ShiftControls.Add(newControl);
            logic.Connect(newControl);
            newControl.Connect(this);
        }
Exemple #12
0
        public void AddControlToTop(ICoatingScheduleLogic logic)
        {
            LineControl newControl = new LineControl(logic)
            {
                VerticalAlignment = VerticalAlignment.Top
            };

            LineControls.Insert(0, newControl);
            logic.Connect(newControl);
            newControl.Connect(this);
        }
        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);
                }
            }
        }
Exemple #14
0
        public override void PushDownChildren(ICoatingScheduleLogic upChild)
        {
            Int32 lineCount  = ChildrenLogic.Count;
            Int32 foundIndex = IndexOfChild(upChild);
            Int32 startIndex = foundIndex >= 0 ? foundIndex : 0;

            for (Int32 index = startIndex; index < lineCount; index++)
            {
                var line = ChildrenLogic[index];
                line.PushDownChildren(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);
                }
            }
        }
Exemple #16
0
        public override bool ChildIsTop(ICoatingScheduleLogic child)
        {
            bool isTop = false;

            if (ChildrenLogic.Count > 0)
            {
                isTop = ChildrenLogic.First() == child;
                if (isTop)
                {
                    isTop = ParentLogic.ChildIsTop(this);
                }
            }
            return(isTop);
        }
        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);
        }
Exemple #18
0
 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);
         }
     }
 }
Exemple #19
0
        public void SwapControls(ICoatingScheduleLogic other)
        {
            ICoatingScheduleControl otherControlParent   = other.ParentLogic.Control;
            ICoatingScheduleControl currentControlParent = ParentLogic.Control;

            ICoatingScheduleControl thisControl = Control;
            ICoatingScheduleControl thatControl = other.Control;

            bool sameParent = otherControlParent.SwapChildControl(thatControl, thisControl);

            if (!sameParent)
            {
                currentControlParent.SwapChildControl(thisControl, thatControl);
            }
        }
Exemple #20
0
 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);
     }
 }
Exemple #21
0
        public bool HasChild(ICoatingScheduleLogic child)
        {
            if (ChildrenLogic.Contains(child))
            {
                return(true);
            }

            bool childFound = false;

            for (Int32 index = 0; !childFound && index < ChildrenLogic.Count; index++)
            {
                var childLogic = ChildrenLogic[index];
                childFound = childLogic.HasChild(child);
            }
            return(childFound);
        }
Exemple #22
0
        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();
 }
Exemple #24
0
        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);
        }
        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);
        }
Exemple #26
0
        public Int32 IndexOfChild(ICoatingScheduleLogic child)
        {
            Int32 foundIndex = -1;

            if (ChildrenLogic.Contains(child))
            {
                return(ChildrenLogic.IndexOf(child));
            }

            for (Int32 index = 0; foundIndex == -1 && index < ChildrenLogic.Count; index++)
            {
                var childLogic = ChildrenLogic[index];
                if (childLogic.HasChild(child))
                {
                    foundIndex = index;
                }
            }

            return(foundIndex);
        }
Exemple #27
0
        public override void SwapChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastLogic)
        {
            ICoatingScheduleLogic childProduct = upChild;
            Int32 currentIndex = ChildrenLogic.IndexOf(childProduct);

            if (currentIndex == 0)
            {
                ChildrenLogic.Remove(childProduct);
                Control.RemoveControl(childProduct.Control);
                ParentLogic.SwapChildUp(upChild, this);
            }
            else
            {
                ICoatingScheduleLogic swapProduct = ChildrenLogic[currentIndex - 1];
                ChildrenLogic[currentIndex - 1] = childProduct;
                ChildrenLogic[currentIndex]     = swapProduct;

                childProduct.SwapControls(swapProduct);
            }
        }
Exemple #28
0
        public override void SwapChildDown(ICoatingScheduleLogic downChild, ICoatingScheduleLogic lastParent)
        {
            ICoatingScheduleLogic childProduct = downChild;
            Int32 currentIndex = ChildrenLogic.IndexOf(childProduct);

            if (currentIndex == ChildrenLogic.Count - 1) // is at bottom
            {
                ChildrenLogic.Remove(childProduct);
                Control.RemoveControl(childProduct.Control);
                ParentLogic.SwapChildDown(downChild, this);
            }
            else
            {
                ICoatingScheduleLogic swapProduct = ChildrenLogic[currentIndex + 1];
                ChildrenLogic[currentIndex + 1] = childProduct;
                ChildrenLogic[currentIndex]     = swapProduct;

                childProduct.SwapControls(swapProduct);
            }
        }
        public override void AddLogic(ICoatingScheduleLogic newController = null)
        {
            CoatingScheduleDay newLogic;

            if (newController != null)
            {
                newLogic = (CoatingScheduleDay)newController;
            }
            else
            {
                newLogic      = new CoatingScheduleDay();
                newLogic.Date = GetNextDay();
            }
            ChildrenLogic.Add(newLogic);
            newLogic.Connect(this);
            if (Control != null)
            {
                Control.AddControlToBottom(newLogic);
            }
            UpdateDateText();
        }
Exemple #30
0
 public void Connect(ICoatingScheduleLogic logic)
 {
     Day         = (CoatingScheduleDay)logic;
     DataContext = Day;
     UpdateControlData();
 }