public void ChangedEventsTest()
        {
            var list = new ObservableCollection<string>();
            var readOnlyList = new ReadOnlyObservableList<string>(list);

            int collectionChangedCalled = 0;
            NotifyCollectionChangedEventHandler collectionChangedHandler = (sender, e) =>
            {
                collectionChangedCalled++;
            };
            int countPropertyChangedCalled = 0;
            PropertyChangedEventHandler propertyChangedHandler = (sender, e) =>
            {
                if (e.PropertyName == nameof(readOnlyList.Count))
                {
                    countPropertyChangedCalled++;
                }
            };

            readOnlyList.CollectionChanged += collectionChangedHandler;
            readOnlyList.PropertyChanged += propertyChangedHandler;
            list.Add("Hello");
            Assert.AreEqual(1, collectionChangedCalled);
            Assert.AreEqual(1, countPropertyChangedCalled);

            readOnlyList.CollectionChanged -= collectionChangedHandler;
            readOnlyList.PropertyChanged -= propertyChangedHandler;
            list.Add("World");
            Assert.AreEqual(1, collectionChangedCalled);
            Assert.AreEqual(1, countPropertyChangedCalled);
        }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_gmdGameMode">The the current game mode.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		public BasicUninstallTask(IMod p_modMod, InstallerGroup p_igpInstallers, IInstallLog p_ilgModInstallLog, IGameMode p_gmdGameMode, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			Mod = p_modMod;
			Installers = p_igpInstallers;
			ModInstallLog = p_ilgModInstallLog;
			GameMode = p_gmdGameMode;
			ActiveMods = p_rolActiveMods;
		}
        public PlaylistManager(int playedItemStackCapacity = 1000, IRandomService randomService = null)
        {
            this.randomService = randomService ?? new RandomService();
            this.items = new ObservableCollection<PlaylistItem>();
            this.readonlyItems = new ReadOnlyObservableList<PlaylistItem>(items);
            this.playedItemsStack = new PlayedItemsStack<PlaylistItem>(playedItemStackCapacity);

            this.items.CollectionChanged += ItemsCollectionChanged;
        }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The the current game mode.</param>
		/// <param name="p_mfiFileInstaller">The file installer to use.</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_booSkipReadme">Whether to skip the installation of readme files.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		public BasicInstallTask(IMod p_modMod, IGameMode p_gmdGameMode, IModFileInstaller p_mfiFileInstaller, IPluginManager p_pmgPluginManager, bool p_booSkipReadme, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			FileInstaller = p_mfiFileInstaller;
			PluginManager = p_pmgPluginManager;
			SkipReadme = p_booSkipReadme;
			ActiveMods = p_rolActiveMods;
		}
			/// <summary>
			/// A simple constructor that initializes the object with the given values.
			/// </summary>
			/// <param name="p_txTransaction">The transaction into which we are enlisting.</param>
			/// <param name="p_polPluginOrderLog">The <see cref="PluginOrderLog"/> whose actions are being transacted.</param>
			public TransactionEnlistment(Transaction p_txTransaction, PluginOrderLog p_polPluginOrderLog)
			{
				CurrentTransaction = p_txTransaction;
				EnlistedPluginOrderLog = p_polPluginOrderLog;
				m_oclOrderedPlugins = new ThreadSafeObservableList<Plugin>(EnlistedPluginOrderLog.m_oclOrderedPlugins);
				m_rolOrderedPlugins = new ReadOnlyObservableList<Plugin>(m_oclOrderedPlugins);

				EnlistedPluginOrderLog.m_oclOrderedPlugins.CollectionChanged += new NotifyCollectionChangedEventHandler(MasterOrderedPlugins_CollectionChanged);
			}
			/// <summary>
			/// A simple constructor that initializes the object with the given values.
			/// </summary>
			/// <param name="p_txTransaction">The transaction into which we are enlisting.</param>
			/// <param name="p_aplPluginLog">The <see cref="ActivePluginLog"/> whose actions are being transacted.</param>
			public TransactionEnlistment(Transaction p_txTransaction, ActivePluginLog p_aplPluginLog)
			{
				CurrentTransaction = p_txTransaction;
				EnlistedPluginLog = p_aplPluginLog;
				m_ostActivePlugins = new ObservableSet<Plugin>(EnlistedPluginLog.m_ostActivePlugins, PluginComparer.Filename);
				m_rolActivePlugins = new ReadOnlyObservableList<Plugin>(m_ostActivePlugins);

				EnlistedPluginLog.m_ostActivePlugins.CollectionChanged += new NotifyCollectionChangedEventHandler(MasterPlugins_CollectionChanged);
			}
Example #7
0
        /// <summary>
        /// Deactivates all the mods.
        /// </summary>
        /// <param name="p_rolModList">The list of Active Mods.</param>
        public void DeactivateMultipleMods(ReadOnlyObservableList <IMod> p_rolModList, bool p_booForceUninstall, bool p_booSilent, bool p_booFilesOnly)
        {
            DialogResult Result = DialogResult.None;

            if (!p_booForceUninstall)
            {
                Result = MessageBox.Show("Do you want to uninstall all the installed mods?", "Deactivate Mods", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }

            if (p_booForceUninstall || (Result == DialogResult.Yes))
            {
                DeactivatingMultipleMods(p_booSilent, new EventArgs <IBackgroundTask>(ModManager.DeactivateMultipleMods(p_rolModList, p_booFilesOnly, ConfirmUpdaterAction)));
            }
        }
Example #8
0
 public MainFormViewModel()
 {
     _tokenizer           = new LatinWordTokenizer();
     _openProjectCommand  = new RelayCommand(OpenProject);
     _saveProjectCommand  = new RelayCommand(SaveProject, CanSaveProject);
     CloseCommand         = new RelayCommand(Close, CanClose);
     _hcTraceManager      = new TraceManager();
     _confidenceThreshold = 20;
     _texts       = new BulkObservableList <TextViewModel>();
     Texts        = new ReadOnlyObservableList <TextViewModel>(_texts);
     _currentText = new TextViewModel(_tokenizer);
     RebuildTask  = new TaskViewModel <ProgressData>(RebuildAsync, () => _hybridEngine != null,
                                                     p => p.PercentCompleted, p => p.CurrentStepMessage);
 }
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_modMod">The mod being installed.</param>
 /// <param name="p_gmdGameMode">The current game mode.</param>
 /// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
 /// <param name="p_futFileUtility">The file utility class.</param>
 /// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
 /// <param name="p_ilgModInstallLog">The install log that tracks mod install info
 /// for the current game mode</param>
 /// <param name="p_pmgPluginManager">The plugin manager.</param>
 /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
 /// <param name="p_rolActiveMods">The list of active mods.</param>
 public ModInstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, IVirtualModActivator p_ivaVirtualModActivator, IProfileManager p_prmProfileManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods)
 {
     Mod                 = p_modMod;
     GameMode            = p_gmdGameMode;
     EnvironmentInfo     = p_eifEnvironmentInfo;
     FileUtility         = p_futFileUtility;
     UIContext           = p_scxUIContext;
     ModInstallLog       = p_ilgModInstallLog;
     PluginManager       = p_pmgPluginManager;
     VirtualModActivator = p_ivaVirtualModActivator;
     ProfileManager      = p_prmProfileManager;
     m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate;
     ActiveMods = p_rolActiveMods;
 }
