Пример #1
0
        public void UpdateIndicatorElements()
        {
            this.Children.Clear();
            switch (this.TrackBarElement.TrackBarMode)
            {
            case TrackBarRangeMode.SingleThumb:
                if (this.TrackBarElement.Ranges.Count <= 0)
                {
                    break;
                }
                TrackBarIndicatorElement indicatorElement1 = new TrackBarIndicatorElement(this.TrackBarElement.Ranges[0]);
                indicatorElement1.IsSelected = this.TrackBarElement.Ranges[0].IsSelected;
                indicatorElement1.StartThumbElement.Visibility = ElementVisibility.Collapsed;
                this.Children.Add((RadElement)indicatorElement1);
                break;

            case TrackBarRangeMode.StartFromTheBeginning:
                using (IEnumerator <TrackBarRange> enumerator = this.TrackBarElement.Ranges.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TrackBarRange            current           = enumerator.Current;
                        TrackBarIndicatorElement indicatorElement2 = new TrackBarIndicatorElement(current);
                        indicatorElement2.IsSelected = current.IsSelected;
                        indicatorElement2.EndThumbElement.IsSelected   = false;
                        indicatorElement2.StartThumbElement.Visibility = ElementVisibility.Collapsed;
                        this.Children.Add((RadElement)indicatorElement2);
                    }
                    break;
                }

            case TrackBarRangeMode.Range:
                using (IEnumerator <TrackBarRange> enumerator = this.TrackBarElement.Ranges.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TrackBarRange current = enumerator.Current;
                        this.Children.Add((RadElement) new TrackBarIndicatorElement(current)
                        {
                            IsSelected = current.IsSelected
                        });
                    }
                    break;
                }
            }
        }
Пример #2
0
        private void ArrangeHorizontal(SizeF finalSize)
        {
            switch (this.TrackBarElement.TrackBarMode)
            {
            case TrackBarRangeMode.SingleThumb:
                if (this.Children.Count <= 0)
                {
                    break;
                }
                SizeF desiredSize1 = this.Children[0].DesiredSize;
                this.Children[0].Arrange(new RectangleF(!this.RightToLeft ? new PointF(0.0f, 0.0f) : new PointF(finalSize.Width - desiredSize1.Width, 0.0f), desiredSize1));
                break;

            case TrackBarRangeMode.StartFromTheBeginning:
                using (RadElementCollection.RadElementEnumerator enumerator = this.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RadElement current      = enumerator.Current;
                        SizeF      desiredSize2 = current.DesiredSize;
                        PointF     location     = !this.RightToLeft ? new PointF(0.0f, 0.0f) : new PointF(finalSize.Width - desiredSize2.Width, 0.0f);
                        current.ZIndex = (int)(1000.0 - (double)current.DesiredSize.Width * 10.0);
                        RectangleF finalRect = new RectangleF(location, desiredSize2);
                        current.Arrange(finalRect);
                    }
                    break;
                }

            case TrackBarRangeMode.Range:
                using (RadElementCollection.RadElementEnumerator enumerator = this.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RadElement current = enumerator.Current;
                        TrackBarIndicatorElement indicatorElement = current as TrackBarIndicatorElement;
                        SizeF      desiredSize2 = current.DesiredSize;
                        RectangleF finalRect    = new RectangleF(!this.RightToLeft ? new PointF(Math.Abs(this.TrackBarElement.Minimum - indicatorElement.RangeInfo.Start) * this.TrackBarElement.TickOffSet, 0.0f) : new PointF((float)((double)finalSize.Width - (double)desiredSize2.Width - (double)Math.Abs(this.TrackBarElement.Minimum - indicatorElement.RangeInfo.Start) * (double)this.TrackBarElement.TickOffSet), 0.0f), desiredSize2);
                        current.Arrange(finalRect);
                    }
                    break;
                }
            }
        }
Пример #3
0
        private void ArrangeVertical(SizeF finalSize)
        {
            switch (this.TrackBarElement.TrackBarMode)
            {
            case TrackBarRangeMode.SingleThumb:
                if (this.Children.Count <= 0)
                {
                    break;
                }
                SizeF desiredSize1 = this.Children[0].DesiredSize;
                this.Children[0].Arrange(new RectangleF(new PointF(0.0f, finalSize.Height - desiredSize1.Height), desiredSize1));
                break;

            case TrackBarRangeMode.StartFromTheBeginning:
                using (RadElementCollection.RadElementEnumerator enumerator = this.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RadElement current      = enumerator.Current;
                        SizeF      desiredSize2 = current.DesiredSize;
                        current.ZIndex = (int)(1000.0 - (double)current.DesiredSize.Height * 10.0);
                        RectangleF finalRect = new RectangleF(new PointF(0.0f, finalSize.Height - desiredSize2.Height), desiredSize2);
                        current.Arrange(finalRect);
                    }
                    break;
                }

            case TrackBarRangeMode.Range:
                using (RadElementCollection.RadElementEnumerator enumerator = this.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        RadElement current = enumerator.Current;
                        TrackBarIndicatorElement indicatorElement = current as TrackBarIndicatorElement;
                        SizeF      desiredSize2 = current.DesiredSize;
                        RectangleF finalRect    = new RectangleF(new PointF(0.0f, finalSize.Height - Math.Abs(this.TrackBarElement.Minimum - indicatorElement.RangeInfo.Start) * this.TrackBarElement.TickOffSet - desiredSize2.Height), desiredSize2);
                        current.Arrange(finalRect);
                    }
                    break;
                }
            }
        }
