Exemplo n.º 1
0
        public void Ctor_PropertyExpressionNull()
        {
            PropertyChangedEventHandler e = null;
            var p = new NotifyingProperty <int> (null, () => e);

            Ignore(p);
        }
Exemplo n.º 2
0
        protected FileSystemEntityViewModel()
        {
            IsExpanded = new NotifyingProperty <bool>(
                x => InteractCommand?.Execute(null)
                );

            ErrorMessage             = new NotifyingProperty <string>(
                x => Focusable.Value = string.IsNullOrEmpty(x)
                );

            DragItem = new DragAndDropHandler(
                () => string.IsNullOrEmpty(ErrorMessage.Value),
                () => new DataObject(DataFormats.FileDrop, new string[] { EntityPath.Value })
                );

            FavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Add(EntityPath.Value),
                x => !ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
                );

            UnfavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Remove(EntityPath.Value),
                x => ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
                );
        }
Exemplo n.º 3
0
 public KeyBindingsViewModel()
 {
     KeyBindings = new ObservableCollection <KeyBindingViewModel>(
         ArgsAndSettings.KeyBindings.OrderBy(x => x.DisplayIndex).Select(x => new KeyBindingViewModel(x, EditBinding, DeleteBinding))
         );
     EmptyBinding = new NotifyingProperty <KeyBindingViewModel>(MakeEmptyBinding());
 }
Exemplo n.º 4
0
        public void Ctor_Default_SetValueThrowsException()
        {
            var p = new NotifyingProperty <int>();

            Assert.AreEqual(0, p.Value);
            p.Value = 42;
        }
        protected FileSystemEntityViewModel()
        {
            IsExpanded = new NotifyingProperty<bool>(
                x => InteractCommand?.Execute(null)
            );

            ErrorMessage = new NotifyingProperty<string>(
                x => Focusable.Value = string.IsNullOrEmpty(x)
            );

            DragItem = new DragAndDropHandler(
                () => string.IsNullOrEmpty(ErrorMessage.Value),
                () => new DataObject(DataFormats.FileDrop, new string[] { EntityPath.Value })
            );

            FavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Add(EntityPath.Value),
                x => !ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
            );

            UnfavoriteCommand = new RelayCommand(
                x => ArgsAndSettings.FavoritedLocations.Remove(EntityPath.Value),
                x => ArgsAndSettings.FavoritedLocations.Contains(EntityPath.Value)
            );
        }
Exemplo n.º 6
0
        public void Ctor_NotifierNull()
        {
            int v = 0;
            var p = new NotifyingProperty <int> (() => v, null);

            Ignore(p);
        }
Exemplo n.º 7
0
        public MainWindowViewModel()
        {
            ActiveViewModel = new MainViewModel();

            WindowState = new NotifyingSetting <WindowState>(x => OnPropertyChanged("IsMaximized"), ArgsAndSettings.WindowState);
            if (WindowState.Value == System.Windows.WindowState.Minimized)
            {
                WindowState.Value = System.Windows.WindowState.Normal;
            }

            CloseCommand    = new RelayCommand(x => Application.Current.MainWindow.Close());
            MinimizeCommand = new RelayCommand(x => WindowState.Value = System.Windows.WindowState.Minimized);
            MaximizeCommand = new RelayCommand(x => WindowState.Value = System.Windows.WindowState.Maximized);
            RestoreCommand  = new RelayCommand(x => {
                if (WindowState.Value == System.Windows.WindowState.Maximized)
                {
                    WindowState.Value = System.Windows.WindowState.Normal;
                }
                else if (IsDockedOnSide.Value)
                {
                    IsDockedOnSide.Value = false;
                }
            });

            Height         = new NotifyingSetting <double>(ArgsAndSettings.Height);
            Width          = new NotifyingSetting <double>(ArgsAndSettings.Width);
            IsDockedOnSide = new NotifyingProperty <bool>(x => OnPropertyChanged("IsMaximized"));
        }
Exemplo n.º 8
0
        public void CreateDependent_DependentsNull()
        {
            Expression <Func <object> >[] dependents = null;
            int v = 0;

            NotifyingProperty.CreateDependent(() => v, () => null, dependents);
        }