Example #10
0
        public void IteratorTest()
        {
            var observableCollection = new ObservableCollection <double>(new List <double>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5
            });
            IReadOnlyObservableCollection <double> source = new ReadOnlyObservableList <double>(observableCollection);
            DynamicTransformingReadOnlyObservableList <double, int> trool = new DynamicTransformingReadOnlyObservableList <double, int>(source, Selector);

            Assert.AreEqual(trool[0], 1);
            Assert.AreEqual(trool[1], 2);
            Assert.AreEqual(trool[2], 3);
            Assert.AreEqual(trool[3], 4);
            Assert.AreEqual(trool[4], 5);
        }
Example #11
0
        public void ClearTest()
        {
            var observableCollection = new ObservableCollection <double>(new List <double>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7
            });
            IReadOnlyObservableCollection <double> source = new ReadOnlyObservableList <double>(observableCollection);
            DynamicTransformingReadOnlyObservableList <double, int> trool = new DynamicTransformingReadOnlyObservableList <double, int>(source, Selector);
            var copy = new TransformingReadOnlyObservableList <int, int>(trool, x => x);

            observableCollection.Clear();
            Assert.AreEqual(trool.Count, 0);

            Assert.IsTrue(trool.SequenceEqual(copy));
        }
Example #12
0
 /// <summary>
 /// Deactivates all the mods.
 /// </summary>
 /// <param name="p_rolModList">The list of Active Mods.</param>
 public void DeactivateMultipleMods(ReadOnlyObservableList <IMod> p_rolModList, bool booForceUninstall)
 {
     if (booForceUninstall)
     {
         DeactivatingMultipleMods(this, new EventArgs <IBackgroundTask>(ModManager.DeactivateMultipleMods(p_rolModList, ConfirmUpdaterAction)));
     }
     else
     {
         DialogResult Result = MessageBox.Show("Do you want to uninstall all the active mods?", "Deativate Mods", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (Result == DialogResult.Yes)
         {
             DeactivatingMultipleMods(this, new EventArgs <IBackgroundTask>(ModManager.DeactivateMultipleMods(p_rolModList, ConfirmUpdaterAction)));
         }
     }
 }
        public void AddElementTest()
        {
            var observableCollection = new ObservableCollection <object>(new List <object>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7
            });
            IReadOnlyObservableList <object> rool = new ReadOnlyObservableList <object>(observableCollection);
            SwitchableListSource <object>    sls  = new SwitchableListSource <object>();

            sls.Source = rool;
            TransformingReadOnlyObservableList <object, object> trool = new TransformingReadOnlyObservableList <object, object>(sls, Selector);

            observableCollection.Add(8.8);
            Assert.AreEqual(trool[trool.Count - 1], 8.8);
        }
Example #14
0
        public void OperationsTest()
        {
            List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >();

            var observableCollection1 = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3
            });
            var rool1 = new ReadOnlyObservableList <int>(observableCollection1);
            var cc1   = new CollectionContainer <int>(rool1);

            cc.Add(cc1);

            var observableCollection2 = new ObservableCollection <int>(new List <int>()
            {
                5, 7, 8
            });
            var rool2 = new ReadOnlyObservableList <int>(observableCollection2);
            var cc2   = new CollectionContainer <int>(rool2);

            cc.Add(cc2);

            var croocs = new CompositeReadOnlyObservableListSource <int>(cc);

            //[1 2 3 5 7 8]
            observableCollection1.Add(4);
            //[1 2 3 4 5 7 8]
            observableCollection1.Add(8);
            //[1 2 3 8 4 5 7 8]
            observableCollection2.Insert(1, 6);
            //[1 2 3 8 4 5 6 7 8]
            observableCollection1.Remove(8);
            //[1 2 3 4 5 6 7 8]
            observableCollection1.Move(1, 3);
            //[1 3 4 2 5 6 7 8]

            var iterator = croocs.View;

            Assert.AreEqual(iterator.Count, 8);
            Assert.AreEqual(iterator[0], 1);
            Assert.AreEqual(iterator[1], 3);
            Assert.AreEqual(iterator[2], 4);
            Assert.AreEqual(iterator[3], 2);
            Assert.AreEqual(iterator[4], 5);
            Assert.AreEqual(iterator[5], 6);
            Assert.AreEqual(iterator[6], 7);
            Assert.AreEqual(iterator[7], 8);
        }
Example #15
0
        public void AddItemsTest()
        {
            List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >();

            var observableCollection1 = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3
            });
            var rool1 = new ReadOnlyObservableList <int>(observableCollection1);
            var cc1   = new CollectionContainer <int>(rool1);

            cc.Add(cc1);

            var observableCollection2 = new ObservableCollection <int>(new List <int>()
            {
                7, 8, 9
            });
            var rool2 = new ReadOnlyObservableList <int>(observableCollection2);
            var cc2   = new CollectionContainer <int>(rool2);

            cc.Add(cc2);

            var croocs = new CompositeReadOnlyObservableListSource <int>(cc);

            observableCollection1.Add(4);
            observableCollection1.Add(5);
            observableCollection1.Add(6);

            var observableCollection3 = new ObservableCollection <int>(new List <int>()
            {
                10, 11, 12
            });
            var rool3 = new ReadOnlyObservableList <int>(observableCollection3);
            var cc3   = new CollectionContainer <int>(rool3);

            croocs.Add(cc3);

            var iterator = croocs.View;
            int i        = 1;

            foreach (var v in iterator)
            {
                Assert.AreEqual(v, i);
                i++;
            }

            Assert.AreEqual(i, 13);
        }
