• 大小: 79KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-25
  • 语言: C#
  • 标签: C#;  LED;  工控  

资源简介

使用c#编写的LED小灯控件,可以使用在工业控制中。 开发环境: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;
using System.Drawing.Drawing2D;

namespace LEDLib
{
    /// 
    /// 初始化
    /// 

    public partial class LEDControl : UserControl
    {
        public LEDControl()
        {
            InitializeComponent();

            // 设置控件属性用户自定义绘制双缓冲调整大小重绘选中重绘支持透明
            Setstyle(Controlstyles.AllPaintingInWmPaint true);
            Setstyle(Controlstyles.OptimizedDoubleBuffer true);
            Setstyle(Controlstyles.ResizeRedraw true);
            Setstyle(Controlstyles.Selectable true);
            Setstyle(Controlstyles.SupportsTransparentBackColor true);
            Setstyle(Controlstyles.UserPaint true);
        }

        /// 
        /// 使能LED双击是否有变色效果
        /// 

        private bool ledClickEnable = true;
        [CategoryAttribute(“状态“) Description(“LED双击变色是否有效“)]
        public bool LEDClickEnable
        {
            set { ledClickEnable = value; }
            get { return ledClickEnable; }
        }

        /// 
        /// LED打开或者关闭
        /// 

        private bool ledSwitch = true;
        [CategoryAttribute(“状态“) Description(“LED打开或关闭“)]
        public bool LEDSwitch
        {
            set { ledSwitch = value; }
            get { return ledSwitch; }
        }

        /// 
        /// LED中心颜色
        /// 

        private Color ledCenterColor = Color.LightYellow;
        [CategoryAttribute(“颜色“) Description(“中心颜色“)]
        public Color LEDCenterColor
        {
            set { ledCenterColor = value; }
            get { return ledCenterColor; }
        }

        /// 
        /// LED边缘颜色
        /// 

        private Color ledSurroundColor = Color.Yellow;
        [CategoryAttribute(“颜色“) Description(“边缘颜色“)]
        public Color LEDSurroundColor
        {
            set { ledSurroundColor = value; }
            get { return ledSurroundColor; }
        }

        /// 
        /// LED外环颜色
        /// 

        private Color ledCircleColor = Color.Gray;
        [CategoryAttribute(“颜色“) Description(“外环颜色“)]
        public Color LEDCircleColor
        {
            set { ledCircleColor = value; }
            get { return ledCircleColor; }
        }

        /// 
        /// 绘制LED响应
        /// 

        /// 
        /// 
        private void LEDControl_Paint(object sender PaintEventArgs e)
        {
            int ledSize;
            Color centerColor;
            Color surroundColor;

            // 获取LED的大小为正圆
            if (this.Width > this.Height)
            {
                ledSize = this.Height - 4;
            }
            else
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-10-13 00:02  LEDLib\
     目录           0  2013-10-13 00:02  LEDLib\LEDLib\
     目录           0  2013-10-13 00:02  LEDLib\LEDLib\bin\
     目录           0  2013-10-13 00:02  LEDLib\LEDLib\bin\Debug\
     文件        7680  2013-10-12 23:41  LEDLib\LEDLib\bin\Debug\LEDLib.dll
     文件       19968  2013-10-12 23:41  LEDLib\LEDLib\bin\Debug\LEDLib.pdb
     文件        5221  2013-10-13 00:01  LEDLib\LEDLib\LEDControl.cs
     文件        1539  2013-10-12 23:28  LEDLib\LEDLib\LEDControl.Designer.cs
     文件        5817  2013-10-12 23:28  LEDLib\LEDLib\LEDControl.resx
     文件        2851  2013-10-06 22:10  LEDLib\LEDLib\LEDLib.csproj
     目录           0  2013-10-13 00:02  LEDLib\LEDLib\obj\
     目录           0  2013-10-13 00:03  LEDLib\LEDLib\obj\Debug\
     文件        2164  2013-10-13 00:03  LEDLib\LEDLib\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6129  2013-10-13 00:02  LEDLib\LEDLib\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         176  2013-10-12 23:28  LEDLib\LEDLib\obj\Debug\GenerateResource.read.1.tlog
     文件         392  2013-10-12 23:28  LEDLib\LEDLib\obj\Debug\GenerateResource.write.1.tlog
     文件         802  2013-10-06 22:24  LEDLib\LEDLib\obj\Debug\LEDLib.csproj.FileListAbsolute.txt
     文件        7680  2013-10-12 23:41  LEDLib\LEDLib\obj\Debug\LEDLib.dll
     文件         180  2013-10-12 23:28  LEDLib\LEDLib\obj\Debug\LEDLib.LEDControl.resources
     文件       19968  2013-10-12 23:41  LEDLib\LEDLib\obj\Debug\LEDLib.pdb
     文件        7319  2013-10-12 23:01  LEDLib\LEDLib\obj\Debug\ResolveAssemblyReference.cache
     目录           0  2013-10-06 22:01  LEDLib\LEDLib\obj\Debug\TempPE\
     目录           0  2013-10-13 00:02  LEDLib\LEDLib\Properties\
     文件        1362  2013-10-06 22:01  LEDLib\LEDLib\Properties\AssemblyInfo.cs
     文件        2548  2013-10-06 22:57  LEDLib\LEDLib.sln
     文件       32256  2013-10-13 00:03  LEDLib\LEDLib.suo
     目录           0  2013-10-13 00:02  LEDLib\LEDLibTest\
     目录           0  2013-10-13 00:02  LEDLib\LEDLibTest\bin\
     目录           0  2013-10-13 00:02  LEDLib\LEDLibTest\bin\Debug\
     文件        7680  2013-10-12 23:41  LEDLib\LEDLibTest\bin\Debug\LEDLib.dll
     文件       19968  2013-10-12 23:41  LEDLib\LEDLibTest\bin\Debug\LEDLib.pdb
............此处省略29个文件信息

评论

共有 条评论