コード例 #1
0
ファイル: CalendarView.cs プロジェクト: Jamnine/OrmFrameEmpty
        private void FocusDateChanged(object sender, RoutedPropertyChangedEventArgs <DateTime> e)
        {
            if (this.DisplayMode != this.calendar.DisplayMode)
            {
                return;
            }

            if (this.calendar != null && this.calendar.FocusHandled)
            {
                return;
            }

            CalendarButton        btn = null;
            CalendarButtonContent content;

            if (this.DateToContent.TryGetValue((DateTime)e.NewValue, out content))
            {
                btn = content.Owner;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Not Found: " + e.NewValue);
                if (this.DateToContent.Count == 0)
                {
                    dateToFocus = e.NewValue;
                    this.calendar.FocusHandled = true;
                }
            }

            if (btn != null && btn.Focus())
            {
                this.calendar.FocusHandled = true;
            }
        }
コード例 #2
0
        private static void IsInAnotherViewChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            bool           shouldBeVisible = !(bool)e.NewValue;
            CalendarButton calendarButton  = sender as CalendarButton;

            calendarButton.Visibility = shouldBeVisible ? Visibility.Visible : Visibility.Collapsed;
        }
コード例 #3
0
ファイル: CalendarView.cs プロジェクト: Jamnine/OrmFrameEmpty
        private bool AddDate(object sender)
        {
            CalendarButton        btn     = sender as CalendarButton;
            CalendarButtonContent content = null;

            if (btn != null)
            {
                content = btn.Content as CalendarButtonContent;
            }
            if (content != null)
            {
                return(this.AddDateToCalendarSelection(content));
            }

            return(false);
        }
コード例 #4
0
ファイル: CalendarView.cs プロジェクト: Jamnine/OrmFrameEmpty
        /// <summary>
        /// When overridden in a derived class, undoes the effects of the <see cref="M:System.Windows.Controls.ItemsControl.PrepareContainerForItemOverride(System.Windows.DependencyObject,System.Object)"/> method.
        /// </summary>
        /// <param name="element">The container element.</param>
        /// <param name="item">The item.</param>
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            CalendarButton button = element as CalendarButton;

            if (button != null)
            {
                button.MouseEnter -= new System.Windows.Input.MouseEventHandler(this.CalendarButtonMouseEnter);
                ////button.MouseLeftButtonDown -= new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonDown);
                ////button.MouseLeftButtonUp -= new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonUp);
                button.RemoveHandler(CalendarButton.MouseLeftButtonDownEvent, new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonDown));
                button.RemoveHandler(CalendarButton.MouseLeftButtonUpEvent, new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonUp));
            }
            CalendarButtonContent content = item as CalendarButtonContent;

            if (content != null && this.DateToContent.ContainsKey(content.Date))
            {
                this.DateToContent.Remove(content.Date);
            }

            base.ClearContainerForItemOverride(element, item);
        }
コード例 #5
0
ファイル: CalendarView.cs プロジェクト: Jamnine/OrmFrameEmpty
        /// <summary>
        /// Prepares the specified element to display the specified item.
        /// </summary>
        /// <param name="element">Element used to display the specified item.</param>
        /// <param name="item">Specified item.</param>
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            CalendarButtonContent content = item as CalendarButtonContent;


            StyleManager.SetTheme(element, StyleManager.GetTheme(this));


            if (content != null)
            {
                // This check fixed an integratin problem with DataForm
                // TODO: Investigate why this check fixed an integratin problem with DataForm
                if (!this.DateToContent.ContainsKey(content.Date))
                {
                    this.DateToContent.Add(content.Date, content);
                }
            }

            CalendarButton button = element as CalendarButton;

            if (button != null && button != item)
            {
                if (content.ButtonType == CalendarButtonType.WeekName ||
                    content.ButtonType == CalendarButtonType.WeekNumber)
                {
                    button.IsTabStop = false;

                    string propertyPath = content.ButtonType == CalendarButtonType.WeekName ? "HideRow" : "HideColumn";

                    Binding binding = new Binding(propertyPath)
                    {
                        Source    = this,
                        Converter = new BoleanToVisibilityConverterRevert(),
                        Mode      = BindingMode.TwoWay
                    };
                    button.SetBinding(Button.VisibilityProperty, binding);

                    if (this.itemsPanel == null)
                    {
                        var calendarPanel = this.GetItemsPanel <CalendarPanel>();
                        if (calendarPanel != null)
                        {
                            this.itemsPanel = calendarPanel;

                            calendarPanel.SetBinding(CalendarPanel.HideFirstColumnProperty, new Binding("HideColumn")
                            {
                                Source = this
                            });
                            calendarPanel.SetBinding(CalendarPanel.HideFirstRowProperty, new Binding("HideRow")
                            {
                                Source = this
                            });
                        }
                    }
                }
                button.Content     = item;
                button.MouseEnter += new System.Windows.Input.MouseEventHandler(this.CalendarButtonMouseEnter);
                ////button.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonDown);
                ////button.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonUp);
                button.AddHandler(CalendarButton.MouseLeftButtonDownEvent, new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonDown), true);
                button.AddHandler(CalendarButton.MouseLeftButtonUpEvent, new System.Windows.Input.MouseButtonEventHandler(this.CalendarButtonMouseLeftButtonUp), true);

                if (dateToFocus.HasValue && content.Date.Equals(dateToFocus.Value))
                {
                    button.FocusOnLoad = true;
                    dateToFocus        = null;
                }
            }
        }