wpf自定义标尺

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;

namespace PhotovolaticRadar.Client.Tools
{
    public class RadarTickBar: TickBar
    {
        protected override void OnRender(DrawingContext dc)
        {
            Double tickFrequencySize;
            Brush foreBrush = this.Fill;
            Pen line_Pen = new Pen(foreBrush, 1);

            FormattedText font = null;
            Size size = new Size(base.ActualWidth, base.ActualHeight);
            int tickCount = (int)((this.Maximum - this.Minimum) / this.TickFrequency) + 1;
            if ((this.Maximum - this.Minimum) % this.TickFrequency == 0)
                tickCount -= 1;
            tickFrequencySize = (size.Width * this.TickFrequency / (this.Maximum - this.Minimum));
            string text = "";
            double num = this.Maximum - this.Minimum;
            int i = 0;
            for (i = 0; i <= tickCount; i++)
            {
                if (i % 5 == 0)
                {
                    text = Convert.ToString(Convert.ToInt32(this.Minimum + this.TickFrequency * i), 10);
                    font = new FormattedText(text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 14, foreBrush);
                    dc.DrawText(font, new Point((tickFrequencySize * i), 20));
                    dc.DrawLine(line_Pen, new Point((tickFrequencySize * i), 44), new Point((tickFrequencySize * i), 64));
                }
                else
                {
                    dc.DrawLine(line_Pen, new Point((tickFrequencySize * i), 54), new Point((tickFrequencySize * i), 64));
                }
            }

        }
    }
}

  

转载于:https://www.cnblogs.com/wrl-wuqingxue/p/7613792.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值