public MainWindowViewModel() { this.AcquiredItems = new DispatcherCollection <Item>(DispatcherHelper.UIDispatcher); FiddlerApplication.AfterSessionComplete += new SessionStateHandler((session) => { if (Regex.IsMatch(session.host, @".+\.omf-game\.jp")) { var contentType = session.ResponseHeaders.FirstOrDefault(x => x.Name == "Content-Type")?.Value; if (contentType == "application/json" && Regex.IsMatch(session.url, "battleresult|battleraidbossresult")) { foreach (var item in GetItems(session.GetResponseBodyAsString())) { var existingItem = this.AcquiredItems.FirstOrDefault(x => x.Name == item.Name && x.ItemImageUrl == item.Img); if (existingItem == null) { var newItem = new Item(item.Name, item.Img); newItem.Count += item.Num; this.AcquiredItems.Add(newItem); continue; } existingItem.Count += item.Num; } } } }); }
public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener<Action<CursorPosition>>( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
public GeneralViewModel() { _players = new DispatcherCollection<DisplayableItem<string>>(DispatcherHelper.UIDispatcher); _players.Add(new DisplayableItem<string>("mpc", "Media General Classic")); _screens = new DispatcherCollection<DisplayableItem<int>>(DispatcherHelper.UIDispatcher); var i = 1; foreach (Screen screen in Screen.AllScreens) { _screens.Add(new DisplayableItem<int>(i++, ScreenUtils.GetDisplayDevice(screen.DeviceName).DeviceString)); } CurrentScreen = App.Config.ScreenNo; _monitorDirectories = new ObservableCollection<string>(App.Config.MonitorDirectories); var monitorDirectoriesListener = new CollectionChangedEventListener(_monitorDirectories) { (sender, args) => { App.Config.MonitorDirectories = _monitorDirectories; App.Client.ResetLibraryUpdater(); } }; CompositeDisposable.Add(monitorDirectoriesListener); }
public FavoriteViewModel() : base("お気に入り") { FavoriteList = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); FavoriteList.Add(new FavoriteUserViewModel(this)); FavoriteList.Add(new FavoriteCommunityViewModel(this)); }
public FavoriteViewModel() : base("お気に入り") { FavoriteInstance = new NicoNicoFavorite(); FavoriteList = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); FavoriteList.Add(new FavoriteUserViewModel(this, FavoriteInstance)); }
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { if(AssociatedObject != null) { Collection = (DispatcherCollection<CommentEntryViewModel>)AssociatedObject.ItemsSource; } }
public FavoriteViewModel() : base("フォロー") { FavoriteList = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); FavoriteList.Add(new FavoriteUserViewModel(this)); FavoriteList.Add(new FavoriteCommunityViewModel(this)); }
public FavoriteViewModel() : base("お気に入り") { FavoriteInstance = new NicoNicoFavorite(); FavoriteList = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); FavoriteList.Add(new FavoriteUserViewModel(this, FavoriteInstance)); }
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { if (AssociatedObject != null) { Collection = (DispatcherCollection <NicoNicoCommentEntry>)AssociatedObject.ItemsSource; Collection.CollectionChanged += Collection_CollectionChanged; } }
public TwitterAccountConfigurationViewModel(SettingFlipViewModel parent, TwitterAccount account) { _parent = parent; this._account = account; _accounts = new DispatcherCollection <TwitterAccountViewModel>(DispatcherHelper.UIDispatcher); Setting.Accounts.Collection.ListenCollectionChanged() .Subscribe(_ => RefreshCandidates()); this.RefreshCandidates(); }
public MainContentViewModel(MainWindowViewModel owner) { Owner = owner; SystemItems = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); UserItems = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); VideoView = new VideoViewViewModel(); }
public NotificationManagerViewModel(NotificationManager model) { _managerModel = model; Items = new DispatcherCollection<NotificationStreamViewModel>(App.Current.Dispatcher); CompositeDisposable.Add(_modelPropChangedEventListener = new PropertyChangedEventListener(model)); CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this)); CompositeDisposable.Add(Observable.Interval(TimeSpan.FromSeconds(60)).Subscribe(Interval_Fired)); _modelPropChangedEventListener.Add(() => model.UnreadItemCount, UnreadItemCount_PropertyChanged); _thisPropChangedEventListener.Add(() => IsActive, IsActive_PropertyChanged); }
public MylistListViewModel(MylistViewModel vm, NicoNicoMylistGroupData group, List <NicoNicoMylistData> list) : base(group.Name) { EditModeViewModel = new MylistEditModeViewModel(this); Owner = vm; Group = group; Mylist = new DispatcherCollection <MylistListEntryViewModel>(DispatcherHelper.UIDispatcher); foreach (NicoNicoMylistData data in list) { Mylist.Add(new MylistListEntryViewModel(this, data)); } Sort(0); }
public MylistListViewModel(MylistViewModel vm, NicoNicoMylistGroupData group, List<NicoNicoMylistData> list) : base(group.Name) { EditModeViewModel = new MylistEditModeViewModel(this); Owner = vm; Group = group; Mylist = new DispatcherCollection<MylistListEntryViewModel>(DispatcherHelper.UIDispatcher); foreach(NicoNicoMylistData data in list) { Mylist.Add(new MylistListEntryViewModel(this, data)); } Sort(SortIndex); }
public void Initialize() { UserInstance = new NicoNicoUser(this, UserPageUrl); UserEntry = UserInstance.GetUserInfo(); Name = UserEntry.UserName; UserContentList = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher) { new UserNicoRepoViewModel(this), new UserMylistViewModel(this), new UserVideoViewModel(this) }; }
public void Initialize() { IsActive = true; Owner.Status = "お気に入りユーザーを取得中"; UserList = new DispatcherCollection<NicoNicoFavoriteUser>(DispatcherHelper.UIDispatcher); Task.Run(() => { foreach(var entry in FavoriteInstance.GetFavoriteUser()) { UserList.Add(entry); } IsActive = false; Owner.Status = ""; }); }
public MainWindowViewModel() { StatusBar = new StatusBarViewModel(); StatusBar.TimerStart(); SignIn = new SignInViewModel(); TabItems = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher) { (SelectedTab = new StartViewModel()) }; AccessLog = new AccessLogViewModel(); }
public void Initialize() { IsActive = true; Owner.Status = "お気に入りユーザーを取得中"; UserList = new DispatcherCollection <NicoNicoFavoriteUserContent>(DispatcherHelper.UIDispatcher); Task.Run(() => { foreach (var entry in FavoriteInstance.GetFavoriteUser()) { UserList.Add(entry); } IsActive = false; Owner.Status = ""; }); }
//ここでScrollViewerのインスタンスを取得する private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) { if (VisualTreeHelper.GetChildrenCount(this.AssociatedObject) != 0) { var border = VisualTreeHelper.GetChild(this.AssociatedObject, 0) as Border; ScrollViewer = border.Child as ScrollViewer; if (AssociatedObject.ItemsSource is DispatcherCollection <ViewModels.AccessLogEntryViewModel> ) { Collection = (DispatcherCollection <ViewModels.AccessLogEntryViewModel>)AssociatedObject.ItemsSource; Collection.CollectionChanged += Collection_CollectionChanged; } } }
public void Initialize() { Task.Run(() => { MylistData = PublicMylist.GetMylist(); Name = MylistData.MylistName; Mylist = new DispatcherCollection <MylistListEntryViewModel>(DispatcherHelper.UIDispatcher); foreach (var entry in MylistData.Data) { Mylist.Add(entry); } Sort(SortIndex); }); }
public MainWindowViewModel() { StatusBar = new StatusBarViewModel(); StatusBar.TimerStart(); SignIn = new SignInViewModel(); TabItems = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher) { (SelectedTab = new StartViewModel()) }; AccessLog = new AccessLogViewModel(); }
public void Initialize() { IsActive = true; Owner.Status = "フォローコミュニティを取得中"; CommunityList = new DispatcherCollection<NicoNicoFavoriteCommunityContent>(DispatcherHelper.UIDispatcher); Task.Run(() => { foreach(var entry in FavoriteInstance.GetFavoriteCommunity()) { CommunityList.Add(entry); } IsActive = false; Owner.Status = ""; }); }
public ResponseFileWriter(KanColleProxy proxy) { this.Log = new DispatcherCollection <string>(DispatcherHelper.UIDispatcher); //kcsとkcsapi以下を保存。キャッシュにある奴は保存されない。 var kscSessionSource = proxy.SessionSource .Where(s => s.Request.PathAndQuery.StartsWith("/kcs/") || s.Request.PathAndQuery.StartsWith("/kcsapi/")); kscSessionSource.Subscribe(s => s.SaveResponseBody(s.GetSaveFilePath())); kscSessionSource .Subscribe(s => Log.Add(DateTimeOffset.Now.ToString("HH:mm:ss : ") + s.Request.PathAndQuery)); }
public MainWindowViewModel() { StatusBar = new StatusBarViewModel(); StatusBar.TimerStart(); SignIn = new SignInViewModel(); TabItems = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher) { (SelectedTab = new StartViewModel()) }; VideoTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); UserTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); MylistTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); CommunityTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); LiveTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); PlayListTabs = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher); AccessLog = new AccessLogViewModel(); Update = new UpdateViewModel(CurrentVersion); }
public async void Initialize() { IsActive = true; Status = "視聴履歴取得中"; AccountHistoryList.Clear(); var account = await HistoryInstance.GetAccountHistoryAsync(); if (account != null) { foreach (var entry in account) { AccountHistoryList.Add(new HistoryEntryViewModel(entry)); } } var local = await HistoryInstance.GetLocalHistoryAsync(); HistoryInstance.MergeHistories(account, local); local.Sort(); local.Reverse(); var collection = new DispatcherCollection <HistoryEntryViewModel>(DispatcherHelper.UIDispatcher); if (local != null) { foreach (var entry in local) { collection.Add(new HistoryEntryViewModel(entry)); } LocalHistoryList = collection; } HistoryInstance.SaveLocalHistory(local); IsActive = false; }
public MainWindowViewModel() { StatusBar = new StatusBarViewModel(); StatusBar.TimerStart(); SignIn = new SignInViewModel(); TabItems = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher) { (SelectedTab = new StartViewModel()) }; VideoTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); UserTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); MylistTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); CommunityTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); LiveTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); PlayListTabs = new DispatcherCollection <TabItemViewModel>(DispatcherHelper.UIDispatcher); AccessLog = new AccessLogViewModel(); Update = new UpdateViewModel(CurrentVersion); }
public void Initialize() { Task.Run(() => { MylistData = PublicMylist.GetMylist(); Name = MylistData.MylistName; Mylist = new DispatcherCollection<MylistListEntryViewModel>(DispatcherHelper.UIDispatcher); foreach(var entry in MylistData.Data) { Mylist.Add(entry); } Sort(SortIndex); }); }
public LazyDataSource() { this._Items = new DispatcherCollection <T>(DispatcherHelper.UIDispatcher); }
public UserNicoRepoViewModel(UserViewModel user) : base("ニコレポ") { User = user; UserNicoRepoList = new DispatcherCollection <NicoRepoResultEntryViewModel>(DispatcherHelper.UIDispatcher); }
//設定ファイルの値からインスタンスを生成する private object GetNeedValue(string name, PropertyInfo property, object value) { switch(name) { case "FontFamily": return new FontFamily((string)value); case "GridLength": return new GridLengthConverter().ConvertFrom(value); case "Uri": return new Uri((string)value); case "DispatcherCollection<NGCommentEntry>": { var col = new DispatcherCollection<NGCommentEntry>(DispatcherHelper.UIDispatcher); dynamic entries = (DynamicJson)value; //NGフィルターのエントリを設定ファイルからパースする foreach(var entry in entries) { var ng = new NGCommentEntry(); ng.Type = Enum.Parse(typeof(NGType), entry.Type); ng.Content = entry.Content; ng.IsEnabled = entry.IsEnabled; //NGフィルターの内容が更新されたら即セーブする ng.PropertyChanged += ((sender, e) => Save()); col.Add(ng); } //新しくフィルターリストにエントリが追加/削除されたらセーブする //追加だったら新しいエントリに即セーブするイベントを設定 col.CollectionChanged += ((sender, e) => { if(e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Count != 0 && e.NewItems[0] is NGCommentEntry) { var ng = e.NewItems[0] as NGCommentEntry; ng.PropertyChanged += ((sdr, ee) => Save()); Save(); } else { Save(); } }); return col; } case "List<String>": { var col = new List<string>(); dynamic entries = (DynamicJson)value; //NGフィルターのエントリを設定ファイルからパースする foreach(var entry in entries) { col.Add(entry); } return col; } default: return value; } }
/// <summary> /// Constructor /// </summary> public InputAreaViewModel() { _provider = new InputAreaSuggestItemProvider(); #region Account control _accountSelectionFlip = new AccountSelectionFlipViewModel(); _accountSelectionFlip.Closed += () => { // After selection accounts, return focus to text box // if input area is opened. if (IsOpening) { FocusToTextBox(); } }; var accountSelectReflecting = false; _accountSelectionFlip.SelectedAccountsChanged += () => { if (!_isSuppressAccountChangeRelay) { // write-back accountSelectReflecting = true; InputAreaModel.BindingAccounts.Clear(); _accountSelectionFlip.SelectedAccounts .ForEach(InputAreaModel.BindingAccounts.Add); accountSelectReflecting = false; _baseSelectedAccounts = InputAreaModel.BindingAccounts.Select(_ => _.Id).ToArray(); } InputInfo.Accounts = AccountSelectionFlip.SelectedAccounts; RaisePropertyChanged(() => AuthInfoGridRowColumn); UpdateTextCount(); RaisePropertyChanged(() => IsPostLimitPredictionEnabled); }; CompositeDisposable.Add(_accountSelectionFlip); CompositeDisposable.Add( new CollectionChangedEventListener( InputAreaModel.BindingAccounts, (_, __) => { RaisePropertyChanged(() => IsPostLimitPredictionEnabled); if (accountSelectReflecting) return; _baseSelectedAccounts = InputAreaModel.BindingAccounts .Select(a => a.Id) .ToArray(); ApplyBaseSelectedAccounts(); UpdateTextCount(); })); #endregion CompositeDisposable.Add(_bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputAreaModel.BindingHashtags, _ => new BindHashtagViewModel(_, () => UnbindHashtag(_)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindingHashtagExisted))); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputAreaModel.Drafts, _ => new TweetInputInfoViewModel(this, _, vm => InputAreaModel.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); CompositeDisposable.Add(_bindingAuthInfos = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputAreaModel.BindingAccounts, account => new TwitterAccountViewModel(account), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingAuthInfos .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindingAuthInfoExisted))); CompositeDisposable.Add( new EventListener<Action<IEnumerable<TwitterAccount>, string, CursorPosition, TwitterStatus>>( h => InputAreaModel.SetTextRequested += h, h => InputAreaModel.SetTextRequested -= h, (infos, body, cursor, inReplyTo) => { OpenInput(false); if (!CheckClearInput(body)) return; if (infos != null) { OverrideSelectedAccounts(infos); } if (inReplyTo != null) { Task.Run(async () => InReplyTo = new StatusViewModel(await StatusModel.Get(inReplyTo))); } switch (cursor) { case CursorPosition.Begin: Messenger.Raise(new TextBoxSetCaretMessage(0)); break; case CursorPosition.End: Messenger.Raise(new TextBoxSetCaretMessage(InputText.Length)); break; } })); CompositeDisposable.Add( new EventListener<Action<IEnumerable<TwitterAccount>, TwitterUser>>( _ => InputAreaModel.SendDirectMessageRequested += _, _ => InputAreaModel.SendDirectMessageRequested -= _, (infos, user) => { OpenInput(false); CheckClearInput(); OverrideSelectedAccounts(infos); DirectMessageTo = new UserViewModel(user); })); CompositeDisposable.Add(InitPostLimitPrediction()); _geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); _geoWatcher.StatusChanged += (_, e) => { if (e.Status != GeoPositionStatus.Ready) { IsLocationEnabled = true; } else { IsLocationEnabled = false; AttachedLocation = null; } }; CompositeDisposable.Add(_geoWatcher); _geoWatcher.Start(); }
public UserMylistViewModel(UserViewModel vm) : base("マイリスト") { User = vm; UserMylistList = new DispatcherCollection <UserMylistEntryViewModel>(DispatcherHelper.UIDispatcher); }
public UserVideoViewModel(UserViewModel vm) : base("投稿動画") { User = vm; UserVideoList = new DispatcherCollection <SearchResultEntryViewModel>(DispatcherHelper.UIDispatcher); }
public TwitterAccountConfigurationViewModel(SettingFlipViewModel parent, TwitterAccount account) { _parent = parent; this._account = account; _accounts = new DispatcherCollection<TwitterAccountViewModel>(DispatcherHelper.UIDispatcher); Setting.Accounts.Collection.ListenCollectionChanged() .Subscribe(_ => RefreshCandidates()); this.RefreshCandidates(); }
public UserNicoRepoViewModel(UserViewModel user) : base("ニコレポ") { User = user; UserNicoRepoList = new DispatcherCollection<NicoRepoResultEntryViewModel>(DispatcherHelper.UIDispatcher); }
public void Initialize() { UserInstance = new NicoNicoUser(this, UserPageUrl); UserEntry = UserInstance.GetUserInfo(); Name = UserEntry.UserName; UserContentList = new DispatcherCollection<TabItemViewModel>(DispatcherHelper.UIDispatcher) { new UserNicoRepoViewModel(this), new UserMylistViewModel(this), new UserVideoViewModel(this) }; }
public UserVideoViewModel(UserViewModel vm) : base("投稿動画") { User = vm; UserVideoList = new DispatcherCollection<SearchResultEntryViewModel>(DispatcherHelper.UIDispatcher); }
public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener<Action<CursorPosition>>( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // create temporary directory and reserve deletion before exit app. do { _tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (Directory.Exists(_tempDir)); Directory.CreateDirectory(_tempDir); App.ApplicationExit += () => { try { Directory.Delete(this._tempDir, true); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { // I think that is sign from God that I must not delete that folder if failed. } }; // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
public UserMylistViewModel(UserViewModel vm) : base("マイリスト") { User = vm; UserMylistList = new DispatcherCollection<NicoNicoUserMylistEntry>(DispatcherHelper.UIDispatcher); }
public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection <BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener <Action <CursorPosition> >( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // create temporary directory and reserve deletion before exit app. do { _tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (Directory.Exists(_tempDir)); Directory.CreateDirectory(_tempDir); App.ApplicationExit += () => { try { Directory.Delete(this._tempDir, true); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { // I think that is sign from God that I must not delete that folder if failed. } }; // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
//設定ファイルの値からインスタンスを生成する private object GetNeedValue(string name, PropertyInfo property, object value) { switch (name) { case "FontFamily": return(new FontFamily((string)value)); case "GridLength": return(new GridLengthConverter().ConvertFrom(value)); case "Uri": return(new Uri((string)value)); case "DispatcherCollection<NGCommentEntry>": { var col = new DispatcherCollection <NGCommentEntry>(DispatcherHelper.UIDispatcher); dynamic entries = (DynamicJson)value; //NGフィルターのエントリを設定ファイルからパースする foreach (var entry in entries) { var ng = new NGCommentEntry(); ng.Type = Enum.Parse(typeof(NGType), entry.Type); ng.Content = entry.Content; ng.IsEnabled = entry.IsEnabled; //NGフィルターの内容が更新されたら即セーブする ng.PropertyChanged += ((sender, e) => Save()); col.Add(ng); } //新しくフィルターリストにエントリが追加/削除されたらセーブする //追加だったら新しいエントリに即セーブするイベントを設定 col.CollectionChanged += ((sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Count != 0 && e.NewItems[0] is NGCommentEntry) { var ng = e.NewItems[0] as NGCommentEntry; ng.PropertyChanged += ((sdr, ee) => Save()); Save(); } else { Save(); } }); return(col); } case "DispatcherCollection<String>": { var col = new DispatcherCollection <string>(DispatcherHelper.UIDispatcher); dynamic entries = (DynamicJson)value; //NGフィルターのエントリを設定ファイルからパースする foreach (var entry in entries) { col.Add(entry); } //新しくフィルターリストにエントリが追加/削除されたらセーブする col.CollectionChanged += ((sender, e) => { Save(); }); return(col); } default: return(value); } }