예제 #1
0
        private void FocusOnDatePart(int selStart)
        {
            ReformatDateText();

            string df = DateFormat;

            if (selStart > df.Length - 1)
            {
                selStart = df.Length - 1;
            }
            char firstchar = df[selStart];

            while (!char.IsLetter(firstchar) && selStart + 1 < df.Length)
            {
                selStart++;
                firstchar = df[selStart];
            }
            while (selStart > 0 && df[selStart - 1] == firstchar)
            {
                selStart--;
            }

            int selLength = 1;

            while (selStart + selLength < df.Length && df[selStart + selLength] == firstchar)
            {
                selLength++;
            }

            DateDisplay.Focus();
            DateDisplay.Select(selStart, selLength);
        }
예제 #2
0
        /// <summary>
        /// Display previous month.
        /// </summary>
        public virtual void PrevMonth()
        {
            if (!IsInteractable())
            {
                return;
            }

            DateDisplay = DateDisplay.AddMonths(-1);
        }
예제 #3
0
        /// <summary>
        /// Display previous year.
        /// </summary>
        public virtual void PrevYear()
        {
            if (!IsInteractable())
            {
                return;
            }

            DateDisplay = DateDisplay.AddYears(-1);
        }
예제 #4
0
        /// <summary>
        /// Update displayed date and month.
        /// </summary>
        protected override void UpdateDate()
        {
            if (dateText != null)
            {
                dateText.text = Date.ToString("D", Culture);
            }

            if (monthText != null)
            {
                monthText.text = DateDisplay.ToString("Y", Culture);
            }
        }
예제 #5
0
        private void FocusOnDatePart(int selstart)
        {
            if (selstart > DateFormat.Length - 1)
            {
                selstart = DateFormat.Length - 1;
            }
            char firstchar = Convert.ToChar(DateFormat.Substring(selstart, 1));

            selstart = DateFormat.IndexOf(firstchar);
            int sellength = Math.Abs((selstart - (DateFormat.LastIndexOf(firstchar) + 1)));

            DateDisplay.Focus();
            DateDisplay.Select(selstart, sellength);
        }
예제 #6
0
        private void DateDisplay_LostFocus(object sender, RoutedEventArgs e)
        {
            DateTime result;

            while ((!DateTime.TryParse(DateDisplay.Text, out result) ||
                    (Convert.ToDateTime(DateDisplay.Text) < MinimumDate) ||
                    (Convert.ToDateTime(DateDisplay.Text) > MaximumDate)) &&
                   DateDisplay.CanUndo)
            {
                DateDisplay.Undo();
            }

            if (DateTime.TryParse(DateDisplay.Text, out result) &&
                SelectedDate != Convert.ToDateTime(DateDisplay.Text))
            {
                SelectedDate = Convert.ToDateTime(DateDisplay.Text);
            }
        }
예제 #7
0
        private bool FocusOnDatePart(int selStart)
        {
            ReformatDateText();

            // Find beginning of field to select
            var df = DateFormat;

            if (selStart > df.Length - 1)
            {
                selStart = df.Length - 1;
            }
            var firstchar = df[selStart];

            while (!char.IsLetter(firstchar) && selStart + 1 < df.Length)
            {
                selStart++;
                firstchar = df[selStart];
            }
            while (selStart > 0 && df[selStart - 1] == firstchar)
            {
                selStart--;
            }

            var selLength = 1;

            while (selStart + selLength < df.Length && df[selStart + selLength] == firstchar)
            {
                selLength++;
            }

            // don't select AM/PM: we have no interface to change it. - We have now
            if (firstchar == 't')
            {
                selLength = 2;
            }
            //return false;

            DateDisplay.Focus();
            DateDisplay.Select(selStart, selLength);
            return(true);
        }
