Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public async Task RemoveApplicationAsync(InstalledApplication app)
        {
            if (!app.CanRemove)
            {
                RaiseError("このアプリケーションを登録解除することはできません。");
            }

            Applications.Remove(app);

            await SaveAsync().ConfigureAwait(false);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicationPath"></param>
        /// <returns></returns>
        public async Task RegisterInstalledApplication(string applicationPath)
        {
            if (Applications.Any(x => String.Equals(x.InstalledPath, applicationPath)))
            {
                RaiseError("既に登録済みのアプリケーションです。");
                return;
            }

            var application = new InstalledApplication(applicationPath);

            await application.InitializeAsync(_appInfo).ConfigureAwait(false);

            if (!application.IsSupported)
            {
                RaiseError("サポートされていないアプリケーションです。");
                return;
            }

            Applications.Add(application);

            await SaveAsync().ConfigureAwait(false);
        }
Example #3
0
        public ApplicationViewModel(ApplicationManager manager, InstalledApplication app)
        {
            _app = app;

            DisplayName = app.ObserveProperty(x => x.DisplayName).ToReactiveProperty();
            Definition = app.ObserveProperty(x => x.Definition).ToReactiveProperty();
            InstalledPath = app.ObserveProperty(x => x.InstalledPath).ToReactiveProperty();
            IsApplicationMissing = InstalledPath.Select(File.Exists).ToReactiveProperty();

            var currentVersion = app.ObserveProperty(x => x.ApplicationVersion).ToReactiveProperty();

            Version = currentVersion.Where(x => x != null)
                                    .Select(x => x.ToString())
                                    .ToReactiveProperty();

            Image64 = InstalledPath.Select(x => GetIcon(x, 64)).ToReactiveProperty();
            Image128 = InstalledPath.Select(x => GetIcon(x, 128)).ToReactiveProperty();

            Latest = app.ObserveProperty(x => x.Latest).ToReactiveProperty();

            HasUpdate = Latest.Select(x => x != null).ToReactiveProperty();
            HasUpdateMessage = HasUpdate.Select(x => x ? "最新版があります" : "お使いのバージョンは最新です").ToReactiveProperty();

            LatestVersion = Latest.CombineLatest(currentVersion, (latest, current) => latest != null ? latest.Version : current)
                                  .Where(x => x != null)
                                  .Select(x => x.ToString())
                                  .ToReactiveProperty();

            ReleaseNote = Latest.Select(x => x != null ? x.ReleaseNote : "更新情報はありません。")
                                .ToReactiveProperty();

            ExecuteCommand = new ReactiveCommand(app.ObserveProperty(x => x.CanExecute));
            ExecuteCommand.Subscribe(_ =>
            {
                app.ExecuteAsync();
            });

            UpdateCommand = new ReactiveCommand(Latest.Select(x => x != null));
            UpdateCommand.Subscribe(async _ =>
            {
                var res = await Messenger.GetResponse(new AsyncConfirmationMessage
                {
                    MessageKey = "Confirm",
                    Caption = "確認",
                    Text = app.UpdateConfirmationMessage

                }).Response;

                if (res != true) return;

                await app.UpdateAsync();

                Messenger.Raise(new AsyncInformationMessage
                {
                    MessageKey = "Close"
                });

                Messenger.Raise(new AsyncInformationMessage
                {
                    MessageKey = "Information",
                    Caption = "完了",
                    Text = "アップデートが完了しました。"
                });
            });

            RemoveCommand = new ReactiveCommand(app.ObserveProperty(x => x.CanRemove));
            RemoveCommand.Subscribe(async _ =>
            {
                var res = await Messenger.GetResponse(new AsyncConfirmationMessage
                {
                    MessageKey = "Confirm",
                    Caption = "確認",
                    Text = "アプリケーションの登録を削除してもよろしいですか?(アプリケーション自体は削除されません)"

                }).Response;

                if (res != true) return;

                await manager.RemoveApplicationAsync(app);

                Messenger.Raise(new AsyncInformationMessage
                {
                    MessageKey = "Close"
                });
            });
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public async Task RemoveApplicationAsync(InstalledApplication app)
        {
            if (!app.CanRemove)
            {
                RaiseError("このアプリケーションを登録解除することはできません。");
            }

            Applications.Remove(app);

            await SaveAsync().ConfigureAwait(false);
        }
Example #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="applicationPath"></param>
        /// <returns></returns>
        public async Task RegisterInstalledApplication(string applicationPath)
        {
            if (Applications.Any(x => String.Equals(x.InstalledPath, applicationPath)))
            {
                RaiseError("既に登録済みのアプリケーションです。");
                return;
            }

            var application = new InstalledApplication(applicationPath);

            await application.InitializeAsync(_appInfo).ConfigureAwait(false);

            if (!application.IsSupported)
            {
                RaiseError("サポートされていないアプリケーションです。");
                return;
            }

            Applications.Add(application);

            await SaveAsync().ConfigureAwait(false);
        }