Exemplo n.º 9
0
        public void NotifyingPropety_ctr_ShouldUseInitialValue()
        {
            const string initial  = "initial";
            var          property = new NotifyingProperty <string>(initial);

            Assert.AreEqual(initial, property.Value);
        }
Exemplo n.º 10
0
 public KeyBindingsViewModel()
 {
     KeyBindings = new ObservableCollection<KeyBindingViewModel>(
         ArgsAndSettings.KeyBindings.OrderBy(x => x.DisplayIndex).Select(x => new KeyBindingViewModel(x, EditBinding, DeleteBinding))
     );
     EmptyBinding = new NotifyingProperty<KeyBindingViewModel>(MakeEmptyBinding());
 }
Exemplo n.º 11
0
 public ConferenceModel(int id, string creator, IEnumerable <string> users)
 {
     Id       = new NotifyingProperty <int>(id);
     Creator  = new NotifyingProperty <string>(creator) ?? throw new ArgumentNullException(nameof(creator));
     Nickname = new NotifyingProperty <string>(Data.Nickname) ?? throw new ArgumentNullException(nameof(Data.Nickname));
     Users    = new ObservableCollection <string>(users) ?? throw new ArgumentNullException(nameof(users));
     Network.GetUpdatedConferenceUsers += Network_GetUpdatedConferenceUsers;
 }
Exemplo n.º 12
0
 public RootVM()
 {
     This             = this;
     CurrentContentVM = new NotifyingProperty <ModelBase>(new ConnectionVM());
     Network.GetRequestToEntryConference  += Model_OnGetRequestToEntryConference;
     Network.GetRequestToCreateConference += Model_OnGetRequestToCreateConference;
     Network.Connected += Network_Connected;
 }
Exemplo n.º 13
0
        public FileExplorerViewModel(string initialDirectory) : base(initialDirectory)
        {
            RootPath = new NotifyingProperty <string>(
                (oldS, newS) => { if (newS.Trim() != oldS)
                                  {
                                      SetPath(newS);
                                  }
                },
                initialDirectory
                );
            DragDropRootPath = new DragAndDropHandler(x => true, SetRootPathAndCaretIndex);
            SelectedItem     = new NotifyingProperty <FileSystemEntityViewModel>(x => {
                SelectedIndex = x == null ? -1 : GetItems(this).Select((e, i) => new { I = i, E = e }).First(z => z.E == x).I;
            });

            _refreshTimer.Interval = TimeSpan.FromMilliseconds(100);
            _refreshTimer.Tick    += _refreshTimer_Tick;

            InteractCommand = new ChainCommand(
                InteractCommand,
                x => {
                if (IsExpanded.Value)
                {
                    _refreshTimer.Start();
                }
                else
                {
                    _refreshTimer.Stop();
                }
            }
                );

            KeyPressHandler         = new KeyPressHandler(KeyPressed);
            PathBoxLostFocusCommand = new RelayCommand(x => PathBoxHasFocus.Value = false);

            PathBoxGotFocusCommand = new RelayCommand(x => {
                DeselectItem();
                PathBoxHasFocus.Value = true;
                if (_updatePathBoxCaretIndex)
                {
                    var arg = (RoutedEventArgs)x;
                    SetCaretIndex((TextBox)arg.Source);
                }
                _updatePathBoxCaretIndex = false;
            });

            PathBoxTextChangedCommand = new RelayCommand(
                x => {
                var arg = (TextChangedEventArgs)x;
                SetCaretIndex((TextBox)arg.Source);
            },
                x => _updatePathBoxCaretIndex
                );

            FavoriteSelectedCommand = new RelayCommand(
                x => SetRootPathAndCaretIndex((string)x)
                );
        }
Exemplo n.º 14
0
        public void NotifyingPropety_Value_ShouldNotRaiseValueChangedEvent_IfNewValueIsEqualToOld_NotNull()
        {
            var raised   = false;
            var property = new NotifyingProperty <string>("test2");

            property.ValueChanged += (sender, e) => raised = true;
            property.Value         = "test2";
            Assert.IsFalse(raised);
        }
