Beispiel #1
0
        /// <summary>
        /// Get the range of children that are visible
        /// </summary>
        /// <param name="firstVisibleItemIndex">The item index of the first visible item</param>
        /// <param name="lastVisibleItemIndex">The item index of the last visible item</param>
        private VisibleRange GetVisibleRange()
        {
            ItemsControl itemsControl = ItemsControl.GetItemsOwner(this);
            int          itemCount    = itemsControl.HasItems ? itemsControl.Items.Count : 0;

            if (itemCount == 0)
            {
                return(VisibleRange.Empty);
            }
            else
            {
                int columns = DataSource.Source.Columns.Length;

                VisibleRange range = new VisibleRange();
                range.firstRow = Math.Max(0, (int)Math.Floor(_offset.Y / PropertiesGridControl.RowHeight) - CREATE_MARGIN_ELEMENTS);
                range.firstCol = (int)Math.Floor(_offset.X / PropertiesGridControl.DataItemWidth);
                range.rowCount = (int)Math.Ceiling((_viewport.Height) / PropertiesGridControl.RowHeight) + (CREATE_MARGIN_ELEMENTS * 2) + 1;         //Anstatt +1 wäre korrekterweise der ausgeblendete Teil der ersten Zeile zu beachten
                range.colCount = Math.Min(columns - range.firstCol, (int)Math.Ceiling((_viewport.Width) / PropertiesGridControl.DataItemWidth) + 1); //--||--

                int lastIndex = (range.firstRow + range.rowCount) * columns + range.firstCol + range.colCount;
                if (lastIndex >= itemCount)
                {
                    //Anzeige kann nicht komplett ausgefüllt werden
                    int maxRowCount = Math.Max(0, itemCount / columns - range.firstRow);
                    range.rowCount = Math.Min(maxRowCount, range.rowCount);
                }
                return(range);
            }
        }
Beispiel #2
0
    public void Init()
    {
        if (this.isInited)
        {
            return;
        }
        if (this.scroll == null)
        {
            this.scroll = GetComponent <ScrollRect>();
        }
        this.scroll.onValueChanged.AddListener(OnScrolling);

        this.isHorizontal    = this.scroll.horizontal;
        this.scaleFactor     = this.scroll.content.localScale;
        this.gridConfig      = this.scroll.content.transform.GetComponent <GridLayoutGroup>();
        this.padding         = gridConfig.padding;
        this.cellSize        = gridConfig.cellSize;
        this.spacing         = gridConfig.spacing;
        this.numPerRowOrCol  = gridConfig.constraintCount;
        gridConfig.enabled   = false;
        this.contentRT       = this.scroll.content;
        this.viewRT          = this.scroll.viewport;
        this.cellAlign       = gridConfig.childAlignment == 0 ? CellAlign.LeftOrTop : CellAlign.Center;
        this.cellTotal       = 0;
        this.curVisibleRange = new VisibleRange()
        {
            from = 0, to = -1
        };
        this.newVisibleRange = new VisibleRange()
        {
            from = 0, to = -1
        };
        this.isInited = true;
    }
Beispiel #3
0
        internal void CalculateScaleBreaksRanges(ObservableCollection <ISupportAxes> series)
        {
            if (Area == null || AxisScaleBreaks.Count == 0)
            {
                return;
            }
            DataRangeDelta  = 0;
            BreakRanges     = new List <DoubleRange>();
            BreakRangesInfo = new Dictionary <DoubleRange, ChartAxisScaleBreak>();
            AxisRanges      = new List <DoubleRange>();
            dataRanges      = new List <DoubleRange>();
            for (int i = 0; i < AxisScaleBreaks.Count; i++)
            {
                if (double.IsNaN(AxisScaleBreaks[i].Start) || (double.IsNaN(AxisScaleBreaks[i].End)))
                {
                    continue;
                }
                var range = new DoubleRange(AxisScaleBreaks[i].Start, AxisScaleBreaks[i].End);
                if (VisibleRange.Inside(range) && range.Delta > 0)
                {
                    ComputeBreakRange(range, i);
                }
            }

            AddDataRange();
            foreach (var range in dataRanges)
            {
                DataRangeDelta += range.Delta;
            }

            ComputeAxisHeight(dataRanges, DataRangeDelta);
        }
