Пример #1
0
        /// <summary>
        /// Retrieves the template parts of the control.
        /// </summary>
        protected override bool ApplyTemplateCore()
        {
            base.ApplyTemplateCore();

            this.qualitativeBarPart = this.GetTemplatePartField <SegmentedLinearGaugeIndicator>(QualitativeBarPartName);
            bool applied = this.qualitativeBarPart != null;

            if (applied)
            {
                foreach (BarIndicatorSegment segment in this.QualitativeRanges)
                {
                    this.qualitativeBarPart.Segments.Add(segment);
                }
                this.QualitativeRanges.Clear();
                this.QualitativeRanges = this.qualitativeBarPart.Segments;
            }

            this.comparativeMeasurePart = this.GetTemplatePartField <MarkerGaugeIndicator>(ComparativeMeasurePartName);
            applied = applied && this.comparativeMeasurePart != null;

            this.scalePart = this.GetTemplatePartField <RadLinearGauge>(ScalePartName);
            applied        = applied && this.scalePart != null;

            if (applied)
            {
                foreach (BulletGraphComparativeMeasure measure in this.AdditionalComparativeMeasures)
                {
                    this.scalePart.Indicators.Add(measure.Visual);
                    this.SyncComparativeMeasureTemplate(measure);
                }
            }

            return(applied);
        }
        /// <summary>
        /// This is a virtual method that resets the state of the indicator.
        /// The parent range is responsible to (indirectly) call this method when
        /// a property of importance changes.
        /// </summary>
        /// <param name="availableSize">A size which can be used by the update logic.</param>
        /// <remarks>
        /// The linear range for example triggers the UpdateOverride() method
        /// of its indicators when its Orientation property changes.
        /// </remarks>
        internal override void UpdateOverride(Size availableSize)
        {
            this.isHorizontal = RadLinearGauge.GetOrientation(this) == Orientation.Horizontal;
            this.minValue     = this.Owner.OwnerGauge.MinValue;

            base.UpdateOverride(availableSize);
        }
