public void Initialize() { kbtter = Kbtter.Instance; listener = new PropertyChangedEventListener(kbtter); CompositeDisposable.Add(listener); RegisterHandlers(); kbtter.Initialize(); setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName); TimelineStatuses.CollectionChanged += (s, e) => { DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() => { if (TimelineStatuses.Count > setting.MainWindow.StatusesShowMax) { TimelineStatuses.RemoveAt(setting.MainWindow.StatusesShowMax); } })); }; TimelineNotifications.CollectionChanged += (s, e) => { DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() => { if (TimelineNotifications.Count > setting.MainWindow.NotificationsShowMax) { TimelineNotifications.RemoveAt(setting.MainWindow.NotificationsShowMax); } })); }; }
/// <summary> /// GO is GOD /// </summary> /// <param name="beam">なまえ</param> public void God(string beam) { if (Token == null) { return; } if (!Setting.System.GodCount.ContainsKey(beam)) { Setting.System.GodCount[beam] = 1; } try { Token.Statuses.UpdateAsync(status => String.Format("{0} is GOD({1}回目) #Kbtter3", beam, Setting.System.GodCount[beam])); } catch { } Task.Run(() => { var p = ++Setting.System.GodCount[beam]; Setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName); Setting.System.GodCount[beam] = p; Setting.SaveJson(App.ConfigurationFileName); }); }
internal async void Initialize() { ShowingStatuses = new Queue <Status>(); Setting = new Kbtter3Setting(); StreamManager = new List <IDisposable>(); Plugins = new List <Kbtter3PluginProvider>(); PluginMonitoringToken = new object(); Logs = new List <string>(); if (!Directory.Exists(CacheFolderName)) { Directory.CreateDirectory(CacheFolderName); } if (!Directory.Exists(PluginFolderName)) { Directory.CreateDirectory(PluginFolderName); } Setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName, Setting); OAuthSession = await OAuth.AuthorizeAsync(Setting.Consumer.Key, Setting.Consumer.Secret); OnStatus += NotifyStatusUpdate; OnEvent += NotifyEventUpdate; OnIdEvent += NotifyIdEventUpdate; OnDirectMessage += NotifyDirectMessageUpdate; LogInformation("Model層初期化完了"); SaveLog(); RaisePropertyChanged("AccessTokenRequest"); }
public MainWindow() { InitializeComponent(); vm = DataContext as MainWindowViewModel; composite = new LivetCompositeDisposable(); ctxlistener = new PropertyChangedWeakEventListener(vm); ctxlistener.Add("AccessTokenRequest", StartAccountSelect); ctxlistener.Add("ReplyStart", ExpandNewTweet); ctxlistener.Add("ToggleNewStatus", ToggleNewTweet); ctxlistener.Add("StatusAction", (s, e) => RequestAction(vm.StatusAction.Type, vm.StatusAction.Information)); ctxlistener.Add("UserTimeline", (s, e) => AddTab("ユーザー定義タブ1", new Frame { NavigationUIVisibility = NavigationUIVisibility.Hidden, Content = new UserCustomizableTimelinePage(vm.UserTimelineViewModel) }, vm.UserTimelineViewModel)); ctxlistener.Add("StatusUpdate", (s, e) => { DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { if (TabControlMain.SelectedIndex != 0 && setting.MainWindow.NotifyNewStatus) { EmphasisTextBlock(TextBlockTimeline); urs++; TextBlockUnreadStatuses.Text = String.Format(" {0}", urs); } })); }); ctxlistener.Add("EventUpdate", (s, e) => { DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { if (TabControlMain.SelectedIndex != 1 && setting.MainWindow.NotifyNewNotification) { EmphasisTextBlock(TextBlockNotification); urn++; TextBlockUnreadNotifications.Text = String.Format(" {0}", urn); } })); }); composite.Add(ctxlistener); setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName); if (!setting.MainWindow.AllowJokeCommands) { ToolBarJokes.Visibility = Visibility.Collapsed; } SetShortcuts(); }
private Task InitializeUserCache() { return(Task.Run(async() => { if (AuthenticatedUser != null) { var upc = new UserProfileCache { Name = AuthenticatedUser.Name, ScreenName = AuthenticatedUser.ScreenName, Description = AuthenticatedUser.Description, Location = AuthenticatedUser.Location, Uri = AuthenticatedUser.Url.ToString(), Statuses = AuthenticatedUser.StatusesCount, Friends = AuthenticatedUser.FriendsCount, Followers = AuthenticatedUser.FollowersCount, Favorites = AuthenticatedUser.FavouritesCount, }; upc.SaveJson(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserProfileFileNameSuffix); using (var wc = new WebClient()) { await wc.DownloadFileTaskAsync( AuthenticatedUser.ProfileImageUrlHttps, CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserImageFileNameSuffix); await wc.DownloadFileTaskAsync( AuthenticatedUser.ProfileBackgroundImageUrlHttps, CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserBackgroundImageFileNameSuffix); } } else { if (!File.Exists(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserProfileFileNameSuffix)) { return; } var upc = Kbtter3Extension.LoadJson <UserProfileCache>(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserProfileFileNameSuffix); AuthenticatedUser.Name = upc.Name; AuthenticatedUser.ScreenName = upc.ScreenName; AuthenticatedUser.Description = upc.Description; AuthenticatedUser.Location = upc.Location; AuthenticatedUser.Url = new Uri(upc.Uri); AuthenticatedUser.StatusesCount = upc.Statuses; AuthenticatedUser.FriendsCount = upc.Friends; AuthenticatedUser.FollowersCount = upc.Followers; AuthenticatedUser.FavouritesCount = upc.Favorites; if (File.Exists(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserImageFileNameSuffix)) { AuthenticatedUser.ProfileImageUrlHttps = new Uri(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserImageFileNameSuffix, UriKind.Relative); } if (File.Exists(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserBackgroundImageFileNameSuffix)) { AuthenticatedUser.ProfileImageUrlHttps = new Uri(CacheFolderName + "/" + AuthenticatedUser.ScreenName + CacheUserBackgroundImageFileNameSuffix, UriKind.Relative); } } })); }
static StatusPage() { setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName); }
public void Load() { Setting = Kbtter3Extension.LoadJson <Kbtter3Setting>(App.ConfigurationFileName); }