protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (string.Equals(e.PropertyName, nameof(Collection))) { HasDependency = ((Collection as List <PackageDependencyGroup>)?.Count ?? 0) > 0; } }
protected async override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (string.Equals(e.PropertyName, nameof(SelectedVersion))) { if ((e.OldValue is null && SelectedVersion == Package.Identity.Version) || e.NewValue is null) { // Skip loading on version list first load return; } var identity = new PackageIdentity(Package.Identity.Id, SelectedVersion); VersionData = await LoadSinglePackageMetadataAsync(identity, Package, _settingsProvider.Model.IsPreReleaseIncluded); if (Package is not null) { // Note: Workaround, this is a hack way to set specific version of package var tempPackage = new NuGetPackage(VersionData, Package.FromPage); tempPackage.AddDependencyInfo(VersionData.Identity.Version, VersionData.DependencySets); ValidateCurrentPackage(tempPackage); } } }
public void SetsValuesCorrectlyForNullPropertyName() { var iniEntry = new IniEntry(); var nullEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, (string)null); Assert.AreEqual(null, nullEventArgs.PropertyName); }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (string.Equals(e.PropertyName, nameof(TargetProjects))) { IsValid = _extensibleProjects.Count > 0; } }
/// <summary> /// Sets color for attribute's value. /// </summary> /// <param name="value">attribute's value.</param> /// <param name="isVisible">The _visibility.</param> public void SetAttributeValueVisibility(object value, bool isVisible) { // default value for visibility is true so there is no need to store true value string strValue = value == null ? string.Empty : value.ToString(); if (!Visibility.ContainsKey(strValue)) { if (!isVisible) { Visibility.Add(strValue, isVisible); } } else { if (isVisible) { Visibility.Remove(strValue); } else { Visibility[strValue] = false; } } // HACK AdvancedPropertyChangedEventArgs eventArgs = new AdvancedPropertyChangedEventArgs(this, "Visibility", new AttributeConfigurationChangeEventArgs(this, "Visibility") { Value = strValue, Visibility = isVisible }); RaisePropertyChanged(this, eventArgs); }
private void OnSelectedLanguageChanged(AdvancedPropertyChangedEventArgs e) { if (this.SelectedLanguage != null) { Task task = SetCulture(this.SelectedLanguage.Culture); } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (Time is not null && !string.IsNullOrEmpty(e.PropertyName) && e.HasPropertyChanged(e.PropertyName)) { if (Is24Hour) { if (AmPm == Meridiem.PM) { if (Time.Value.Hours < 12) { var newTimeValue = new TimeSpan(Time.Value.Hours + 12, Time.Value.Minutes, Time.Value.Seconds); TimeValueString = newTimeValue.ToString(); } else { var newTimeValue = new TimeSpan(Time.Value.Hours - 12, Time.Value.Minutes, Time.Value.Seconds); TimeValueString = newTimeValue.ToString(); } } else { TimeValueString = Time.Value.ToString(); } } else { TimeValueString = Time.Value.ToString() + " " + AmPm.ToString(); } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (e.HasPropertyChanged(() => SelectedColumn)) { SetColorPickers(); } else if (e.HasPropertyChanged(() => Grid)) { SetColorPickers(); } else if (e.HasPropertyChanged(() => ForeColor)) { if (Columns.FirstOrDefault(x => x.Name == SelectedColumn.Name) != null) { var column = Columns.First(x => x.Name == SelectedColumn.Name); column.IsChangedColor = !ForeColor.Equals(column.ForeColor); column.ForeColor = ForeColor; } SelectedColumn.ForeColor = ForeColor; } else if (e.HasPropertyChanged(() => BackColor)) { if (Columns.FirstOrDefault(x => x.Name == SelectedColumn.Name) != null) { var column = Columns.First(x => x.Name == SelectedColumn.Name); column.IsChangedColor = !BackColor.Equals(column.BackColor); column.BackColor = BackColor; } SelectedColumn.BackColor = BackColor; } base.OnPropertyChanged(e); }
/// <summary> /// Raises the <see cref="PropertyChanged"/> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="oldValue">The old value.</param> /// <param name="newValue">The new value.</param> protected void RaisePropertyChanged(object sender, string propertyName, object oldValue, object newValue) { // This is 1 of the 3 places where the AdvancedPropertyChangedEventArgs are created var eventArgs = new AdvancedPropertyChangedEventArgs(sender, propertyName, oldValue, newValue); RaisePropertyChanged(sender, eventArgs); }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (e.IsNewValueMeaningful && e.IsOldValueMeaningful) { Console.WriteLine($"ViewModel PropertyChanged, New Value : {e.NewValue}, Old Value : {e.OldValue}, Prop. Name : {e.PropertyName}"); } }
public void RaisesAdvancedPropertyChangedEvents_WhenSetViaSetValueMethod() { var counter = 0; var propertyName = default(string); var oldValue = default(object); var newValue = default(object); var observableObject = new CustomObject(); dynamic dynamicObservableObject = observableObject; // Setting value via dynamic property. observableObject.SetValue("Property1", "oldtest"); observableObject.PropertyChanged += (sender, e) => { AdvancedPropertyChangedEventArgs args = e as AdvancedPropertyChangedEventArgs; if (args is not null) { counter++; propertyName = args.PropertyName; oldValue = args.OldValue; newValue = args.NewValue; } }; observableObject.SetValue("Property1", "newtest"); Assert.AreEqual(1, counter); Assert.AreEqual(propertyName, "Property1"); Assert.AreEqual(oldValue, "oldtest"); Assert.AreEqual(newValue, "newtest"); }
public void SetsValuesCorrectlyForEmptyPropertyName() { var iniEntry = new IniEntry(); var nullEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, string.Empty); Assert.AreEqual(string.Empty, nullEventArgs.PropertyName); }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (DateTimeValue is not null && !string.IsNullOrEmpty(e.PropertyName) && e.HasPropertyChanged(e.PropertyName) && SelectedFormat is not null) { DateTimeValueString = DateTimeValue.Value.ToString(SelectedFormat.FormatValue); }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (e.PropertyName == "CurrentLineIndex") { OnCurrentLineChanged(); } base.OnPropertyChanged(e); }
/// <summary> /// Updates the IsMetadataModified flag according to the configured list of properties which modify that flag. /// Also update the BankPath property if the PresetBank changes. /// </summary> /// <param name="e"></param> protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (e.PropertyName == nameof(PreviewNotePlayer) || e.PropertyName == nameof(PresetHash)) { UpdateIsMetadataModified(); } }
public void AdvancedPropertyChangedEventArgsTest() { var args = new AdvancedPropertyChangedEventArgs("name", 13, "after"); Assert.IsNotNull(args); Assert.AreEqual("name", args.PropertyName); Assert.AreEqual(13, args.Before); Assert.AreEqual("after", args.After); }
internal void cctor > b__61_0(object sender, AdvancedPropertyChangedEventArgs args) { EmailConfirmationViewModel emailConfirmationViewModel = sender as EmailConfirmationViewModel; if (emailConfirmationViewModel != null) { emailConfirmationViewModel.UsernameHintVisible = string.IsNullOrEmpty(args.get_NewValue() as string); } }
/// <summary> /// Raises the <see cref="PropertyChanged"/> event. /// <para /> /// This is the one and only method that actually raises the <see cref="PropertyChanged"/> event. All other /// methods are (and should be) just overloads that eventually call this method. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> protected virtual void RaisePropertyChanged(object sender, AdvancedPropertyChangedEventArgs e) { PropertyChanged.SafeInvoke(sender, e); if (ReferenceEquals(this, sender)) { OnPropertyChanged(e); } }
private void NamePropertyConflicted(AdvancedPropertyChangedEventArgs e) { var message = new NameConflict(e); foreach (var subscriber in nameConflictSubscribes) { subscriber.Tell(message); } }
protected virtual void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (IsEditing && e.IsNewValueMeaningful && e.NewValue != e.OldValue) { // Throw away an old collection tracker RemoveTracker(e.PropertyName); ApplyTracker(e.PropertyName, e.NewValue); MarkPropertyModified(e.PropertyName); } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (string.Equals(e.PropertyName, nameof(DisplayName))) { return; } UpdateDisplayName(); }
private static void SelectedRowIndexChangedEventHandler(object sender, AdvancedPropertyChangedEventArgs advancedPropertyChangedEventArgs) { var vm = sender as DataGridViewModel; if (vm == null) { return; } vm.RemoveRowCommand.RaiseCanExecuteChanged(); }
public void OnPropertyChanged(string propertyName, object before, object after) { var x = new AdvancedPropertyChangedEventArgs(this, propertyName, before, after); OnPropertyChanged(x); if (!Equals(before, after)) { PropertyChanged?.Invoke(this, x); } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (Value is null) { return; } if (string.Equals(e.PropertyName, nameof(IsChecked))) { _onCheckedChangedCallback((bool)e.NewValue, Value); } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); switch (e.PropertyName) { case "ReleaseGroup": case "SelectedShow": Console.WriteLine(e.PropertyName); break; } }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { base.OnPropertyChanged(e); switch (e.PropertyName) { case "ReleaseGroup": case "SelectedShow": Console.WriteLine(e.PropertyName); break; } }
public void SetsValuesCorrectlyWithTwoArguments() { var iniEntry = new IniEntry(); var iniFile = new IniFile(); var originalEventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName"); var eventArgs = new AdvancedPropertyChangedEventArgs(iniFile, originalEventArgs); Assert.AreEqual(iniEntry, eventArgs.OriginalSender); Assert.AreEqual(iniFile, eventArgs.LatestSender); Assert.AreEqual("PropertyName", eventArgs.PropertyName); }
public void SetsValuesCorrectlyWithAllARguments() { IniEntry iniEntry = new IniEntry(); var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName", (object)"old value", "new value"); Assert.AreEqual(iniEntry, eventArgs.OriginalSender); Assert.AreEqual(iniEntry, eventArgs.LatestSender); Assert.AreEqual("PropertyName", eventArgs.PropertyName); Assert.AreEqual("old value", eventArgs.OldValue); Assert.AreEqual("new value", eventArgs.NewValue); Assert.AreEqual(true, eventArgs.IsOldValueMeaningful); Assert.AreEqual(true, eventArgs.IsNewValueMeaningful); }
protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedPreviewNotePlayer)) { RemovePreviewPlayer.RaiseCanExecuteChanged(); } if (e.PropertyName == nameof(SelectedPreviewNote)) { RemoveNote.RaiseCanExecuteChanged(); } base.OnPropertyChanged(e); }
public void SetsValuesCorrectlyWithTheeArgumentsExceptOldValue() { var iniEntry = new IniEntry(); var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, "PropertyName", (object)"new value"); Assert.AreEqual(iniEntry, eventArgs.OriginalSender); Assert.AreEqual(iniEntry, eventArgs.LatestSender); Assert.AreEqual("PropertyName", eventArgs.PropertyName); Assert.AreEqual(null, eventArgs.OldValue); Assert.AreEqual("new value", eventArgs.NewValue); Assert.AreEqual(false, eventArgs.IsOldValueMeaningful); Assert.AreEqual(true, eventArgs.IsNewValueMeaningful); }
public void SetsValuesCorrectlyWithPropertyNameOnly() { IniEntry iniEntry = new IniEntry(); IniFile iniFile = new IniFile(); var eventArgs = new AdvancedPropertyChangedEventArgs(iniEntry, iniFile, "PropertyName"); Assert.AreEqual(iniEntry, eventArgs.OriginalSender); Assert.AreEqual(iniFile, eventArgs.LatestSender); Assert.AreEqual("PropertyName", eventArgs.PropertyName); Assert.AreEqual(null, eventArgs.OldValue); Assert.AreEqual(null, eventArgs.NewValue); Assert.AreEqual(false, eventArgs.IsOldValueMeaningful); Assert.AreEqual(false, eventArgs.IsNewValueMeaningful); }
/// <summary> /// Occurs when the value of the IsNotificationVisible property is changed. /// </summary> /// <param name="e"> /// The event argument /// </param> private void OnIsNotificationVisibleChanged(AdvancedPropertyChangedEventArgs e) { if ((bool) e.NewValue) { if (_notificationBarViewModel == null) { var typeFactory = TypeFactory.Default; _notificationBarViewModel = typeFactory.CreateInstance<NotificationBarViewModel>(); _uiVisualizerService.Activate(_notificationBarViewModel, "NotificationRegion"); } else { _uiVisualizerService.Activate(_notificationBarViewModel); } } else { _uiVisualizerService.Deactivate(_notificationBarViewModel); } }
/// <summary> /// Called when a property value has changed. /// </summary> /// <param name="e">The <see cref="AdvancedPropertyChangedEventArgs"/> instance containing the event data.</param> protected override void OnPropertyChanged(AdvancedPropertyChangedEventArgs e) { if (IsSaving || IsCanceling || IsClosing || IsClosed) { return; } if (string.IsNullOrEmpty(e.PropertyName)) { return; } lock (_modelLock) { if (_modelObjects.ContainsKey(e.PropertyName)) { // Clean up old model var oldModelValue = _modelObjects[e.PropertyName]; if (oldModelValue != null) { UninitializeModelInternal(e.PropertyName, oldModelValue, ModelCleanUpMode.CancelEdit); } var newModelValue = GetValue(e.PropertyName); _modelObjects[e.PropertyName] = newModelValue; if (newModelValue != null) { InitializeModelInternal(e.PropertyName, newModelValue); } // Since the model has been changed, copy all values from the model to the view model foreach (KeyValuePair<string, ViewModelToModelMapping> viewModelToModelMap in _viewModelToModelMap) { ViewModelToModelMapping mapping = viewModelToModelMap.Value; IViewModelToModelConverter converter = mapping.Converter; if (string.CompareOrdinal(mapping.ModelProperty, e.PropertyName) == 0) { var values = new object[mapping.ValueProperties.Length]; if (newModelValue != null) { // We have a new model, ignore OneWayToSource if (mapping.Mode == ViewModelToModelMode.OneWayToSource) { continue; } for (var index = 0; index < mapping.ValueProperties.Length; index++) { var property = mapping.ValueProperties[index]; values[index] = PropertyHelper.GetPropertyValue(newModelValue, property, false); } } else { var property = mapping.ViewModelProperty; var propertyData = GetPropertyData(property); values[0] = propertyData.GetDefaultValue(); } values[0] = converter.Convert(values, this); SetValue(mapping.ViewModelProperty, values[0], true, ValidateModelsOnInitialization); } } } } // If we are validating, don't map view model values back to the model if (!IsValidating) { if (_viewModelToModelMap.ContainsKey(e.PropertyName)) { lock (_modelLock) { var mapping = _viewModelToModelMap[e.PropertyName]; var model = _modelObjects[mapping.ModelProperty]; if (model != null) { var modelInfo = _modelObjectsInfo[mapping.ModelProperty]; if (!modelInfo.IsCanceling) { var viewModelValue = GetValue(e.PropertyName); var propertiesToSet = mapping.ValueProperties; #if !WINDOWS_PHONE && !NET35 && !XAMARIN_FORMS if (_modelErrorInfo.ContainsKey(mapping.ModelProperty)) { mapping.ValueProperties.ForEach(_modelErrorInfo[mapping.ModelProperty].ClearDefaultErrors); } #endif // Only TwoWay, OneWayToSource mappings should be mapped if ((mapping.Mode == ViewModelToModelMode.TwoWay) || (mapping.Mode == ViewModelToModelMode.OneWayToSource)) { var valuesToSet = mapping.Converter.ConvertBack(viewModelValue, this); if (propertiesToSet.Length != valuesToSet.Length) { Log.Error("Properties - values count mismatch, properties '{0}', values '{1}'", string.Join(", ", propertiesToSet), string.Join(", ", valuesToSet)); } for (int index = 0; index < propertiesToSet.Length && index < valuesToSet.Length; index++) { if (PropertyHelper.TrySetPropertyValue(model, propertiesToSet[index], valuesToSet[index], false)) { Log.Debug("Updated property '{0}' on model type '{1}' to '{2}'", propertiesToSet[index], model.GetType().Name, ObjectToStringHelper.ToString(valuesToSet[index])); } else { Log.Warning("Failed to set property '{0}' on model type '{1}'", propertiesToSet[index], model.GetType().Name); } } } } } else { Log.Warning("Value for model property '{0}' is null, cannot map properties from view model to model", mapping.ModelProperty); } } } } if (InvalidateCommandsOnPropertyChanged) { ViewModelCommandManager.InvalidateCommands(); } }