protected virtual void ManageSelectedItems(
     GridLayout layout,
     TimeTableVisualElement clickedElement)
 {
     foreach (TimeTableVisualElement child in layout.Children)
     {
         child.Selected = child == clickedElement && !child.Selected;
     }
 }
Пример #2
0
 public TimeCellFormattingEventArgs(
     int column,
     int row,
     TimeTableVisualElement element,
     bool isMinute)
 {
     this.column   = column;
     this.row      = row;
     this.element  = element;
     this.isMinute = isMinute;
 }
        protected virtual void FillHours(
            GridLayout container,
            int step,
            int columnsCount,
            string format,
            bool AmPmIndicator)
        {
            foreach (RadElement child in container.Children)
            {
                child.Click -= new EventHandler(this.element_Click);
            }
            container.Children.Clear();
            container.Columns.Clear();
            container.Rows.Clear();
            for (int index = 0; index < columnsCount; ++index)
            {
                GridLayoutColumn gridLayoutColumn = new GridLayoutColumn();
                gridLayoutColumn.SizingType = GridLayoutSizingType.Proportional;
                gridLayoutColumn.Width      = -1f;
                container.Columns.Add(gridLayoutColumn);
            }
            int           num1           = !AmPmIndicator ? 1440 / step : 720 / step;
            int           num2           = 0;
            int           num3           = 0;
            DateTime      dateTime       = new DateTime(this.Value.Year, this.Value.Month, this.Value.Day, 0, 0, 0);
            GridLayoutRow gridLayoutRow1 = new GridLayoutRow();

            gridLayoutRow1.SizingType  = GridLayoutSizingType.Fixed;
            gridLayoutRow1.FixedHeight = (float)this.RowHeight;
            container.Rows.Add(gridLayoutRow1);
            for (int index = 0; index < num1; ++index)
            {
                if (num2 >= columnsCount)
                {
                    num2 = 0;
                    ++num3;
                    GridLayoutRow gridLayoutRow2 = new GridLayoutRow();
                    gridLayoutRow2.SizingType  = GridLayoutSizingType.Fixed;
                    gridLayoutRow2.FixedHeight = (float)this.RowHeight;
                    container.Rows.Add(gridLayoutRow2);
                }
                TimeTableVisualElement element = new TimeTableVisualElement();
                int num4 = (int)element.SetValue(GridLayout.ColumnIndexProperty, (object)num2);
                int num5 = (int)element.SetValue(GridLayout.RowIndexProperty, (object)num3);
                element.Text = dateTime.ToString(this.Owner.Culture.DateTimeFormat.ShortTimePattern, (IFormatProvider)this.Owner.Culture);
                if (this.Owner.Culture.DateTimeFormat.AMDesignator != "")
                {
                    element.Text = element.Text.Replace(this.Owner.Culture.DateTimeFormat.AMDesignator, "");
                }
                if (this.Owner.Culture.DateTimeFormat.PMDesignator != "")
                {
                    element.Text = element.Text.Replace(this.Owner.Culture.DateTimeFormat.PMDesignator, "");
                }
                element.Time          = dateTime;
                element.Click        += new EventHandler(this.element_Click);
                dateTime              = dateTime.AddMinutes((double)step);
                element.Alignment     = ContentAlignment.MiddleCenter;
                element.AutoSize      = true;
                element.TextAlignment = ContentAlignment.MiddleCenter;
                if (this.Owner.Value != null && this.Owner.Value is DateTime)
                {
                    if (((DateTime)this.Owner.Value).Hour > 12 && AmPmIndicator)
                    {
                        if (element.Time.Hour + 12 < this.minValue.Hour || element.Time.Hour + 12 > this.maxValue.Hour)
                        {
                            element.Enabled = false;
                        }
                    }
                    else if (element.Time.Hour < this.minValue.Hour || element.Time.Hour > this.maxValue.Hour)
                    {
                        element.Enabled = false;
                    }
                }
                this.OnTimeCellFormatting(new TimeCellFormattingEventArgs((int)element.GetValue(GridLayout.ColumnIndexProperty), (int)element.GetValue(GridLayout.RowIndexProperty), element, false));
                container.Children.Add((RadElement)element);
                ++num2;
            }
        }
        protected virtual void FillMinutes(GridLayout container, int step, int columnsCount)
        {
            foreach (RadElement child in container.Children)
            {
                child.Click -= new EventHandler(this.elementMinutes_Click);
            }
            container.Children.Clear();
            container.Columns.Clear();
            container.Rows.Clear();
            for (int index = 0; index < columnsCount; ++index)
            {
                GridLayoutColumn gridLayoutColumn = new GridLayoutColumn();
                gridLayoutColumn.SizingType = GridLayoutSizingType.Proportional;
                gridLayoutColumn.Width      = -1f;
                container.Columns.Add(gridLayoutColumn);
            }
            int num1 = 60 / step;

            if (60 % step != 0)
            {
                ++num1;
            }
            int           num2           = 0;
            int           num3           = 0;
            DateTime      dateTime1      = new DateTime(this.Value.Year, this.Value.Month, this.Value.Day, 0, 0, 0);
            GridLayoutRow gridLayoutRow1 = new GridLayoutRow();

            gridLayoutRow1.SizingType  = GridLayoutSizingType.Fixed;
            gridLayoutRow1.FixedHeight = (float)this.RowHeight;
            container.Rows.Add(gridLayoutRow1);
            for (int index = 0; index < num1; ++index)
            {
                if (num2 >= columnsCount)
                {
                    num2 = 0;
                    ++num3;
                    GridLayoutRow gridLayoutRow2 = new GridLayoutRow();
                    gridLayoutRow2.SizingType  = GridLayoutSizingType.Fixed;
                    gridLayoutRow2.FixedHeight = (float)this.RowHeight;
                    container.Rows.Add(gridLayoutRow2);
                }
                TimeTableVisualElement element = new TimeTableVisualElement();
                int num4 = (int)element.SetValue(GridLayout.ColumnIndexProperty, (object)num2);
                int num5 = (int)element.SetValue(GridLayout.RowIndexProperty, (object)num3);
                element.Text          = "  :" + dateTime1.ToString("mm");
                element.Time          = dateTime1;
                element.Click        += new EventHandler(this.elementMinutes_Click);
                element.Alignment     = ContentAlignment.MiddleCenter;
                element.AutoSize      = true;
                element.TextAlignment = ContentAlignment.MiddleCenter;
                dateTime1             = dateTime1.AddMinutes((double)step);
                if (this.Owner.Value != null && this.Owner.Value is DateTime)
                {
                    DateTime dateTime2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, ((DateTime)this.Owner.Value).Hour, element.Time.Minute, element.Time.Second);
                    if (dateTime2.TimeOfDay < this.minValue.TimeOfDay || dateTime2.TimeOfDay > this.maxValue.TimeOfDay)
                    {
                        element.Enabled = false;
                    }
                }
                this.OnTimeCellFormatting(new TimeCellFormattingEventArgs((int)element.GetValue(GridLayout.ColumnIndexProperty), (int)element.GetValue(GridLayout.RowIndexProperty), element, true));
                container.Children.Add((RadElement)element);
                ++num2;
            }
        }
        private bool ReArrangeMinutes(int hour, out int minutes)
        {
            minutes = 0;
            bool flag1 = false;
            bool flag2 = false;

            if (hour == this.minValue.Hour)
            {
                foreach (TimeTableVisualElement child in this.containerMinutes.ContentElement.Children)
                {
                    if (child.Time.Minute < this.minValue.Minute)
                    {
                        if (child.Selected)
                        {
                            child.Selected = false;
                            flag2          = true;
                        }
                        child.Enabled = false;
                    }
                    else
                    {
                        child.Enabled = true;
                        if (flag2)
                        {
                            child.Selected = true;
                            flag2          = false;
                            minutes        = child.Time.Minute;
                            flag1          = true;
                        }
                    }
                }
            }
            else if (hour == this.maxValue.Hour)
            {
                for (int index = this.containerMinutes.ContentElement.Children.Count - 1; index >= 0; --index)
                {
                    TimeTableVisualElement child = this.containerMinutes.ContentElement.Children[index] as TimeTableVisualElement;
                    if (child.Time.Minute > this.maxValue.Minute)
                    {
                        if (child.Selected)
                        {
                            child.Selected = false;
                            flag2          = true;
                        }
                        child.Enabled = false;
                    }
                    else
                    {
                        child.Enabled = true;
                        if (flag2)
                        {
                            child.Selected = true;
                            flag2          = false;
                            minutes        = child.Time.Minute;
                            flag1          = true;
                        }
                    }
                }
            }
            else
            {
                foreach (RadElement child in this.containerMinutes.ContentElement.Children)
                {
                    child.Enabled = true;
                }
            }
            return(flag1);
        }