Bonjour,
Voila j'ai pondu tout ce code et voila que je n'arrive pas à savoir pourquoi l'état désactiver"Disiable" ne s'active pas (tout les autre marche). J'ai cherché et encore cherché mais je trouve rien
Merci d'avance de m'aider.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 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; namespace UC_RichIcone { [DefaultEvent("Click")] public partial class UC_RichIcon : UserControl { public enum StateType { Disabled, Neutral, Over, Clicked }; private StateType StateButton; private Image m_ImageNormal = null; private Image m_ImageClick = null; private Image m_ImageOver = null; private Image m_ImageDisiable = null; private bool Enable = false; public UC_RichIcon() { InitializeComponent(); } private void UC_RichIcon_Load(object sender, EventArgs e) { this.BackgroundImageLayout = ImageLayout.Stretch; this.BackgroundImage = m_ImageNormal; } [Description("Etat du button")] public StateType EtatBouton { get { return StateButton; } set { StateButton = value; if (StateButton == StateType.Disabled && m_ImageDisiable != null) this.BackgroundImage = m_ImageDisiable; if (StateButton == StateType.Clicked && m_ImageClick !=null) this.BackgroundImage = m_ImageClick; if (StateButton == StateType.Neutral && m_ImageNormal !=null) this.BackgroundImage = m_ImageNormal; if (StateButton == StateType.Over && m_ImageOver !=null) this.BackgroundImage = m_ImageOver; // On refresh le contrôle this.Refresh(); } } [Description("si la propriete est pas init , disable est par default")] public bool IsEnable { get { return Enable; } set { Enable = value; if (!Enable) StateButton = StateType.Disabled; if(!Enable && m_ImageDisiable != null) this.BackgroundImage = m_ImageDisiable; else if(m_ImageNormal != null) this.BackgroundImage = m_ImageNormal; // On refresh le contrôle this.Refresh(); } } [Description("image etat normal")] public Image ImageNormal { get { return m_ImageNormal; } set { m_ImageNormal = value; this.Refresh(); } } [Description("image etat cliquer")] public Image ImageClick { get { return m_ImageClick; } set { m_ImageClick = value; this.Refresh(); } } [Description("image etat mouse over")] public Image ImageOver { get { return m_ImageOver; } set { m_ImageOver = value; this.Refresh(); } } [Description("image etat desactivé")] public Image ImageDisiable { get { return m_ImageDisiable; } set { m_ImageDisiable = value; this.Refresh(); } } private void UC_RichIcon_MouseUp(object sender, MouseEventArgs e) { if (Enable) { StateButton = StateType.Over; if (m_ImageOver != null) this.BackgroundImage = m_ImageOver; } } private void UC_RichIcon_MouseDown(object sender, MouseEventArgs e) { if (Enable) { StateButton = StateType.Clicked; if(m_ImageClick !=null) this.BackgroundImage = m_ImageClick; } } private void UC_RichIcon_MouseLeave(object sender, EventArgs e) { if (Enable) { StateButton = StateType.Neutral; if (m_ImageNormal != null) this.BackgroundImage = m_ImageNormal; } } private void UC_RichIcon_MouseEnter(object sender, EventArgs e) { if (Enable) { StateButton = StateType.Over; if (m_ImageOver != null) this.BackgroundImage = m_ImageOver; } } } }
Partager