コード例 #1
0
        /// <summary>
        /// 起動時のログイン
        /// </summary>
        private async void Login()
        {
            await Task.Run(() =>
            {
                while (this.AddAccount == null)
                {
                    System.Threading.Thread.Sleep(100);
                }
            });

            //トークンファイルが正常に読み込めなかった場合、ログイン画面を表示する
            try
            {
                //トークンの読み込み
                if (!await AccountTokens.LoadTokensAsync())
                {
                }
                //列データの読み込み
                else if (this.Timelines.LoadColumnData())
                {
                    this.MainWindowModel.Notify("カラム読み込み完了.", NotificationType.Normal);
                }
            }
            catch (TwitterException e)
            {
                this.MainWindowModel.Notify("トークン認証失敗.", NotificationType.Error);
                DebugConsole.Write(e);
                return;
            }
            catch (Exception e) when(e is HttpRequestException || e is WebException)
            {
                this.MainWindowModel.Notify("ネットワークに正常に接続できませんでした\n左下の更新ボタンを押して再認証してください", NotificationType.Error);
                DebugConsole.Write(e);
                return;
            }
            catch (Exception e)
            {
                DebugConsole.Write(e);
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// 更新ボタンを押したとき
        /// </summary>
        public async void UpdateTimelines()
        {
            if (AccountTokens.TokensCount == 0 || AccountTokens.Users.Count == 0)
            {
                this.MainWindowModel.Notify("トークン再認証開始", NotificationType.Normal);
                await AccountTokens.LoadTokensAsync();

                return;
            }

            if (this.Timelines.Timelines.Count == 0)
            {
                return;
            }

            foreach (var timeline in this.Timelines.Timelines)
            {
                timeline.TimelineViewModel.Clear();
                await timeline.TimelineViewModel.Update();
            }
        }