Пример #4
0
 public void RefreshRanges()
 {
     foreach (RadElement child in this.Children)
     {
         TrackBarIndicatorElement indicatorElement = child as TrackBarIndicatorElement;
         indicatorElement.Orientation = this.TrackBarElement.Orientation;
         if (indicatorElement != null)
         {
             if (!indicatorElement.RangeInfo.IsSelected)
             {
                 indicatorElement.StartThumbElement.IsSelected = false;
                 indicatorElement.EndThumbElement.IsSelected   = false;
             }
             if (!indicatorElement.StartThumbElement.Equals((object)this.TrackBarElement.CurrentThumb))
             {
                 indicatorElement.StartThumbElement.IsSelected = false;
             }
             if (!indicatorElement.EndThumbElement.Equals((object)this.TrackBarElement.CurrentThumb))
             {
                 indicatorElement.EndThumbElement.IsSelected = false;
             }
         }
     }
 }
Пример #5
0
 public TrackBarThumbElement(TrackBarIndicatorElement owner, bool isFirst)
 {
     this.owner   = owner;
     this.isFirst = isFirst;
 }
Пример #6
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (!this.AllowKeyNavigation)
            {
                return;
            }
            if (this.CurrentThumb == null)
            {
                TrackBarIndicatorElement child = this.BodyElement.IndicatorContainerElement.Children[0] as TrackBarIndicatorElement;
                if (child == null || child.Children.Count < 3)
                {
                    return;
                }
                this.CurrentThumb = child.Children[this.Orientation == Orientation.Horizontal ? 2 : 0] as TrackBarThumbElement;
                if (this.CurrentThumb == null)
                {
                    return;
                }
            }
            int oldValue = (int)this.Value;

            if (!this.CurrentThumb.IsFirst && (this.TrackBarMode == TrackBarRangeMode.SingleThumb || this.TrackBarMode == TrackBarRangeMode.StartFromTheBeginning))
            {
                if (e.KeyData == Keys.Home)
                {
                    this.CurrentThumb.RangeInfo.End = this.Minimum;
                }
                else if (e.KeyData == Keys.End)
                {
                    this.CurrentThumb.RangeInfo.End = this.Maximum;
                }
                else if (e.KeyData == Keys.Prior)
                {
                    this.CurrentThumb.RangeInfo.End -= (float)this.LargeChange;
                }
                else if (e.KeyData == Keys.Next)
                {
                    this.CurrentThumb.RangeInfo.End += (float)this.LargeChange;
                }
                else if (this.Orientation == Orientation.Horizontal)
                {
                    if (e.KeyData == Keys.Left)
                    {
                        this.CurrentThumb.RangeInfo.End -= (float)this.SmallChange;
                    }
                    else if (e.KeyData == Keys.Right)
                    {
                        this.CurrentThumb.RangeInfo.End += (float)this.SmallChange;
                    }
                }
                else if (e.KeyData == Keys.Down)
                {
                    this.CurrentThumb.RangeInfo.End -= (float)this.SmallChange;
                }
                else if (e.KeyData == Keys.Up)
                {
                    this.CurrentThumb.RangeInfo.End += (float)this.SmallChange;
                }
            }
            else if (this.Orientation == Orientation.Horizontal)
            {
                if (e.KeyData == Keys.Left)
                {
                    this.CurrentThumb.RangeInfo.Start -= (float)this.SmallChange;
                }
                else if (e.KeyData == Keys.Right)
                {
                    this.CurrentThumb.RangeInfo.Start += (float)this.SmallChange;
                }
            }
            else if (e.KeyData == Keys.Down)
            {
                this.CurrentThumb.RangeInfo.Start -= (float)this.SmallChange;
            }
            else if (e.KeyData == Keys.Up)
            {
                this.CurrentThumb.RangeInfo.Start += (float)this.SmallChange;
            }
            this.FireScrollEvent(oldValue);
        }