Example #1
0
        public void CheckForUpdatesAsync_Fail_Test()
        {
            target          = new UpdateChecker(@"https://tikzedt.googlecode.com/svn/trunk/junk.junk");
            target.Status  += (s, e) => statusargs = e;
            target.Success += (s, e) => successargs = e;
            successargs     = null;
            statusargs      = null;

            bool expected = true;
            bool actual;

            actual = target.CheckForUpdatesAsync();
            Assert.AreEqual(expected, actual);

            Assert.IsNull(successargs);
            Assert.IsNotNull(statusargs);

            Assert.IsTrue(statusargs.HasFailed);
        }
Example #2
0
        public void CheckForUpdatesAsyncTest()
        {
            target          = new UpdateChecker(@"https://tikzedt.googlecode.com/svn/trunk/VersionInfo.xml");
            target.Status  += (s, e) => statusargs = e;
            target.Success += (s, e) => successargs = e;
            successargs     = null;
            statusargs      = null;

            bool expected = true;
            bool actual;

            actual = target.CheckForUpdatesAsync();
            Assert.AreEqual(expected, actual);

            Assert.IsNotNull(successargs);
            Assert.IsNotNull(statusargs);

            Assert.IsFalse(statusargs.HasFailed);
            Assert.IsTrue(Uri.IsWellFormedUriString(successargs.DownloadURL, UriKind.Absolute));
            Assert.IsTrue(Uri.IsWellFormedUriString(successargs.WebpageURL, UriKind.Absolute));
        }
Example #3
0
        private void MainWindow_Load(object z, EventArgs x)
        {
            modListControl1.SetWorker("Loading...");
            ToggleConsole(false);

            UpdateChk = new UpdateChecker(BuildData.CurrentVersion, BuildData.UpdateUrl, new Action(() => {
                this.Invoke(new MethodInvoker(() =>
                {
                    var dialog = GUI.MessageBox.Show(this, "New version of OpenModManager is avaiable!\nDo you want to download it?", "Update checker", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialog == DialogResult.Yes)
                    {
                        Process.Start(BuildData.ReleasesPage);
                    }
                }));
            }));

            modListControl1.AddModSource(new ModDirectorySource("Mods directory", Path.Combine(Program.ProcFactory.GetGamePath(), @"HatinTimeGame\Mods"), true));
            modListControl1.AddModSource(new ModDirectorySource("Mods directory (disabled)", Path.Combine(Program.ProcFactory.GetGamePath(), @"HatinTimeGame\Mods\Disabled"), true, true, true));

            var autoLoad = Properties.Settings.Default.AutoScanDownloadedMods;

            modListControl1.AddModSource(new ModDirectorySource("Downloaded mods", GameFinder.GetWorkshopDir(), autoLoad, false, true));
            modListControl1.AddModSource(new ModDirectorySource("Downloaded mods (disabled)", Path.Combine(GameFinder.GetWorkshopDir(), "Disabled"), autoLoad, false, true));

            modListControl1.ReloadList();

            SetModListState(null);

            Automation.AddAutomationEventHandler(
                WindowPattern.WindowOpenedEvent,
                AutomationElement.RootElement,
                TreeScope.Children,
                (sender, e) =>
            {
                var element = sender as AutomationElement;
                Console.WriteLine("new window opened");
            });

            UpdateChk.CheckForUpdatesAsync();
        }
Example #4
0
        private async void Start()
        {
            var aggregator = new MessageAggregator();

            _relay = aggregator;
            IConfigStore       configStore  = new ConfigStore(Application.persistentDataPath);
            IPreviewImageStore previewStore = new PreviewImageStore(Application.persistentDataPath);

            _library = new Library(configStore, _previewBuilder, previewStore, _relay);
            var factory = new ImportFolderFactory(_library);

            // Misc
            var checker         = new UpdateChecker(_relay);
            var appVersionModel = new AppVersionDisplayModel(_relay);

            _tracker = new SelectionTracker(_library);

            // Main View
            var progressModel    = new ProgressModel();
            var applicationModel = new ApplicationModel(_relay);
            var searchViewModel  = new SearchModel(_library, _relay);
            var itemsViewModel   = new ItemsModel(_library, _relay);

            // Main Menu
            var importFoldersViewModel = new ImportFoldersModel(configStore, factory, _relay);
            var savedSearchesViewModel = new SavedSearchesModel(configStore, _relay);
            var collectionsViewModel   = new CollectionsModel(configStore, _library, _relay);

            // Detail Menu
            var detailMenuModel = new DetailMenuModel(_library, _relay);

            // Dialogs
            var addCollectionModel       = new AddCollectionModel(_relay);
            var addSavedSearchViewModel  = new AddSavedSearchModel(_relay);
            var addImportFolderViewModel = new AddImportFolderModel(_relay);
            var applicationSettingsModel = new ApplicationSettingsModel(configStore);
            var userFeedbackModel        = new UserFeedbackModel();
            var updateNotificationModel  = new UpdateNotificationModel(configStore);
            var exitingModel             = new ExitingModel(_library, OnShutdownComplete);
            var editScreenModel          = new EditScreenModel(_library);

            BindViewModels();
            BindSettings();

            // Wire up misc items
            _disposables.Add(importFoldersViewModel);
            _editScreen.MainView = _mainGroup;

            // Also restores app settings for import etc.
            await applicationSettingsModel.InitializeAsync();

            await _library.InitializeAsync();

            InitializeViewModelsAsync();

            aggregator.Subscribe(
                // Main View
                progressModel,
                searchViewModel,
                itemsViewModel,

                // Main Menu
                importFoldersViewModel,
                savedSearchesViewModel,
                collectionsViewModel,

                // DetailMenu
                detailMenuModel,

                // Misc
                appVersionModel,
                _tracker,

                // Dialogs
                addCollectionModel,
                addSavedSearchViewModel,
                addImportFolderViewModel,
                applicationSettingsModel,
                userFeedbackModel,
                updateNotificationModel,
                exitingModel,
                editScreenModel);

            void BindViewModels()
            {
                // Main View
                _progressView.BindTo(progressModel);
                _applicationView.BindTo(applicationModel);
                _searchView.BindTo(searchViewModel);
                _libraryView.BindTo(itemsViewModel);

                // Main Menu
                _importFoldersView.BindTo(importFoldersViewModel);
                _savedSearchesView.BindTo(savedSearchesViewModel);
                _collectionsView.BindTo(collectionsViewModel);

                // Detail Menu
                _detailMenu.BindTo(detailMenuModel);

                // Misc
                _versionButton.BindTo(appVersionModel);

                // Dialogs
                _addCollectionDialog.BindTo(addCollectionModel);
                _addImportFolderDialog.BindTo(addImportFolderViewModel);
                _addSavedSearchDialog.BindTo(addSavedSearchViewModel);
                _applicationSettingsDialog.BindTo(applicationSettingsModel);
                _userFeedbackDialog.BindTo(userFeedbackModel);
                _updateNotificationDialog.BindTo(updateNotificationModel);
                _exitingDialog.BindTo(exitingModel);
                _editScreen.BindTo(editScreenModel);
            }

            void BindSettings()
            {
                var rt = applicationSettingsModel.RuntimeSettings;

                rt.ImportParallelism.ValueChanged += factor => _library.Parallelism = factor;
                rt.LogLevel.ValueChanged          += logLevel => UnityLogger.LogLevel = logLevel;

                rt.UiScalePercent.ValueChanged += factor =>
                {
                    foreach (var canvas in FindObjectsOfTypeAll <CanvasScaler>())
                    {
                        canvas.scaleFactor = applicationSettingsModel.UiScalePercent / 125f;
                    }
                };

                rt.ScrollSensitivity.ValueChanged += sensitivity =>
                {
                    foreach (var area in FindObjectsOfType <ScrollRect>())
                    {
                        area.scrollSensitivity = sensitivity;
                    }
                };

                rt.PreviewResolution.ValueChanged  += res => _previewBuilder.PreviewResolution.Value = Mathf.RoundToInt(Mathf.Pow(2f, res));
                rt.PreviewJpegQuality.ValueChanged += quality => _previewBuilder.Quality = quality;
            }

            async void InitializeViewModelsAsync()
            {
                await savedSearchesViewModel.InitializeAsync();

                await importFoldersViewModel.InitializeAsync();

                await collectionsViewModel.InitializeAsync();

                await updateNotificationModel.InitializeAsync();

                // run update checks
                await checker.CheckForUpdatesAsync();
            }
        }