public void Initialize()
        {
            #region bind events
            CompositeDisposable.Add(
                Observable.FromEvent<bool>(
                    h => MainWindowModel.WindowCommandsDisplayChanged += h,
                    h => MainWindowModel.WindowCommandsDisplayChanged -= h)
                          .Subscribe(visible =>
                          {
                              var offset = visible
                                               ? Interlocked.Increment(ref _visibleCount)
                                               : Interlocked.Decrement(ref _visibleCount);
                              ShowWindowCommands = offset >= 0;
                          }));
            CompositeDisposable.Add(
                Observable.FromEvent<TaskDialogOptions>(
                    h => MainWindowModel.TaskDialogRequested += h,
                    h => MainWindowModel.TaskDialogRequested -= h)
                          .Subscribe(options => this.Messenger.RaiseSafe(() =>
                              new TaskDialogMessage(options))));
            CompositeDisposable.Add(
                Observable.FromEvent(
                    h => MainWindowModel.StateStringChanged += h,
                    h => MainWindowModel.StateStringChanged -= h)
                          .Subscribe(_ => RaisePropertyChanged(() => StateString)));
            CompositeDisposable.Add(
                Observable.Interval(TimeSpan.FromSeconds(0.5))
                          .Subscribe(_ => UpdateStatistics()));
            CompositeDisposable.Add(
                Observable.FromEvent<AccountSelectDescription>(
                    h => MainWindowModel.AccountSelectActionRequested += h,
                    h => MainWindowModel.AccountSelectActionRequested -= h)
                          .Subscribe(
                              desc =>
                              {
                                  // ensure close before opening.
                                  _globalAccountSelectionFlipViewModel.Close();

                                  _globalAccountSelectionFlipViewModel.SelectedAccounts =
                                      desc.SelectionAccounts;
                                  _globalAccountSelectionFlipViewModel.SelectionReason = "";
                                  switch (desc.AccountSelectionAction)
                                  {
                                      case AccountSelectionAction.Favorite:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "favorite";
                                          break;
                                      case AccountSelectionAction.Retweet:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "retweet";
                                          break;
                                  }
                                  IDisposable disposable = null;
                                  disposable = Observable.FromEvent(
                                      h => _globalAccountSelectionFlipViewModel.Closed += h,
                                      h => _globalAccountSelectionFlipViewModel.Closed -= h)
                                                         .Subscribe(_ =>
                                                         {
                                                             if (disposable == null) return;
                                                             disposable.Dispose();
                                                             disposable = null;
                                                             desc.Callback(
                                                                 this._globalAccountSelectionFlipViewModel
                                                                     .SelectedAccounts);
                                                         });
                                  _globalAccountSelectionFlipViewModel.Open();
                              }));
            CompositeDisposable.Add(
                Observable.FromEvent(
                    h => ThemeManager.ThemeChanged += h,
                    h => ThemeManager.ThemeChanged -= h
                    ).Subscribe(_ => this.Messenger.RaiseAsync(new InteractionMessage("InvalidateTheme"))));

            #endregion

            #region special navigations
            // check first boot
            if (Setting.IsFirstGenerated)
            {
                var kovm = new KeyOverrideViewModel();
                Messenger.RaiseSafeSync(() => new TransitionMessage(
                    typeof(KeyOverrideWindow),
                    kovm, TransitionMode.Modal, null));
            }

            // register new account if accounts haven't been authorized yet
            if (!Setting.Accounts.Collection.Any())
            {
                var auth = new AuthorizationViewModel();
                auth.AuthorizeObservable
                    .Subscribe(Setting.Accounts.Collection.Add);
                Messenger.RaiseSafeSync(() => new TransitionMessage(
                    typeof(AuthorizationWindow),
                    auth, TransitionMode.Modal, null));
            }
            #endregion

            TabManager.Load();
            TabManager.Save();

            if (TabManager.Columns.Count == 1 && TabManager.Columns[0].Tabs.Count == 0)
            {
                // lost tab info
                this.ReInitTabs();
            }

            // check cleanup parameter
            if (Setting.AutoCleanupTweets.Value &&
                Setting.AutoCleanupThreshold.Value < 0)
            {
                var msg = this.Messenger.GetResponseSafe(() =>
                    new TaskDialogMessage(new TaskDialogOptions
                    {
                        Title = AppInitResources.MsgCleanupConfigTitle,
                        MainIcon = VistaTaskDialogIcon.Information,
                        MainInstruction = AppInitResources.MsgCleanupConfigInst,
                        Content = AppInitResources.MsgCleanupConfigContent,
                        ExpandedInfo = AppInitResources.MsgCleanupConfigExInfo,
                        CommonButtons = TaskDialogCommonButtons.YesNo
                    }));
                Setting.AutoCleanupTweets.Value = msg.Response.Result == TaskDialogSimpleResult.Yes;
                Setting.AutoCleanupThreshold.Value = 100000;
            }

            // check execution properties
            if (Setting.ShowStartupConfigurationWarning.Value)
            {
                if (App.ExecutionMode == ExecutionMode.Standalone)
                {
                    var msg = this.Messenger.GetResponseSafe(() =>
                        new TaskDialogMessage(new TaskDialogOptions
                    {
                        Title = AppInitResources.MsgExecModeWarningTitle,
                        MainIcon = VistaTaskDialogIcon.Warning,
                        MainInstruction = AppInitResources.MsgExecModeWarningInst,
                        Content = AppInitResources.MsgExecModeWarningContent,
                        FooterIcon = VistaTaskDialogIcon.Error,
                        FooterText = AppInitResources.MsgExecModeWarningFooter,
                        CommonButtons = TaskDialogCommonButtons.Close,
                        VerificationText = Resources.MsgDoNotShowAgain
                    }));
                    Setting.ShowStartupConfigurationWarning.Value = !msg.Response.VerificationChecked.GetValueOrDefault();
                }
                else if (App.DatabaseDirectoryUserSpecified)
                {
                    var msg = this.Messenger.GetResponseSafe(() =>
                        new TaskDialogMessage(new TaskDialogOptions
                    {
                        Title = AppInitResources.MsgDatabasePathWarningTitle,
                        MainIcon = VistaTaskDialogIcon.Warning,
                        MainInstruction = AppInitResources.MsgDatabasePathWarningInst,
                        Content = AppInitResources.MsgDatabasePathWarningContent,
                        FooterIcon = VistaTaskDialogIcon.Error,
                        FooterText = AppInitResources.MsgDatabasePathWarningFooter,
                        CommonButtons = TaskDialogCommonButtons.Close,
                        VerificationText = Resources.MsgDoNotShowAgain
                    }));
                    Setting.ShowStartupConfigurationWarning.Value = !msg.Response.VerificationChecked.GetValueOrDefault();
                }
            }

            Task.Run(() => App.RaiseUserInterfaceReady());

            // initially focus to timeline
            MainWindowModel.SetFocusTo(FocusRequest.Timeline);

            PostInitialize();
        }
        public void Initialize()
        {
            #region bind events
            CompositeDisposable.Add(
                Observable.FromEvent<bool>(
                    h => MainWindowModel.WindowCommandsDisplayChanged += h,
                    h => MainWindowModel.WindowCommandsDisplayChanged -= h)
                          .Subscribe(visible =>
                          {
                              var offset = visible
                                               ? Interlocked.Increment(ref _visibleCount)
                                               : Interlocked.Decrement(ref _visibleCount);
                              ShowWindowCommands = offset >= 0;
                          }));
            CompositeDisposable.Add(
                Observable.FromEvent<TaskDialogOptions>(
                    h => MainWindowModel.TaskDialogRequested += h,
                    h => MainWindowModel.TaskDialogRequested -= h)
                          .Subscribe(options => this.Messenger.Raise(new TaskDialogMessage(options))));
            CompositeDisposable.Add(
                Observable.FromEvent(
                    h => MainWindowModel.StateStringChanged += h,
                    h => MainWindowModel.StateStringChanged -= h)
                          .Subscribe(_ => RaisePropertyChanged(() => StateString)));
            CompositeDisposable.Add(
                Observable.Interval(TimeSpan.FromSeconds(0.5))
                          .Subscribe(_ => UpdateStatistics()));
            CompositeDisposable.Add(
                Observable.FromEvent<AccountSelectDescription>(
                    h => MainWindowModel.AccountSelectActionRequested += h,
                    h => MainWindowModel.AccountSelectActionRequested -= h)
                          .Subscribe(
                              desc =>
                              {
                                  _globalAccountSelectionFlipViewModel.SelectedAccounts =
                                      desc.SelectionAccounts;
                                  _globalAccountSelectionFlipViewModel.SelectionReason = "";
                                  switch (desc.AccountSelectionAction)
                                  {
                                      case AccountSelectionAction.Favorite:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "favorite";
                                          break;
                                      case AccountSelectionAction.Retweet:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "retweet";
                                          break;
                                  }
                                  IDisposable disposable = null;
                                  disposable = Observable.FromEvent(
                                      h => _globalAccountSelectionFlipViewModel.Closed += h,
                                      h => _globalAccountSelectionFlipViewModel.Closed -= h)
                                                         .Subscribe(_ =>
                                                         {
                                                             if (disposable == null) return;
                                                             disposable.Dispose();
                                                             disposable = null;
                                                             desc.Callback(
                                                                 this
                                                                     ._globalAccountSelectionFlipViewModel
                                                                     .SelectedAccounts);
                                                         });
                                  _globalAccountSelectionFlipViewModel.Open();
                              }));
            #endregion

            #region special navigations
            // check first boot
            if (Setting.IsFirstGenerated)
            {
                var kovm = new KeyOverrideViewModel();
                Messenger.Raise(new TransitionMessage(
                                         typeof(KeyOverrideWindow),
                                         kovm, TransitionMode.Modal, null));
            }

            // register new account if accounts haven't been authorized yet
            if (!Setting.Accounts.Collection.Any())
            {
                var auth = new AuthorizationViewModel();
                auth.AuthorizeObservable
                    .Subscribe(Setting.Accounts.Collection.Add);
                Messenger.RaiseAsync(new TransitionMessage(
                                         typeof(AuthorizationWindow),
                                         auth, TransitionMode.Modal, null));
            }
            #endregion

            TabManager.Load();
            TabManager.Save();

            if (TabManager.Columns.Count == 1 && TabManager.Columns[0].Tabs.Count == 0)
            {
                // lost tab info
                this.ReInitTabs();
            }

            Task.Run(() => App.RaiseUserInterfaceReady());
        }
