当前位置: 首页>>代码示例>>C#>>正文


C# Calendar.FindDayButtonFromDay方法代码示例

本文整理汇总了C#中System.Globalization.Calendar.FindDayButtonFromDay方法的典型用法代码示例。如果您正苦于以下问题:C# Calendar.FindDayButtonFromDay方法的具体用法?C# Calendar.FindDayButtonFromDay怎么用?C# Calendar.FindDayButtonFromDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.Calendar的用法示例。


在下文中一共展示了Calendar.FindDayButtonFromDay方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyIsTodayHighlighted

 private void VerifyIsTodayHighlighted(Calendar calendar)
 {
     CalendarDayButton b = calendar.FindDayButtonFromDay(DateTime.Today);
     Assert.IsTrue(b.IsToday);
     calendar.IsTodayHighlighted = false;
     Assert.IsFalse(b.IsToday);
     _isLoaded = false;
 }
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:CalendarTest.cs

示例2: VerifySelectedDate

        private void VerifySelectedDate(Calendar calendar, DateTime d)
        {
            CalendarDayButton b;
            Assert.IsTrue(CompareDates(calendar.SelectedDate.Value, d));
            Assert.IsTrue(calendar.SelectedDates.Contains(d));
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);

            for (int i = 7; i < 48; i++)
            {
                if (i != b.Index)
                {
                    Assert.IsFalse(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
                }
            }
        }
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:CalendarTest.cs

示例3: VerifyDisplayModeVisibleDayCount

 private void VerifyDisplayModeVisibleDayCount(Calendar calendar)
 {
     calendar.DisplayMode = CalendarMode.Year;
     calendar.DisplayMode = CalendarMode.Month;
     Assert.IsFalse((calendar.FindDayButtonFromDay(new DateTime(2008, 6, 14))).IsEnabled);
     Assert.IsFalse((calendar.FindDayButtonFromDay(new DateTime(2008, 6, 30))).IsEnabled);
     _isLoaded = false;
 }
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:CalendarTest.cs

