码迷,mamicode.com
首页 > Windows程序 > 详细

wpf自定义标尺

时间:2017-09-30 11:41:47      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:.text   poi   using   format   vol   else   awl   eric   min   

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));
                }
            }

        }
    }
}

  

wpf自定义标尺

标签:.text   poi   using   format   vol   else   awl   eric   min   

原文地址:http://www.cnblogs.com/wrl-wuqingxue/p/7613792.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!