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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
/*
usage CButton But0 = new (this,"Welcome");
*/
namespace CustomItemButton
{
public class CButton : Button
{
private Form SrcForm;
private Button But;
//constructeur
public CButton(Form SForm, string Text = "",
int PosH = 0, int PosV = 0 ,
int LenV = 200, int LenH = 50,
string FontName = "Times New Roman",
float SizeFont = 16)
{
//ça miaule donc methode ? (Rendre le champ readonly):-> But = new Button();
NewButton();
SetForm(SForm);
//default
SrcForm.Controls.Add(But);
But.BackColor = Color.FromArgb(0, 0, 0);
But.ForeColor = Color.FromArgb(0, 255, 00);
But.Text = Text;
But.Font = new Font(FontName, SizeFont);
But.FlatStyle = FlatStyle.Popup;
But.Location = new Point(PosH, PosV);
But.Height = LenH;
But.Width = LenV;
//association
But.Click += new System.EventHandler(But_DoubleClick);
}
private void NewButton()
{
But = new Button();
}
private void SetForm(Form SForm)
{
SrcForm = SForm;
}
public override String Text
{
get { return But.Text; }
set { But.Text = value; }
}
private void But_DoubleClick(Object sender, EventArgs e)
{
SrcForm.Text = But.Text;//a adapter
}
}
}
/* memo
* public event EventHandler DoubleClick;
* public event EventHandler ThresholdReached;
*
*/ |
Partager