/// <summary> /// Sets the value of the control and specifies the source of the action. /// </summary> /// <param name="newValue">New value for Value property.</param> /// <param name="source">Source of the action.</param> public void SetValue(bool newValue, eEventSource source) { CancelableEventSourceArgs cancelEventArgs = new CancelableEventSourceArgs(source); OnValueChanging(cancelEventArgs); if (cancelEventArgs.Cancel) { SwitchOffset = 0; this.Refresh(); return; } _Value = newValue; _AsyncValue = newValue; if (ShouldSyncProperties) BarFunctions.SyncProperty(this, "Value"); SwitchOffset = 0; if (this.Displayed) this.Refresh(); ExecuteCommand(); EventSourceArgs sourceEventArgs = new EventSourceArgs(source); OnValueChanged(sourceEventArgs); }
/// <summary> /// Raises ValueChanging event. /// </summary> /// <param name="e">Provides event arguments.</param> protected virtual void OnValueChanging(CancelableEventSourceArgs e) { EventHandler handler = ValueChanging; if (handler != null) handler(this, e); }
/// <summary> /// Raises BeforeMenuOpen event. /// </summary> /// <param name="e">Provides event arguments.</param> protected virtual void OnBeforeMenuOpen(CancelableEventSourceArgs e) { CancelableEventSourceHandler handler = BeforeMenuOpen; if (handler != null) handler(this, e); }
/// <summary> /// Queries whether popup can be closed. /// </summary> /// <param name="eventSource">Source of closing request.</param> /// <returns>true if popup can be closed otherwise false.</returns> internal bool QueryPopupClosing(eEventSource eventSource) { CancelableEventSourceHandler handler = QueryPopupClose; if (handler != null) { CancelableEventSourceArgs e = new CancelableEventSourceArgs(eventSource); handler(this, e); return !e.Cancel; } return true; }
/// <summary> /// Sets whether radial menu is open and provides the source of the action. /// </summary> /// <param name="isOpen">true to open menu, false to close it.</param> /// <param name="source">Source of the action.</param> public void SetIsOpen(bool isOpen, eEventSource source) { if (isOpen == _IsOpen) return; if (isOpen) { CancelableEventSourceArgs cancel = new CancelableEventSourceArgs(source); OnBeforeMenuOpen(cancel); if (cancel.Cancel) return; } bool oldValue = _IsOpen; _IsOpen = isOpen; _MenuContainer.Expanded = isOpen; OnIsOpenChanged(oldValue, isOpen); }