Exemplo n.º 15
0
 public MainViewModel()
 {
     TextNotifyingProperty           = new NotifyingProperty <string>();
     TextValidatingNotifyingProperty = new ValidatingNotifyingProperty <string>("", true, new Dictionary <string, Func <string, bool> >
     {
         { "Can not be empty", v => v.Length == 0 },
         { "Can not be more than six characters", v => v.Length > 6 }
     });
 }
Exemplo n.º 16
0
        public void CreateDependent_PropertyDeclTypeDoesNotImplementINotifyPropertyChanged()
        {
            int x = 0, y = 1;

            NotifyingProperty.CreateDependent(
                () => x,
                () => null,
                () => y);
        }
Exemplo n.º 17
0
        public void CreateDependent_DependentsHasNoMemberReference()
        {
            var o = new NotifyPropertyChanged();
            Func <int, string> f = a => a.ToString();

            NotifyingProperty.CreateDependent(
                () => o.CurrentStep,
                () => null,
                () => f(42));
        }
Exemplo n.º 18
0
        public void NotifyingPropety_Value_ShouldRaiseValueChangedEvent_IfPreviouslyUnsetValueIsSet()
        {
            var raised   = false;
            var property = new NotifyingProperty <string>();

            property.ValueChanged += (sender, e) => raised = true;

            property.Value = "test";
            Assert.IsTrue(raised);
        }
Exemplo n.º 19
0
        public void NotifyingPropet_Valuey_ShouldRaiseValueChangedEvent_IfModified()
        {
            const string initial  = "initial";
            var          raised   = false;
            var          property = new NotifyingProperty <string>(initial);

            property.ValueChanged += (sender, e) => raised = true;

            property.Value = "test";
            Assert.IsTrue(raised);
        }
Exemplo n.º 20
0
        public void NotifyingPropety_Value_ShouldRaisePropertyChangedAfterValueChangedEvent()
        {
            const string initial  = "initial";
            var          raised   = 1;
            var          property = new NotifyingProperty <string>(initial);

            // different values of raised will show which one was exceuted first.
            property.ValueChanged    += (sender, e) => raised *= 2;
            property.PropertyChanged += (sender, e) => raised += 3;

            property.Value = "test";
            Assert.AreEqual(5, raised);
        }
Exemplo n.º 21
0
            public Worker()
            {
                currentStep = NotifyingProperty.Create(() => CurrentStep, () => PropertyChanged);
                totalSteps  = NotifyingProperty.Create(() => TotalSteps, () => PropertyChanged);

                // A PropertyChanged notification will be created for Progress every time
                // either the CurrentStep *or* TotalSteps changes.
                NotifyingProperty.CreateDependent(
                    () => Progress,
                    () => PropertyChanged,
                    () => CurrentStep,
                    () => TotalSteps);
            }
Exemplo n.º 22
0
        /// <summary>
        /// Sets the value of the notifying property.
        /// </summary>
        /// <param name="notifyingProperty">The notifying property.</param>
        /// <param name="value">The value to set.</param>
        /// <param name="forceUpdate">If set to <c>true</c> we'll force an update
        /// of the binding by calling NotifyPropertyChanged.</param>
        protected void SetValue(NotifyingProperty notifyingProperty, object value, bool forceUpdate = false)
        {
            //  We'll only set the value and notify that it has changed if the
            //  value is different - or if we are forcing an update.
            if (notifyingProperty.Value != value || forceUpdate)
            {
                //  Set the value.
                notifyingProperty.Value = value;

                //  Notify that the property has changed.
                NotifyPropertyChanged(notifyingProperty.Name);
            }
        }
