コード例 #1
0
 /// <summary>
 /// Called when [selected game changed].
 /// </summary>
 /// <param name="game">The game.</param>
 protected override void OnSelectedGameChanged(IGame game)
 {
     Task.Run(async() => await DLCManager.RefreshDLCAsync(gameService.GetSelected()).ConfigureAwait(false)).ConfigureAwait(false);
     base.OnSelectedGameChanged(game);
 }
コード例 #2
0
        /// <summary>
        /// Called when [activated].
        /// </summary>
        /// <param name="disposables">The disposables.</param>
        protected override void OnActivated(CompositeDisposable disposables)
        {
            Task.Run(async() => await DLCManager.RefreshDLCAsync(gameService.GetSelected()).ConfigureAwait(false)).ConfigureAwait(false);

            WikiCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                await appAction.OpenAsync(Constants.WikiUrl);
            }).DisposeWith(disposables);

            LogsCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (Directory.Exists(StaticResources.GetLogLocation()))
                {
                    await appAction.OpenAsync(StaticResources.GetLogLocation());
                }
            }).DisposeWith(disposables);

            ErrorLogCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var game = gameService.GetSelected();
                if (game != null)
                {
                    if (File.Exists(game.LogLocation))
                    {
                        await appAction.OpenAsync(game.LogLocation);
                    }
                }
            }).DisposeWith(disposables);

            ShortcutsCommand = ReactiveCommand.Create(() =>
            {
                IsOpen = true;
            }).DisposeWith(disposables);

            CloseCommand = ReactiveCommand.Create(() =>
            {
                IsOpen = false;
            }).DisposeWith(disposables);

            DLCCommand = ReactiveCommand.Create(() =>
            {
                IsOpen = false;
                DLCManager.Open();
            }).DisposeWith(disposables);

            void evaluateVisibility()
            {
                LogsVisible = Directory.Exists(StaticResources.GetLogLocation());
                var game = gameService.GetSelected();

                ErrorLogVisible = game != null && File.Exists(game.LogLocation);
            }

            evaluateVisibility();
            this.WhenAnyValue(p => p.IsOpen).Where(p => p).Subscribe(s =>
            {
                evaluateVisibility();
            }).DisposeWith(disposables);

            base.OnActivated(disposables);
        }