/// <summary> Sets the enabled state. /// </summary> /// <param name="token">An unique token to change the state back</param> /// <param name="value"><see langword="true"/> to enable; else <see langword="false"/> to disabled</param> /// <returns><see langword="true"/> if enabled; else <see langword="false"/></returns> /// <remarks> /// If the <paramref name="value"/> is <see langword="false"/> the objection (with the <paramref name="token"/> ) will be added.<br/> /// If the <paramref name="value"/> is <see langword="true"/> the objection (with the <paramref name="token"/> ) will be removed.<br/> /// As long at least one objection ist pressend, the <see cref="IsEnabled"/> returns <see langword="false"/>. <br/> /// Multiple objections with same token does not increase the objection counter. /// </remarks> public bool SetEnabled(object token, bool value) { lock (_enableObjections) { bool oldIsEnabled = _enableObjections.Count == 0; if (value == false) { if (!_enableObjections.Contains(token)) // ADDED [xgksc 2013-01-24] to prevent multiple objection with same token { _enableObjections.Add(token); } } else { //FIX: System.ArgumentOutOfRangeException in List<>.Remove(o) (ObjectVM.SetEnabled) var idx = _enableObjections.IndexOf(token); if (idx >= 0) { _enableObjections.RemoveAt(idx); } } bool newIsEnabled = _enableObjections.Count == 0; if (oldIsEnabled != newIsEnabled) { IsEnabled = newIsEnabled; OnPropertyChanged("IsEnabled"); EventUtil.Raise(IsEnabledChanged, this, new RoutedPropertyChangedEventArgs <bool>(oldIsEnabled, newIsEnabled), "{54239EDA-24CB-4B82-9023-D9E403E0194F}"); } return(newIsEnabled); } }
/// <summary> Raises the <see cref="CanExecuteChanged"/>-event. /// </summary> protected void OnCanExecuteChanged() { //if(canExecute!=CanExecute) OnPropertyChanged("CanExecute"); EventUtil.Raise(CanExecuteChanged, this, EventArgs.Empty, "{5992B5C0-13B1-4921-8176-E0EA4B005C1B}"); if (_lazyCanExecuteObservable.IsValueCreated) { _lazyCanExecuteObservable.Value.Raise(CanExecute); } }
protected virtual void RequestUserFeedbackCore(UserFeedbackEventArgs args) { if (args.Source == null) { args.Source = this; } //Routing strategy: bubble to root until first handler found which sets the IsHandled/IsHandledAsync to true if (UserFeedbackRequested != null) { EventUtil.Raise(UserFeedbackRequested, this, args, "{B85E48C5-EBC3-401C-A4F9-D89E930D7278}"); if (args.AsyncHandled) { return; } if (args.Handled) { return; } } if (LazyWeakEventStore.IsValueCreated) { EventManager.Raise <EventHandler <UserFeedbackEventArgs>, UserFeedbackEventArgs>(LazyWeakEventStore, "UserFeedbackRequestedEvent", args); if (args.AsyncHandled) { return; } if (args.Handled) { return; } } if (Parent is ObjectBM) { ((ObjectBM)Parent).RequestUserFeedbackCore(args); } else if (Parent != null) { Parent.RequestUserFeedback(args); } else { throw new NotImplementedException("UserFeedbackRequested handler not registered and no parent present!" + "\n\t" + "Model: " + DebugUtil.FormatTypeName(this) + "\n\t" + "OriganalSource: " + DebugUtil.FormatTypeName(args.Source) + "\n\t" + "EventArgs: " + DebugUtil.FormatTypeName(args) + "\n\t" + "ErrorID: {8502A3BA-6131-436C-9D2F-627391E060D8}"); } }
/// <summary> Called by <see cref="IObjectBM"/>.OnTreeChanged(TreeChangedEventArgs) when tree changed. /// </summary> /// <param name="eventDelegate">The event delegate.</param> /// <param name="businessObject">The business object.</param> /// <param name="eventArgs">The <see cref="TreeChangedEventArgs"/> instance containing the event data.</param> internal static void OnTreeChanged(EventHandler <TreeChangedEventArgs> eventDelegate, ObjectBM businessObject, TreeChangedEventArgs eventArgs) { if (eventDelegate == null) { return; } if (!IsTreeChangedEventDelayed && !IsTreeChangedEventSkipped && s_DelayedTreeChangedEvents.Count == 0) { EventUtil.Raise(eventDelegate, businessObject, eventArgs, "{3B5112B8-C8D9-4E00-AC37-AE191EA26E79}"); } else if (!IsTreeChangedEventSkipped) { s_DelayedTreeChangedEvents.Add(new Tuple <EventHandler <TreeChangedEventArgs>, ObjectBM, TreeChangedEventArgs>(eventDelegate, businessObject, eventArgs)); } }
private static void RaiseDelayedEvents() { s_RaisingDelayedTreeChangeEvents = true; try { while (s_DelayedTreeChangedEvents.Count > 0) { var tuple = s_DelayedTreeChangedEvents[0]; //Debug.WriteLine("=>Raise TreeChanged " + tuple.Item2.GetType().Name); // typeof (BusinessObjectTreeHelper).Log(Flow.RaiseEvent("TreeChanged").); EventUtil.Raise(tuple.Item1, tuple.Item2, tuple.Item3, "{F126564B-958D-4768-BA8D-C736DC3C9925}"); s_DelayedTreeChangedEvents.RemoveAt(0); } } catch { throw; } finally { s_RaisingDelayedTreeChangeEvents = false; } }
/// <summary> Raises the MetadataChanged-event.<br/> /// For derived classes: Called when <see cref="Metadata"/> property changes. /// </summary> protected virtual void OnMetadataChanged(ValueChangedEventArgs <ViewModelMetadata> e) { if (HasMetadata) { Metadata.DataProviderChanged += (o1, e1) => OnDataProviderChanged(e1); var oldMetadata = e.PreviousValue; var oldDataProvider = oldMetadata != null ? (oldMetadata.HasDataProvider?oldMetadata.DataProvider:null):null; var newDataProvider = Metadata.HasDataProvider?Metadata.DataProvider:null; if (oldDataProvider != newDataProvider) { OnDataProviderChanged(new ValueChangedEventArgs <IDataProvider>(oldDataProvider, newDataProvider)); } } //if (SuppressAnyEvents == 0) ... EventUtil.Raise(MetadataChanged, this, e, "{C9E46906-5D20-4D65-8A28-6849E145D786}"); EventManager.Raise <EventHandler <ValueChangedEventArgs <ViewModelMetadata> >, ValueChangedEventArgs <ViewModelMetadata> >(LazyWeakEventStore, "MetadataChangedEvent", e); }
public static void RaiseTreeChangedEventWithHelper() { EventUtil.Raise(TreeChanged, null, null, "{07434A30-743D-4BB8-8F49-1161BA900183}"); }
public UIAccessClass() { Fields = new BackingFieldsStore(this, OnPropertyChanged); Fields[nameof(Window)].ValueChanged += (s, e) => EventUtil.Raise(WindowChanged, this, new ValueChangedEventArgs <Window>((Window)e.PreviousValue, (Window)e.NewValue), "{5AC93EA1-BB23-49CE-86F4-7DA533825945}"); }
public void RaiseEventHandler1EventArgsEvent() { EventUtil.Raise(EventHandler1EventArgsEvent, this, EventArgs.Empty, "{9EDDC463-BD20-4436-9168-B317A6D25A84}"); }
public void Common() { TestEvent += FailTestEvent; Assert.Throws <MultiTargetInvocationException>(() => EventUtil.Raise(TestEvent, this, EventArgs.Empty, "{F2D351D0-FE36-46AC-8D9D-C33969840478}")); }
public void RaiseːTargetInvocationExceptionEvent() { EventUtil.Raise(TargetInvocationExceptionEvent, this, EventArgs.Empty, "{9EDDC463-BD20-4436-9168-B317A6D25A84}"); }
public void RaiseCustomEventHandler() { EventUtil.Raise(CustomEventHandlerEvent, this, EventArgs.Empty, "{9EDDC463-BD20-4436-9168-B317A6D25A84}"); }
public void RaiseEventHandler1ValueChangedEventArgsEvent() { EventUtil.Raise(EventHandler1ValueChangedEventArgsEvent, this, DefaultValueChangedEventArgs, "{9EDDC463-BD20-4436-9168-B317A6D25A84}"); }
protected void OnPropertyChanged(string propertyName) { EventUtil.Raise(PropertyChanged, this, new PropertyChangedEventArgs(propertyName), "{D8D0E6E6-4ADA-4828-BF1A-80E538170B48}"); }
/// <summary> Raises the <see cref="BusinessPropertyChanged"/> event. /// </summary> /// <param name="e">The <see cref="KsWare.Presentation.BusinessFramework.BusinessPropertyChangedEventArgs"/> instance containing the event data.</param> protected virtual void OnBusinessPropertyChanged(BusinessPropertyChangedEventArgs e) { EventUtil.Raise(BusinessPropertyChanged, this, e, "{3364EB50-71E9-4EBF-BBB0-14F5AFB84AA4}"); EventManager.Raise <EventHandler <BusinessPropertyChangedEventArgs>, BusinessPropertyChangedEventArgs>(LazyWeakEventStore, "PropertyChangedEvent", e); }
protected virtual void OnActionProviderChanged(ValueChangedEventArgs <IActionProvider> e) { //OnPropertyChanged("ActionProvider"); EventUtil.Raise(ActionProviderChanged, this, e, "{B8F22E4D-0288-40A9-A28E-1D2D4DACA7A1}"); EventManager.Raise <EventHandler, EventArgs>(LazyWeakEventStore, "ActionProviderChangedEvent", e); }
protected void OnPropertyChanged(string propertyName) { OnBusinessPropertyChanged(new BusinessPropertyChangedEventArgs(propertyName)); EventUtil.Raise(_propertyChanged, this, new PropertyChangedEventArgs(propertyName), "{5AF425CD-76F1-44D3-A3AE-D00B7811504D}"); }