Beispiel #4
0
        protected override Size MeasureOverride(Size availableSize)
        {
            UpdateScrollInfo(availableSize);

            // Figure out range that's visible based on layout algorithm
            VisibleRange visibleRange = GetVisibleRange();

            _prevVisibleRange = visibleRange;
            if (SCROLL_CREATE_ITEMS_DELAY_MS == 0)
            {
                CalculateChildren(visibleRange);
            }
            else
            {
                Task.Delay(SCROLL_CREATE_ITEMS_DELAY_MS).ContinueWith((t) =>
                {
                    //Wartet für die angegeben Zeitspanne
                    //Falls sich der angezeigte Bereich in dieser Zeit nicht geändert hat
                    // -> Child-Element erzeugen
                    if (visibleRange.Equals(_prevVisibleRange) && !visibleRange.Equals(_calculatedVisibleRange))
                    {
                        _calculatedVisibleRange = visibleRange;
                        CalculateChildren(visibleRange);
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }

            return(availableSize);
        }
Beispiel #5
0
        /// <summary>
        /// Revirtualize items that are no longer visible
        /// </summary>
        private void CleanUpItems(VisibleRange visibleRange, int columCount)
        {
            UIElementCollection children = this.InternalChildren;

            if (children.Count > 0)
            {
                ItemsControl            itemsControl = ItemsControl.GetItemsOwner(this);
                IItemContainerGenerator generator    = this.ItemContainerGenerator;

                int firstVisibleIndex = visibleRange.firstRow * columCount + visibleRange.firstCol;
                int lastVisibleIndex  = (visibleRange.firstRow + visibleRange.rowCount) * columCount + visibleRange.firstCol + visibleRange.colCount;

                for (int i = children.Count - 1; i >= 0; i--)
                {
                    GeneratorPosition childGeneratorPos = new GeneratorPosition(i, 0);
                    int itemIndex = generator.IndexFromGeneratorPosition(childGeneratorPos);

                    if (itemIndex < firstVisibleIndex || itemIndex > lastVisibleIndex)
                    {
                        if (!((ItemViewModel)itemsControl.Items.GetItemAt(itemIndex)).InEditMode)
                        {
                            generator.Remove(childGeneratorPos, 1);
                            RemoveInternalChildRange(i, 1);
                        }
                    }
                }
            }
        }
        public void AsSerializableObject_InitializedAsFunction_FunctionIsReturned()
        {
            string       function     = "function() { alert(''); }";
            VisibleRange visibleRange = new VisibleRange(function);
            object       target       = visibleRange.AsSerializableObject();

            target.Should().Be(function);
        }
Beispiel #7
0
 public ViewModel()
 {
     this.visibleRange = new VisibleRange()
     {
         Start = DateTime.Today, End = DateTime.Today.AddDays(3)
     };
     this.tasks = this.GetTasks();
     this.timeLineRecurrenceBehavior = new TimeLineRecurrenceBehavior();
 }
Beispiel #8
0
        /// <summary>
        ///VisibleRange`4 构造函数 的测试
        ///</summary>
        public void VisibleRangeConstructorTestHelper <EntityT, ItemT, CreatureT, CharacterT>()
            where EntityT : WorldEntity
            where ItemT : BaseItem
            where CreatureT : BaseCreature
            where CharacterT : BaseCharacter
        {
            VisibleRange <EntityT, ItemT, CreatureT, CharacterT> target = new VisibleRange <EntityT, ItemT, CreatureT, CharacterT>();

            Assert.Inconclusive("TODO: 实现用来验证目标的代码");
        }
Beispiel #9
0
        private void SetUpVisibleRange(XDocument xDocument, XNamespace xnamespace)
        {
            DateTime dateTimeStart = DateTime.Parse(xDocument.Root.Element(xnamespace + "StartDate").Value);
            DateTime dateTimeEnd   = DateTime.Parse(xDocument.Root.Element(xnamespace + "FinishDate").Value);

            this.VisibleRange = new Telerik.Windows.Controls.Scheduling.VisibleRange()
            {
                Start = dateTimeStart.Date.AddDays(1), End = dateTimeEnd.Date.AddDays(1)
            };
        }
        public void AsSerializableObject_DateRangeIsSet_ObjectIsSerialized()
        {
            DateTime     start        = DateTime.Today;
            DateTime     end          = DateTime.Today.AddDays(2);
            VisibleRange visibleRange = new VisibleRange(start, end);
            object       target       = visibleRange.AsSerializableObject();

            target.ShouldBeEquivalentTo(new
            {
                start = start.ToString("yyyy-MM-dd"),
                end   = end.ToString("yyyy-MM-dd")
            });
        }
Beispiel #11
0
        public void Properties() => Create(vm =>
        {
            var view = new ScrollViewer {
                DataContext = vm
            };
            var src = new VisibleRange();

            src.Attach(view);
            Assert.That(src.First, Is.EqualTo(0));
            Assert.That(src.Last, Is.EqualTo(0));
            Assert.That(src.Unit, Is.EqualTo(0));
            src.Detach();
        });
Beispiel #12
0
        /// <summary>
        ///ItemOutOfRange 的测试
        ///</summary>
        public void ItemOutOfRangeTestHelper <EntityT, ItemT, CreatureT, CharacterT>()
            where EntityT : WorldEntity
            where ItemT : BaseItem
            where CreatureT : BaseCreature
            where CharacterT : BaseCharacter
        {
            VisibleRange <EntityT, ItemT, CreatureT, CharacterT> target = new VisibleRange <EntityT, ItemT, CreatureT, CharacterT>(); // TODO: 初始化为适当的值

            ItemT[] expected = null;                                                                                                  // TODO: 初始化为适当的值
            ItemT[] actual;
            target.ItemOutOfRange = expected;
            actual = target.ItemOutOfRange;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #13
0
        /// <summary>
        ///EnumerableToArray 的测试
        ///</summary>
        public void EnumerableToArrayTestHelper <EntityT, ItemT, CreatureT, CharacterT, T>()
            where EntityT : WorldEntity
            where ItemT : BaseItem
            where CreatureT : BaseCreature
            where CharacterT : BaseCharacter
        {
            IEnumerable <T> enumerable = null; // TODO: 初始化为适当的值

            T[] expected = null;               // TODO: 初始化为适当的值
            T[] actual;
            actual = VisibleRange <EntityT, ItemT, CreatureT, CharacterT> .EnumerableToArray <T>(enumerable);

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Beispiel #14
0
        public void Invoke()
        {
            var view = new ScrollViewer();
            var src  = new VisibleRange();

            Assert.That(view.ActualWidth, Is.EqualTo(0), nameof(view.ActualWidth));
            Assert.That(view.ActualHeight, Is.EqualTo(0), nameof(view.ActualHeight));
            src.Attach(view);

            Assert.That(src.First, Is.EqualTo(0), nameof(src.First));
            Assert.That(src.Last, Is.EqualTo(0), nameof(src.Last));
            Assert.That(src.Unit, Is.EqualTo(0), nameof(src.Unit));
            src.Unit = 100;
            Assert.That(src.First, Is.EqualTo(0), nameof(src.First));
            Assert.That(src.Last, Is.EqualTo(3), nameof(src.Last));
            Assert.That(src.Unit, Is.EqualTo(100), nameof(src.Unit));

            src.Detach();
        }
Beispiel #15
0
 void LateUpdate()
 {
     if (this.isOnShowing)
     {
         return;
     }
     if (this.isNeedReload)
     {
         this.Reload();
     }
     if (this.isDirty)
     {
         this.newVisibleRange = this.CalcVisibleRange();
         if (this.newVisibleRange.to - this.newVisibleRange.from >= 0)
         {
             this.RefreshVisibleCell();
         }
         this.isDirty = false;
     }
 }
Beispiel #16
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     if (e.KeyCode == Keys.PageUp)
     {
         VisibleRange = VisibleRange.Shift(-m_large_change); RaiseScrollEndEvent();
     }
     if (e.KeyCode == Keys.PageDown)
     {
         VisibleRange = VisibleRange.Shift(+m_large_change); RaiseScrollEndEvent();
     }
     if (e.KeyCode == Keys.Up && e.Control)
     {
         VisibleRange = VisibleRange.Shift(-m_small_change); RaiseScrollEndEvent();
     }
     if (e.KeyCode == Keys.Down && e.Control)
     {
         VisibleRange = VisibleRange.Shift(+m_small_change); RaiseScrollEndEvent();
     }
 }
 public bool IsLabeled(double inverseMapScale)
 {
     return(VisibleRange.IsInRange(inverseMapScale) && this.IsOn);
 }
Beispiel #18
0
 public ViewModel()
 {
     this.visibleRange = new VisibleRange() { Start = DateTime.Today, End = DateTime.Today.AddDays(1) };
     this.tasks = this.GetTasks();
     this.timeLineRecurrenceBehavior = new TimeLineRecurrenceBehavior();
 }
Beispiel #19
0
        protected override void GenerateVisibleLabels()
        {
            ChartSeriesBase actualSeries =
                Area.VisibleSeries
                .Where(series => series.ActualXAxis == this)
                .Max(filteredSeries => filteredSeries.DataCount);

            actualSeries = actualSeries != null ? actualSeries : Area is SfChart ? (Area as SfChart).TechnicalIndicators.Where(series => series.ActualXAxis == this)
                           .Max(filteredSeries => filteredSeries.DataCount) : null;

            SetRangeForAxisStyle();

            if (actualSeries != null)
            {
                var XValuesCount = actualSeries.ActualXValues as List <double>;
                if (XValuesCount != null && XValuesCount.Count > 0)
                {
                    double interval     = Interval != 0 ? Interval : ActualInterval;
                    double position     = VisibleRange.Start - (VisibleRange.Start % ActualInterval);
                    var    xValues      = actualSeries.ActualXValues as List <double>;
                    var    xStartValue  = xValues[0].FromOADate();
                    double distinctDate = 0d;
                    int    year         = xStartValue.Year,
                           month        = xStartValue.Month,
                           hour         = xStartValue.Hour,
                           mins         = xStartValue.Minute,
                           secs         = xStartValue.Second,
                           millisecs    = xStartValue.Millisecond;
                    DateTime date       = xStartValue.Date;

                    switch (ActualIntervalType)
                    {
                    case DateTimeIntervalType.Months:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Year > year)
                                {
                                    year  = xValue.Year;
                                    month = xValue.Month;
                                }

                                if (xValue.Year == year)
                                {
                                    if (xValue.Month > month)
                                    {
                                        month = xValue.Month;
                                    }

                                    if (xValue.Month == month)
                                    {
                                        object obj = GetLabelContent(pos, actualSeries);
                                        var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                        dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                        dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                        VisibleLabels.Add(dateTimeAxisLabel);
                                        month = xValue.AddMonths((int)interval).Month;
                                        year  = xValue.AddMonths((int)interval).Year;
                                    }
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Years:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Year > year)
                                {
                                    year = xValue.Year;
                                }
                                if (xValue.Year == year)
                                {
                                    object obj = GetLabelContent(pos, actualSeries);
                                    var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                    dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                    dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                    VisibleLabels.Add(dateTimeAxisLabel);
                                    year = xValue.AddYears((int)interval).Year;
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Days:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Date > date)
                                {
                                    date = xValue.Date;
                                }

                                if (xValue.Date == date)
                                {
                                    object obj = GetLabelContent(pos, actualSeries);
                                    var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                    dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                    dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                    VisibleLabels.Add(dateTimeAxisLabel);
                                    date = xValue.AddDays((int)interval).Date;
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Hours:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Date > date)
                                {
                                    date = xValue.Date;
                                    hour = xValue.Hour;
                                }

                                if (xValue.Date == date)
                                {
                                    if (xValue.Hour > hour)
                                    {
                                        hour = xValue.Hour;
                                    }

                                    if (xValue.Hour == hour)
                                    {
                                        object obj = GetLabelContent(pos, actualSeries);
                                        var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                        dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                        dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                        VisibleLabels.Add(dateTimeAxisLabel);
                                        hour = xValue.AddHours((int)interval).Hour;
                                        date = xValue.AddHours((int)interval).Date;
                                    }
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Minutes:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));

                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Date > date)
                                {
                                    date = xValue.Date;
                                    hour = xValue.Hour;
                                }

                                if (xValue.Date == date)
                                {
                                    if (xValue.Hour > hour)
                                    {
                                        hour = xValue.Hour;
                                        mins = xValue.Minute;
                                    }

                                    if (xValue.Hour == hour)
                                    {
                                        if (xValue.Minute > mins)
                                        {
                                            mins = xValue.Minute;
                                        }

                                        if (xValue.Minute == mins)
                                        {
                                            object obj = GetLabelContent(pos, actualSeries);
                                            var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                            dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                            dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                            VisibleLabels.Add(dateTimeAxisLabel);
                                            hour = xValue.AddMinutes((int)interval).Hour;
                                            mins = xValue.AddMinutes((int)interval).Minute;
                                            date = xValue.AddMinutes((int)interval).Date;
                                        }
                                    }
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Seconds:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Date > date)
                                {
                                    date = xValue.Date;
                                    hour = xValue.Hour;
                                }

                                if (xValue.Date == date)
                                {
                                    if (xValue.Hour > hour)
                                    {
                                        hour = xValue.Hour;
                                        mins = xValue.Minute;
                                    }

                                    if (xValue.Hour == hour)
                                    {
                                        if (xValue.Minute > mins)
                                        {
                                            mins = xValue.Minute;
                                            secs = xValue.Second;
                                        }

                                        if (xValue.Minute == mins)
                                        {
                                            if (xValue.Second > secs)
                                            {
                                                secs = xValue.Second;
                                            }

                                            if (xValue.Second == secs)
                                            {
                                                object obj = GetLabelContent(pos, actualSeries);
                                                var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                                dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                                dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                                VisibleLabels.Add(dateTimeAxisLabel);
                                                hour = xValue.AddSeconds((int)interval).Hour;
                                                mins = xValue.AddSeconds((int)interval).Minute;
                                                date = xValue.AddSeconds((int)interval).Date;
                                                secs = xValue.AddSeconds((int)interval).Second;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Milliseconds:
                        for (; position <= VisibleRange.End; position++)
                        {
                            int pos = ((int)Math.Round(position));
                            if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count)
                            {
                                var xValue = xValues[pos].FromOADate();
                                if (xValue.Date > date)
                                {
                                    date = xValue.Date;
                                    hour = xValue.Hour;
                                }

                                if (xValue.Date == date)
                                {
                                    if (xValue.Hour > hour)
                                    {
                                        hour = xValue.Hour;
                                        mins = xValue.Minute;
                                    }

                                    if (xValue.Hour == hour)
                                    {
                                        if (xValue.Minute > mins)
                                        {
                                            mins = xValue.Minute;
                                            secs = xValue.Second;
                                        }

                                        if (xValue.Minute == mins)
                                        {
                                            if (xValue.Second > secs)
                                            {
                                                secs      = xValue.Second;
                                                millisecs = xValue.Millisecond;
                                            }

                                            if (xValue.Second == secs)
                                            {
                                                if (xValue.Millisecond > millisecs)
                                                {
                                                    millisecs = xValue.Millisecond;
                                                }

                                                if (xValue.Millisecond == millisecs)
                                                {
                                                    object obj = GetLabelContent(pos, actualSeries);
                                                    var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                                    dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                                    dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                                    VisibleLabels.Add(dateTimeAxisLabel);
                                                    hour      = xValue.AddMilliseconds((int)interval).Hour;
                                                    mins      = xValue.AddMilliseconds((int)interval).Minute;
                                                    date      = xValue.AddMilliseconds((int)interval).Date;
                                                    secs      = xValue.AddMilliseconds((int)interval).Second;
                                                    millisecs = xValue.AddMilliseconds((int)interval).Millisecond;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        break;

                    case DateTimeIntervalType.Auto:
                        for (; position <= VisibleRange.End; position += interval)
                        {
                            if (VisibleRange.Inside(position) && position < actualSeries.DataCount && position > -1)
                            {
                                int    pos               = ((int)Math.Round(position));
                                var    xValue            = xValues[pos].FromOADate();
                                object obj               = GetLabelContent(pos, actualSeries);
                                var    dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]);
                                dateTimeAxisLabel.IntervalType = ActualIntervalType;
                                dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType);
                                VisibleLabels.Add(dateTimeAxisLabel);
                            }
                        }

                        break;
                    }
                }
            }
        }
Beispiel #20
0
 public void Refresh()
 {
     _calculatedVisibleRange = VisibleRange.Empty;
 }
Beispiel #21
0
 private void SetUpVisibleRange(XDocument xDocument, XNamespace xnamespace)
 {
     DateTime dateTimeStart = DateTime.Parse(xDocument.Root.Element(xnamespace + "StartDate").Value);
     DateTime dateTimeEnd = DateTime.Parse(xDocument.Root.Element(xnamespace + "FinishDate").Value);
     this.VisibleRange = new Telerik.Windows.Controls.Scheduling.VisibleRange() { Start = dateTimeStart.Date.AddDays(1), End = dateTimeEnd.Date.AddDays(1) };
 }
Beispiel #22
0
        private void CalculateChildren(VisibleRange visibleRange)
        {
            // We need to access InternalChildren before the generator to work around a bug
            UIElementCollection     children  = this.InternalChildren;
            IItemContainerGenerator generator = this.ItemContainerGenerator;

            int          columCount   = DataSource.Source.Columns.Length;
            ItemsControl itemsControl = ItemsControl.GetItemsOwner(this);

            int lastRow = visibleRange.firstRow + visibleRange.rowCount;

            for (int r = visibleRange.firstRow; r < lastRow; r++)
            {
                int firstVisibleItemInRow  = r * columCount + visibleRange.firstCol;
                int lastVisibleItemInRow   = firstVisibleItemInRow + visibleRange.colCount - 1;
                GeneratorPosition startPos = generator.GeneratorPositionFromIndex(firstVisibleItemInRow);

                // Get index where we'd insert the child for this position. If the item is realized
                // (position.Offset == 0), it's just position.Index, otherwise we have to add one to
                // insert after the corresponding child
                int childIndex = (startPos.Offset == 0) ? startPos.Index : startPos.Index + 1;

                using (generator.StartAt(startPos, GeneratorDirection.Forward, true))
                {
                    for (int itemIndex = firstVisibleItemInRow; itemIndex <= lastVisibleItemInRow; ++itemIndex, ++childIndex)
                    {
                        if (((ItemViewModel)itemsControl.Items[itemIndex]).Item != null)
                        {
                            bool newlyRealized;

                            // Get or create the child
                            UIElement child = generator.GenerateNext(out newlyRealized) as UIElement;
                            if (newlyRealized)
                            {
                                // Figure out if we need to insert the child at the end or somewhere in the middle
                                if (childIndex >= children.Count)
                                {
                                    base.AddInternalChild(child);
                                }
                                else
                                {
                                    base.InsertInternalChild(childIndex, child);
                                }
                                generator.PrepareItemContainer(child);
                                this.DataSource.HoverManager.RegisterItem(child);
                            }
                            else
                            {
                                // The child has already been created, let's be sure it's in the right spot
                                //Debug.Assert(child == children[childIndex], "Wrong child was generated");
                            }

                            // Measurements will depend on layout algorithm
                            if (child != null)
                            {
                                child.Measure(GetChildSize());
                            }
                        }
                    }
                }
            }

            // Note: this could be deferred to idle time for efficiency
            CleanUpItems(visibleRange, columCount);
        }