상속: DialogService
예제 #1
0
        public SystemTrayViewModel(IWindowManager windowManager, MetroDialogService dialogService,
            ShellViewModel shellViewModel, MainManager mainManager)
        {
            _windowManager = windowManager;
            _shellViewModel = shellViewModel;

            DialogService = dialogService;
            MainManager = mainManager;

            MainManager.EnableProgram();
            MainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;

            var generalSettings = SettingsProvider.Load<GeneralSettings>();
            Enabled = !generalSettings.Suspended;
            if (generalSettings.ShowOnStartup)
                ShowWindow();
        }
예제 #2
0
        /// <summary>
        ///     Checks to see if the program has updated and shows a dialog if so.
        /// </summary>
        /// <param name="dialogService">The dialog service to use for progress and result dialogs</param>
        /// <returns></returns>
        public static async Task CheckChangelog(MetroDialogService dialogService)
        {
            var settings = SettingsProvider.Load<GeneralSettings>();
            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            if ((settings.LastRanVersion != null) && (currentVersion > settings.LastRanVersion))
            {
                Logger.Info("Updated from {0} to {1}, showing changelog.", settings.LastRanVersion, currentVersion);

                // Ask the user whether he/she wants to see what's new
                var showChanges = await dialogService.
                    ShowQuestionMessageBox("New version installed",
                        $"Artemis has recently updated from version {settings.LastRanVersion} to {currentVersion}. \n" +
                        "Would you like to see what's new?");

                // If user wants to see changelog, show it to them
                if ((showChanges != null) && showChanges.Value)
                    await ShowChanges(dialogService, currentVersion);
            }

            settings.LastRanVersion = currentVersion;
            settings.Save();
        }
예제 #3
0
        public ProfileEditorViewModel(MainManager mainManager, EffectModel gameModel, ProfileViewModel profileViewModel,
            MetroDialogService dialogService, string lastProfile, ILayerEditorVmFactory layerEditorVmFactory)
        {
            _mainManager = mainManager;
            _gameModel = gameModel;
            _layerEditorVmFactory = layerEditorVmFactory;

            Profiles = new BindableCollection<ProfileModel>();
            Layers = new BindableCollection<LayerModel>();
            ProfileViewModel = profileViewModel;
            DialogService = dialogService;
            LastProfile = lastProfile;

            PropertyChanged += EditorStateHandler;
            ProfileViewModel.PropertyChanged += LayerSelectedHandler;
            mainManager.DeviceManager.OnKeyboardChangedEvent += DeviceManagerOnOnKeyboardChangedEvent;

            _saveTimer = new Timer(5000);
            _saveTimer.Elapsed += ProfileSaveHandler;

            LoadProfiles();
        }
예제 #4
0
        /// <summary>
        ///     Fetches all releases from GitHub, looks up the current release and shows the changelog
        /// </summary>
        /// <param name="dialogService">The dialog service to use for progress and result dialogs</param>
        /// <param name="version">The version to fetch the changelog for</param>
        /// <returns></returns>
        private static async Task ShowChanges(MetroDialogService dialogService, Version version)
        {
            var progressDialog = await dialogService.ShowProgressDialog("Changelog", "Fetching release data from GitHub..");
            progressDialog.SetIndeterminate();

            var jsonClient = new WebClient();

            // GitHub trips if we don't add a user agent
            jsonClient.Headers.Add("user-agent",
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

            // Random number to get around cache issues
            var rand = new Random(DateTime.Now.Millisecond);
            var json = await jsonClient.DownloadStringTaskAsync(
                "https://api.github.com/repos/SpoinkyNL/Artemis/releases?random=" + rand.Next());

            // Get a list of releases
            var releases = JsonConvert.DeserializeObject<JArray>(json);
            var release = releases.FirstOrDefault(r => r["tag_name"].Value<string>() == version.ToString());
            try
            {
                await progressDialog.CloseAsync();
            }
            catch (InvalidOperationException)
            {
                // Occurs when main window is closed before finished
            }

            if (release != null)
                dialogService.ShowMessageBox(release["name"].Value<string>(), release["body"].Value<string>());
            else
                dialogService.ShowMessageBox("Couldn't fetch release",
                    "Sorry, Artemis was unable to fetch the release data off of GitHub.\n" +
                    "If you'd like, you can always find out the latest changes on the GitHub page accessible from the options menu");
        }