示例#3
0
        public void Initialize()
        {
            CompositeDisposable.Add(
                Observable.FromEvent<bool>(
                    h => MainWindowModel.WindowCommandsDisplayChanged += h,
                    h => MainWindowModel.WindowCommandsDisplayChanged -= h)
                          .Subscribe(visible =>
                          {
                              var offset = visible
                                               ? Interlocked.Increment(ref _visibleCount)
                                               : Interlocked.Decrement(ref _visibleCount);
                              ShowWindowCommands = offset >= 0;
                          }));
            CompositeDisposable.Add(
                Observable.FromEvent<TaskDialogOptions>(
                    h => MainWindowModel.TaskDialogRequested += h,
                    h => MainWindowModel.TaskDialogRequested -= h)
                          .Subscribe(options => this.Messenger.Raise(new TaskDialogMessage(options))));
            CompositeDisposable.Add(
                Observable.FromEvent(
                    h => MainWindowModel.StateStringChanged += h,
                    h => MainWindowModel.StateStringChanged -= h)
                          .Subscribe(_ => RaisePropertyChanged(() => StateString)));
            CompositeDisposable.Add(
                Observable.Interval(TimeSpan.FromSeconds(0.5))
                          .Subscribe(_ => UpdateStatistics()));
            CompositeDisposable.Add(
                Observable.FromEvent<AccountSelectDescription>(
                    h => MainWindowModel.AccountSelectActionRequested += h,
                    h => MainWindowModel.AccountSelectActionRequested -= h)
                          .Subscribe(
                              desc =>
                              {
                                  _globalAccountSelectionFlipViewModel.SelectedAccounts =
                                      desc.SelectionAccounts;
                                  _globalAccountSelectionFlipViewModel.SelectionReason = "";
                                  switch (desc.AccountSelectionAction)
                                  {
                                      case AccountSelectionAction.Favorite:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "favorite";
                                          break;
                                      case AccountSelectionAction.Retweet:
                                          _globalAccountSelectionFlipViewModel.SelectionReason =
                                              "retweet";
                                          break;
                                  }
                                  IDisposable disposable = null;
                                  disposable = Observable.FromEvent(
                                      h => _globalAccountSelectionFlipViewModel.Closed += h,
                                      h => _globalAccountSelectionFlipViewModel.Closed -= h)
                                                         .Subscribe(_ =>
                                                         {
                                                             if (disposable == null) return;
                                                             disposable.Dispose();
                                                             disposable = null;
                                                             desc.Callback(
                                                                 this
                                                                     ._globalAccountSelectionFlipViewModel
                                                                     .SelectedAccounts);
                                                         });
                                  _globalAccountSelectionFlipViewModel.Open();
                              }));

            if (Setting.IsFirstGenerated)
            {
                var kovm = new KeyOverrideViewModel();
                Messenger.Raise(new TransitionMessage(
                                         typeof(KeyOverrideWindow),
                                         kovm, TransitionMode.Modal, null));
            }

            // Start receiving
            if (!AccountsStore.Accounts.Any())
            {
                var auth = new AuthorizationViewModel();
                auth.AuthorizeObservable
                    .Subscribe(info =>
                               AccountsStore.Accounts.Add(
                                   new AccountSetting
                                   {
                                       AuthenticateInfo = info,
                                       IsUserStreamsEnabled = true
                                   }));
                Messenger.RaiseAsync(new TransitionMessage(
                                         typeof(AuthorizationWindow),
                                         auth, TransitionMode.Modal, null));
            }
            TabManager.Load();
            TabManager.Save();

            if (TabManager.Columns.Count != 1 || TabManager.Columns[0].Tabs.Count != 0) return;
            var response = this.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions
            {
                Title = "タブ情報の警告",
                CommonButtons = TaskDialogCommonButtons.YesNo,
                MainIcon = VistaTaskDialogIcon.Warning,
                MainInstruction = "タブ情報が失われた可能性があります。",
                Content = "タブが空です。" + Environment.NewLine +
                          "初回起動時に生成されるタブを再生成しますか?",
            }));
            if (response.Response.Result != TaskDialogSimpleResult.Yes) return;
            Setting.ResetTabInfo();
            TabManager.Columns.Clear();
            TabManager.Load();
            TabManager.Save();
        }