Example #16
0
        public void IteratorTransformingTest()
        {
            var observableCollection = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            });
            var rool  = new ReadOnlyObservableList <int>(observableCollection);
            var frooc = new FilteredReadOnlyObservableList <int>(rool, i => i % 2 == 0);
            TransformingReadOnlyObservableList <int, int> trool = new TransformingReadOnlyObservableList <int, int>(frooc, Selector);

            Assert.AreEqual(trool[0], 4);
            Assert.AreEqual(trool[1], 8);
            Assert.AreEqual(trool[2], 12);
            Assert.AreEqual(trool[3], 16);
            Assert.AreEqual(trool[4], 20);
        }
        public void ClearTest()
        {
            var observableCollection = new ObservableCollection <object>(new List <object>()
            {
                1, 2, 3, 4, 5, 6, 7
            });
            IReadOnlyObservableList <object> rool = new ReadOnlyObservableList <object>(observableCollection);
            SwitchableListSource <object>    sls  = new SwitchableListSource <object>();

            sls.Source = rool;
            TransformingReadOnlyObservableList <object, object> trool =
                new TransformingReadOnlyObservableList <object, object>(sls, Selector);

            observableCollection.Clear();
            Assert.AreEqual(trool.Count, 0);
        }
        public void MoveElementTest()
        {
            var observableCollection = new ObservableCollection <double>(new List <double>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7
            });
            IReadOnlyObservableCollection <double>           source = new ReadOnlyObservableList <double>(observableCollection);
            TransformingReadOnlyObservableList <double, int> trool  = new TransformingReadOnlyObservableList <double, int>(source, Selector);

            Assert.IsTrue(trool.Count() == 7);
            int posOld = 0;
            int posNew = 4;

            observableCollection.Move(posOld, posNew);
            Assert.AreEqual(trool[posNew], 1);
        }
Example #19
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            //var stringList = values.OfType<string>().Where(x => !string.IsNullOrEmpty(x)).ToArray();
            //return string.Join(" - ", stringList);

            ReadOnlyObservableList <QueueListItem> crawlingQueuelistItem = (ReadOnlyObservableList <QueueListItem>)values[0];

            if (crawlingQueuelistItem.Count() == 0)
            {
                return(values[1]);
            }

            string blogStringArray = string.Join(" - ", crawlingQueuelistItem.Select(x => x.Blog.Name));

            return(values[1] + " - " + blogStringArray);
        }
Example #20
0
        public CrawlerService(IShellService shellService)
        {
            _timeconstraintApi =
                RateLimiter.Create(shellService.Settings.MaxConnectionsApi /
                                   (double)shellService.Settings.ConnectionTimeIntervalApi);

            _timeconstraintSvc =
                RateLimiter.Create(shellService.Settings.MaxConnectionsSvc /
                                   (double)shellService.Settings.ConnectionTimeIntervalSvc);

            _activeItems                    = new ObservableCollection <QueueListItem>();
            _readonlyActiveItems            = new ReadOnlyObservableList <QueueListItem>(_activeItems);
            _libraryLoaded                  = new TaskCompletionSource <bool>();
            _databasesLoaded                = new TaskCompletionSource <bool>();
            _activeItems.CollectionChanged += ActiveItemsCollectionChanged;
        }
        public DummyPluginManager(string pluginsFile, IGameMode gameMode, IMod mod)
        {
            StreamReader reader = new StreamReader(pluginsFile);

            string installationPath = Path.Combine(gameMode.GameModeEnvironmentInfo.InstallationPath, gameMode.GetModFormatAdjustedPath(mod.Format, null, false));

            string line;
            while ((line = reader.ReadLine()) != null)
            {
                if (line[0] != '#')
                {
                    m_Plugins.Add(new Plugin(Path.Combine(installationPath, line.ToLower()), line, null));
                }
            }
            ((INotifyCollectionChanged)m_Plugins).CollectionChanged += new NotifyCollectionChangedEventHandler(ActivePlugins_CollectionChanged);
            m_ROOLPlugins = new ReadOnlyObservableList<Plugin>(m_Plugins);
        }
Example #22
0
 /// <summary>
 /// A simple constructor that initializes the object with its dependencies.
 /// </summary>
 public ProfileSwitchSetupTask(ReadOnlyObservableList <IMod> modsToDeactivate, List <IMod> modsToInstall, IProfileManager profileManager, IModProfile profileToInstall,
                               IModProfile profileToSwitch, IInstallLog installLog, ModInstallerFactory modInstallerFactory, VirtualModActivator virtualModActivator, string scriptedLogPath, bool filesOnly,
                               ConfirmActionMethod confirmActionMethod, ConfirmItemOverwriteDelegate overwriteConfirmationDelegate)
 {
     _installLog                    = installLog;
     _modInstallerFactory           = modInstallerFactory;
     _modsToDeactivate              = modsToDeactivate;
     VirtualModActivator            = virtualModActivator;
     _logPath                       = scriptedLogPath;
     _filesOnly                     = filesOnly;
     _profileToInstall              = profileToInstall;
     _profileToSwitch               = profileToSwitch;
     _profileManager                = profileManager;
     _modsToInstall                 = modsToInstall;
     _confirmMethod                 = confirmActionMethod;
     _overwriteConfirmationDelegate = overwriteConfirmationDelegate;
 }
