//Copy Constructor
 public TECSubScope(TECSubScope sourceSubScope, Dictionary <Guid, Guid> guidDictionary = null,
                    ObservableListDictionary <ITECObject> characteristicReference      = null) : this()
 {
     if (guidDictionary != null)
     {
         guidDictionary[_guid] = sourceSubScope.Guid;
     }
     foreach (IEndDevice device in sourceSubScope.Devices)
     {
         Devices.Add(device);
     }
     foreach (TECPoint point in sourceSubScope.Points)
     {
         var toAdd = new TECPoint(point);
         characteristicReference?.AddItem(point, toAdd);
         Points.Add(toAdd);
     }
     foreach (TECInterlockConnection interlock in sourceSubScope.Interlocks)
     {
         var toAdd = new TECInterlockConnection(interlock);
         characteristicReference?.AddItem(interlock, toAdd);
         Interlocks.Add(toAdd);
     }
     foreach (TECScopeBranch branch in sourceSubScope.ScopeBranches)
     {
         var toAdd = new TECScopeBranch(branch);
         characteristicReference?.AddItem(branch, toAdd);
         ScopeBranches.Add(toAdd);
     }
     this.copyPropertiesFromScope(sourceSubScope);
 }
Beispiel #2
0
 private void buildConnectionDictionary(TECSystem system, ObservableListDictionary <IControllerConnection> currentDictionary)
 {
     foreach (TECController controller in Controllers)
     {
         var controllerInstances = TypicalInstanceDictionary.GetInstances(controller);
         foreach (IControllerConnection connection in controller.ChildrenConnections)
         {
             List <IConnectable> instanceConnectables = system.GetAll <IConnectable>();
             if (connection is TECNetworkConnection netConnect)
             {
                 var instanceConnection = controllerInstances.Where(x => system.Controllers.Contains(x))
                                          .SelectMany(x => x.ChildrenConnections)
                                          .OfType <TECNetworkConnection>()
                                          .Where(x => x.Children.SequenceEqual(netConnect.Children.SelectMany(y => TypicalInstanceDictionary.GetInstances(y).Where(z => instanceConnectables.Contains(z)))))
                                          .FirstOrDefault();
                 currentDictionary.AddItem(connection, instanceConnection);
             }
             else if (connection is TECHardwiredConnection hardConnect)
             {
                 var instanceConnection = controllerInstances.Where(x => system.Controllers.Contains(x))
                                          .SelectMany(x => x.ChildrenConnections)
                                          .OfType <TECHardwiredConnection>()
                                          .Where(x => x.Child == TypicalInstanceDictionary.GetInstances(hardConnect.Child).Where(z => instanceConnectables.Contains(z)).FirstOrDefault())
                                          .FirstOrDefault();
                 currentDictionary.AddItem(connection, instanceConnection);
             }
         }
     }
 }
        public void PopulateSerieInfo(ObservableListDictionary <int, VM_AnimeGroup_User> groups, ObservableListDictionary <int, VM_AnimeSeries_User> series)
        {
            List <int> allgroups = RecursiveGetGroups(groups, this).Select(a => a.AnimeGroupID).ToList();

            AllSeries    = new HashSet <int>(series.Values.Where(a => allgroups.Contains(a.AnimeGroupID)).Select(a => a.AnimeSeriesID));
            DirectSeries = new HashSet <int>(series.Values.Where(a => a.AnimeGroupID == AnimeGroupID).Select(a => a.AnimeSeriesID));
        }