示例4: DayButton_AutomationPeer

        public void DayButton_AutomationPeer()
        {
            Calendar calendar = new Calendar();
            Assert.IsNotNull(calendar);
            _isLoaded = false;
            DateTime date = new DateTime(2000, 2, 2);
            calendar.DisplayDate = date;
            calendar.SelectedDate = date;

            CalendarAutomationPeer calendarAutomationPeer = (CalendarAutomationPeer)CalendarAutomationPeer.CreatePeerForElement(calendar);
            Assert.IsNotNull(calendarAutomationPeer);
            TestPeer testPeer = new TestPeer(calendar);

            calendar.Loaded += new RoutedEventHandler(calendar_Loaded);
            TestPanel.Children.Add(calendar);
            EnqueueConditional(IsLoaded);

            EnqueueCallback(delegate
            {
                CalendarDayButton dayButton = calendar.FindDayButtonFromDay(date);
                Assert.IsNotNull(dayButton);
                AutomationPeer peer = CalendarAutomationPeer.CreatePeerForElement(dayButton);
                Assert.IsNotNull(peer);

                Assert.AreEqual(peer.GetAutomationControlType(), AutomationControlType.Button, "Incorrect Control type for Daybutton");
                Assert.AreEqual(peer.GetClassName(), dayButton.GetType().Name, "Incorrect ClassName value for DayButton");
                Assert.AreEqual(peer.GetName(), dayButton.Content.ToString(), "Incorrect Name value for DayButtonPeer");
                Assert.IsTrue(peer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.IsTrue(peer.IsControlElement(), "Incorrect IsControlElement value");
                Assert.IsFalse(peer.IsKeyboardFocusable(), "Incorrect IsKeyBoardFocusable value");

                #region DayButtonAutomationPeer ISelectionItemProvider tests:

                ISelectionItemProvider selectionItem = (ISelectionItemProvider)peer.GetPattern(PatternInterface.SelectionItem);
                Assert.IsNotNull(selectionItem);
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.AreEqual(calendarAutomationPeer, testPeer.GetPeerFromProvider(selectionItem.SelectionContainer));
                selectionItem.RemoveFromSelection();
                Assert.IsFalse(selectionItem.IsSelected);
                selectionItem.AddToSelection();
                Assert.IsTrue(selectionItem.IsSelected);


                //check selection in SingleDate mode
                CalendarDayButton dayButton2 = calendar.FindDayButtonFromDay(date.AddDays(1));
                Assert.IsNotNull(dayButton2);
                AutomationPeer peer2 = CalendarAutomationPeer.CreatePeerForElement(dayButton2);
                Assert.IsNotNull(peer2);
                ISelectionItemProvider selectionItem2 = (ISelectionItemProvider)peer2.GetPattern(PatternInterface.SelectionItem);
                Assert.IsNotNull(selectionItem2);
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem2.AddToSelection();
                Assert.IsTrue(selectionItem2.IsSelected);
                Assert.IsFalse(selectionItem.IsSelected);

                //check blackout day
                selectionItem.RemoveFromSelection();
                calendar.BlackoutDates.Add(new CalendarDateRange(date));
                selectionItem.AddToSelection();
                Assert.IsFalse(selectionItem.IsSelected);

                //check selection in None mode
                calendar.SelectionMode = CalendarSelectionMode.None;
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem2.AddToSelection();
                Assert.IsFalse(selectionItem2.IsSelected);

                //check selection in MultiRange mode
                calendar.BlackoutDates.Clear();
                calendar.SelectionMode = CalendarSelectionMode.MultipleRange;
                Assert.IsFalse(selectionItem.IsSelected);
                Assert.IsFalse(selectionItem2.IsSelected);
                selectionItem.AddToSelection();
                selectionItem2.AddToSelection();
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.IsTrue(selectionItem2.IsSelected);
                selectionItem2.RemoveFromSelection();
                Assert.IsTrue(selectionItem.IsSelected);
                Assert.IsFalse(selectionItem2.IsSelected);
                #endregion

                #region DayButtonAutomationPeer IInvoke tests:

                //check selection and trailing day functionality
                CalendarDayButton dayButton4 = calendar.FindDayButtonFromDay(new DateTime(2000,1,31));
                Assert.IsNotNull(dayButton4);
                AutomationPeer peer4 = CalendarAutomationPeer.CreatePeerForElement(dayButton4);
                Assert.IsNotNull(peer4);
                IInvokeProvider invokeItem = (IInvokeProvider)peer4.GetPattern(PatternInterface.Invoke);
                Assert.IsNotNull(invokeItem);
                invokeItem.Invoke();
                dayButton4 = calendar.FindDayButtonFromDay(new DateTime(2000, 1, 31));
                Assert.IsTrue(dayButton4.IsSelected);
                Assert.AreEqual(calendar.DisplayDate.Month, 1);

                #endregion

                #region DayButtonAutomationPeer ITableItemProvider tests:

                ITableItemProvider tableItem = (ITableItemProvider)peer.GetPattern(PatternInterface.TableItem);
//.........这里部分代码省略.........
开发者ID:dfr0,项目名称:moon,代码行数:101,代码来源:CalendarTest.cs

示例5: VerifyKeyboardSingleRange

        private void VerifyKeyboardSingleRange(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            DateTime d, end;
            CalendarDayButton b;

            //single selection with keyboard in SingleRange Mode
            calendar.TestHook.ProcessDownKey(false, false);
            d = DateTime.Today.AddDays(7);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessUpKey(false, false);
            d = DateTime.Today;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessLeftKey(false);
            d = DateTime.Today.AddDays(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessRightKey(false);
            d = DateTime.Today;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessPageDownKey(false);
            d = DateTime.Today.AddMonths(1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessPageUpKey(false);
            d = d.AddMonths(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessHomeKey(false);
            d = calendar.DisplayDateInternal;
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessEndKey(false);
            d = d.AddMonths(1);
            d = d.AddDays(-1);
            VerifySelectedDate(calendar, d);

            calendar.TestHook.ProcessDownKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(d, end) < 1)
            {
                b = calendar.FindDayButtonFromDay(d);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                d = d.AddDays(1);
            }

            calendar.TestHook.ProcessUpKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            d = d.AddDays(-8);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);

            calendar.TestHook.ProcessUpKey(false, true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

            calendar.TestHook.ProcessLeftKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-8);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 9);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

            calendar.TestHook.ProcessRightKey(true);
            calendar.TestHook.ProcessShiftKeyUp();
            end = d.AddDays(-7);
            Assert.IsTrue(DateTime.Compare(calendar.SelectedDate.Value, calendar.SelectedDates[0]) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 8);
            while (DateTime.Compare(end, d) < 1)
            {
                b = calendar.FindDayButtonFromDay(end);
                Assert.IsTrue(b.IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)b.DataContext));
                end = end.AddDays(1);
            }

//.........这里部分代码省略.........
开发者ID:dfr0,项目名称:moon,代码行数:101,代码来源:CalendarTest.cs

示例6: VerifySelectDaySingleRangeMouseHover

        private void VerifySelectDaySingleRangeMouseHover(Calendar calendar)
        {
            //Assumes that the Calendar is Gregorian
            CalendarDayButton b;
            System.Globalization.Calendar cal = new GregorianCalendar();
            int start, end;
            DateTime r1, r2;

            r1 = new DateTime(2003, 10, 10);
            r2 = new DateTime(2003, 11, 1);

            Clear();
            calendar.DisplayDate = r1;
            b = calendar.FindDayButtonFromDay(r1);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);

            while (DateTime.Compare(r2, r1) > 0)
            {
                r1 = cal.AddDays(r1, 1);
                b = calendar.FindDayButtonFromDay(r1);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            }
            end = b.Index;
            Assert.IsTrue(calendar.SelectedDates.Count == 0);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            b = calendar.FindDayButtonFromDay(r2);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 23);
            Assert.IsTrue(_eventCount == 1);

            Assert.IsTrue(DateTimeHelper.CompareYearMonth(calendar.DisplayDate, r2) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 23);
            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));

            _isLoaded = false;
        }