Exemplo n.º 23
0
        public DocumentViewModel(string filePath, Action <string, string> filePathChangingCallback)
        {
            _fileInfo = ArgsAndSettings.CachedFiles.FirstOrDefault(x => x.OriginalFilePath == filePath || x.CachedFilePath == filePath);
            IsDirty   = new NotifyingProperty <bool>(x => SaveFileInfo());

            if (_fileInfo == null)
            {
                var uid                 = Guid.NewGuid().ToString();
                var fileName            = Path.GetFileName(filePath);
                var cachedDirectoryPath = Path.Combine(Constants.FileCachePath, uid);

                _fileInfo = new SerializableFileInfo();
                _fileInfo.CachedFilePath = Path.Combine(cachedDirectoryPath, fileName);
                Directory.CreateDirectory(cachedDirectoryPath);

                if (File.Exists(filePath))
                {
                    _fileInfo.OriginalFilePath = filePath;
                    _fileInfo.Hash             = Methods.HashFile(filePath);
                    File.Copy(filePath, _fileInfo.CachedFilePath);
                }
                else
                {
                    File.WriteAllText(_fileInfo.CachedFilePath, "");
                }

                ArgsAndSettings.CachedFiles.Add(_fileInfo);
            }

            FileName = new NotifyingProperty <string>(
                (oldName, newName) => {
                UpdateCachedFileName(newName);
                filePathChangingCallback(oldName, newName);
            },
                Path.GetFileName(_fileInfo.CachedFilePath)
                );

            FilePath = new NotifyingProperty <string>(_fileInfo.OriginalFilePath);

            DocumentContent = new AvalonTextViewModel(_fileInfo.CachedFilePath);
            DocumentContent.Content.PropertyChanged += (s, e) => UpdateHash();
            DocumentContent.ApiProvider.Save         = SaveChanges;

            _fileCheckTimer.Interval = TimeSpan.FromMilliseconds(150);
            _fileCheckTimer.Tick    += (s, e) => UpdateIsDirty();
            _fileCheckTimer.Start();
            UpdateIsDirty();
        }
Exemplo n.º 24
0
        public AvalonTextViewModel(string filepath)
        {
            Content = new NotifyingProperty <string>(File.ReadAllText(filepath));

            KeyBindingHandler = new KeyBindingExecution(
                ex => {
                ApplicationState.SetMessageAreaText(ex.Message);
                ApplicationState.SetMessageAreaTextColor("DarkRed");
            }
                );

            KeyBindingHandler.SetScriptArg("textbox", ApiProvider);
            KeyBindingHandler.SetScriptArgs(new DefaultProviderRegistry());

            LostFocusCommand = new RelayCommand(x => KeyBindingHandler.ClearPressedKeys());
        }
Exemplo n.º 25
0
        /// <summary>
        /// Sets the value of the notifying property.
        /// </summary>
        /// <param name="notifyingProperty">The notifying property.</param>
        /// <param name="value">The value to set.</param>
        /// <param name="forceUpdate">If set to <c>true</c> we'll force an update
        /// of the binding by calling NotifyPropertyChanged.</param>
        protected void SetValue(NotifyingProperty notifyingProperty, object value, bool forceUpdate = false)
        {
            ThrowIf.Variable.IsNull(notifyingProperty, nameof(notifyingProperty));
            //  We'll only set the value and notify that it has changed if the
            //  value is different - or if we are forcing an update.
            if (notifyingProperty.Value == value && !forceUpdate)
            {
                return;
            }

            //  Set the value.
            notifyingProperty.Value = value;

            //  Notify that the property has changed.
            OnPropertyChanged(notifyingProperty.Name);
        }
Exemplo n.º 26
0
        public void Value_SetInvokesEventOnChange()
        {
            int c = 0;
            PropertyChangedEventHandler e = (o, _e) => {
                Assert.AreEqual("v", _e.PropertyName);
                ++c;
            };
            int v = 0;
            var p = new NotifyingProperty <int> (() => v, () => e);

            p.Value = 0;
            Assert.AreEqual(0, c);
            p.Value = 1;
            Assert.AreEqual(1, c);
            Assert.AreEqual(1, p.Value);
        }