示例#4
0
        public void Initialize()
        {
            MainWindowModel.OnWindowCommandDisplayChanged += _ =>
                                                             ShowWindowCommands = _;

            CompositeDisposable.Add(Observable.FromEvent(
                h => MainWindowModel.OnStateStringChanged += h,
                h => MainWindowModel.OnStateStringChanged -= h)
                                              .Subscribe(_ => RaisePropertyChanged(() => StateString)));
            CompositeDisposable.Add(Observable.FromEvent(
                h => StatisticsService.OnStatisticsParamsUpdated += h,
                h => StatisticsService.OnStatisticsParamsUpdated -= h)
                                              .Subscribe(_ => UpdateStatistics()));

            MainWindowModel.OnExecuteAccountSelectActionRequested += (action, status, selecteds, aftercall) =>
            {
                _globalAccountSelectorViewModel.SelectedAccounts = selecteds;
                _globalAccountSelectorViewModel.SelectionReason = "";
                switch (action)
                {
                    case AccountSelectionAction.Favorite:
                        _globalAccountSelectorViewModel.SelectionReason = "favorite";
                        break;
                    case AccountSelectionAction.Retweet:
                        _globalAccountSelectorViewModel.SelectionReason = "retweet";
                        break;
                }
                IDisposable disposable = null;
                disposable = Observable.FromEvent(h => _globalAccountSelectorViewModel.OnClosed += h,
                                                  h => _globalAccountSelectorViewModel.OnClosed -= h)
                                       .Subscribe(_ =>
                                       {
                                           if (disposable != null)
                                           {
                                               disposable.Dispose();
                                               disposable = null;
                                               aftercall(_globalAccountSelectorViewModel.SelectedAccounts);
                                           }
                                       });
                _globalAccountSelectorViewModel.Open();
            };

            if (Setting.IsFirstGenerated)
            {
                var kovm = new KeyOverrideViewModel();
                Messenger.Raise(new TransitionMessage(
                                         typeof(KeyOverrideWindow),
                                         kovm, TransitionMode.Modal, null));
            }

            // Start receiving
            if (AccountsStore.Accounts.Any())
            {
                UserBaseConnectionsManager.Update();
            }
            else
            {
                var auth = new AuthorizationViewModel();
                auth.AuthorizeObservable.Subscribe(_ =>
                {
                    AccountsStore.Accounts.Add(
                        new AccountSetting
                        {
                            AuthenticateInfo = _,
                            IsUserStreamsEnabled = true
                        });
                    UserBaseConnectionsManager.Update();
                });
                Messenger.RaiseAsync(new TransitionMessage(
                                         typeof(AuthorizationWindow),
                                         auth, TransitionMode.Modal, null));
            }
            MainAreaModel.CreateTab(new TabModel("hello", "from all where ()"));
            MainAreaModel.CreateTab(new TabModel("home", "from all where user <- *.following"));
            MainAreaModel.CreateTab(new TabModel("replies", "from all where to -> *"));
            MainAreaModel.CreateTab(new TabModel("my", "from all where user <- *"));
            MainAreaModel.CreateTab(new TabModel("Krile", "from all where source == \"Krile\""));
            MainAreaModel.CreateColumn(new TabModel("Favorites", "from all where user <- * && ( favs > 0 || rts > 0)"));
        }
