private string getTemplateText(TECObject item)
        {
            TECTemplates templates = ScopeManager as TECTemplates;

            if (templates.IsTemplateObject(item))
            {
                string parentString = "";
                if (item is TECSubScope subScope)
                {
                    TECSubScope parent = templates.SubScopeSynchronizer.GetParent(subScope);
                    if (item != parent && parent != null)
                    {
                        parentString = String.Format(" of {0}",
                                                     parent.Name);
                    }
                }
                else if (item is TECEquipment equipment)
                {
                    TECEquipment parent = templates.EquipmentSynchronizer.GetParent(equipment);
                    if (item != parent && parent != null)
                    {
                        parentString = String.Format(" of {0}",
                                                     parent.Name);
                    }
                }

                return(String.Format("Reference{0}",
                                     parentString));
            }
            return("Instance Template");
        }
 private void deleteConnectionTypeExecute(TECObject obj)
 {
     if (obj is TECProtocol prot)
     {
         (Selected as TECDevice).PossibleProtocols.Remove(prot);
     }
     else if (obj is TECConnectionType connType)
     {
         (Selected as TECDevice).HardwiredConnectionTypes.Remove(connType);
     }
 }
 private void setReadOnly(TECObject value)
 {
     ReadOnly = false;
     if (ScopeManager is TECBid)
     {
         if (value is TECHardware)
         {
             ReadOnly = true;
         }
     }
 }
示例#4
0
        public static List <UpdateItem> NewStack(TECObject toSave)
        {
            DBType type = DBType.Bid;

            if (toSave is TECTemplates)
            {
                type = DBType.Templates;
            }
            List <UpdateItem> saveStack = new List <UpdateItem>();

            saveStack.AddRange(newStackForObject(toSave));
            if (toSave is IRelatable saveable)
            {
                saveStack.AddRange(DeltaStacker.ChildStack(Change.Add, saveable, type));
            }
            return(saveStack);
        }
示例#5
0
        private static List <UpdateItem> newStackForObject(TECObject toSave)
        {
            List <UpdateItem> outStack = new List <UpdateItem>();

            List <TableBase> tables = DatabaseHelper.GetTables(toSave);

            foreach (TableBase table in tables)
            {
                var fields = table.Fields;
                var data   = DatabaseHelper.PrepareDataForObjectTable(fields, toSave);
                if (data != null)
                {
                    outStack.Add(new UpdateItem(Change.Add, table.NameString, data));
                }
            }
            return(outStack);
        }
示例#6
0
 private void setupAddRemoveMethods(TECObject obj)
 {
     if (obj is TECSystem system)
     {
         setupAddRemoveMethods(system);
     }
     else if (obj is TECBid bid)
     {
         setupAddRemoveMethods(bid);
     }
     else if (obj is TECTemplates templates)
     {
         setupAddRemoveMethods(templates);
     }
     else
     {
         throw new Exception("Cannot setup methods for object: " + obj);
     }
 }
示例#7
0
        private ControllersPanelsVM(TECObject parent, IEnumerable <TECController> controllers, ObservableCollection <TECPanel> panels)
        {
            AddControllerCommand    = new RelayCommand(addControllerExecute, canAddController);
            AddPanelCommand         = new RelayCommand(addPanelExecute, canAddPanel);
            DeleteControllerCommand = new RelayCommand <TECController>(deleteControllerExecute);
            DeletePanelCommand      = new RelayCommand <TECPanel>(deletePanelExecute);
            ChangeTypeCommand       = new RelayCommand <TECProvidedController>(changeTypeExecute, canChangeType);

            setupAddRemoveMethods(parent);

            sourceControllers = new ObservableCollection <TECController>(controllers);
            PanelsSource      = panels;

            populateControllerCollection();
            populatePanelSelections();

            sourceControllers.CollectionChanged += collectionChanged;
            PanelsSource.CollectionChanged      += collectionChanged;

            this.parent        = parent;
            parent.TECChanged += parentChanged;
        }
示例#8
0
 protected void NotifySelected(TECObject item)
 {
     Selected?.Invoke(item);
 }
 public static TECObject FindObjectInSystems(ObservableCollection <TECTypical> systems, TECObject reference)
 {
     foreach (TECTypical system in systems)
     {
         if (system.Guid == reference.Guid)
         {
             return(system);
         }
         else
         {
             foreach (TECEquipment equipment in system.Equipment)
             {
                 if (equipment.Guid == reference.Guid)
                 {
                     return(equipment);
                 }
                 else
                 {
                     foreach (TECSubScope subScope in equipment.SubScope)
                     {
                         if (subScope.Guid == reference.Guid)
                         {
                             return(subScope);
                         }
                         else
                         {
                             foreach (TECDevice device in subScope.Devices)
                             {
                                 if (device.Guid == reference.Guid)
                                 {
                                     return(device);
                                 }
                             }
                             foreach (TECPoint point in subScope.Points)
                             {
                                 if (point.Guid == reference.Guid)
                                 {
                                     return(point);
                                 }
                             }
                         }
                     }
                 }
             }
             foreach (TECPanel panel in system.Panels)
             {
                 if (panel.Guid == reference.Guid)
                 {
                     return(panel);
                 }
             }
             foreach (TECController controller in system.Controllers)
             {
                 if (controller.Guid == reference.Guid)
                 {
                     return(controller);
                 }
             }
             foreach (TECScopeBranch branch in system.ScopeBranches)
             {
                 if (branch.Guid == reference.Guid)
                 {
                     return(branch);
                 }
             }
         }
     }
     return(null);
 }
 private bool canDeleteConnectionType(TECObject arg)
 {
     return(Selected is TECDevice && (arg is TECProtocol || arg is TECConnectionType));
 }
 private void systemHierarchyVM_Selected(TECObject obj)
 {
     Selected?.Invoke(obj);
 }
示例#12
0
 protected void RaiseSelectedChanged(TECObject obj)
 {
     ObjectSelected?.Invoke(obj);
 }