Exemplo n.º 27
0
        public FileExplorerViewModel(string initialDirectory) : base(initialDirectory) {
            RootPath = new NotifyingProperty<string>(
                (oldS, newS) => { if(newS.Trim() != oldS) SetPath(newS); },
                initialDirectory
            );
            DragDropRootPath = new DragAndDropHandler(x => true, SetRootPathAndCaretIndex);
            SelectedItem = new NotifyingProperty<FileSystemEntityViewModel>(x => {
                SelectedIndex = x == null ? -1 : GetItems(this).Select((e, i) => new { I = i, E = e }).First(z => z.E == x).I;
            });

            _refreshTimer.Interval = TimeSpan.FromMilliseconds(100);
            _refreshTimer.Tick += _refreshTimer_Tick;

            InteractCommand = new ChainCommand(
                InteractCommand,
                x => {
                    if(IsExpanded.Value) _refreshTimer.Start();
                    else _refreshTimer.Stop();
                }
            );

            KeyPressHandler = new KeyPressHandler(KeyPressed);
            PathBoxLostFocusCommand = new RelayCommand(x => PathBoxHasFocus.Value = false);

            PathBoxGotFocusCommand = new RelayCommand(x => {
                DeselectItem();
                PathBoxHasFocus.Value = true;
                if(_updatePathBoxCaretIndex) {
                    var arg = (RoutedEventArgs)x;
                    SetCaretIndex((TextBox)arg.Source);
                }
                _updatePathBoxCaretIndex = false;
            });

            PathBoxTextChangedCommand = new RelayCommand(
                x => {
                    var arg = (TextChangedEventArgs)x;
                    SetCaretIndex((TextBox)arg.Source);
                },
                x => _updatePathBoxCaretIndex
            );

            FavoriteSelectedCommand = new RelayCommand(
                x => SetRootPathAndCaretIndex((string)x)
            );
        }
Exemplo n.º 28
0
        public DocumentViewModel(string filePath, Action<string, string> filePathChangingCallback)
        {
            _fileInfo = ArgsAndSettings.CachedFiles.FirstOrDefault(x => x.OriginalFilePath == filePath || x.CachedFilePath == filePath);
            IsDirty = new NotifyingProperty<bool>(x => SaveFileInfo());

            if(_fileInfo == null) {
                var uid = Guid.NewGuid().ToString();
                var fileName = Path.GetFileName(filePath);
                var cachedDirectoryPath = Path.Combine(Constants.FileCachePath, uid);

                _fileInfo = new SerializableFileInfo();
                _fileInfo.CachedFilePath = Path.Combine(cachedDirectoryPath, fileName);
                Directory.CreateDirectory(cachedDirectoryPath);

                if(File.Exists(filePath)) {
                    _fileInfo.OriginalFilePath = filePath;
                    _fileInfo.Hash = Methods.HashFile(filePath);
                    File.Copy(filePath, _fileInfo.CachedFilePath);
                } else {
                    File.WriteAllText(_fileInfo.CachedFilePath, "");
                }

                ArgsAndSettings.CachedFiles.Add(_fileInfo);
            }

            FileName = new NotifyingProperty<string>(
                (oldName, newName) => {
                    UpdateCachedFileName(newName);
                    filePathChangingCallback(oldName, newName);
                },
                Path.GetFileName(_fileInfo.CachedFilePath)
            );

            FilePath = new NotifyingProperty<string>(_fileInfo.OriginalFilePath);

            DocumentContent = new AvalonTextViewModel(_fileInfo.CachedFilePath);
            DocumentContent.Content.PropertyChanged += (s,e) => UpdateHash();
            DocumentContent.ApiProvider.Save = SaveChanges;

            _fileCheckTimer.Interval = TimeSpan.FromMilliseconds(150);
            _fileCheckTimer.Tick += (s, e) => UpdateIsDirty();
            _fileCheckTimer.Start();
            UpdateIsDirty();
        }