Beispiel #4
0
        private VM_MainListHelper()
        {
            SerSearchType = SeriesSearchType.TitleOnly;

            CurrentWrapperList = new ObservableCollection <IListWrapper>();
            EpisodesForSeries  = new ObservableCollection <VM_AnimeEpisode_User>();
            AVDumpFiles        = new ObservableCollection <VM_AVDump>();
            BookmarkedAnime    = new ObservableCollection <VM_BookmarkedAnime>();


            AllGroupsDictionary       = new ObservableListDictionary <int, VM_AnimeGroup_User>();
            AllSeriesDictionary       = new ObservableListDictionary <int, VM_AnimeSeries_User>();
            AllAnimeDictionary        = new Dictionary <int, VM_AniDB_Anime>();
            AllGroupFiltersDictionary = new Dictionary <int, VM_GroupFilter>();
            ViewGroups          = CollectionViewSource.GetDefaultView(CurrentWrapperList);
            ViewGroupsForms     = CollectionViewSource.GetDefaultView(AllGroupsDictionary.Values);
            ViewAVDumpFiles     = CollectionViewSource.GetDefaultView(AVDumpFiles);
            ViewBookmarkedAnime = CollectionViewSource.GetDefaultView(BookmarkedAnime);

            ViewSeriesSearch = CollectionViewSource.GetDefaultView(AllSeriesDictionary.Values);
            ViewSeriesSearch.SortDescriptions.Add(new SortDescription("SeriesName", ListSortDirection.Ascending));
            ViewSeriesSearch.Filter = SeriesSearchFilter;

            BreadCrumbs = new ObservableCollection <IListWrapper>();

            //LastAnimeGroupID = 0;
            //LastAnimeSeriesID = 0;
            //LastGroupFilterID = 0;
            CurrentOpenGroupFilter = "";
            LastGroupForGF         = new Dictionary <string, int>();
            LastEpisodeForSeries   = new Dictionary <int, int>();
        }
Beispiel #5
0
        public TECSystem(TECSystem source, Dictionary <Guid, Guid> guidDictionary      = null,
                         ObservableListDictionary <ITECObject> characteristicReference = null,
                         Tuple <TemplateSynchronizer <TECEquipment>, TemplateSynchronizer <TECSubScope> > synchronizers = null) : this()
        {
            if (guidDictionary == null)
            {
                guidDictionary = new Dictionary <Guid, Guid>();
            }

            guidDictionary[_guid] = source.Guid;
            foreach (TECEquipment equipment in source.Equipment)
            {
                var toAdd = new TECEquipment(equipment, guidDictionary, characteristicReference, ssSynchronizer: synchronizers?.Item2);
                if (synchronizers != null && synchronizers.Item1.Contains(equipment))
                {
                    synchronizers.Item1.LinkNew(synchronizers.Item1.GetTemplate(equipment), toAdd);
                }
                if (characteristicReference != null)
                {
                    characteristicReference.AddItem(equipment, toAdd);
                }
                Equipment.Add(toAdd);
            }
            foreach (TECController controller in source._controllers)
            {
                var toAdd = controller.CopyController(guidDictionary);
                if (characteristicReference != null)
                {
                    characteristicReference.AddItem(controller, toAdd);
                }
                _controllers.Add(toAdd);
            }
            foreach (TECPanel panel in source.Panels)
            {
                var toAdd = new TECPanel(panel, guidDictionary);
                if (characteristicReference != null)
                {
                    characteristicReference.AddItem(panel, toAdd);
                }
                Panels.Add(toAdd);
            }
            foreach (TECMisc misc in source.MiscCosts)
            {
                var toAdd = new TECMisc(misc);
                MiscCosts.Add(toAdd);
            }
            foreach (TECScopeBranch branch in source.ScopeBranches)
            {
                var toAdd = new TECScopeBranch(branch);
                ScopeBranches.Add(toAdd);
            }
            foreach (TECProposalItem item in source.ProposalItems)
            {
                var toAdd = new TECProposalItem(item, guidDictionary);
                ProposalItems.Add(toAdd);
            }
            this.copyPropertiesFromLocated(source);
            ModelLinkingHelper.LinkSystem(this, guidDictionary);
        }
        private List <VM_AnimeGroup_User> RecursiveGetGroups(ObservableListDictionary <int, VM_AnimeGroup_User> groups, VM_AnimeGroup_User initialgrp)
        {
            List <VM_AnimeGroup_User> ls = groups.Values.Where(a => a.AnimeGroupParentID.HasValue && a.AnimeGroupParentID.Value == initialgrp.AnimeGroupID).ToList();

            foreach (VM_AnimeGroup_User v in ls.ToList())
            {
                ls.AddRange(RecursiveGetGroups(groups, v));
            }
            ls.Add(initialgrp);
            return(ls);
        }
 protected override ITECObject createInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     if (!this.IsTypical)
     {
         throw new Exception("Attempted to create an instance of an object which is already instanced.");
     }
     else
     {
         return(new TECFBOController(this));
     }
 }
 ITECObject ITypicalable.CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     if (!this.IsTypical)
     {
         throw new Exception("Attempted to create an instance of an object which is already instanced.");
     }
     else
     {
         return(new TECPanel(this));
     }
 }
 ITECObject ITypicalable.CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     if (!this.IsTypical)
     {
         throw new Exception("Attempted to create an instance of an object which is already instanced.");
     }
     else
     {
         return(new TECSubScope(this, characteristicReference: typicalDictionary));
     }
 }