예제 #8
0
        private static void activateIntrfaceVersion()
        {
            Interfaces.MenuItem  m_VersionsAndActions = new Interfaces.MenuItem("Versions and Actions", null);
            Interfaces.IDoAction showVersion          = new VersionDisplay();
            Interfaces.MenuItem  m_ShowVersion        = new Interfaces.MenuItem("Show Version", showVersion);

            m_VersionsAndActions.AddMenuItem(m_ShowVersion);

            Interfaces.MenuItem  m_Actions     = new Interfaces.MenuItem("Actions", null);
            Interfaces.IDoAction charsCount    = new CharsCount();
            Interfaces.MenuItem  m_CharsCount  = new Interfaces.MenuItem("Chars Count", charsCount);
            Interfaces.IDoAction countSpaces   = new SpacesCount();
            Interfaces.MenuItem  m_CountSpaces = new Interfaces.MenuItem("Count Spaces", countSpaces);

            m_Actions.AddMenuItem(m_CharsCount);
            m_Actions.AddMenuItem(m_CountSpaces);
            m_VersionsAndActions.AddMenuItem(m_Actions);

            // Show Time and Date menu
            Interfaces.MenuItem  m_ShowDateAndTime = new Interfaces.MenuItem("Show Date/Time", null);
            Interfaces.IDoAction showTime          = new TimeDisplay();
            Interfaces.MenuItem  m_ShowTime        = new Interfaces.MenuItem("Show Time", showTime);
            Interfaces.IDoAction showDate          = new DateDisplay();
            Interfaces.MenuItem  m_ShowDate        = new Interfaces.MenuItem("Show Date", showDate);

            m_ShowDateAndTime.AddMenuItem(m_ShowTime);
            m_ShowDateAndTime.AddMenuItem(m_ShowDate);

            // Main menu
            Interfaces.MenuItem firstMenu = new Interfaces.MenuItem("My Menu implemented with Interfaces", null);
            Interfaces.MainMenu mainMenu  = new Interfaces.MainMenu(firstMenu);

            firstMenu.AddMenuItem(m_VersionsAndActions);
            firstMenu.AddMenuItem(m_ShowDateAndTime);

            mainMenu.Show();
        }
예제 #9
0
 /// <summary>
 /// Display previous year.
 /// </summary>
 public virtual void PrevYear()
 {
     DateDisplay = DateDisplay.AddYears(-1);
 }
예제 #10
0
 /// <summary>
 /// Display next year.
 /// </summary>
 public virtual void NextYear()
 {
     DateDisplay = DateDisplay.AddYears(1);
 }
예제 #11
0
 /// <summary>
 /// Display previous month.
 /// </summary>
 public virtual void PrevMonth()
 {
     DateDisplay = DateDisplay.AddMonths(-1);
 }
예제 #12
0
 /// <summary>
 /// Display next month.
 /// </summary>
 public virtual void NextMonth()
 {
     DateDisplay = DateDisplay.AddMonths(1);
 }
예제 #13
0
        private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape || e.Key == Key.Back)
            {
                if (DateDisplay.Text.Length > 0)
                {
                    DateDisplay.Text.Remove(DateDisplay.Text.Length - 1);
                }
                //DateDisplay.Clear();
                return;
            }

            if (e.KeyboardDevice.Modifiers == ModifierKeys.Shift)
            {
                return;
            }

            DateTime dateResult;
            var      selstart = DateDisplay.SelectionStart;

            while (!DateTime.TryParse(DateDisplay.Text, out dateResult))
            {
                DateDisplay.Undo();
            }

            e.Handled = true;
            switch (e.Key)
            {
            case Key.Up:
                SelectedDate = Increase(selstart, 1);
                FocusOnDatePart(selstart);
                break;

            case Key.Down:
                SelectedDate = Increase(selstart, -1);
                FocusOnDatePart(selstart);
                break;

            case Key.Left:
                selstart = SelectPreviousPosition(selstart);
                if (selstart > -1)
                {
                    FocusOnDatePart(selstart);
                }
                else
                {
                    this.MoveFocus(new TraversalRequest(FocusNavigationDirection.Previous));
                }
                break;

            case Key.Tab:
            case Key.Right:
                selstart = SelectNextPosition(selstart);
                if (selstart > -1)
                {
                    FocusOnDatePart(selstart);
                }
                else
                {
                    PopUpCalendarButton.Focus();
                }
                break;

            default:
                try
                {
                    if (!Char.IsDigit(Convert.ToChar(e.KeyboardDevice.ToString())))
                    {
                        if (e.Key == Key.D0 ||
                            e.Key == Key.D1 ||
                            e.Key == Key.D2 ||
                            e.Key == Key.D3 ||
                            e.Key == Key.D4 ||
                            e.Key == Key.D5 ||
                            e.Key == Key.D6 ||
                            e.Key == Key.D7 ||
                            e.Key == Key.D8 ||
                            e.Key == Key.D9)
                        {
                            e.Handled = false;
                        }
                    }
                    break;
                }
                catch { break; }
            }
        }
예제 #14
0
 private void DateDisplay_GotFocus(object sender, RoutedEventArgs e)
 {
     //DateDisplay.Clear();
     DateDisplay.SelectAll();
 }