티스토리 뷰
[ 동영상 추가 ] - 오류
프로젝트 새항목 추가 - 클래스 추가 (클래스 이름이 버튼이름이 됨)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/* 추가 참조 */
using System.Windows.Forms;
using System.Drawing;
namespace Bitmap_Button_Test1
{
class FlatButton : Control
{
private SolidBrush borderBrush, textBrush;
private Rectangle borderRectangle;
private bool active = false;
private StringFormat stringFormat = new StringFormat();
/* properties */
public override Cursor Cursor { get; set; } = Cursors.Hand;
public float BorderThickness { get; set; } = 2;
/* constructor */
public FlatButton()
{
borderBrush = new SolidBrush(ColorTranslator.FromHtml("#31302b"));
textBrush = new SolidBrush(ColorTranslator.FromHtml("#FFF"));
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
this.Paint += FlatButton_Paint;
}
/* events */
private void FlatButton_Paint(object sender, PaintEventArgs e)
{
borderRectangle = new Rectangle(0, 0, Width, Height);
e.Graphics.DrawRectangle(new Pen(borderBrush, BorderThickness), borderRectangle);
e.Graphics.DrawString(this.Text, this.Font, (active) ? textBrush : borderBrush, borderRectangle, stringFormat);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
base.BackColor = ColorTranslator.FromHtml("#31302b");
active = true;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
base.BackColor = ColorTranslator.FromHtml("#FFF");
active = false;
}
}
}
'오늘도 개발자 > C#' 카테고리의 다른 글
C# Tutorial Making Custom Button - C#1 (0) | 2019.01.05 |
---|---|
[C#] 이미지 사이즈 변경(Resize) (0) | 2018.03.13 |
[C#] WM_Paint 강제 발생 방법 (0) | 2018.03.09 |
[C#] 프로퍼티(Property) - 작성 中 (0) | 2018.03.06 |
[C#] GDI+ 계단현상 제거 (0) | 2018.03.05 |
- Total
- Today
- Yesterday
- 이사
- Sanitize
- 철거
- 스프레드연산자
- 워드프레스
- FTP권한문제
- 지대공
- 빛의성당
- ontent
- url복사
- 한빛미디어
- 썸머노트
- Lighitsail
- wp-members
- Theme Customization
- 사용자정의하기
- CSPRNG
- 도스 코파스
- 빈화면
- 코스모스팜
- 고흐1인칭시점
- php
- wordpress #워드프레스 #url
- MySQL
- URL인코딩
- 라이트세일
- URL디코딩
- 이전설치
- 11번가 아마존 #우주패스 #우주쓰레기
- WordPress
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |