Пример #1
0
        /// <summary>
        /// Generates a line to be added to the canvas. Line color is determined by the position on the grid
        /// </summary>
        protected void AddLine(int position, SolidColorBrush ValueFillColor)
        {
            ColoredLine line = new ColoredLine()
            {
                StrokeThickness = 2,
                EmptyFillColor  = EmptyColor,
                ValueFillColor  = ValueFillColor,
                X1 = ResolveX1(position),
                X2 = ResolveX2(position),
                Y1 = ResolveY1(position),
                Y2 = ResolveY2(position),
            };

            GaugeLines.Add(line);
            Children.Add(line);
            line.UseEmptyColor();
        }
        public override void DrawComponentLayout()
        {
            Children.Clear();
            GaugeLines.Clear();
            numLines = 0;
            var    centerPoint          = GetCenterPoint(this);
            double factorDelimiter      = (Width > Height) ? centerPoint.Y : centerPoint.X;
            var    lineStartFactor      = factorDelimiter - ((factorDelimiter / 2));
            var    lineEndFactor        = factorDelimiter - ((factorDelimiter / 10));
            var    fillColor            = new SolidColorBrush(Colors.Green);
            var    emptyColor           = new SolidColorBrush(Colors.Black);
            var    lineSeparationFactor = GetLineSeparationFactor();

            for (double degrees = 135d; degrees < 405d; degrees += lineSeparationFactor)
            {
                var         radians = ((Math.PI / 180) * degrees);
                var         startX  = (centerPoint.X + (lineStartFactor * Math.Cos(radians)));
                var         startY  = (centerPoint.Y + (lineStartFactor * Math.Sin(radians)));
                var         endX    = (centerPoint.X + (lineEndFactor * Math.Cos(radians)));
                var         endY    = (centerPoint.Y + (lineEndFactor * Math.Sin(radians)));
                ColoredLine line    = new ColoredLine()
                {
                    X1 = startX,
                    X2 = endX,
                    Y1 = startY,
                    Y2 = endY,
                    StrokeThickness = 2,
                    ValueFillColor  = fillColor,
                    EmptyFillColor  = emptyColor,
                };
                GaugeLines.Add(line);
                Children.Add(line);
                line.UseEmptyColor();
                numLines++;
            }
            PreviousLineNumber = 0;
            Update();
        }