private void SetExpanded(bool expanded, eEventSource action) { ExpandedChangeEventArgs e = new ExpandedChangeEventArgs(action, expanded); InvokeExpandedChanging(e); if (e.Cancel) return; m_Expanded = expanded; OnExpandedChanged(); InvokeExpandedChanged(e); }
/// <summary> /// Initializes a new instance of the EventSourceArgs class. /// </summary> /// <param name="source"></param> public EventSourceArgs(eEventSource source) { Source = source; }
public ClickEventArgs(eEventSource action, MouseButtons button) { this.EventSource=action; this.Button=button; }
/// <summary> /// Advances the current position of the slider by the specified amount. /// </summary> /// <param name="value">The amount by which to increment the sliders current position. </param> public virtual void Increment(int value, eEventSource eventSource) { SetValue(this.Value + value, eventSource); }
private void SetValue(int value, eEventSource source) { if (value == m_Value) return; CancelIntValueEventArgs e = new CancelIntValueEventArgs(); e.NewValue = value; e.EventSource = source; OnValueChanging(e); if (e.Cancel) return; if (value < m_Minimum) m_Value = m_Minimum; else if (value > m_Maximum) m_Value = m_Maximum; else m_Value = value; OnValueChanged(); if (ShouldSyncProperties) BarFunctions.SyncProperty(this, "Value"); this.Refresh(); OnAppearanceChanged(); ExecuteCommand(); }
/// <summary> /// Sets the Checked property of the item, raises appropriate events and provides the information about the source of the change. /// </summary> /// <param name="newValue">New value for Checked property</param> /// <param name="source">Source of the change.</param> public virtual void SetChecked(CheckState newValue, eEventSource source) { CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(null, this, source); InvokeCheckedChanging(e); if (e.Cancel) return; m_CheckState = newValue; m_Checked = (newValue != CheckState.Unchecked); if (this.Command != null) this.Command.Checked = m_Checked; this.OnCheckedChanged(source); OnCheckStateChanged(EventArgs.Empty); if (ShouldSyncProperties) BarFunctions.SyncProperty(this, "CheckState"); if (this.Displayed) this.Refresh(); }
/// <summary> /// Default constructor. /// </summary> public CheckBoxChangeEventArgs(CheckBoxItem oldchecked, CheckBoxItem newchecked, eEventSource eventSource) { NewChecked = newchecked; OldChecked = oldchecked; EventSource = eventSource; }
private void SetExpanded(bool expanded, eEventSource source) { if(ExpandedChanging!=null) { ExpandedChangeEventArgs args=new ExpandedChangeEventArgs(source, expanded); ExpandedChanging(this,args); if(args.Cancel) return; } m_Expanded = expanded; OnExpandedChanged(); if(ExpandedChanged!=null) { ExpandedChangeEventArgs args=new ExpandedChangeEventArgs(source, expanded); ExpandedChanged(this,args); } }
/// <summary> /// Creates new instance of the object. /// </summary> public RibbonPopupCloseEventArgs(object source, eEventSource eventSource) { this.Source = source; this.EventSource = eventSource; }
/// <summary> /// Displays the active ribbon panel on the popup if ribbon control is collapsed. /// </summary> /// <param name="source">Reference to the object that was cause of the event. This is provided to the BeforeRibbonPanelPopupClose event if an menu needs to be closed.</param> /// <param name="eventSource">Indicates the event source. This is provided to the BeforeRibbonPanelPopupClose event if an menu needs to be closed.</param> public void PopupRibbon(object source, eEventSource eventSource) { if (this.Expanded || this.SelectedRibbonTabItem == null || this.SelectedRibbonTabItem.Panel == null) return; if (m_PopupRibbonPanel == this.SelectedRibbonTabItem.Panel) return; Control f = this.FindForm(); if (f == null) f = this.Parent; if (f == null) return; // Close any currently open panels. RibbonPanel previousVisiblePanel = m_PopupRibbonPanel; if (previousVisiblePanel != null) { RibbonPopupCloseEventArgs pce = new RibbonPopupCloseEventArgs(source, eventSource); OnBeforeRibbonPanelPopupClose(pce); if (pce.Cancel) return; } //Raise events CancelEventArgs ce = new CancelEventArgs(); OnBeforeRibbonPanelPopup(ce); if (ce.Cancel) return; m_PopupMode = true; RibbonPanel panel = this.SelectedRibbonTabItem.Panel; panel.SuspendLayout(); this.Controls.Remove(panel); panel.Visible = false; panel.Dock = DockStyle.None; f.Controls.Add(panel); Point p = m_RibbonStrip.PointToScreen(new Point(0, m_RibbonStrip.Height)); p = f.PointToClient(p); panel.Font = this.Font; panel.Bounds = new Rectangle(p.X, p.Y - DefaultBottomDockPadding - 1, this.Width, GetPopupRibbonPanelHeight(panel)); panel.SetPopupMode(true, this); panel.ResumeLayout(); panel.Visible = true; panel.BringToFront(); CloseRibbonMenu(previousVisiblePanel); SetupActiveWindowTimer(); m_PopupRibbonPanel = panel; // Raise events... OnAfterRibbonPanelPopup(new EventArgs()); }
/// <summary> /// Closes the Ribbon Menu if one is currently displayed. /// </summary> public void CloseRibbonMenu(object source, eEventSource eventSource) { if (!m_PopupMode || m_PopupRibbonPanel == null) return; RibbonPopupCloseEventArgs pce = new RibbonPopupCloseEventArgs(source, eventSource); OnBeforeRibbonPanelPopupClose(pce); if (pce.Cancel) return; CloseRibbonMenu(m_PopupRibbonPanel); m_PopupRibbonPanel = null; m_PopupMode = false; }
private void CollapseToolbar(eEventSource source) { if (this.Expanded) this.Expanded = false; }
/// <summary> /// Initializes a new instance of the CancelableEventSourceArgs class. /// </summary> /// <param name="cancel"></param> public CancelableEventSourceArgs(eEventSource source, bool cancel) : base(source) { Cancel = cancel; }
/// <summary> /// Initializes a new instance of the EventSourceArgs class. /// </summary> /// <param name="source"></param> public CancelableEventSourceArgs(eEventSource source) : base(source) { }
/// <summary> /// Raises the click event and provide the information about the source of the event. /// </summary> /// <param name="source"></param> public override void RaiseClick(eEventSource source) { if (_AutoCheck && CanRaiseClick && !(this.CheckBoxStyle == eCheckBoxStyle.RadioButton && this.Checked)) { if (this.ThreeState) { if (this.CheckState == CheckState.Unchecked) SetChecked(CheckState.Checked, source); else if (this.CheckState == CheckState.Checked) SetChecked(CheckState.Indeterminate, source); else if (this.CheckState == CheckState.Indeterminate) SetChecked(CheckState.Unchecked, source); } else SetChecked(!this.Checked, source); ExecuteCommand(); } base.RaiseClick(source); }
/// <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> /// Sets the Checked property of the item, raises appropriate events and provides the information about the source of the change. /// </summary> /// <param name="newValue">New value for Checked property</param> /// <param name="source">Source of the change.</param> public virtual void SetChecked(bool newValue, eEventSource source) { // Allow user to cancel the checking if (m_CheckBoxStyle == eCheckBoxStyle.RadioButton && newValue && this.Parent != null) { CheckBoxItem b = null; foreach (BaseItem item in this.Parent.SubItems) { if (item == this) continue; b = item as CheckBoxItem; if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton) { break; } } CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(b, this, source); InvokeCheckedChanging(e); if (e.Cancel) return; } else { CheckBoxChangeEventArgs e = new CheckBoxChangeEventArgs(null, this, source); InvokeCheckedChanging(e); if (e.Cancel) return; } m_Checked = newValue; if (m_Checked && m_CheckState == CheckState.Unchecked || !m_Checked && m_CheckState != CheckState.Unchecked) { m_CheckState = m_Checked ? CheckState.Checked : CheckState.Unchecked; } if (this.Command != null) this.Command.Checked = m_Checked; this.OnCheckedChanged(source); OnCheckedBindableChanged(EventArgs.Empty); if (ShouldSyncProperties) BarFunctions.SyncProperty(this, "Checked"); if (this.Displayed) this.Refresh(); }
/// <summary> /// Sets the value of the control with state transition animation (if enabled) and specifies the source of the action. /// </summary> /// <param name="value">New value for Value property.</param> /// <param name="source">Source of the action.</param> public void SetValueAndAnimate(bool value, eEventSource source) { if (!IsAnimationEnabled) { SetValue(value, source); return; } BackgroundWorker worker = _AnimationWorker; if (worker != null) { worker.CancelAsync(); SetValue(value, source); return; } if (Value != value) { _AsyncValue = value; _AsyncSource = source; _AsyncTotalSwitchOffset = _ButtonBounds.Width - SwitchWidth; _AnimationWorker = new BackgroundWorker(); _AnimationWorker.WorkerSupportsCancellation = true; _AnimationWorker.DoWork += AnimationWorkerDoWork; _AnimationWorker.RunWorkerCompleted += AnimationWorkerRunWorkerCompleted; _AnimationWorker.RunWorkerAsync(); } }
/// <summary> /// Called after Checked property has changed. /// </summary> protected virtual void OnCheckedChanged(eEventSource source) { CheckBoxItem previous = null; if (m_CheckBoxStyle == eCheckBoxStyle.RadioButton && m_Checked && this.Parent != null) { BaseItem[] items = new BaseItem[this.Parent.SubItems.Count]; this.Parent.SubItems.CopyTo(items, 0); foreach (BaseItem item in items) { if (item == this) continue; CheckBoxItem b = item as CheckBoxItem; if (b != null && b.Checked && b.CheckBoxStyle == eCheckBoxStyle.RadioButton) { b.Checked = false; previous = b; } } } InvokeCheckedChanged(new CheckBoxChangeEventArgs(previous, this, source)); }
public ExpandedChangeEventArgs(eEventSource action, bool newExpandedValue) { this.EventSource=action; this.NewExpandedValue=newExpandedValue; }
/// <summary> /// Sets the currently selected item in the control. /// </summary> /// <param name="selection">Reference to selected item.</param> /// <param name="source">Source of the event.</param> public void SetSelectedItem(CrumbBarItem selection, eEventSource source) { bool raiseChangedEvents = selection != _SelectedItem; if (raiseChangedEvents) { CrumbBarSelectionEventArgs eventArgs = new CrumbBarSelectionEventArgs(selection); OnSelectedItemChanging(eventArgs); if (eventArgs.Cancel) return; selection = eventArgs.NewSelectedItem; } if (_SelectedItem != null) _SelectedItem.IsSelected = false; ArrayList newItems = new ArrayList(); if (selection == null) selection = GetFirstVisibleItem(); _ViewContainer.Expanded = false; // closes any open popups _ViewContainer.RestoreOverflowItems(); if (selection != null) { CrumbBarItem current = selection; while (current != null) { newItems.Insert(0, GetItemView(current, true)); current = current.Parent as CrumbBarItem; } UpdateSelectedItemImage(selection); } else UpdateSelectedItemImage(null); // Remove current view items _ViewContainer.ClearViewItems(); if (selection != null) { _ViewContainer.SubItems.AddRange((BaseItem[])newItems.ToArray(typeof(BaseItem))); } _ViewContainer.NeedRecalcSize = true; _SelectedItem = selection; if (_SelectedItem != null) _SelectedItem.IsSelected = true; this.RecalcLayout(); if (raiseChangedEvents) { CrumbBarSelectionEventArgs eventArgs = new CrumbBarSelectionEventArgs(selection); OnSelectedItemChanged(eventArgs); } }
/// <summary> /// Initializes a new instance of the RatingChangeEventArgs class. /// </summary> /// <param name="newRating"></param> /// <param name="oldRating"></param> /// <param name="eventSource"></param> public RatingChangeEventArgs(int newRating, int oldRating, eEventSource eventSource) { NewRating = newRating; OldRating = oldRating; EventSource = eventSource; }
/// <summary> /// Creates new instance of the class. /// </summary> /// <param name="item">Reference to DockContainerItem that is about to close</param> public DockTabClosingEventArgs(DockContainerItem item, eEventSource source) { this.DockContainerItem=item; this.Source=source; }
/// <summary> /// Sets the Rating value of the control and provides information about source of the rating change. /// </summary> /// <param name="newRating">New Rating value.</param> /// <param name="eEventSource">Source of this change.</param> public void SetRating(int newRating, eEventSource source) { if (newRating == _Rating) return; RatingChangeEventArgs e = new RatingChangeEventArgs(newRating, _Rating, source); OnRatingChanging(e); if (e.Cancel) return; newRating = e.NewRating; _Rating = newRating; OnRatingChanged(e); ExecuteCommand(); this.Refresh(); }
/// <summary> /// Advances the current position of the slider by the amount of the Step property. /// </summary> public virtual void PerformStep(eEventSource eventSource) { SetValue(this.Value + m_Step, eventSource); }
private void SetDisplayMonth(DateTime date, eEventSource source) { SetDisplayMonth(date.Month, date.Year, source); }
/// <summary> /// Invokes button's Click event. /// </summary> /// <param name="source">Indicates source of the event.</param> public void InvokeClick(eEventSource source, MouseButtons mouseButton) { OnClick(new ClickEventArgs(source, mouseButton)); }
private void SetDisplayMonth(int month, int year, eEventSource source) { DateTime d = new DateTime(year, month, 1); bool monthChanged = d != _DisplayMonth; if (monthChanged) OnMonthChanging(new DevComponents.DotNetBar.Events.EventSourceArgs(source)); _DisplayMonth = d; // Initialize days string[] dayNames = DateTimeInput.GetActiveCulture().DateTimeFormat.AbbreviatedDayNames; string[] shortestDayNames = DateTimeInput.GetActiveCulture().DateTimeFormat.ShortestDayNames; if (_DayNames != null) dayNames = _DayNames; int firstDay = (int)_FirstDayOfWeek, currentDay = firstDay; for (int i = 0; i < 7; i++) { DayLabel day = this.SubItems[i] as DayLabel; day.Text = _TwoLetterDayName ? GetTwoLetterDayName(shortestDayNames[currentDay]) : dayNames[currentDay]; day.Visible = true; day.Displayed = true; day.TrackMouse = false; day.Selectable = false; day.IsDayLabel = true; ApplyDayOfWeekMarker(day); currentDay++; if (currentDay > 6) currentDay = 0; } // Recurring monthly markers bool[] monthlyMarkers = GetMonthlyMarkers(); bool[] weeklyMarkers = GetWeeklyMarkers(); bool[] annualMarkers = GetAnnualMarkers(month); bool[] markedDays = GetMarkedDays(month, year); DateTime today = _ShowTodayMarker ? (_TodayDate == DateTime.MinValue ? DateTime.Today : _TodayDate) : DateTime.MinValue; bool markToday = today != DateTime.MinValue; // Initialize days, If Visible=true, but Displayed=False item not displayed but takes space in layout. // If Visible=false item not visible and does not take space in layout. int firstDayOfMonth = (int)d.DayOfWeek - firstDay; if (firstDayOfMonth < 0) firstDayOfMonth = 7 + firstDayOfMonth; int startIndex = 7; if (firstDayOfMonth > 0) { DateTime dt = d; dt = dt.AddDays(-firstDayOfMonth); annualMarkers = GetAnnualMarkers(dt.Month); markedDays = GetMarkedDays(dt.Month, dt.Year); for (int i = startIndex; i < startIndex + firstDayOfMonth; i++) { DayLabel day = this.SubItems[i] as DayLabel; day.Date = dt; day.Visible = true; ResetDayLabel(day); if (weeklyMarkers[(int)dt.DayOfWeek]) ApplyWeeklyMarker(day); if (monthlyMarkers[dt.Day - 1]) ApplyMonthlyMarker(day); if (annualMarkers[dt.Day - 1]) ApplyAnnualMarker(day); if (markedDays[dt.Day - 1]) ApplyDayMarker(day); if (markToday && today == dt) day.IsToday = true; if (!_WeekendDaysSelectable && DayLabel.IsWeekend(dt)) { day.Selectable = false; day.TrackMouse = false; } day.Enabled = CanSelect(dt); day.Displayed = _TrailingDaysVisible && _TrailingDaysBeforeVisible; day.IsTrailing = true; dt = dt.AddDays(1); } startIndex += firstDayOfMonth; } annualMarkers = GetAnnualMarkers(month); markedDays = GetMarkedDays(month, year); bool newMonthFirstSwitch = true; int runningWeek = 0, dayCount = startIndex % 7; for (int i = startIndex; i < 49; i++) { DayLabel day = this.SubItems[i] as DayLabel; day.Date = d; ResetDayLabel(day); if (d.Month != month && newMonthFirstSwitch) { annualMarkers = GetAnnualMarkers(d.Month); markedDays = GetMarkedDays(d.Month, d.Year); newMonthFirstSwitch = false; } if (weeklyMarkers[(int)d.DayOfWeek]) ApplyWeeklyMarker(day); if (monthlyMarkers[d.Day - 1]) ApplyMonthlyMarker(day); if (annualMarkers[d.Day - 1]) ApplyAnnualMarker(day); if (markedDays[d.Day - 1]) ApplyDayMarker(day); if (markToday && today == d) day.IsToday = true; if (!_WeekendDaysSelectable && DayLabel.IsWeekend(d)) { day.Selectable = false; day.TrackMouse = false; } day.Enabled = CanSelect(d); day.Visible = true; if (d.Month != month) { day.IsTrailing = true; day.Displayed = _TrailingDaysVisible && _TrailingDaysAfterVisible; } else { day.Displayed = true; day.IsTrailing = false; if (day.Date == _SelectedDate) day.IsSelected = true; } if (dayCount == 6) { if (_ShowWeekNumbers) { DayLabel week = this.SubItems[49 + runningWeek] as DayLabel; week.Text = DateTimeInput.GetActiveCulture().Calendar.GetWeekOfYear(d, _WeekOfYearRule, _FirstDayOfWeek).ToString(); week.Visible = true; week.TrackMouse = false; week.Selectable = false; if (d.Month != month && d.AddDays(-dayCount).Month != month) week.Displayed = _TrailingDaysVisible; else week.Displayed = true; ApplyWeekOfYearMarker(week); } runningWeek++; dayCount = -1; } d = d.AddDays(1); dayCount++; } // Update Navigation Container ItemContainer nav = GetNavigationContainer(); nav.Visible = true; nav.Displayed = true; LabelItem label = nav.SubItems[NavMonthLabel] as LabelItem; label.Width = _DaySize.Width * 3; label.Text = DateTimeInput.GetActiveCulture().DateTimeFormat.MonthNames[month - 1]; label = nav.SubItems[NavYearLabel] as LabelItem; label.Text = year.ToString(); label.Width = (int)(_DaySize.Width * 1.4); // Enable/disable navigation buttons UpdateNavigationButtonsEnabled(); this.OnAppearanceChanged(); this.Refresh(); if (monthChanged) { OnMonthChanged(new DevComponents.DotNetBar.Events.EventSourceArgs(source)); if (_YearSelector != null) RemoveYearSelector(false); } }
/// <summary> /// Raises the click event and provide the information about the source of the event. /// </summary> /// <param name="source"></param> public virtual void RaiseClick(eEventSource source) { //if (BaseItem.IsOnPopup(this)) // NativeFunctions.sndPlaySound("MenuCommand", NativeFunctions.SND_ASYNC | NativeFunctions.SND_NODEFAULT); if (!CanRaiseClick) return; IOwnerItemEvents owner = this.GetIOwnerItemEvents(); BaseItem rootParent = this.RootParentItem; if (m_AutoCollapseOnClick) { if ((!this.SystemItem || this.SystemItem && this.Name.StartsWith("mdi-")) && (IsOnPopup(this)) && !(m_Parent != null && m_Parent.SystemItem && !(m_Parent is DisplayMoreItem))) { if (!(this is PopupItem && ((PopupItem)this).ShowSubItems && (SubItems.Count > 0 || ((PopupItem)this).PopupType == ePopupType.Container))) CollapseAll(this); } if (m_Parent != null && m_Parent.AutoExpand && this.SubItems.Count == 0) m_Parent.AutoExpand = false; } if (m_InClickEvent) return; m_InClickEvent = true; try { this.OnClick(); if (Click != null) Click(this, new DevComponents.DotNetBar.Events.EventSourceArgs(source)); if (rootParent != null) { Bar bar = rootParent.ContainerControl as Bar; if (bar != null) bar.InvokeItemClick(this, new DevComponents.DotNetBar.Events.EventSourceArgs(source)); } if (owner != null && !this.SystemItem && !this.IsOnCustomizeMenu && !this.IsOnCustomizeDialog) owner.InvokeItemClick(this); } finally { m_InClickEvent = false; } }
private void SetChecked(CheckState newValue, eEventSource source) { m_CheckBox.SetChecked(newValue, source); }