示例#5
0
 public void AddNewAccount()
 {
     if (Setting.Accounts.Collection.Count >= 2 &&
         (Setting.GlobalConsumerKey.Value == null || Setting.GlobalConsumerSecret.Value == null) ||
         Setting.GlobalConsumerKey.Value == App.ConsumerKey)
     {
         _parent.Messenger.RaiseAsync(
             new TaskDialogMessage(new TaskDialogOptions
             {
                 Title = "認証の上限",
                 MainIcon = VistaTaskDialogIcon.Error,
                 MainInstruction = "認証数の上限に達しました。",
                 Content = "さらにアカウントを認証するには、Twitter API キーを登録しなければなりません。",
                 FooterIcon = VistaTaskDialogIcon.Information,
                 FooterText = "APIキーを登録すると、すべてのアカウントの登録が一旦解除されます。",
                 CommonButtons = TaskDialogCommonButtons.Close,
             }));
         return;
     }
     var auth = new AuthorizationViewModel();
     auth.AuthorizeObservable.Subscribe(Setting.Accounts.Collection.Add);
     this._parent.Messenger.RaiseAsync(
         new TransitionMessage(typeof(AuthorizationWindow), auth, TransitionMode.Modal, null));
 }
示例#6
0
 public void AddNewAccount()
 {
     if (Setting.Accounts.Collection.Count >= 2 &&
         (Setting.GlobalConsumerKey.Value == null || Setting.GlobalConsumerSecret.Value == null) ||
         Setting.GlobalConsumerKey.Value == App.ConsumerKey)
     {
         _parent.Messenger.RaiseSafe(() =>
             new TaskDialogMessage(new TaskDialogOptions
             {
                 Title = SettingFlipResources.AccountLimitTitle,
                 MainIcon = VistaTaskDialogIcon.Error,
                 MainInstruction = SettingFlipResources.AccountLimitInst,
                 Content = SettingFlipResources.AccountLimitContent,
                 FooterIcon = VistaTaskDialogIcon.Information,
                 FooterText = SettingFlipResources.AccountLimitFooter,
                 CommonButtons = TaskDialogCommonButtons.Close
             }));
         return;
     }
     var auth = new AuthorizationViewModel();
     auth.AuthorizeObservable.Subscribe(Setting.Accounts.Collection.Add);
     this._parent.Messenger.RaiseSafe(() =>
         new TransitionMessage(typeof(AuthorizationWindow), auth, TransitionMode.Modal, null));
 }