private void Application_Startup(object sender, StartupEventArgs e) { UpgradeSettings(); var tabsModel = new TabsModel(Muon.Properties.Settings.Default); var settingsViewModel = new SettingsViewModel(tabsModel); if (Muon.Properties.Settings.Default.Auth == null) { ShutdownMode = ShutdownMode.OnExplicitShutdown; bool?authResult = new SettingsWindow(settingsViewModel).ShowDialog(); if (authResult != true) { Shutdown(); return; } ShutdownMode = ShutdownMode.OnLastWindowClose; } var mainWindowViewModel = new MainWindowViewModel(new MainWindowModel( new ReactiveProperty <Status>(), new MastodonClient(Muon.Properties.Settings.Default.AppRegistration, Muon.Properties.Settings.Default.Auth), tabsModel)); new MainWindow(mainWindowViewModel).Show(); }
public static MvcHtmlString PSTabs(this HtmlHelper htmlHelper, List <TabItem> tabs) { var model = new TabsModel { ID = "tabs", Tabs = tabs }; if (tabs.Count > 0) { tabs[0].Active = true; } return(htmlHelper.PSTabs(model)); }
public StatusesViewModel(TimelineModelBase model, IReactiveProperty <Status> inReplyTo, TabsModel tabs, bool streamingOnStartup = false) { this.model = model; this.inReplyTo = inReplyTo; this.tabs = tabs; IsStreaming = this.model.StreamingStarted.ToReadOnlyReactiveProperty(); IsStreamingAvailable = this.model.IsStreamingAvailable; Statuses = this.model.ToReadOnlyReactiveCollection(s => new StatusViewModel(s)); ReloadCommand = new AsyncReactiveCommand() .WithSubscribe(() => this.model.FetchPreviousAsync()); ReloadOlderCommand = new AsyncReactiveCommand() .WithSubscribe(() => this.model.FetchNextAsync()); ToggleStreamingCommand = Observable.Repeat(IsStreamingAvailable, 1).ToReactiveCommand() .WithSubscribe(() => this.model.StreamingStarting.Value = !IsStreaming.Value); var IsStatusSelected = SelectedStatus.Select(x => x != null); OpenCommand = IsStatusSelected.ToReactiveCommand() .WithSubscribe(() => Process.Start(SelectedStatus.Value.Status.Url ?? SelectedStatus.Value.Status.Reblog.Url)); FavouriteCommand = IsStatusSelected.ToAsyncReactiveCommand() .WithSubscribe(() => this.model.FavouriteAsync(SelectedStatus.Value.Status.Id)); ReblogCommand = IsStatusSelected.ToAsyncReactiveCommand() .WithSubscribe(() => this.model.ReblogAsync(SelectedStatus.Value.Status.Id)); ReplyCommand = IsStatusSelected.ToReactiveCommand() .WithSubscribe(() => this.inReplyTo.Value = SelectedStatus.Value.Status); DeleteCommand = IsStatusSelected.ToAsyncReactiveCommand() .WithSubscribe(() => this.model.DeleteAsync(SelectedStatus.Value.Status.Id)); OpenAccountTabCommand = IsStatusSelected.ToReactiveCommand() .WithSubscribe(() => { Account account = SelectedStatus.Value.OriginalStatus.Account; this.tabs.SwitchToOrOpen(new AccountTabParameters() { Name = $"user: {account.AccountName}", Id = account.Id }); }); this.model.StreamingStarting.Value = streamingOnStartup; ReloadCommand.Execute(); }
public SettingsViewModel(TabsModel tabsModel) { Tabs = tabsModel; Instance = new ReactiveProperty <string>(Properties.Settings.Default.AppRegistration?.Instance); AccessToken = new ReactiveProperty <string>(Properties.Settings.Default.Auth?.AccessToken ?? ""); ShowHomeTimelineTab = new ReactiveProperty <bool>(tabsModel.OfType <TimelineTabParameters>()?.Any(x => x.Type == TimelineType.Home) ?? false); ShowLocalTimelineTab = new ReactiveProperty <bool>(tabsModel.OfType <TimelineTabParameters>()?.Any(x => x.Type == TimelineType.Local) ?? false); ShowFederatedTimelineTab = new ReactiveProperty <bool>(tabsModel.OfType <TimelineTabParameters>()?.Any(x => x.Type == TimelineType.Federated) ?? false); ShowNotificationsTab = new ReactiveProperty <bool>(tabsModel.OfType <NotificationTabParameters>()?.Any() ?? false); RequestTokenCommand = Instance .Select(x => !string.IsNullOrEmpty(x)) .ToAsyncReactiveCommand() .WithSubscribe(executeRequestTokenCommand); AuthorizeCommand = AccessToken .CombineLatest(WaitingForAuthCode, (token, waiting) => waiting && token.Length > 0) .ToAsyncReactiveCommand() .WithSubscribe(executeAuthorizeCommand); OkCommand = new ReactiveCommand().WithSubscribe(executeOkCommand); CancelCommand = new ReactiveCommand().WithSubscribe(executeCancelCommand); }
public TimelineViewModel(TimelineTabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client) : base(param, inReplyTo) { switch (param.Type) { case TimelineType.Home: Statuses = new StatusesViewModel(new HomeTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup); break; case TimelineType.Local: Statuses = new StatusesViewModel(new LocalTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup); break; case TimelineType.Federated: Statuses = new StatusesViewModel(new FederatedTimelineModel(client), inReplyTo, tabs, param.StreamingOnStartup); break; } }
public static TabContentViewModelBase FromParam(TabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client) { switch (param) { case AccountTabParameters aparam: return(new AccountTabViewModel(aparam, inReplyTo, tabs, client)); case TimelineTabParameters tparam: return(new TimelineViewModel(tparam, inReplyTo, tabs, client)); case NotificationTabParameters nparam: return(new NotificationsViewModel(nparam, client)); default: throw new NotImplementedException(); } }
public AccountTabViewModel(AccountTabParameters param, IReactiveProperty <Status> inReplyTo, TabsModel tabs, IMastodonClient client) : base(param, inReplyTo) { GetAccount(param.Id); Statuses = new StatusesViewModel(new AccountTimelineModel(param.Id, client), inReplyTo, tabs); }
public static MvcHtmlString PSTabs(this HtmlHelper htmlHelper, TabsModel model) { return(htmlHelper.Partial("~/Controls/Tabs/Views/Tabs.cshtml", model)); }