/// <summary> /// Returns the text label of the CalendarDayButton that is associated /// with this CalendarDayButtonAutomationPeer. This method is called by /// GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> /// <remarks> /// The name property can be thought of as the string of text that a /// user would use to explain which control is being referred to. It is /// important to have a textual representation for all controls in the /// graphical user interface (GUI) so that you can programmatically /// refer to the control in a localized manner. The value is settable /// on control instances through the AutomationProperties.Name attached /// property. /// </remarks> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } CalendarDayButton button = OwningCalendarDayButton; if (string.IsNullOrEmpty(name) && button != null) { if (button.DataContext is DateTime) { name = ((DateTime)button.DataContext).ToLongDateString(); } else if (button.Content != null) { name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString()); } } } return(name); }
private void HighlightDay(CalendarDayButton button, DateTime date) { if (cache.ContainsKey(date)) { if (cache[date]) { button.Background = Brushes.LightBlue; } else { button.Background = Brushes.White; } return; } if (Evento.get_Day_Events(p.ID, date).Count > 0) { cache.Add(date, true); button.Background = Brushes.LightBlue; } else { cache.Add(date, false); button.Background = Brushes.White; } }
/* * data context change event on calendar */ private void calendarButton_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { CalendarDayButton button = (CalendarDayButton)sender; DateTime date = (DateTime)button.DataContext; HighlightDay(button, date); }
void calendarButton_Loaded(object sender, EventArgs e) { CalendarDayButton button = (CalendarDayButton)sender; DateTime date = (DateTime)button.DataContext; HighlightDay(button, date); button.DataContextChanged += new DependencyPropertyChangedEventHandler(calendarButton_DataContextChanged); }
internal void RaiseSelectionEvents(SelectionChangedEventArgs e) { int numSelected = this.OwningPersianCalendar.SelectedDates.Count; int numAdded = e.AddedItems.Count; if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) && numSelected == 1 && numAdded == 1) { CalendarDayButton selectedButton = this.OwningPersianCalendar.FindDayButtonFromDay((DateTime)e.AddedItems[0]); if (selectedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } } else { if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection)) { foreach (DateTime date in e.AddedItems) { CalendarDayButton selectedButton = this.OwningPersianCalendar.FindDayButtonFromDay(date); if (selectedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { foreach (DateTime date in e.RemovedItems) { CalendarDayButton removedButton = this.OwningPersianCalendar.FindDayButtonFromDay(date); if (removedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(removedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } } }
private void CalendarDayButton_Click(object sender, RoutedEventArgs e) { CalendarDayButton button = sender as CalendarDayButton; DateTime date = GetDate(GetFirstCalendarDate(), button); if (date != DateTime.MinValue && DayClick != null) { DayClick(sender, new CalendarEventArgs(date)); } }
void calendarButton_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { DateTime?d = ((sender as CalendarDayButton).DataContext) as DateTime?; DateTime da = Convert.ToDateTime(d); CalendarDayButton button = (CalendarDayButton)sender; DateTime date = (DateTime)button.DataContext; HighlightDay(button, date); }
/* * highlights event on calendar */ private void HighlightDay(CalendarDayButton button, DateTime date) { if (highlightedDates.Contains(date)) { button.Background = (SolidColorBrush) new BrushConverter().ConvertFromString("#75B791"); } else { button.Background = (SolidColorBrush) new BrushConverter().ConvertFromString("#FFF1BE"); } }
private void HighlightDay(CalendarDayButton button, DateTime date) { if (PersistentDataProvider.Current.WorkoutDays.Contains(date)) { button.Background = Brushes.LawnGreen; } else { button.Background = Brushes.Transparent; } }
private void HighlightDay(CalendarDayButton button, DateTime date) { if (gameDates.Contains(date)) { button.Background = Brushes.PaleVioletRed; } else { button.Background = Brushes.White; } }
private void HighlightDay(CalendarDayButton button, DateTime date) { if (significantDates.Contains(date)) { button.Background = Brushes.OrangeRed; } else { button.Background = Brushes.Transparent; } }
//Marca los dias importantes, añadiendo un fondo azulado a los dias importantes y transparente al resto private void HighlightDay(CalendarDayButton button, DateTime date) { button.IsEnabled = false; if (_significantDates.Contains(date)) { button.Background = Brushes.LightBlue; } else { button.Background = Brushes.Transparent; } }
/// <summary> /// Clear any existing selection and then selects the current element. /// </summary> void ISelectionItemProvider.Select() { if (EnsureSelection()) { Calendar calendar = OwningCalendar; CalendarDayButton button = OwningCalendarDayButton; if (button.DataContext != null) { calendar.SelectedDate = (DateTime)button.DataContext; } } }
/// <summary> /// Raise an automation peer event for the selection of a day button. /// </summary> /// <param name="calendar"> /// The Calendar associated with this automation peer. /// </param> /// <param name="date">The selected date.</param> /// <param name="eventToRaise">The selection event to raise.</param> private static void RaiseDayButtonSelectionEvent(Calendar calendar, DateTime date, AutomationEvents eventToRaise) { CalendarDayButton button = calendar.FindDayButtonFromDay(date); if (button != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(button); if (peer != null) { peer.RaiseAutomationEvent(eventToRaise); } } }
private void DropDownCalendar_Loaded_IsTodayHighlighted(object sender, RoutedEventArgs e) { CalendarDayButton b = _elementToCleanUp.TestHook.DropDownCalendar.FindDayButtonFromDay(DateTime.Today); Assert.IsTrue(b.IsToday); Assert.IsFalse(b.IsSelected); _elementToCleanUp.IsTodayHighlighted = false; Assert.IsFalse(b.IsToday); _elementToCleanUp.TestHook.DropDownCalendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null); Assert.IsTrue(b.IsSelected); Assert.IsTrue(CompareDates(_elementToCleanUp.SelectedDate.Value, DateTime.Today)); _elementToCleanUp.IsDropDownOpen = false; _isLoaded = false; }
static void SetBlackout(CalendarDayButton dayButton, bool collapsed) { ControlTemplate template = dayButton.Template; Path blackoutPath = template.FindName("Blackout", dayButton) as Path; if (collapsed) { blackoutPath.Visibility = System.Windows.Visibility.Collapsed; } else { blackoutPath.Visibility = System.Windows.Visibility.Visible; } }
private static void OnIsBlackOutDisabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CalendarDayButton dayButton = d as CalendarDayButton; if (dayButton.IsLoaded) { SetBlackout(dayButton, (bool)e.NewValue); } else { dayButton.Loaded += (s, ee) => { SetBlackout(dayButton, (bool)e.NewValue); }; } }
/// <summary> /// Returns the string that describes the functionality of the /// CalendarDayButton that is associated with this /// CalendarDayButtonAutomationPeer. This method is called by /// GetHelpText. /// </summary> /// <returns> /// The help text, or String.Empty if there is no help text. /// </returns> protected override string GetHelpTextCore() { CalendarDayButton button = OwningCalendarDayButton; if (button != null && button.DataContext != null && button.DataContext is DateTime) { DateTime dataContext = (DateTime)OwningCalendarDayButton.DataContext; Globalization.DateTimeFormatInfo info = DateTimeHelper.GetCurrentDateFormat(); return(!button.IsBlackout ? dataContext.Date.ToString(info.LongDatePattern, info) : string.Format(info, "Blackout Day - {0}", dataContext.Date.ToString(info.LongDatePattern, info))); } return(base.GetHelpTextCore()); }
/// <summary> /// Returns the string that describes the functionality of the /// CalendarDayButton that is associated with this /// CalendarDayButtonAutomationPeer. This method is called by /// GetHelpText. /// </summary> /// <returns> /// The help text, or String.Empty if there is no help text. /// </returns> protected override string GetHelpTextCore() { CalendarDayButton button = OwningCalendarDayButton; if (button != null && button.DataContext != null && button.DataContext is DateTime) { DateTime dataContext = (DateTime)OwningCalendarDayButton.DataContext; Globalization.DateTimeFormatInfo info = DateTimeHelper.GetCurrentDateFormat(); return(!button.IsBlackout ? dataContext.Date.ToString(info.LongDatePattern, info) : string.Format(info, System.Windows.Controls.Properties.Resources.CalendarAutomationPeer_BlackoutDayHelpText, dataContext.Date.ToString(info.LongDatePattern, info))); } return(base.GetHelpTextCore()); }
/// <summary> /// Removes the current element from the collection of selected items. /// </summary> void ISelectionItemProvider.RemoveFromSelection() { // Return if the item is not already selected. CalendarDayButton button = OwningCalendarDayButton; if (!button.IsSelected) { return; } Calendar calendar = OwningCalendar; if (calendar != null && button.DataContext != null) { calendar.SelectedDates.Remove((DateTime)button.DataContext); } }
void DateTooltips(CalendarDayButton button, DateTime date) { Models.Calendar c = CalArray.FirstOrDefault(x => x.Date.Equals(date)); string[] l = ClArray.Where(X => X.CalID.Equals(c.ID)).Select(x => x.LogEntry.Trim()).Reverse().ToArray(); button.ToolTip = null; for (int i = 0; i < l.Length; i++) { if (i < l.Length - 1) { button.ToolTip += l[i].Trim() + "\n"; } else { button.ToolTip += l[i].Trim(); } } }
/// <summary> /// Ensure selection of the CalendarDayButton is possible. /// </summary> /// <returns> /// A value indicating whether selection of the CalendarDayButton is /// possible. /// </returns> private bool EnsureSelection() { CalendarDayButton button = OwningCalendarDayButton; if (!button.IsEnabled) { throw new ElementNotEnabledException(); } // If the day is a blackout day or the SelectionMode is None, // selection is not allowed Calendar calendar = OwningCalendar; return(!button.IsBlackout && button.Visibility != Visibility.Collapsed && calendar != null && calendar.SelectionMode != CalendarSelectionMode.None); }
internal void HighlightDay(CalendarDayButton button, DateTime date) { if (significantDates.Contains(date)) { button.Style = HighlightedDateStyle; DateTooltips(button, date); } else if (DayOfWedding.Equals(date)) { button.Style = BigDayStyle; button.ToolTip = rm.GetString("DateOfWedding"); } else { button.Style = NormalDateStyle; button.ToolTip = null; } }
public DateTime GetDate(DateTime firstDate, CalendarDayButton button) { int weekDay = (int)firstDate.DayOfWeek; if (weekDay == 0) { weekDay = 7; } if (weekDay == 1) { weekDay = 8; } for (int counter = 0; counter < calendarButtons.Count; counter++) { if (button == calendarButtons[counter]) { return(firstDate.AddDays(counter).AddDays(-weekDay)); } } return(DateTime.MinValue); }
/// <summary> /// Adds the current element to the collection of selected items. /// </summary> void ISelectionItemProvider.AddToSelection() { // Return if the item is already selected CalendarDayButton button = OwningCalendarDayButton; if (button.IsSelected) { return; } Calendar calendar = OwningCalendar; if (EnsureSelection() && button.DataContext != null) { if (calendar.SelectionMode == CalendarSelectionMode.SingleDate) { calendar.SelectedDate = (DateTime)button.DataContext; } else { calendar.SelectedDates.Add((DateTime)button.DataContext); } } }
/// <summary> /// Initializes a new instance of the CalendarDayButtonAutomationPeer class. /// </summary> /// <param name="owner">Owning CalendarDayButton</param> public CalendarDayButtonAutomationPeer(CalendarDayButton owner) : base(owner) { }
public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this CalendarDayButton This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > MouseDownObserver(this CalendarDayButton This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseDown += h, h => This.MouseDown -= h)); }
public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this CalendarDayButton This) { return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h)); }
public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this CalendarDayButton This) { return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h)); }