1.在Label里 画圆,存在窗体刷新会丢失画。

  public void SetShowConnectStatus(Label lbl, bool isOk)
{
lbl.Text = "";
Graphics gra = lbl.CreateGraphics();
gra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Color c = isOk ? Color.Green : Color.Red;
Brush bush = new SolidBrush(c);//填充的颜色
gra.FillEllipse(bush, , , lbl.Width / , lbl.Width / ); }

2.在控件Paint事件里画,Invalidate 刷新。

  private bool isRotaryConnectOK = false;
private void button1_Click(object sender, EventArgs e)
{ isRotaryConnectOK =!isRotaryConnectOK;
lblRotaryConnectStatus.Invalidate();
} private void lblRotaryConnectStatus_Paint(object sender, PaintEventArgs e)
{
Graphics gp = e.Graphics;
       gp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Color c = isRotaryConnectOK ? Color.Lime : Color.Red;
SolidBrush s = new SolidBrush(c);
gp.FillEllipse(s, , , lblRotaryConnectStatus.Width/, lblRotaryConnectStatus.Width / );
}

void FillEllipse(Brush brush,int x,int y,int width,int height);
其中brush为指定画刷,(x1,y1)为指定矩形的左上角坐标,width为指定矩形的宽,height为指定矩形的高。

添加文字:

Font font_ = new Font("微软雅黑", 14, FontStyle.Regular);
SolidBrush brush_ = new SolidBrush(Color.White);
gp.DrawString(adcLsbNumber_, font_, brush_,8, 6);

C#红绿状态灯的更多相关文章

  1. FPGA驱动LCD显示红绿蓝彩条

    实验目的:先简单熟悉LCD灯的驱动和时序图的代码实现.设计功能是让LCD显示红绿蓝三种颜色,即三个彩带.本次实验比较容易实现,主要是对LCD驱动时序图的理解和时序参数的配置. 实验条件:1.LCD原理 ...

  2. RK3399 友善NanoPC-T4开发板使用sysfs方法控制status LED状态灯-【申嵌视频-RK3399篇】

    实验1:sysfs 操作方法控制NanoPC-T4开发板上LED灯 (status LED状态灯:GPIO0_B5/LED1_OUT)root@NanoPC-T4: cd /sys/class/led ...

  3. MACD:黄白线、红绿柱与0轴关系

    一.MACD的基本问题: (1)参数:统一用12,26,9 (2)MACD   位正.位不正原则 以下四种情况是黄白线.红绿柱与0轴关系的完全分类,行情出不了这四种情况, 即便黄白线在0轴单边反复缠绕 ...

  4. Amazon才推众包物流,“京东众包”已红绿上阵,“达达”还手握10万配送大军

    据外媒消息,Amazon正在开发一款App,想让大家都来为他家送包裹. Amazon的设想是,在市区招募实体零售商,租用空间或者按包裹向其支付费用.这项服务在内部代号为“On My Way”,目前还在 ...

  5. SAP OOALV 添加状态灯

    *&---------------------------------------------------------------------* INCLUDE <icon>. T ...

  6. 阶段小项目1:循环间隔1秒lcd显示红绿蓝

    #include<stdlib.h>#include<stdio.h>#include<string.h>#include<error.h>#inclu ...

  7. Hierarchical clustering:利用层次聚类算法来把100张图片自动分成红绿蓝三种色调—Jaosn niu

    #!/usr/bin/python # coding:utf-8 from PIL import Image, ImageDraw from HierarchicalClustering import ...

  8. [LeetCode] Similar RGB Color 相似的红绿蓝颜色

    In the following, every capital letter represents some hexadecimal digit from 0 to f. The red-green- ...

  9. [LeetCode] 800. Similar RGB Color 相似的红绿蓝颜色

    In the following, every capital letter represents some hexadecimal digit from 0 to f. The red-green- ...

随机推荐

  1. golang 常量

    介绍 常量使用const修改 常量在定义时必须初始化 常量定义后不能修改 常量只能修饰bool.数值类型(int.float).string类型 golang中没有硬性规定常量必使用大写字母,但仍然通 ...

  2. 【leetcode-66】 加一

    给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一. 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字. 你可以假设除了整数 0 之外,这个整数不会以零开头. 示例 1: 输入 ...

  3. [Android] Android ViewPager 中加载 Fragment的两种方式 方式(一)

    Android ViewPager 中加载 Fragmenet的两种方式 一.当fragment里面的内容较少时,直接 使用fragment xml布局文件填充 文件总数 布局文件:view_one. ...

  4. Ubuntu Server Download

    点击查看所有版本(中国站点) http://mirror.lzu.edu.cn/ubuntu-releases/

  5. springboot(二十):数据库连接池介绍

    概述 性能方面 hikariCP>druid>tomcat-jdbc>dbcp>c3p0 .hikariCP的高性能得益于最大限度的避免锁竞争. druid功能最为全面,sql ...

  6. C# MVC EF框架 用事务

    using System.Transactions; [HttpPost] public JsonResult Update(InfoModel list) { using (TransactionS ...

  7. 【python小练】0011题

    第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights. #word.tx ...

  8. WebSocket 快速开始

    [Html5客户端API] 1.创建websocket对象 var connection =  new WebSocket('ws[s]://www.example.com/chat',可选自己实现的 ...

  9. PHP cURL实现模拟登录与采集使用方法详解教程

    来源:http://www.zjmainstay.cn/php-curl 本文将通过案例,整合浏览器工具与PHP程序,教你如何让数据 唾手可得 . 对于做过数据采集的人来说,cURL一定不会陌生.虽然 ...

  10. 进程池爬取并存入mongodb

    设置进程池爬取拉钩网: # coding = utf- import json import pymongo import pandas as pd import requests from lxml ...