Ejemplo n.º 1
0
        private void scrollingTimer_Tick(object sender, EventArgs e)
        {
            if (this.shouldScroll)
            {
                int offset = 0;
                if (this.scrollUp)
                {
                    FastNavigationItem item = this.hostedControl.Items[0] as FastNavigationItem;
                    if (item.View.ViewStartDate <= this.Calendar.RangeMinDate)
                    {
                        return;
                    }
                    viewIndex--;
                    offset = 1;
                }
                else
                {
                    FastNavigationItem item = this.hostedControl.Items[this.hostedControl.Items.Count - 1] as FastNavigationItem;
                    if (item.View.ViewEndDate >= this.Calendar.RangeMaxDate)
                    {
                        return;
                    }
                    viewIndex++;
                    offset = -1;
                }

                int a = Calendar.RangeMaxDate.Month + (Calendar.RangeMaxDate.Year * 12);
                int b = Calendar.RangeMinDate.Month + (Calendar.RangeMinDate.Year * 12);
                if ((a - b) > hostedControl.Items.Count)
                {
                    CalendarView maxView = (this.hostedControl.Items[this.hostedControl.Items.Count - 1] as FastNavigationItem).View;
                    maxView = maxView.GetNextView(-offset);

                    int maxViewMonth = maxView.ViewStartDate.Month;
                    int maxViewYear  = maxView.ViewStartDate.Year;

                    CalendarView minView = (this.hostedControl.Items[0] as FastNavigationItem).View;
                    minView = minView.GetNextView(-offset);

                    int minViewMonth = minView.ViewStartDate.Month;
                    int minViewYear  = minView.ViewStartDate.Year;

                    InitializeNavItems(viewIndex);

                    if ((maxViewMonth >= this.Calendar.RangeMaxDate.Month && maxViewYear >= this.Calendar.RangeMaxDate.Year) ||
                        (minViewMonth <= this.Calendar.RangeMinDate.Month && minViewYear <= this.Calendar.RangeMinDate.Year))
                    {
                        viewIndex += offset;
                    }
                }

                this.scrollingTimer.Interval = 2500 / (Math.Abs(offsetPoint.Y) + 1);
            }
        }
Ejemplo n.º 2
0
        private void SetNavigationItemsVisibility()
        {
            for (int i = 0; i < this.hostedControl.Items.Count; i++)
            {
                FastNavigationItem item = this.hostedControl.Items[i] as FastNavigationItem;
                item.Visibility = ElementVisibility.Visible;
            }

            for (int i = 0; i < this.hostedControl.Items.Count; i++)
            {
                FastNavigationItem item = this.hostedControl.Items[i] as FastNavigationItem;

                for (int j = i + 1; j < this.hostedControl.Items.Count; j++)
                {
                    FastNavigationItem item2 = this.hostedControl.Items[j] as FastNavigationItem;
                    if (item.View.Equals(item2.View))
                    {
                        item2.Visibility = ElementVisibility.Collapsed;
                    }
                }
            }

            // Get Visible Items
            List <FastNavigationItem> visibleItems = new List <FastNavigationItem>();

            for (int i = 0; i < this.hostedControl.Items.Count; i++)
            {
                if (this.hostedControl.Items[i].Visibility == ElementVisibility.Visible)
                {
                    visibleItems.Add(this.hostedControl.Items[i] as FastNavigationItem);
                    this.hostedControl.Items[i].Visibility = ElementVisibility.Collapsed;
                }
            }

            for (int i = 0; i < this.hostedControl.Items.Count; i++)
            {
                if (visibleItems.Count > i)
                {
                    (this.hostedControl.Items[i] as FastNavigationItem).View       = visibleItems[i].View;
                    (this.hostedControl.Items[i] as FastNavigationItem).Text       = visibleItems[i].View.GetTitleContent();
                    (this.hostedControl.Items[i] as FastNavigationItem).Visibility = ElementVisibility.Visible;
                }
                else
                {
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 private void items_ItemsChanged(RadItemCollection changed, RadItem target, ItemsChangeOperation operation)
 {
     if (operation == ItemsChangeOperation.Inserted)
     {
         this.Children.Add(target);
     }
     else if (operation == ItemsChangeOperation.Cleared)
     {
         for (int i = this.Children.Count - 1; i >= 0; i--)
         {
             FastNavigationItem item = this.Children[i] as FastNavigationItem;
             if (item != null)
             {
                 this.Children.Remove(item);
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void items_ItemsChanged(
            RadItemCollection changed,
            RadItem target,
            ItemsChangeOperation operation)
        {
            switch (operation)
            {
            case ItemsChangeOperation.Inserted:
                this.Children.Add((RadElement)target);
                break;

            case ItemsChangeOperation.Cleared:
                for (int index = this.Children.Count - 1; index >= 0; --index)
                {
                    FastNavigationItem child = this.Children[index] as FastNavigationItem;
                    if (child != null)
                    {
                        this.Children.Remove((RadElement)child);
                    }
                }
                break;
            }
        }
Ejemplo n.º 5
0
        private void LoadFastNavigationItems()
        {
            this.viewIndex = 0;

            InitializeNavItems(0);

            this.hostedControl.Items.Clear();

            if (this.hostedControl.Items.Count == 0)
            {
                this.dropDown.SizingMode = SizingMode.None;

                int fastNavigationItemsCnt = this.FastNavigationItemsCount;
                int months =
                    (this.Calendar.RangeMaxDate.Year * 12 + this.Calendar.RangeMaxDate.Month) -
                    (this.Calendar.RangeMinDate.Year * 12 + this.Calendar.RangeMinDate.Month) + 1;
                if (fastNavigationItemsCnt > months)
                {
                    fastNavigationItemsCnt = months;
                }

                FastNavigationItem previosItem = null;
                for (int i = 1; i <= fastNavigationItemsCnt; i++)
                {
                    FastNavigationItem item = null;
                    switch (i)
                    {
                    case 1:
                        item = item1;
                        break;

                    case 2:
                        item = item2;
                        break;

                    case 3:
                        item = item3;
                        break;

                    case 4:
                        item = item4;
                        break;

                    case 5:
                        item = item5;
                        break;

                    case 6:
                        item = item6;
                        break;

                    case 7:
                        item = item7;
                        break;

                    case 8:
                        item = item8;
                        break;

                    case 9:
                        item = item9;
                        break;

                    case 10:
                        item = item10;
                        break;

                    case 11:
                        item = item11;
                        break;

                    case 12:
                        item = item12;
                        break;

                    case 13:
                        item = item13;
                        break;
                    }

                    if (item == null)
                    {
                        continue;
                    }

                    if (previosItem != null && item.View.ViewStartDate == previosItem.View.ViewStartDate && item.View.ViewEndDate == previosItem.View.ViewEndDate)
                    {
                        previosItem = item;
                        continue;
                    }

                    this.hostedControl.Items.Add(item);

                    previosItem = item;
                }
            }

            SetNavigationItemsVisibility();
        }
Ejemplo n.º 6
0
        private void InitializeNavItems(int offset)
        {
            if (item1 == null)
            {
                item1  = new FastNavigationItem(this.Calendar, this.View);
                item2  = new FastNavigationItem(this.Calendar, this.View);
                item3  = new FastNavigationItem(this.Calendar, this.View);
                item4  = new FastNavigationItem(this.Calendar, this.View);
                item5  = new FastNavigationItem(this.Calendar, this.View);
                item6  = new FastNavigationItem(this.Calendar, this.View);
                item7  = new FastNavigationItem(this.Calendar, this.View);
                item8  = new FastNavigationItem(this.Calendar, this.View);
                item9  = new FastNavigationItem(this.Calendar, this.View);
                item10 = new FastNavigationItem(this.Calendar, this.View);
                item11 = new FastNavigationItem(this.Calendar, this.View);
                item12 = new FastNavigationItem(this.Calendar, this.View);
                item13 = new FastNavigationItem(this.Calendar, this.View);

                // To be reviewed later Boyko Markov
                item1.PerformLayout();
                item2.PerformLayout();
                item3.PerformLayout();
                item4.PerformLayout();
                item5.PerformLayout();
                item6.PerformLayout();
                item7.PerformLayout();
                item8.PerformLayout();
                item9.PerformLayout();
                item10.PerformLayout();
                item11.PerformLayout();
                item12.PerformLayout();
                item13.PerformLayout();
            }

            int defaultStep = 3;

            switch (this.FastNavigationItemsCount)
            {
            case 3:
                defaultStep = 1;
                break;

            case 7:
                defaultStep = 3;
                break;

            case 9:
                defaultStep = 4;
                break;

            case 11:
                defaultStep = 5;
                break;

            case 13:
                defaultStep = 6;
                break;
            }

            int yearDif  = this.Calendar.DefaultView.ViewStartDate.Year - this.Calendar.RangeMinDate.Year;
            int monthDif = this.Calendar.DefaultView.ViewStartDate.Month - this.Calendar.RangeMinDate.Month;

            int realMonthDif = (yearDif * 12) + monthDif;

            if (realMonthDif < FastNavigationItemsCount)
            {
                defaultStep = realMonthDif;
            }

            if (this.FastNavigationItemsCount > 1)
            {
                CalendarView item1View = this.Calendar.GetNewViewFromStep(-defaultStep + offset);
                CalendarView item2View = this.Calendar.GetNewViewFromStep(-defaultStep + 1 + offset);
                CalendarView item3View = this.Calendar.GetNewViewFromStep(-defaultStep + 2 + offset);

                item1.View = item1View;
                item2.View = item2View;
                item3.View = item3View;

                item1.Text = item1.View.GetTitleContent();
                item2.Text = item2.View.GetTitleContent();
                item3.Text = item3.View.GetTitleContent();
            }

            if (this.FastNavigationItemsCount > 3)
            {
                CalendarView item4View = this.Calendar.GetNewViewFromStep(-defaultStep + 3 + offset);
                CalendarView item5View = this.Calendar.GetNewViewFromStep(-defaultStep + 4 + offset);
                CalendarView item6View = this.Calendar.GetNewViewFromStep(-defaultStep + 5 + offset);
                CalendarView item7View = this.Calendar.GetNewViewFromStep(-defaultStep + 6 + offset);

                item4.View = item4View;
                item5.View = item5View;
                item6.View = item6View;
                item7.View = item7View;

                item4.Text = item4.View.GetTitleContent();
                item5.Text = item5.View.GetTitleContent();
                item6.Text = item6.View.GetTitleContent();
                item7.Text = item7.View.GetTitleContent();
            }

            if (this.FastNavigationItemsCount > 7)
            {
                item8.View = this.Calendar.GetNewViewFromStep(-defaultStep + 7 + offset);
                item9.View = this.Calendar.GetNewViewFromStep(-defaultStep + 8 + offset);
                item8.Text = item8.View.GetTitleContent();
                item9.Text = item9.View.GetTitleContent();
            }

            if (this.FastNavigationItemsCount > 9)
            {
                item10.View = this.Calendar.GetNewViewFromStep(-defaultStep + 9 + offset);
                item11.View = this.Calendar.GetNewViewFromStep(-defaultStep + 10 + offset);
                item10.Text = item10.View.GetTitleContent();
                item11.Text = item11.View.GetTitleContent();
            }

            if (this.fastNavigationItemsCount > 11)
            {
                item12.View = this.Calendar.GetNewViewFromStep(-defaultStep + 11 + offset);
                item13.View = this.Calendar.GetNewViewFromStep(-defaultStep + 12 + offset);
                item12.Text = item12.View.GetTitleContent();
                item13.Text = item13.View.GetTitleContent();
            }

            SetNavigationItemsVisibility();
            this.dropDown.Invalidate();
            this.hostedControl.Refresh();
        }