• 大小: 149KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-25
  • 语言: C#
  • 标签: C#;  温度计;  窗体控件  

资源简介

使用C#编写的一个温度计控件,控件可以变大小,背景颜色、指针等颜色可以改变。 开发环境:Visual Studio 2010 开发语言:C#

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ThermometerLib
{
    public partial class ThermometerControl : UserControl
    {
        /// 
        /// 初始化控件
        /// 预设绘图方式:双缓冲、支持透明背景色、自定义绘制
        /// 

        public ThermometerControl()
        {
            Setstyle(Controlstyles.AllPaintingInWmPaint true);
            Setstyle(Controlstyles.OptimizedDoubleBuffer true);
            Setstyle(Controlstyles.ResizeRedraw true);
            Setstyle(Controlstyles.Selectable true);
            Setstyle(Controlstyles.SupportsTransparentBackColor true);
            Setstyle(Controlstyles.UserPaint true);

            InitializeComponent();
        }

        // 温度
        private float temperature = 0;
        [CategoryAttribute(“温度“) Description(“当前温度“)]
        public float Temperature
        {
            set { temperature = value; }
            get { return temperature; }
        }

        // 最高温度
        private float highTemperature = 50;
        [CategoryAttribute(“温度“) Description(“最高温度“)]
        public float HighTemperature
        {
            set { highTemperature = value; }
            get { return highTemperature; }
        }

        // 最低温度
        private float lowTemperature = -20;
        [CategoryAttribute(“温度“) Description(“最低温度“)]
        public float LowTemperature
        {
            set { lowTemperature = value; }
            get { return lowTemperature; }
        }

        // 当前温度数值的字体
        private Font tempFont = new Font(“宋体“ 12);
        [CategoryAttribute(“温度“) Description(“当前温度数值的字体“)]
        public Font TempFont
        {
            set { tempFont = value; }
            get { return tempFont; }
        }

        // 当前温度数值的颜色
        private Color tempColor = Color.Black;
        [CategoryAttribute(“温度“) Description(“当前温度数值的颜色“)]
        public Color TempColor
        {
            set { tempColor = value; }
            get { return tempColor; }
        }

        // 大刻度线数量
        private int bigScale = 5;
        [CategoryAttribute(“刻度“) Description(“大刻度线数量“)]
        public int BigScale
        {
            set { bigScale = value; }
            get { return bigScale; }
        }

        // 小刻度线数量
        private int smallScale = 5;
        [CategoryAttribute(“刻度“) Description(“小刻度线数量“)]
        public int SmallScale
        {
            set { smallScale = value; }
            get { return smallScale; }
        }

        // 刻度字体
        private Font drawFont = new Font(“Aril“ 9);
        [CategoryAttribute(“刻度“) Description(“刻度数字的字体“)]
        public Font DrawFont
        {
            get { return drawFont; }
            set { drawFont = value; }
        }

        // 字体颜色
        private Color drawColor = Color.Blac

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-12-09 21:54  ThermometerLib\
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\bin\
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\bin\Debug\
     文件       11264  2013-12-09 21:42  ThermometerLib\ThermometerLib\bin\Debug\ThermometerLib.dll
     文件       26112  2013-12-09 21:42  ThermometerLib\ThermometerLib\bin\Debug\ThermometerLib.pdb
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\bin\Release\
     文件       10752  2013-12-09 21:48  ThermometerLib\ThermometerLib\bin\Release\ThermometerLib.dll
     文件       22016  2013-12-09 21:48  ThermometerLib\ThermometerLib\bin\Release\ThermometerLib.pdb
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\obj\
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\obj\Debug\
     文件        2164  2013-10-16 17:36  ThermometerLib\ThermometerLib\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6184  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         224  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\GenerateResource.read.1.tlog
     文件         504  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\GenerateResource.write.1.tlog
     文件        7319  2013-11-20 22:09  ThermometerLib\ThermometerLib\obj\Debug\ResolveAssemblyReference.cache
     目录           0  2013-10-16 17:36  ThermometerLib\ThermometerLib\obj\Debug\TempPE\
     文件         978  2013-10-16 23:15  ThermometerLib\ThermometerLib\obj\Debug\ThermometerLib.csproj.FileListAbsolute.txt
     文件       11264  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\ThermometerLib.dll
     文件       26112  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\ThermometerLib.pdb
     文件         180  2013-12-09 21:42  ThermometerLib\ThermometerLib\obj\Debug\ThermometerLib.ThermometerControl.resources
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\obj\Release\
     文件        6188  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
     文件         224  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\GenerateResource.read.1.tlog
     文件         508  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\GenerateResource.write.1.tlog
     目录           0  2013-12-09 21:47  ThermometerLib\ThermometerLib\obj\Release\TempPE\
     文件         994  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\ThermometerLib.csproj.FileListAbsolute.txt
     文件       10752  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\ThermometerLib.dll
     文件       22016  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\ThermometerLib.pdb
     文件         180  2013-12-09 21:48  ThermometerLib\ThermometerLib\obj\Release\ThermometerLib.ThermometerControl.resources
     目录           0  2013-12-09 21:54  ThermometerLib\ThermometerLib\Properties\
............此处省略59个文件信息

评论

共有 条评论