Ejemplo n.º 1
0
        public async void SetApiKeys()
        {
            var reconf = "再設定";

            if (Setting.GlobalConsumerKey.Value == null)
            {
                reconf = "設定";
            }
            var resp = await this.Messenger.GetResponseAsync(
                new TaskDialogMessage(new TaskDialogOptions
            {
                Title = "APIキーの" + reconf,
                MainIcon = VistaTaskDialogIcon.Warning,
                MainInstruction = "登録されたアカウントがすべて登録解除されます。",
                Content = "APIキーの" + reconf + "を行うと、登録されたアカウントはすべてKrileから消去されます。" + Environment.NewLine + "続行しますか?",
                CommonButtons = TaskDialogCommonButtons.YesNo
            }));

            if (resp.Response.Result == TaskDialogSimpleResult.No)
            {
                return;
            }
            var kovm = new KeyOverrideViewModel();

            this._parent.Messenger.Raise(
                new TransitionMessage(typeof(KeyOverrideWindow), kovm, TransitionMode.Modal, null));
        }
Ejemplo n.º 2
0
        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 =>
            {
                // 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();
            }));
            #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();
            }

            // check execution properties
            if (Setting.ShowStartupConfigurationWarning.Value)
            {
                if (App.ExecutionMode == ExecutionMode.Standalone)
                {
                    var msg = this.Messenger.GetResponse(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.GetResponse(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();
        }