public TrayMainWindowViewModel(IViewModel mainArea, TrayMainWindowMenu menu, IStatusViewModel status,
            LoginInfo loginInfo, IWelcomeViewModel welcomeViewModel) {
            _mainArea = Consts.FirstRun /* || Cheat.Consts.IsTestVersion */ ? welcomeViewModel : mainArea;
            _menu = menu;
            _status = status;
            _loginInfo = loginInfo;

            welcomeViewModel.Close.Subscribe(x => MainArea = mainArea);

            _taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.Status, FormatTaskbarToolTip)
                .ToProperty(this, x => x.TitleToolTip);

            _avatarUrl = this.WhenAnyValue<TrayMainWindowViewModel, Uri, AccountInfo>(x => x.LoginInfo.Account,
                x => new Uri("http:" + AvatarCalc.GetAvatarURL(x)))
                .ToProperty(this, x => x.AvatarUrl);

            _installUpdate =
                ReactiveCommand.CreateAsyncTask(
                    this.WhenAnyValue(x => x.UpdateState, state => state == AppUpdateState.UpdateAvailable),
                    async x => await RequestAsync(new OpenWebLink(ViewType.Update)).ConfigureAwait(false))
                    .DefaultSetup("InstallUpdate");
            _goAccount =
                ReactiveCommand.CreateAsyncTask(
                    async x => await RequestAsync(new OpenWebLink(ViewType.Profile)).ConfigureAwait(false))
                    .DefaultSetup("OpenProfile");
            _goPremium =
                ReactiveCommand.CreateAsyncTask(
                    async x =>
                        await
                            RequestAsync(
                                new OpenWebLink(_loginInfo.IsPremium ? ViewType.PremiumAccount : ViewType.GoPremium))
                                .ConfigureAwait(false))
                    .DefaultSetup("GoPremium");

            IViewModel previousMain = null;

            _switchQueue = ReactiveCommand.CreateAsyncTask(
                async x => {
                    if (previousMain == null) {
                        previousMain = _mainArea;
                        MainArea = await RequestAsync(new GetQueue()).ConfigureAwait(false);
                    } else {
                        MainArea = previousMain;
                        previousMain = null;
                    }
                });
            status.SwitchQueue = _switchQueue; // TODO..

            Listen<LoginChanged>()
                .Select(x => x.LoginInfo)
                .ObserveOnMainThread()
                .BindTo(this, x => x.LoginInfo);
            // We need to receive these right away..
            // toDO: Think about how to make this only on WhenActivated
            Listen<AppStateUpdated>()
                .Select(x => x.UpdateState)
                .ObserveOnMainThread()
                .BindTo(this, x => x.UpdateState);
        }
예제 #2
0
 public WelcomeView(IWelcomeViewModel viewModel)
 {
     InitializeComponent();
     Model = viewModel;
 }
예제 #3
0
 public WelcomeView(IWelcomeViewModel viewModel)
 {
     InitializeComponent();
     Model = viewModel;
 }