상속: Command, ICommand, INotifyPropertyChanged
예제 #1
0
 public MainWindowViewModel()
 {
     closeCommand = new ViewModelCommand(Close);
     openCommand = new ViewModelCommand(Open);
     formatChangeCommand = new ViewModelCommand(FormatChangeButtonClick);
     stopCommand = new ViewModelCommand(StopButtonClick);
 }
예제 #2
0
        public MainWindowViewModel()
		{
            closeCommand = new ViewModelCommand(Close);
            openCommand = new ViewModelCommand(Open);
            previousFolderCommand = new ViewModelCommand(PreviousFolder);
            previousPageCommand = new ViewModelCommand(PreviousPage);
            nextFolderCommand = new ViewModelCommand(NextFolder);
            nextPageCommand = new ViewModelCommand(NextPage);
            model = new Model();
            SetCurrentPage();
        }
예제 #3
0
        public AccountViewModel(Account model, MainViewModel managerVM)
        {
            _accountModel = model;
            _userName = _accountModel.Builder.Name;
            _userMailAddress = _accountModel.Builder.Email;
            _manager = managerVM;
            _stream = new StreamManagerViewModel(_accountModel);
            _notification = new NotificationManagerViewModel(_accountModel.Notification);
            OpenAccountListCommand = new ViewModelCommand(OpenAccountListCommand_Execute);
            ActivateCommand = new ViewModelCommand(ActivateCommand_Execute);
            CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this));

            _thisPropChangedEventListener.Add(() => IsActive, IsActive_PropertyChanged);
            DataCacheDictionary
                .DownloadImage(new Uri(_accountModel.Builder.IconUrl.Replace("$SIZE_SEGMENT", "s38-c-k")))
                .ContinueWith(tsk => UserIconUrl = tsk.Result);
        }
예제 #4
0
        public StreamViewModel(Stream circle)
        {
            _circleModel = circle;
            _name = circle.Name;
            _status = StreamStateType.UnLoaded;
            ReconnectCommand = new ViewModelCommand(ReconnectCommand_Executed);
            ResumeCommand = new ViewModelCommand(ReconnectCommand_Executed);
            ResumeButton = new ResumeButtonViewModel() { ClickCommand = ReconnectCommand };
            CompositeDisposable.Add(_modelPropChangedEventListener = new PropertyChangedEventListener(circle));
            CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this));
            CompositeDisposable.Add(_activities = ViewModelHelper.CreateReadOnlyDispatcherCollection<Activity, ViewModel>(
                _circleModel.Activities, item => new ActivityViewModel(item, _isActive), App.Current.Dispatcher));

            _modelPropChangedEventListener.Add(() => circle.Status, Model_Status_PropertyChanged);
            _modelPropChangedEventListener.Add(() => circle.ChangedActivityCount, Model_ChangedActivityCount_PropertyChanged);
            _thisPropChangedEventListener.Add(() => ScrollOffset, ScrollOffset_PropertyChanged);
        }
예제 #5
0
 public ActivityViewModel(Activity activity, bool isActive)
 {
     _model = activity;
     _isActive = isActive;
     _comments = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         _model.Comments, item => new CommentViewModel(item, _isActive), App.Current.Dispatcher);
     _comments.CollectionChanged += _comments_CollectionChanged;
     SendCommentCommand = new ViewModelCommand(SendCommentCommand_Executed);
     CancelCommentCommand = new ViewModelCommand(CancelCommentCommand_Executed);
     CompositeDisposable.Add(_comments);
     CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this));
     CompositeDisposable.Add(
         Observable.Merge(
             Observable.Return(Unit.Default),
             Observable.FromEventPattern<EventHandler, EventArgs>(
                 handler => _model.Updated += handler,
                 handler => _model.Updated -= handler).Select(info => Unit.Default))
             .Subscribe(info => Task.Run(() => Refresh(_isActive))));
     _thisPropChangedEventListener.Add(() => IsCheckedCommentsHeader, IsCheckedCommentsHeader_PropertyChanged);
 }
예제 #6
0
파일: CommandTest.cs 프로젝트: veigr/Livet
        public void WeakHandlerTest()
        {
            using (var dispatcher = new TestDispatcherContext())
            {
                int eventReceivedCount = 0;

                DispatcherHelper.UIDispatcher = dispatcher.Dispatcher;

                var handlerResultList = new List<string>();

                var command = new ViewModelCommand(() => { }, () => true);

                var realReceiver1 = new EventReceiver(command,() => eventReceivedCount++);
                var realReceiver2 = new EventReceiver(command, () => eventReceivedCount++);

                var receiver1 = new WeakReference(realReceiver1);
                var receiver2 = new WeakReference(realReceiver2);
                var receiver3 = new EventReceiver(command, () => eventReceivedCount++);

                command.RaiseCanExecuteChanged();
                System.Threading.Thread.Sleep(1000);

                eventReceivedCount.Is(3);

                realReceiver1 = null;
                realReceiver2 = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

                receiver1.IsAlive.Is(false);
                receiver2.IsAlive.Is(false);
                receiver3.IsNot(null);

                command.RaiseCanExecuteChanged();
                System.Threading.Thread.Sleep(1000);
                eventReceivedCount.Is(4);
            }
        }
예제 #7
0
파일: CommandTest.cs 프로젝트: veigr/Livet
        public void CanExecuteHandlerBasicTest()
        {
            using (var dispatcher = new TestDispatcherContext())
            {
                DispatcherHelper.UIDispatcher = dispatcher.Dispatcher;

                var handlerResultList = new List<string>();

                var command = new ViewModelCommand(() => { }, () => true);

                EventHandler handler1 = (sender, e) => handlerResultList.Add("Handler1");
                EventHandler handler2 = (sender, e) => handlerResultList.Add("Handler2");
                EventHandler handler3 = (sender, e) => handlerResultList.Add("Handler3");

                command.CanExecuteChanged += handler1;
                command.CanExecuteChanged += handler2;
                command.CanExecuteChanged += handler3;

                command.RaiseCanExecuteChanged();
                System.Threading.Thread.Sleep(1000);

                handlerResultList.Count.Is(3);
                handlerResultList[0].Is("Handler1");
                handlerResultList[1].Is("Handler2");
                handlerResultList[2].Is("Handler3");

                handlerResultList.Clear();

                command.CanExecuteChanged -= handler2;

                command.RaiseCanExecuteChanged();
                System.Threading.Thread.Sleep(1000);

                handlerResultList.Count.Is(2);
                handlerResultList[0].Is("Handler1");
                handlerResultList[1].Is("Handler3");
            }
        }
예제 #8
0
		public TimeLineViewModel()
		{
			tweetCommand = new ViewModelCommand(Tweet, () => !String.IsNullOrEmpty(Text));
		}
예제 #9
0
		public ConfigViewModel()
		{
			inputCommand = new ViewModelCommand(Input, () => !String.IsNullOrEmpty(PinCode));
		}
예제 #10
0
 public EditViewModelBase()
 {
     this._exitCommand = new ViewModelCommand(this.Exit);
     this._registerCommand = new ViewModelCommand(this.Register);
 }
예제 #11
0
 public SearchViewModelBase()
 {
     this.Condition = new Condition();
     this._searchCommand = new ViewModelCommand(this.Search);
     this._transitEditCommand = new ViewModelCommand(this.TransitEdit);
 }
예제 #12
0
        public FolderSelectWindowViewModel()
		{
            closeCommand = new ViewModelCommand(Close);
        }