Beispiel #10
0
        public void AddItemTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS   = new TECSubScope();
            TECSubScope valueSS = new TECSubScope();

            dict.AddItem(keySS, valueSS);

            Assert.IsTrue(dict.GetFullDictionary().ContainsKey(keySS));
            Assert.IsTrue(dict.GetFullDictionary()[keySS].Contains(valueSS));
        }
Beispiel #11
0
 ITECObject ITypicalable.CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     if (!this.IsTypical)
     {
         throw new Exception("Attempted to create an instance of an object which is already instanced.");
     }
     else
     {
         //Can be typical, but is not kept in sync
         return(null);
     }
 }
Beispiel #12
0
        public void ContainsKeyTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            Assert.IsTrue(dict.ContainsKey(keySS));
        }
Beispiel #13
0
        public void GetTypicalTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            var typ = dict.GetTypical(valueSS1);

            Assert.AreEqual(keySS, typ);
        }
Beispiel #14
0
        public void RemoveKeyTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            dict.RemoveKey(keySS);

            Assert.IsFalse(dict.GetFullDictionary().ContainsKey(keySS));
        }
Beispiel #15
0
        public void GetInstancesTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            var instances = dict.GetInstances(keySS);

            Assert.IsTrue(instances.Contains(valueSS1));
            Assert.IsTrue(instances.Contains(valueSS2));
        }
Beispiel #16
0
        public void GetFullDictionaryTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            var underlying = dict.GetFullDictionary();

            Assert.AreEqual(1, underlying.Keys.Count);
            Assert.AreEqual(2, underlying[keySS].Count);
        }
Beispiel #17
0
 public TECTypical(TECTypical source, Dictionary <Guid, Guid> guidDictionary     = null,
                   ObservableListDictionary <ITECObject> characteristicReference = null) : this()
 {
     if (guidDictionary != null)
     {
         guidDictionary[_guid] = source.Guid;
     }
     foreach (TECEquipment equipment in source.Equipment)
     {
         var toAdd = new TECEquipment(equipment, guidDictionary, characteristicReference);
         if (characteristicReference != null)
         {
             characteristicReference.AddItem(equipment, toAdd);
         }
         Equipment.Add(toAdd);
     }
     foreach (TECController controller in source.Controllers)
     {
         var toAdd = controller.CopyController(guidDictionary);
         if (characteristicReference != null)
         {
             characteristicReference.AddItem(controller, toAdd);
         }
         AddController(toAdd);
     }
     foreach (TECPanel panel in source.Panels)
     {
         var toAdd = new TECPanel(panel, guidDictionary);
         if (characteristicReference != null)
         {
             characteristicReference.AddItem(panel, toAdd);
         }
         Panels.Add(toAdd);
     }
     foreach (TECMisc misc in source.MiscCosts)
     {
         var toAdd = new TECMisc(misc);
         MiscCosts.Add(toAdd);
     }
     foreach (TECScopeBranch branch in source.ScopeBranches)
     {
         var toAdd = new TECScopeBranch(branch);
         ScopeBranches.Add(toAdd);
     }
     copyPropertiesFromLocated(source);
 }
 //Copy Constructor
 public TECEquipment(TECEquipment equipmentSource, Dictionary <Guid, Guid> guidDictionary = null,
                     ObservableListDictionary <ITECObject> characteristicReference        = null, TemplateSynchronizer <TECSubScope> ssSynchronizer = null) : this()
 {
     if (guidDictionary != null)
     {
         guidDictionary[_guid] = equipmentSource.Guid;
     }
     foreach (TECSubScope subScope in equipmentSource.SubScope)
     {
         var toAdd = new TECSubScope(subScope, guidDictionary, characteristicReference);
         if (ssSynchronizer != null && ssSynchronizer.Contains(subScope))
         {
             ssSynchronizer.LinkNew(ssSynchronizer.GetTemplate(subScope), toAdd);
         }
         characteristicReference?.AddItem(subScope, toAdd);
         SubScope.Add(toAdd);
     }
     copyPropertiesFromScope(equipmentSource);
 }