Example #23
0
        public void IteratorTest()
        {
            List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >();

            var observableCollection1 = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3
            });
            var rool1 = new ReadOnlyObservableList <int>(observableCollection1);
            var cc1   = new CollectionContainer <int>(rool1);

            cc.Add(cc1);

            var observableCollection2 = new ObservableCollection <int>(new List <int>()
            {
                4, 5, 6
            });
            var rool2 = new ReadOnlyObservableList <int>(observableCollection2);
            var cc2   = new CollectionContainer <int>(rool2);

            cc.Add(cc2);

            var croocs = new CompositeReadOnlyObservableListSource <int>(cc);

            int i = 1;

            for (int j = 0; j < croocs.Count; j++)
            {
                foreach (var v in croocs[j].Collection)
                {
                    Assert.AreEqual(v, i);
                    i++;
                }
            }
            Assert.AreEqual(i, 7);

            var iterator = croocs.View;

            i = 1;
            foreach (var v in iterator)
            {
                Assert.AreEqual(v, i);
                i++;
            }
        }
        public void SelectedIndexAndItemTest()
        {
            var observableCollection = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3, 4, 5, 6
            });
            var rool = new ReadOnlyObservableList <int>(observableCollection);
            var cs   = new CollectionSelector <int>(rool);

            cs.SelectedItemChanged  += Load1;
            cs.SelectedItemChanging += Load2;
            cs.SelectedIndex         = 1;
            Assert.AreEqual(cs.SelectedItem, 2);
            Assert.AreEqual(changingItems.Count, 1);
            Assert.AreEqual(changingItems[0], -1);
            Assert.AreEqual(changeItems.Count, 1);
            Assert.AreEqual(changeItems[0], 1);
        }
 /// <summary>
 /// Deactivates all the mods.
 /// </summary>
 /// <param name="p_rolModList">The list of Active Mods.</param>
 public void DeactivateMultipleMods(ReadOnlyObservableList <IMod> p_rolModList, bool booForceUninstall)
 {
     if ((p_rolModList != null) && (p_rolModList.Count > 0))
     {
         if (booForceUninstall)
         {
             DeactivateMods(p_rolModList.ToList());
         }
         else
         {
             DialogResult Result = MessageBox.Show("Do you want to uninstall all the active mods?", "Deativate Mods", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (Result == DialogResult.Yes)
             {
                 DeactivateMods(p_rolModList.ToList());
             }
         }
     }
 }
Example #26
0
        public void Translate_CannotMapMorphemes_ReturnsEmptyTranslation()
        {
            var sourceAnalyzer = Substitute.For <IMorphologicalAnalyzer>();

            sourceAnalyzer.AddAnalyses("habló", new WordAnalysis(new[]
            {
                new TestMorpheme("s1", "v", "talk", MorphemeType.Stem),
                new TestMorpheme("s2", "v", "pst", MorphemeType.Affix)
            }, 0, "v"));
            var targetGenerator = Substitute.For <IMorphologicalGenerator>();
            var targetMorphemes = new ReadOnlyObservableList <IMorpheme>(new ObservableList <IMorpheme>());

            targetGenerator.Morphemes.Returns(targetMorphemes);
            var transferer = new SimpleTransferer(new GlossMorphemeMapper(targetGenerator));
            var engine     = new TransferEngine(sourceAnalyzer, transferer, targetGenerator);

            Assert.That(engine.TranslateWord("habló"), Is.Empty);
        }
        public DummyPluginManager(string pluginsFile, IGameMode gameMode, IMod mod)
        {
            StreamReader reader = new StreamReader(pluginsFile);

            string installationPath = Path.Combine(gameMode.GameModeEnvironmentInfo.InstallationPath, gameMode.GetModFormatAdjustedPath(mod.Format, null, false));

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line[0] != '#')
                {
                    m_Plugins.Add(new Plugin(Path.Combine(installationPath, line.ToLower()), line, null));
                }
            }
            ((INotifyCollectionChanged)m_Plugins).CollectionChanged += new NotifyCollectionChangedEventHandler(ActivePlugins_CollectionChanged);
            m_ROOLPlugins = new ReadOnlyObservableList <Plugin>(m_Plugins);
        }
Example #28
0
        public void AddListWithTransformingTest()
        {
            var croocs     = new CompositeReadOnlyObservableListSource <int>();
            var viewCroocs = croocs.View;

            viewCroocs.CollectionChanged += ViewCroocs_CollectionChanged1;
            TransformingReadOnlyObservableList <int, int> trool = new TransformingReadOnlyObservableList <int, int>(viewCroocs, Selector);

            var observableCollection1 = new ObservableCollection <int>(new List <int>()
            {
                0, 1, 2, 3
            });
            var rool1 = new ReadOnlyObservableList <int>(observableCollection1);
            var cc1   = new CollectionContainer <int>(rool1);

            croocs.Add(cc1);

            var observableCollection2 = new ObservableCollection <int>(new List <int>()
            {
                4, 5, 6
            });
            var rool2 = new ReadOnlyObservableList <int>(observableCollection2);
            var cc2   = new CollectionContainer <int>(rool2);

            croocs.Add(cc2);

            Assert.AreEqual(viewCroocs.Count, 7);
            Assert.AreEqual(viewCroocs[0], 0);
            Assert.AreEqual(viewCroocs[1], 1);
            Assert.AreEqual(viewCroocs[2], 2);
            Assert.AreEqual(viewCroocs[3], 3);
            Assert.AreEqual(viewCroocs[4], 4);
            Assert.AreEqual(viewCroocs[5], 5);
            Assert.AreEqual(viewCroocs[6], 6);

            Assert.AreEqual(trool.Count, 7);
            Assert.AreEqual(trool[0], 0);
            Assert.AreEqual(trool[1], 1);
            Assert.AreEqual(trool[2], 2);
            Assert.AreEqual(trool[3], 3);
            Assert.AreEqual(trool[4], 4);
            Assert.AreEqual(trool[5], 5);
            Assert.AreEqual(trool[6], 6);
        }
		/// <summary>
		/// Activates the given mod.
		/// </summary>
		/// <remarks>
		/// The given mod is either installed or upgraded, as appropriate.
		/// </remarks>
		/// <param name="p_modMod">The mod to install.</param>
		/// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param>
		/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
		public IBackgroundTaskSet Activate(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			ModMatcher mmcMatcher = new ModMatcher(InstallationLog.ActiveMods, true);
			IMod modOldVersion = mmcMatcher.FindAlternateVersion(p_modMod, true);
			ConfirmUpgradeResult curAction = (modOldVersion == null) ? ConfirmUpgradeResult.NormalActivation : p_dlgUpgradeConfirmationDelegate(modOldVersion, p_modMod);
			switch (curAction)
			{
				case ConfirmUpgradeResult.Upgrade:
					ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(modOldVersion, p_modMod, p_dlgOverwriteConfirmationDelegate);
                    return muiUpgrader;
				case ConfirmUpgradeResult.NormalActivation:
					ModInstaller minInstaller = InstallerFactory.CreateInstaller(p_modMod, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods);
					return minInstaller;
				case ConfirmUpgradeResult.Cancel:
					return null;
				default:
					throw new Exception(String.Format("Unrecognized value for ConfirmUpgradeResult: {0}", curAction));
			}
		}
        public void ReplaceElementTest()
        {
            var observableCollection = new ObservableCollection <double>(new List <double>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7
            });
            IReadOnlyObservableCollection <double>           source = new ReadOnlyObservableList <double>(observableCollection);
            TransformingReadOnlyObservableList <double, int> trool  = new TransformingReadOnlyObservableList <double, int>(source, Selector, Delete);

            deleteItems.Clear();

            Assert.IsTrue(trool.Count() == 7);
            int pos = 0;

            observableCollection[pos] = 9.9;
            Assert.AreEqual(trool[pos], 9);
            Assert.AreEqual(deleteItems.Count, 1);
            Assert.AreEqual(deleteItems[0], 1);
        }
