Esempio n. 1
0
        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;
                        }
                    }
                }
            });
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 5
0
        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;
            }
        }
Esempio n. 7
0
        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;
     }
 }
Esempio n. 10
0
 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();
 }
Esempio n. 11
0
        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);
 }
Esempio n. 14
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);
        }
Esempio n. 15
0
        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();
        }
Esempio n. 18
0
 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 = "";
     });
 }
Esempio n. 19
0
        //ここで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;
                }
            }
        }
Esempio n. 20
0
        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 = "";
            });
        }
Esempio n. 23
0
        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));
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 27
0
        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);

            });
        }
Esempio n. 28
0
 public LazyDataSource()
 {
     this._Items = new DispatcherCollection <T>(DispatcherHelper.UIDispatcher);
 }
Esempio n. 29
0
 public UserNicoRepoViewModel(UserViewModel user) : base("ニコレポ")
 {
     User             = user;
     UserNicoRepoList = new DispatcherCollection <NicoRepoResultEntryViewModel>(DispatcherHelper.UIDispatcher);
 }
Esempio n. 30
0
        //設定ファイルの値からインスタンスを生成する
        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;
            }
        }
Esempio n. 31
0
        /// <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();
        }
Esempio n. 32
0
 public UserMylistViewModel(UserViewModel vm) : base("マイリスト")
 {
     User           = vm;
     UserMylistList = new DispatcherCollection <UserMylistEntryViewModel>(DispatcherHelper.UIDispatcher);
 }
Esempio n. 33
0
 public UserVideoViewModel(UserViewModel vm) : base("投稿動画")
 {
     User          = vm;
     UserVideoList = new DispatcherCollection <SearchResultEntryViewModel>(DispatcherHelper.UIDispatcher);
 }
Esempio n. 34
0
 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();
 }
Esempio n. 35
0
        public UserNicoRepoViewModel(UserViewModel user) : base("ニコレポ") {

            User = user;
            UserNicoRepoList = new DispatcherCollection<NicoRepoResultEntryViewModel>(DispatcherHelper.UIDispatcher);

        }
Esempio n. 36
0
        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)
            };
        }
Esempio n. 37
0
        public UserVideoViewModel(UserViewModel vm) : base("投稿動画") {

            User = vm;
            UserVideoList = new DispatcherCollection<SearchResultEntryViewModel>(DispatcherHelper.UIDispatcher);
        }
Esempio n. 38
0
        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);
 }
Esempio n. 40
0
        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);
        }
Esempio n. 41
0
        //設定ファイルの値からインスタンスを生成する
        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);
            }
        }