Beispiel #19
0
        public void RemoveValuesForKeysTest()
        {
            ObservableListDictionary <ITECScope> dict = new ObservableListDictionary <ITECScope>();

            TECSubScope keySS    = new TECSubScope();
            TECSubScope valueSS1 = new TECSubScope();
            TECSubScope valueSS2 = new TECSubScope();

            dict.AddItem(keySS, valueSS1);
            dict.AddItem(keySS, valueSS2);

            dict.RemoveValuesForKeys(new List <ITECScope>()
            {
                valueSS1
            }, new List <ITECScope>()
            {
                keySS
            });

            Assert.IsFalse(dict.GetFullDictionary()[keySS].Contains(valueSS1));
        }
Beispiel #20
0
        private void executeValueChanged <T>(T item, string propertyName, ObservableListDictionary <T> dict) where T : ITECObject
        {
            PropertyInfo property = item.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);

            if (property != null && property.CanWrite)
            {
                if (dict.ContainsKey(item))
                {
                    foreach (T instance in dict.GetInstances(item))
                    {
                        property.SetValue(instance, property.GetValue(item), null);
                    }
                }
                else if (item as TECTypical == this)
                {
                    foreach (var instance in Instances)
                    {
                        property.SetValue(instance, property.GetValue(item), null);
                    }
                }
            }
        }
Beispiel #21
0
 protected override ITECObject createInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     throw new NotImplementedException();
 }
 ITECObject ITypicalable.CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     return(this.createInstance(typicalDictionary));
 }
 protected abstract ITECObject createInstance(ObservableListDictionary <ITECObject> typicalDictionary);
Beispiel #24
0
 ITECObject ITypicalable.CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary)
 {
     throw new NotImplementedException();
 }
 public void InstanceDictionaryLinking()
 {
     foreach (TECTypical typical in bid.Systems)
     {
         ObservableListDictionary <ITECObject> list = typical.TypicalInstanceDictionary;
         foreach (TECSystem instance in typical.Instances)
         {
             int scopeFound = 0;
             foreach (TECEquipment equip in instance.Equipment)
             {
                 if (!list.ContainsValue(equip))
                 {
                     Assert.Fail("Equipment in instance not in characteristic instances.");
                 }
                 else
                 {
                     scopeFound++;
                 }
                 foreach (TECSubScope ss in equip.SubScope)
                 {
                     if (!list.ContainsValue(ss))
                     {
                         Assert.Fail("Subscope in instance not in characteristic instances.");
                     }
                     else
                     {
                         scopeFound++;
                     }
                     foreach (TECPoint point in ss.Points)
                     {
                         if (!list.ContainsValue(point))
                         {
                             Assert.Fail("Point in instance not in characteristic instances.");
                         }
                         else
                         {
                             scopeFound++;
                         }
                     }
                     foreach (TECInterlockConnection connection in ss.Interlocks)
                     {
                         if (!list.ContainsValue(connection))
                         {
                             Assert.Fail("Interlock in instance not in characteristic instances.");
                         }
                         else
                         {
                             scopeFound++;
                         }
                     }
                 }
             }
             foreach (TECController controller in instance.Controllers)
             {
                 if (!list.ContainsValue(controller))
                 {
                     Assert.Fail("Controller in instance not in characteristic instances.");
                 }
                 else
                 {
                     scopeFound++;
                 }
             }
             foreach (TECPanel panel in instance.Panels)
             {
                 if (!list.ContainsValue(panel))
                 {
                     Assert.Fail("Panel in instance not in characteristic instances.");
                 }
                 else
                 {
                     scopeFound++;
                 }
             }
             Assert.AreEqual(list.Count, scopeFound, "Number of scope found doesn't match the number of scope in characteristic instances.");
         }
     }
 }
Beispiel #26
0
 public ITECObject CreateInstance(ObservableListDictionary <ITECObject> typicalDictionary = null)
 {
     throw new NotImplementedException();
 }