Example #1
0
 public void RemoveController(TECController controller)
 {
     controller.DisconnectAll();
     _controllers.Remove(controller);
     foreach (TECPanel panel in this.Panels)
     {
         if (panel.Controllers.Contains(controller))
         {
             panel.Controllers.Remove(controller);
         }
     }
     notifyCombinedChanged(Change.Remove, "Controllers", this, controller);
     CostChanged?.Invoke(-controller.CostBatch);
 }
Example #2
0
        public void Add(int value)
        {
            if (baseValue + value < attribute.BaseValue)
            {
                return;
            }

            baseValue += value;
            compValue += value;
            UpdateLabel();

            if (value > 0)
            {
                cost += baseValue * 100;
            }
            else
            {
                cost -= (baseValue - value) * 100;
            }

            CostChanged.Raise();
        }
Example #3
0
 private void raiseCostChanged(ITECObject sender, CostBatch obj)
 {
     CostChanged?.Invoke(obj);
 }
Example #4
0
 private void notifyCostChanged(CostBatch costBatch)
 {
     CostChanged?.Invoke(costBatch);
 }
 protected virtual void notifyCostChanged(CostBatch costs)
 {
     CostChanged?.Invoke(costs);
 }
Example #6
0
 private void collectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, string collectionName)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         int       pointNumber  = 0;
         CostBatch costs        = new CostBatch();
         bool      pointChanged = false;
         bool      costChanged  = false;
         foreach (object item in e.NewItems)
         {
             if (item is INotifyPointChanged pointItem)
             {
                 pointNumber += pointItem.PointNumber;
                 pointChanged = true;
             }
             if (item is INotifyCostChanged costItem)
             {
                 costs      += costItem.CostBatch;
                 costChanged = true;
             }
             notifyCombinedChanged(Change.Add, collectionName, this, item);
             if (item is TECTypical typical)
             {
                 costChanged  = false;
                 pointChanged = false;
             }
         }
         if (pointChanged)
         {
             PointChanged?.Invoke(pointNumber);
         }
         if (costChanged)
         {
             CostChanged?.Invoke(costs);
         }
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
     {
         int       pointNumber  = 0;
         CostBatch costs        = new CostBatch();
         bool      pointChanged = false;
         bool      costChanged  = false;
         foreach (object item in e.OldItems)
         {
             if (item is INotifyPointChanged pointItem)
             {
                 pointNumber += pointItem.PointNumber;
                 pointChanged = true;
             }
             if (item is INotifyCostChanged costItem)
             {
                 costs      += costItem.CostBatch;
                 costChanged = true;
             }
             notifyCombinedChanged(Change.Remove, collectionName, this, item);
             if (item is TECTypical typ)
             {
                 if (typ.Instances.Count == 0)
                 {
                     costChanged  = false;
                     pointChanged = false;
                 }
                 foreach (TECSystem instance in typ.Instances)
                 {
                     foreach (TECSubScope subScope in instance.GetAllSubScope())
                     {
                         TECController parentController = subScope.Connection?.ParentController;
                         if (parentController != null && this.Controllers.Contains(parentController))
                         {
                             parentController.Disconnect(subScope);
                         }
                     }
                     foreach (TECController controller in instance.Controllers)
                     {
                         TECController parentController = controller.ParentConnection?.ParentController;
                         if (parentController != null && this.Controllers.Contains(parentController))
                         {
                             parentController.Disconnect(controller);
                         }
                     }
                 }
             }
         }
         if (pointChanged)
         {
             PointChanged?.Invoke(pointNumber * -1);
         }
         if (costChanged)
         {
             CostChanged?.Invoke(costs * -1);
         }
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Move)
     {
         notifyCombinedChanged(Change.Edit, collectionName, this, sender, sender);
     }
 }
Example #7
0
 public void AddController(TECController controller)
 {
     _controllers.Add(controller);
     notifyCombinedChanged(Change.Add, "Controllers", this, controller);
     CostChanged?.Invoke(controller.CostBatch);
 }