zoukankan      html  css  js  c++  java
  • winform 制作圆形图片框

     1 public partial class CirclePictureBox : PictureBox
     2     {
     3         public CirclePictureBox()
     4         {
     5             Circle = true;
     6             InitializeComponent();
     7         }        
     8 
     9         protected override void OnPaint(PaintEventArgs pe)
    10         {            
    11             base.OnPaint(pe);            
    12         }
    13 
    14         //圆形大小随控件大小变化
    15         protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
    16         {
    17             if (width > 0 && height > 0)
    18             {
    19                 CircleSize = new Size(width, height);
    20             }
    21             base.SetBoundsCore(x, y, width, height, specified);
    22         }
    23 
    24         bool _circle;
    25         [Description(" 获取或设置按钮椭圆效果。"), DefaultValue(true)]
    26         public bool Circle
    27         {
    28             get
    29             {
    30                 return _circle;
    31             }
    32 
    33             set
    34             {
    35                 if (value)
    36                 {
    37                     GraphicsPath gp = new GraphicsPath();
    38                     gp.AddEllipse(0, 0, _circleSize.Width, _circleSize.Height);//圆形                       
    39                     this.Region = new Region(gp);
    40                     this.BorderStyle = BorderStyle.None;
    41                     this.Invalidate();
    42                 }
    43                 _circle = value;
    44             }
    45         }
    46 
    47         Size _circleSize=new Size(50,50);
    48         [Description(" 圆形的大小")]
    49         Size CircleSize
    50         {
    51             get
    52             {
    53                 return _circleSize;
    54             }
    55             set
    56             {
    57                 _circleSize = value;
    58                 Circle = true;
    59             }
    60         }
    61     }
  • 相关阅读:
    图书馆管理系统

    有理数类的设计
    题目4-多关键字排序(基于自定义比较函数)
    图总结
    树、二叉树、查找算法总结
    数据结构小结
    C语言文件
    第二次博客作业
    第一次博客作业
  • 原文地址:https://www.cnblogs.com/jieliu726/p/4674336.html
Copyright © 2011-2022 走看看