开发者ID:dfr0,项目名称:moon,代码行数:46,代码来源:CalendarTest.cs

示例7: VerifySelectDaySingleRangeMouseEnter

        private void VerifySelectDaySingleRangeMouseEnter(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            CalendarDayButton b;
            int start, end;

            //
            //verify if a single day can be selected
            //
            Clear();
            DateTime d = new DateTime(2003, 10, 1);
            calendar.DisplayDate = d;
            b = calendar.FindDayButtonFromDay(d);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);


            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 0);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            calendar.SelectedDates.Clear();

            //
            //verify SingleRange selection with MouseEnter -- One single set
            //
            Clear();
            d = new DateTime(2003, 10, 10);
            b = calendar.FindDayButtonFromDay(d);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);

            d = new DateTime(2003, 10, 20);
            b = calendar.FindDayButtonFromDay(d);
            end = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
            Assert.IsTrue(calendar.SelectedDates.Count == 0);
            Assert.IsNull(calendar.SelectedDate);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 11);
            Assert.IsTrue(_removedDays.Count == 0);
            Assert.IsTrue(_eventCount == 1);
            int j = 0;
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
                Assert.IsTrue(calendar.SelectedDates.Contains((DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                Assert.IsTrue(CompareDates((DateTime)_addedDays[j], (DateTime)((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).DataContext));
                j++;
            }

            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));
            Assert.IsTrue(calendar.SelectedDates.Count == 11);


            //
            //verify SingleRange selection with MouseEnter -- two sets
            //
            Clear();
            d = new DateTime(2003, 10, 10);
            b = calendar.FindDayButtonFromDay(d);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);


            d = new DateTime(2003, 10, 20);
            b = calendar.FindDayButtonFromDay(d);
            end = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            //check if the selectedDates are not updated yet
            Assert.IsTrue(calendar.SelectedDates.Count == 11);

            d = new DateTime(2003, 10, 1);
//.........这里部分代码省略.........
开发者ID:dfr0,项目名称:moon,代码行数:101,代码来源:CalendarTest.cs

示例8: VerifySelectDaySingle

        private void VerifySelectDaySingle(Calendar calendar)
        {
            // Assumes that the Calendar is Gregorian
            CalendarDayButton b;

            Clear();
            DateTime d = new DateTime(2003, 10, 1);
            calendar.DisplayDate = d;
            b = calendar.FindDayButtonFromDay(d);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);

            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 1);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(CompareDates((DateTime)_removedDays[0], new DateTime(2000, 2, 2)));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            //check if the trailing days work in Single Mode
            Clear();
            b = calendar.FindDayButtonFromDay(new DateTime(2003, 9, 30));
            d = (DateTime)b.DataContext;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            //we find the button again since the button changed when clicked-on
            b = calendar.FindDayButtonFromDay(new DateTime(2003, 9, 30));
            Assert.IsTrue(_addedDays.Count == 1);
            Assert.IsTrue(_removedDays.Count == 1);
            Assert.IsTrue(_eventCount == 1);
            Assert.IsTrue(CompareDates((DateTime)_addedDays[0], (DateTime)b.DataContext));
            Assert.IsTrue(CompareDates((DateTime)_removedDays[0], new DateTime(2003, 10, 1)));
            Assert.IsTrue(b.IsSelected);
            Assert.AreEqual(b.DataContext, calendar.SelectedDate);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));
            Assert.AreEqual(d, calendar.SelectedDate);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);
            Assert.AreEqual(calendar.DisplayDate, new DateTime(2003, 9, 1));
            b = calendar.FindDayButtonFromDay(d);
            Assert.IsTrue(b.IsSelected);
            Assert.IsTrue(calendar.SelectedDates.Count == 1);
            Assert.IsTrue(calendar.SelectedDates.Contains(d));

            _isLoaded = false;
        }
开发者ID:dfr0,项目名称:moon,代码行数:47,代码来源:CalendarTest.cs


注:本文中的System.Globalization.Calendar.FindDayButtonFromDay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。