Example #31
0
        public void AddElementTest()
        {
            var observableCollection = new ObservableCollection <Person>(new List <Person>()
            {
                new Person(3, "M"), new Person(2, "F"), new Person(1, "M")
            });
            var rool  = new ReadOnlyObservableList <Person>(observableCollection);
            var srool = rool.AsQueryableCollection().OrderBy(x => x.Sex).ThenBy(x => x.Age).ListAsObservable();

            srool.PropertyChanged += SroolOnPropertyChanged;

            observableCollection.Add(new Person(6, "F"));
            observableCollection.Insert(2, new Person(4, "F"));
            observableCollection.Add(new Person(5, "M"));
            observableCollection.Insert(1, new Person(7, "M"));

            Assert.AreEqual(srool.Count, 7);
            Assert.IsTrue(observableCollection.OrderBy(x => x.Sex).ThenBy(x => x.Age).SequenceEqual(srool));
        }
        public void OperationsTest()
        {
            List <CollectionContainer <int> > cc = new List <CollectionContainer <int> >();

            var observableCollection1 = new ObservableCollection <int>(new List <int>()
            {
                1, 2, 3
            });
            var rool1 = new ReadOnlyObservableList <int>(observableCollection1);
            var cc1   = new CollectionContainer <int>(rool1);

            cc.Add(cc1);

            var observableCollection2 = new ObservableCollection <int>(new List <int>()
            {
                5, 7, 8
            });
            var rool2 = new ReadOnlyObservableList <int>(observableCollection2);
            var cc2   = new CollectionContainer <int>(rool2);

            cc.Add(cc2);

            CompositeReadOnlyObservableCollectionSource <int> croocs = new CompositeReadOnlyObservableCollectionSource <int>(cc);

            //[1 2 3 5 7 8]
            observableCollection1.Add(4);
            //[1 2 3 4 5 7 8]
            observableCollection1.Add(8);
            //[1 2 3 4 8 5 7 8]
            observableCollection2.Insert(1, 6);
            //[1 2 3 4 8 5 6 7 8]
            observableCollection1.Remove(8);
            //[1 2 3 4 5 6 7 8]

            var iterator = croocs.View;
            int i        = 1;

            foreach (var v in iterator)
            {
                Assert.AreEqual(v, i);
                i++;
            }
        }
        public void OnRemoveElementTest2()
        {
            var observableCollection = new ObservableCollection <double>(new List <double>()
            {
                1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7
            });
            IReadOnlyObservableCollection <double>           source = new ReadOnlyObservableList <double>(observableCollection);
            TransformingReadOnlyObservableList <double, int> trool  = new TransformingReadOnlyObservableList <double, int>(source, Selector, Delete);

            Assert.IsTrue(observableCollection.Remove(2.2));
            Assert.AreEqual(trool.Count, 6);
            Assert.AreEqual(deleteItems.Count, 1);
            Assert.AreEqual(deleteItems[0], 2);

            observableCollection.RemoveAt(3);
            Assert.AreEqual(trool.Count, 5);
            Assert.AreEqual(deleteItems.Count, 2);
            Assert.AreEqual(deleteItems[1], 5);
            Assert.AreEqual(trool[1], 3);
        }
        public void OperationsTest()
        {
            var observableCollection = new ObservableCollection <object>(new List <object>()
            {
                1, 2, 3, 4, 5, 6, 7
            });
            IReadOnlyObservableList <object> rool = new ReadOnlyObservableList <object>(observableCollection);
            SwitchableListSource <object>    sls  = new SwitchableListSource <object>();

            sls.Source = rool;
            TransformingReadOnlyObservableList <object, object> trool = new TransformingReadOnlyObservableList <object, object>(sls, Selector, Delete);

            deleteItems.Clear();

            //[1 2 3 4 5 6 7]
            observableCollection.Insert(3, 8);
            //[1 2 3 8 4 5 6 7]
            observableCollection.Add(9);
            //[1 2 3 8 4 5 6 7 9]
            observableCollection.RemoveAt(0);
            //[2 3 8 4 5 6 7 9]
            observableCollection[2] = 10;
            //[2 3 10 4 5 6 7 9]
            observableCollection.Move(4, 5);
            //[2 3 10 4 6 5 7 9]

            Assert.AreEqual(deleteItems.Count, 2);
            Assert.AreEqual(deleteItems[0], 1);
            Assert.AreEqual(deleteItems[1], 8);

            Assert.AreEqual(trool.Count, 8);
            Assert.AreEqual(trool[0], 2);
            Assert.AreEqual(trool[1], 3);
            Assert.AreEqual(trool[2], 10);
            Assert.AreEqual(trool[3], 4);
            Assert.AreEqual(trool[4], 6);
            Assert.AreEqual(trool[5], 5);
            Assert.AreEqual(trool[6], 7);
            Assert.AreEqual(trool[7], 9);
        }