Пример #3
0
        private Point ArrangeRectangle(double value, Size finalSize)
        {
            Point result = new Point();

            double finalValue = Math.Abs(value - this.StartValue);
            double extent     = RadGauge.MapLogicalToPhysicalValue(finalValue, this.isHorizontal ? finalSize.Width : finalSize.Height, this.MinMaxValueDifference);

            bool   flip      = this.Value < this.StartValue;
            double barLength = extent;

            if (this.isHorizontal)
            {
                this.bar.Width  = barLength;
                this.bar.Height = this.Thickness;

                result.X = flip ? this.barLocation - extent : this.barLocation;
                result.Y = ((finalSize.Height / 2) - (this.bar.Height / 2)) + RadLinearGauge.GetIndicatorOffset(this);
            }
            else
            {
                this.bar.Height = barLength;
                this.bar.Width  = this.Thickness;

                result.X = ((finalSize.Width / 2) - (this.bar.Width / 2)) + RadLinearGauge.GetIndicatorOffset(this);
                result.Y = flip ? this.barLocation : this.barLocation - extent;
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// This is a virtual method that resets the state of the indicator.
        /// The parent range is responsible to (indirectly) call this method when
        /// a property of importance changes.
        /// </summary>
        /// <param name="availableSize">A size which can be used by the update logic.</param>
        /// <remarks>
        /// The linear range for example triggers the UpdateOverride() method
        /// of its indicators when its Orientation property changes.
        /// </remarks>
        internal override void UpdateOverride(Size availableSize)
        {
            base.UpdateOverride(availableSize);

            this.isHorizontal = RadLinearGauge.GetOrientation(this) == Orientation.Horizontal;

            this.UpdateBarLocation(this.StartValue);
        }
Пример #5
0
        /// <summary>
        /// A virtual method that is called when the Owner of this indicator changes.
        /// </summary>
        /// <param name="newOwner">The new Owner.</param>
        /// <param name="oldOwner">The old Owner.</param>
        internal override void OnOwnerChanged(GaugePanel newOwner, GaugePanel oldOwner)
        {
            base.OnOwnerChanged(newOwner, oldOwner);

            Orientation orientation = RadLinearGauge.GetOrientation(newOwner);

            this.isHorizontal = orientation == Orientation.Horizontal;
            RadLinearGauge.SetOrientation(this, orientation);
        }
Пример #6
0
        private Point CreateStartPoint(Size rangeSize)
        {
            double halfVisualElementWidth  = this.visualElement.DesiredSize.Width / 2;
            double halfVisualElementHeight = this.visualElement.DesiredSize.Height / 2;

            if (this.isHorizontal)
            {
                return(new Point(-halfVisualElementWidth, ((rangeSize.Height / 2) - halfVisualElementHeight) + RadLinearGauge.GetIndicatorOffset(this)));
            }

            return(new Point(((rangeSize.Width / 2) - halfVisualElementWidth) + RadLinearGauge.GetIndicatorOffset(this), rangeSize.Height - halfVisualElementHeight));
        }
Пример #7
0
        private void PrivateUpdate()
        {
            if (this.Owner != null && this.Owner.OwnerGauge is RadRadialGauge)
            {
                var gauge = (RadRadialGauge)this.Owner.OwnerGauge;
                this.maxAngle = gauge.MaxAngle;
                this.minAngle = gauge.MinAngle;
            }

            this.isHorizontal = RadLinearGauge.GetOrientation(this.Owner) == Orientation.Horizontal;
            this.minValue     = this.Owner.OwnerGauge.MinValue;
        }
Пример #8
0
        /// <summary>
        /// Called in the arrange pass of the layout system.
        /// </summary>
        /// <param name="finalSize">The final size that was given by the layout system.</param>
        /// <returns>The final size of the panel.</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            this.isHorizontal = RadLinearGauge.GetOrientation(this.OwnerGauge) == Orientation.Horizontal;

            this.availableExtent     = this.isHorizontal ? finalSize.Width : finalSize.Height;
            this.halfAvailableExtent = this.availableExtent / 2;

            this.halfAvailableWidth  = finalSize.Width / 2;
            this.halfAvailableHeight = finalSize.Height / 2;

            return(base.ArrangeOverride(finalSize));
        }
        /// <summary>
        /// This method is called whenever the segments
        /// need to recreate their visual representation.
        /// </summary>
        /// <param name="availableSize">The available size which the visual parts can occupy.</param>
        internal override void ResetSegments(Size availableSize)
        {
            this.SegmentInfos.Clear();

            this.extent = this.isHorizontal ? availableSize.Width : availableSize.Height;

            double logicalRange  = this.MinMaxValueDifference;
            double physicalStart = RadGauge.MapLogicalToPhysicalValue(this.StartValue - this.minValue, this.extent, logicalRange);

            double indicatorExtent = RadGauge.MapLogicalToPhysicalValue(this.ActualValue - this.minValue, this.extent, logicalRange) - physicalStart;
            double startPosition   = this.isHorizontal ? physicalStart : (this.extent - physicalStart);

            double halfAvailableWidth  = availableSize.Width / 2;
            double halfAvailableHeight = availableSize.Height / 2;
            double offset = RadLinearGauge.GetIndicatorOffset(this);

            foreach (BarIndicatorSegment segment in this.Segments)
            {
                if (segment.Path == null)
                {
                    Debug.Assert(false, "Missing segment path.");
                    continue;
                }
                double lengthRatio = segment.Length / this.TotalSegmentLength;
                double lineLength  = indicatorExtent * lengthRatio;

                SegmentInfo info = new SegmentInfo();
                info.Start = startPosition;
                info.End   = startPosition + (this.isHorizontal ? lineLength : -lineLength);
                this.SegmentInfos.Add(info);

                LineSegment line = new LineSegment();
                line.Point = this.isHorizontal ? new Point(info.End, halfAvailableHeight + offset) : new Point(halfAvailableWidth + offset, info.End);

                info.PathSegment = line;

                PathFigure figure = new PathFigure();
                figure.StartPoint = this.isHorizontal ? new Point(info.Start, halfAvailableHeight + offset) : new Point(halfAvailableWidth + offset, info.Start);
                figure.Segments.Add(line);

                PathGeometry geom = new PathGeometry();
                geom.Figures.Add(figure);

                Path path = segment.Path;
                path.Stroke          = segment.Stroke;
                path.StrokeThickness = segment.Thickness;
                path.Data            = geom;

                startPosition = info.End;
            }
        }
Пример #10
0
        /// <summary>
        /// A virtual method that is called when the Orientation property changes.
        /// </summary>
        /// <param name="newOrientation">The new Orientation.</param>
        /// <param name="oldOrientation">The old Orientation.</param>
        internal virtual void OnOrientationChanged(Orientation newOrientation, Orientation oldOrientation)
        {
            this.isHorizontal = newOrientation == Orientation.Horizontal;

            foreach (UIElement element in this.Indicators)
            {
                GaugeIndicator indicator = element as GaugeIndicator;
                if (indicator == null)
                {
                    continue;
                }

                RadLinearGauge.SetOrientation(indicator, newOrientation);
            }

            this.InvalidateMeasure();
        }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the BulletGraphMeasureBase class.
 /// </summary>
 protected BulletGraphMeasureBase()
 {
     this.Visual = this.CreateVisual();
     RadLinearGauge.SetIndicatorOffset(this.Visual, -20);
 }