Exemplo n.º 29
0
        public KeyBindingViewModel(KeyBinding binding, Action<KeyBinding, KeyBinding> bindingChangedCallback, Action<KeyBindingViewModel> deleteBindingCallback)
        {
            _currentBinding = binding;
            _bindingChangedCallback = bindingChangedCallback;
            KeyPressHandler = new KeyPressHandler(
                KeyPressed,
                keyDownCanExecute: x => IsEditingBinding.Value,
                keyUpCanExecute: x => IsEditingBinding.Value
            );
            Keys = new NotifyingProperty<HashSet<Key>>(_currentBinding.Keys);
            PathOrLiteral = new NotifyingProperty<string>(x => CommitChanges(), (binding as LuaKeyBinding)?.PathOrLiteral);
            ExecuteOnKeyUp = new NotifyingProperty<bool>(
                x => {
                    if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.ExecuteOnKeyUp
            );
            ExecuteOnKeyDown = new NotifyingProperty<bool>(
                x => {
                    if(!x) RepeatOnKeyDown.Value = x;
                    else if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.ExecuteOnKeyDown
            );
            RepeatOnKeyDown = new NotifyingProperty<bool>(
                x => {
                    if (x) ExecuteOnKeyDown.Value = x;
                    else if(IsEditingBinding.Value) EndEditBinding();
                    else CommitChanges();
                },
                _currentBinding.RepeatOnKeyDown
            );
            IsEditingBinding = new NotifyingProperty<bool>();
            StartEditingCommand = new RelayCommand(x => StartEditBinding());
            EndEditingCommand = new RelayCommand(x => EndEditBinding());
            if (deleteBindingCallback != null) DeleteBindingCommand = new RelayCommand(x => deleteBindingCallback(this));

            PathOrLiteralGotFocusCommand = new RelayCommand(x => PathOrLiteralIsFocused.Value = true);
            PathOrLiteralLostFocusCommand = new RelayCommand(x => PathOrLiteralIsFocused.Value = false);
            DragDrop = new DragAndDropHandler(AllowDrop, Drop);
            LostKeyboardFocusCommand = new RelayCommand(x => KeyPressHandler.ClearPressedKeys());
        }
        public SelectableButtonViewModel(string text, ICommand command)
        {
            Text.Value = text;

            bool _ignoreSelectedChanged = false;
            IsSelected = new NotifyingProperty<bool>(isSelected => {
                if (_ignoreSelectedChanged || !isSelected) return;
                Command.Execute(null);
            });

            Command = new RelayCommand(
                x => {
                    _ignoreSelectedChanged = true;
                    IsSelected.Value = true;
                    command.Execute(x);
                    _ignoreSelectedChanged = false;
                },
                command.CanExecute
            );
        }
Exemplo n.º 31
0
        public void CreateDependent_NotifierNull()
        {
            int v = 0;

            NotifyingProperty.CreateDependent(() => v, null);
        }
Exemplo n.º 32
0
 public void CreateDependent_PropertyNull()
 {
     NotifyingProperty.CreateDependent <int>(null, () => null);
 }
Exemplo n.º 33
0
 public RenameViewModel(Func<string, string> validate, string currentName, Action requestClose)
 {
     Name = new NotifyingProperty<string>(x => ValidationError.Value = validate(x), currentName);
     OkCommand = new RelayCommand(x => { DialogResult = true; requestClose(); });
     CancelCommand = new RelayCommand(x => { DialogResult = false; requestClose(); });
 }
Exemplo n.º 34
0
 public void Ctor_Default_SetValueThrowsException()
 {
     var p = new NotifyingProperty<int>();
     Assert.AreEqual (0, p.Value);
     p.Value = 42;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Gets the value of a notifying property.
 /// </summary>
 /// <param name="notifyingProperty">The notifying property.</param>
 /// <returns>The value of the notifying property.</returns>
 protected object GetValue(NotifyingProperty notifyingProperty)
 {
     ThrowIf.Variable.IsNull(notifyingProperty, nameof(notifyingProperty));
     return(notifyingProperty.Value);
 }
Exemplo n.º 36
0
 public void Value_SetInvokesEventOnChange()
 {
     int c = 0;
     PropertyChangedEventHandler e = (o, _e) => {
         Assert.AreEqual ("v", _e.PropertyName);
         ++c;
     };
     int v = 0;
     var p = new NotifyingProperty<int> (() => v, () => e);
     p.Value = 0;
     Assert.AreEqual (0, c);
     p.Value = 1;
     Assert.AreEqual (1, c);
     Assert.AreEqual (1, p.Value);
 }
Exemplo n.º 37
0
 public NotifyPropertyChanged()
 {
     currentStep = NotifyingProperty.Create(() => CurrentStep, () => null);
 }
Exemplo n.º 38
0
            public Worker()
            {
                currentStep = NotifyingProperty.Create (() => CurrentStep, () => PropertyChanged);
                totalSteps  = NotifyingProperty.Create (() => TotalSteps,  () => PropertyChanged);

                // A PropertyChanged notification will be created for Progress every time
                // either the CurrentStep *or* TotalSteps changes.
                NotifyingProperty.CreateDependent (
                        () => Progress,
                        () => PropertyChanged,
                        () => CurrentStep,
                        () => TotalSteps);
            }
Exemplo n.º 39
0
 public NotifyPropertyChanged()
 {
     currentStep = NotifyingProperty.Create (() => CurrentStep, () => null);
 }
Exemplo n.º 40
0
 public RenameViewModel(Func <string, string> validate, string currentName, Action requestClose)
 {
     Name          = new NotifyingProperty <string>(x => ValidationError.Value = validate(x), currentName);
     OkCommand     = new RelayCommand(x => { DialogResult = true; requestClose(); });
     CancelCommand = new RelayCommand(x => { DialogResult = false; requestClose(); });
 }
Exemplo n.º 41
0
 public void Ctor_NotifierNull()
 {
     int v = 0;
     var p = new NotifyingProperty<int> (() => v, null);
     Ignore (p);
 }
Exemplo n.º 42
0
        public KeyBindingViewModel(KeyBinding binding, Action <KeyBinding, KeyBinding> bindingChangedCallback, Action <KeyBindingViewModel> deleteBindingCallback)
        {
            _currentBinding         = binding;
            _bindingChangedCallback = bindingChangedCallback;
            KeyPressHandler         = new KeyPressHandler(
                KeyPressed,
                keyDownCanExecute: x => IsEditingBinding.Value,
                keyUpCanExecute: x => IsEditingBinding.Value
                );
            Keys           = new NotifyingProperty <HashSet <Key> >(_currentBinding.Keys);
            PathOrLiteral  = new NotifyingProperty <string>(x => CommitChanges(), (binding as LuaKeyBinding)?.PathOrLiteral);
            ExecuteOnKeyUp = new NotifyingProperty <bool>(
                x => {
                if (IsEditingBinding.Value)
                {
                    EndEditBinding();
                }
                else
                {
                    CommitChanges();
                }
            },
                _currentBinding.ExecuteOnKeyUp
                );
            ExecuteOnKeyDown = new NotifyingProperty <bool>(
                x => {
                if (!x)
                {
                    RepeatOnKeyDown.Value = x;
                }
                else if (IsEditingBinding.Value)
                {
                    EndEditBinding();
                }
                else
                {
                    CommitChanges();
                }
            },
                _currentBinding.ExecuteOnKeyDown
                );
            RepeatOnKeyDown = new NotifyingProperty <bool>(
                x => {
                if (x)
                {
                    ExecuteOnKeyDown.Value = x;
                }
                else if (IsEditingBinding.Value)
                {
                    EndEditBinding();
                }
                else
                {
                    CommitChanges();
                }
            },
                _currentBinding.RepeatOnKeyDown
                );
            IsEditingBinding    = new NotifyingProperty <bool>();
            StartEditingCommand = new RelayCommand(x => StartEditBinding());
            EndEditingCommand   = new RelayCommand(x => EndEditBinding());
            if (deleteBindingCallback != null)
            {
                DeleteBindingCommand = new RelayCommand(x => deleteBindingCallback(this));
            }

            PathOrLiteralGotFocusCommand  = new RelayCommand(x => PathOrLiteralIsFocused.Value = true);
            PathOrLiteralLostFocusCommand = new RelayCommand(x => PathOrLiteralIsFocused.Value = false);
            DragDrop = new DragAndDropHandler(AllowDrop, Drop);
            LostKeyboardFocusCommand = new RelayCommand(x => KeyPressHandler.ClearPressedKeys());
        }
Exemplo n.º 43
0
 public void Ctor_PropertyExpressionNull()
 {
     PropertyChangedEventHandler e = null;
     var p = new NotifyingProperty<int> (null, () => e);
     Ignore (p);
 }