Example #35
0
        public void AddElementTest()
        {
            var observableCollection = new ObservableCollection <Person>(new List <Person>()
            {
                new Person(3), new Person(2), new Person(1)
            });
            var rool  = new ReadOnlyObservableList <Person>(observableCollection);
            var srool = new SortedReadOnlyObservableList <Person>(rool, Person.CompareByAge, nameof(Person.Age));

            srool.PropertyChanged += SroolOnPropertyChanged;

            observableCollection.Add(new Person(6));
            observableCollection.Insert(2, new Person(4));
            observableCollection.Add(new Person(5));
            observableCollection.Insert(1, new Person(7));

            Assert.AreEqual(srool.Count, 7);
            for (int i = 0; i < observableCollection.Count; i++)
            {
                Assert.AreEqual(srool[i].Age, i + 1);
            }
        }
        public void AddElementTest()
        {
            var observableCollection = new ObservableCollection <Observable>(new List <Observable>()
            {
                new Observable(3), new Observable(2), new Observable(1)
            });
            var rool  = new ReadOnlyObservableList <Observable>(observableCollection);
            var srool = new KeySortedReadOnlyObservableList <Observable, int>(rool, x => x.Subject, null, null);

            srool.PropertyChanged += SroolOnPropertyChanged;

            observableCollection.Add(new Observable(6));
            observableCollection.Insert(2, new Observable(4));
            observableCollection.Add(new Observable(5));
            observableCollection.Insert(1, new Observable(7));

            Assert.AreEqual(srool.Count, 7);
            for (int i = 0; i < observableCollection.Count; i++)
            {
                Assert.AreEqual(srool[i].Prop, i + 1);
            }
        }
Example #37
0
        public void TransformingOperationsTest1()
        {
            var observableCollection = new ObservableCollection <Person>(new List <Person>()
            {
                new Person(3, "M"), new Person(1, "M"), new Person(7, "M"), new Person(5, "M"), new Person(4, "F"), new Person(6, "F"), new Person(2, "F"), new Person(7, "M")
            });
            var rool  = new ReadOnlyObservableList <Person>(observableCollection);
            var srool = rool.AsQueryableCollection().OrderBy(x => x.Sex).ThenBy(x => x.Age).ListAsObservable();
            var trool = new TransformingReadOnlyObservableList <Person, int>(srool, Selector);

            Assert.AreEqual(srool.Count, 8);
            Assert.IsTrue(observableCollection.OrderBy(x => x.Sex).ThenBy(x => x.Age).SequenceEqual(srool));

            observableCollection.Add(new Person(10, "F"));
            observableCollection.Insert(3, new Person(9, "M"));
            observableCollection.Move(5, 2);
            observableCollection[8] = new Person(8, "F");

            Assert.AreEqual(srool.Count, 10);
            Assert.IsTrue(observableCollection.OrderBy(x => x.Sex).ThenBy(x => x.Age).SequenceEqual(srool));
            Assert.IsTrue(observableCollection.OrderBy(x => x.Sex).ThenBy(x => x.Age).Select(x => x.Age).SequenceEqual(trool));
        }
Example #38
0
        public TextViewModel(ITokenizer <string, int> tokenizer, string name, string metadataFileName,
                             string sourceFileName, string targetFileName, string alignmentFileName)
        {
            Name = name;
            _metadataFileName  = metadataFileName;
            _targetFileName    = targetFileName;
            _alignmentFileName = alignmentFileName;
            _tokenizer         = tokenizer;

            _sourceSegments                = new List <Segment>();
            _targetSegments                = new List <Segment>();
            _approvedSegments              = new HashSet <int>();
            _paragraphs                    = new HashSet <int>();
            _goToNextSegmentCommand        = new RelayCommand(GoToNextSegment, CanGoToNextSegment);
            _goToPrevSegmentCommand        = new RelayCommand(GoToPrevSegment, CanGoToPrevSegment);
            _approveSegmentCommand         = new RelayCommand(ApproveSegment, CanApproveSegment);
            _applyAllSuggestionsCommand    = new RelayCommand(ApplyAllSuggestions, CanApplyAllSuggestions);
            _selectSourceSegmentCommand    = new RelayCommand <int>(SelectSourceSegment);
            _selectTargetSegmentCommand    = new RelayCommand <int>(SelectTargetSegment);
            _suggestions                   = new BulkObservableList <SuggestionViewModel>();
            Suggestions                    = new ReadOnlyObservableList <SuggestionViewModel>(_suggestions);
            _sourceSegmentWords            = new List <string>();
            _unapprovedTargetSegmentRanges = new BulkObservableList <Range <int> >();
            UnapprovedTargetSegmentRanges  = new ReadOnlyObservableList <Range <int> >(
                _unapprovedTargetSegmentRanges);
            _alignedSourceWords = new BulkObservableList <AlignedWordViewModel>();
            AlignedSourceWords  = new ReadOnlyObservableList <AlignedWordViewModel>(_alignedSourceWords);
            _suggester          = new WordTranslationSuggester()
            {
                ConfidenceThreshold = 0.2
            };

            LoadMetadataFile();
            LoadTextFile(sourceFileName, _sourceSegments);
            SourceText = GenerateText(_sourceSegments);
            LoadTextFile(_targetFileName, _targetSegments);
            TargetText = GenerateText(_targetSegments);
            UpdateUnapprovedTargetSegmentRanges();
        }
 public TranscodingManager()
 {
     this.transcodeItems = new ObservableCollection<TranscodeItem>();
     this.readOnlyTranscodeItems = new ReadOnlyObservableList<TranscodeItem>(transcodeItems);
 }
Example #40
0
		/// <summary>
		/// Activates the given mod.
		/// </summary>
		/// <param name="p_modMod">The mod to activate.</param>
		/// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param>
		/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
		/// <param name="p_rolActiveMods">The list or Active mods.</param>
		/// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
		public IBackgroundTaskSet ActivateMod(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			if (InstallationLog.ActiveMods.Contains(p_modMod))
				return null;
			DeleteXMLInstalledFile(p_modMod);
			return Activator.Activate(p_modMod, p_dlgUpgradeConfirmationDelegate, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods);
		}
Example #41
0
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_futFileUtility">The file utility class.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
        public ModInstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods, ModManager p_mmModManager)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			FileUtility = p_futFileUtility;
			UIContext = p_scxUIContext;
			ModInstallLog = p_ilgModInstallLog;
			PluginManager = p_pmgPluginManager;
			m_dlgOverwriteConfirmationDelegate = p_dlgOverwriteConfirmationDelegate;
			ActiveMods = p_rolActiveMods;
            m_mmModManager = p_mmModManager;
		}
Example #42
0
		/// <summary>
		/// Deletes the given mod.
		/// </summary>
		/// <remarks>
		/// The mod is deactivated, unregistered, and then deleted.
		/// </remarks>
		/// <param name="p_modMod">The mod to delete.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <returns>A background task set allowing the caller to track the progress of the operation,
		/// or <c>null</c> if no long-running operation needs to be done.</returns>
		public IBackgroundTaskSet DeleteMod(IMod p_modMod, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			ModDeleter mddDeleter = InstallerFactory.CreateDelete(p_modMod, p_rolActiveMods);
			mddDeleter.TaskSetCompleted += new EventHandler<TaskSetCompletedEventArgs>(Deactivator_TaskSetCompleted);
			mddDeleter.Install();
			DeleteXMLInstalledFile(p_modMod);
			return mddDeleter;
		}
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
        public ModUninstaller(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ReadOnlyObservableList<IMod> p_rolActiveMods, ModManager p_mmModManager)
		{
			Mod = p_modMod;
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			ModInstallLog = p_ilgModInstallLog;
			PluginManager = p_pmgPluginManager;
			ActiveMods = p_rolActiveMods;
            m_mmModManager = p_mmModManager;
		}
        /// <summary>
        /// Merges the chargenmorphcfg.xml file of the Dragon Age mods.
        /// </summary>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <param name="p_modMod">The current mod.</param>
		/// <param name="p_booRemove">Whether we're adding or removing the mod.</param>
		public override void ModFileMerge(ReadOnlyObservableList<IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove)
        {
            
            List<string> lstFiles = null;
            XDocument XDoc = null;
            XDocument XDocMerge = null;
            bool booMerge = false;            
            Byte[] bFile = null;
            strXMLDirectory = Path.Combine(m_gmdGameModeInfo.InstallationPath, "NMM_chargenmorphcfg");

            #region activeMods

			if (p_booRemove && File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml")))
				File.Delete(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));


			if ((!File.Exists(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"))) || (p_booRemove))
            {
				foreach (IMod modMod in p_rolActiveMods)
                {
					if (modMod.Filename != p_modMod.Filename)
                    {
                        lstFiles = modMod.GetFileList();

                        foreach (string strFile in lstFiles)
                        {
                            if (strFile.EndsWith("chargenmorphcfg.xml"))
                            {
                                bFile = modMod.GetFile(strFile);
                                string responseText = Encoding.ASCII.GetString(bFile);

                                XDoc = XDocument.Parse(responseText.Replace("???", ""));
                                if (XDocMerge == null)
                                {
                                    XDocMerge = XDoc;
                                    booMerge = true;
                                }
                                else
                                {
                                    foreach (XElement ele in XDoc.Root.Elements())
                                    {
                                        XElement xeDoc = XDoc.Root.Element(ele.Name.ToString());
                                        XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                        MergeElements(xeDoc, xeDocMerge);
                                    }

                                }
                            }
                        }
                    }
                }
            }
            else
            {

                bFile = File.ReadAllBytes(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
                string responseText = Encoding.ASCII.GetString(bFile);

                XDoc = XDocument.Parse(responseText.Replace("???", ""));
                booMerge = true;
            }

            #endregion

            #region currentMod
			if ((p_modMod != null) && (!p_rolActiveMods.Contains(p_modMod)))
            {
				lstFiles = p_modMod.GetFileList();
                foreach (string strFile in lstFiles)
                {
                    if (strFile.EndsWith("chargenmorphcfg.xml"))
                    {
						bFile = p_modMod.GetFile(strFile);
                        string responseText = Encoding.ASCII.GetString(bFile);

                        XDocMerge = XDocument.Parse(responseText.Replace("???", ""));

                        if (booMerge)
                        {
                            foreach (XElement ele in XDoc.Root.Elements())
                            {
                                XElement xeDoc = XDoc.Root.Element(ele.Name.ToString());
                                XElement xeDocMerge = XDocMerge.Root.Element(ele.Name.ToString());
                                MergeElements(xeDoc, xeDocMerge);
                            }
                        }
                    }
                }
            }
            #endregion

            if (!Directory.Exists(strXMLDirectory))
                Directory.CreateDirectory(strXMLDirectory);

            if(XDoc != null)
                XDoc.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            else if(XDocMerge != null)
                XDocMerge.Save(Path.Combine(strXMLDirectory, "chargenmorphcfg.xml"));
            
        }
		/// <summary>
		/// Merges the mod files if requested by the game.
		/// </summary>
		/// <returns>Merges the mod files if requested by the game.</returns>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <param name="p_modMod">The current mod.</param>
		/// <param name="p_booRemove">Whether we're adding or removing the mod.</param>
		public virtual void ModFileMerge(ReadOnlyObservableList<IMod> p_rolActiveMods, IMod p_modMod, bool p_booRemove)
		{
		}
Example #46
0
		/// <summary>
		/// Deactivates all the mods.
		/// </summary>
		/// <param name="p_rolModList">The list of Active Mods.</param>
        public void DeactivateMultipleMods(ReadOnlyObservableList<IMod> p_rolModList, bool booForceUninstall)
		{
			if ((p_rolModList != null) && (p_rolModList.Count > 0))
			{
				if (booForceUninstall)
					DeactivateMods(p_rolModList.ToList());
				else
				{
					DialogResult Result = MessageBox.Show("Do you want to uninstall all the active mods?", "Deativate Mods", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
					if (Result == DialogResult.Yes)
					{
						DeactivateMods(p_rolModList.ToList());
					}
				}
			}
		}
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod being installed.</param>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_ilgModInstallLog">The install log that tracks mod install info
		/// for the current game mode</param>
		/// <param name="p_pmgPluginManager">The plugin manager.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		public ModDeleter(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IInstallLog p_ilgModInstallLog, IPluginManager p_pmgPluginManager, ReadOnlyObservableList<IMod> p_rolActiveMods)
            : base(p_modMod, p_gmdGameMode, p_eifEnvironmentInfo, p_ilgModInstallLog, p_pmgPluginManager, p_rolActiveMods, null)
		{
		}
Example #48
0
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
		/// of supported <see cref="IModFormat"/>s.</param>
		/// <param name="p_gmdGameMode">The <see cref="IGameMode"/> for which mods are to be registered.</param>
		public ModRegistry(IModFormatRegistry p_frgFormatRegistry, IGameMode p_gmdGameMode)
		{
			GameMode = p_gmdGameMode;
			FormatRegistry = p_frgFormatRegistry;
			RegisteredMods = new ReadOnlyObservableList<IMod>(m_oclRegisteredMods);
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		public DeactivateMultipleModsTask(ReadOnlyObservableList<IMod> p_rolModList, IInstallLog p_iilInstallLog, ModInstallerFactory p_mifModInstallerFactory)
		{
			m_iilInstallLog = p_iilInstallLog;
			m_mifModInstallerFactory = p_mifModInstallerFactory;
			m_rolModList = p_rolModList;
		}
Example #50
0
		/// <summary>
		/// Runs the managed updaters.
		/// </summary>
		/// <param name="p_rolModList">The mod list.</param>
		/// <param name="p_camConfirm">The delegate to call to confirm an action.</param>
		/// <returns>The background task that will run the updaters.</returns>
		public IBackgroundTask DeactivateMultipleMods(ReadOnlyObservableList<IMod> p_rolModList, ConfirmActionMethod p_camConfirm)
		{
			DeactivateMultipleModsTask dmmDeactivateAllMods = new DeactivateMultipleModsTask(p_rolModList, this.InstallationLog, this.InstallerFactory);
			dmmDeactivateAllMods.Update(p_camConfirm);
			return dmmDeactivateAllMods;
		}
		/// <summary>
		/// The default constructor.
		/// </summary>
		public ActivityMonitor()
		{
			Tasks = new ReadOnlyObservableList<IBackgroundTask>(m_oclTasks);
			ActiveTasks = new ReadOnlyObservableList<IBackgroundTask>(m_setActiveTasks);
		}
		private void OnDeserialized(StreamingContext context)
		{
			AddHousesListListeners(this.houses);
			this.housesReadOnly = new ReadOnlyObservableList<House>(this.houses);
			AddHousesLazyListListeners(this.housesLazy);
			if (this.housesLazy != null)
				this.housesLazyReadOnly = new ReadOnlyObservableList<House>(this.housesLazy);
		}
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_mprManagedPluginRegistry">The <see cref="PluginRegistry"/> that contains the list
		/// of managed <see cref="Plugin"/>s.</param>
		/// <param name="p_posOrderSerializer">The object that serializes and deserializes
		/// data from a plugin order log permanent store.</param>
		/// <param name="p_povOrderValidator">The object that validates plugin order.</param>
		private PluginOrderLog(PluginRegistry p_mprManagedPluginRegistry, IPluginOrderLogSerializer p_posOrderSerializer, IPluginOrderValidator p_povOrderValidator)
		{			
			ManagedPluginRegistry = p_mprManagedPluginRegistry;
			LogSerializer = p_posOrderSerializer;
			OrderValidator = p_povOrderValidator;
			LoadPluginOrder();
			m_rolOrderedPlugins = new ReadOnlyObservableList<Plugin>(m_oclOrderedPlugins);
		}
		/// <summary>
		/// The default constructor.
		/// </summary>
		public DownloadMonitor()
		{
			Tasks = new ReadOnlyObservableList<AddModTask>(m_oclTasks);
			ActiveTasks = new ReadOnlyObservableList<AddModTask>(m_setActiveTasks);
		}
 public MockSelectionService()
 {
     this.innerMusicFiles = new ObservableCollection<MusicFileDataModel>();
     this.selectedMusicFiles = new ObservableCollection<MusicFileDataModel>();
     this.musicFiles = new ReadOnlyObservableList<MusicFileDataModel>(innerMusicFiles);
 }
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_pgfPluginFactory">The factory to use to create plugins.</param>
		public PluginRegistry(IPluginFactory p_pgfPluginFactory)
		{
			PluginFactory = p_pgfPluginFactory;
			RegisteredPlugins = new ReadOnlyObservableList<Plugin>(m_ostRegisteredPlugins);
		}
		protected virtual void LazyInitHousesLazy()
		{
			if (this.housesLazy != null)
				return;
				
			this.housesLazy = new ObservableList<House>();
			AddHousesLazyListListeners(this.housesLazy);
			
			this.housesLazyReadOnly = new ReadOnlyObservableList<House>(this.housesLazy);
		}
		private void OnDeserializing(StreamingContext context)
		{
			this.houses = new ObservableList<House>();
			this.housesReadOnly = new ReadOnlyObservableList<House>(this.houses);
		}
Example #59
0
		/// <summary>
		/// Runs the basic install script.
		/// </summary>
		/// <remarks>
		/// A basic install installs all of the files in the mod to the installation directory,
		/// and activates all plugin files.
		/// </remarks>
		/// <param name="p_mfiFileInstaller">The file installer to use.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <returns><c>true</c> if the installation was successful;
		/// <c>false</c> otherwise.</returns>
		protected bool RunBasicInstallScript(IModFileInstaller p_mfiFileInstaller, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			BasicInstallTask bitTask = new BasicInstallTask(Mod, GameMode, p_mfiFileInstaller, PluginManager, EnvironmentInfo.Settings.SkipReadmeFiles, p_rolActiveMods);
			OnTaskStarted(bitTask);
			return bitTask.Execute();
		}
Example #60
0
		/// <summary>
		/// deactivates the given mod.
		/// </summary>
		/// <param name="p_modMod">The mod to deactivate.</param>
		/// <param name="p_rolActiveMods">The list of active mods.</param>
		/// <returns>A background task set allowing the caller to track the progress of the operation.</returns>
		public IBackgroundTaskSet DeactivateMod(IMod p_modMod, ReadOnlyObservableList<IMod> p_rolActiveMods)
		{
			if (!InstallationLog.ActiveMods.Contains(p_modMod))
				return null;
			ModUninstaller munUninstaller = InstallerFactory.CreateUninstaller(p_modMod, p_rolActiveMods);
			munUninstaller.Install();
			DeleteXMLInstalledFile(p_modMod);
			return munUninstaller;
		}