Fugashi Bit Viewer
Revision | 238d2d7fea9b67e10da3c04d488ba525cece2ee9 (tree) |
---|---|
Time | 2011-01-10 09:10:43 |
Author | kimikage <kimikage_ceo@hotm...> |
Commiter | kimikage |
最小化時に落ちる不具合の修正,#regionの設定
@@ -64,6 +64,8 @@ namespace Fugashi | ||
64 | 64 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
65 | 65 | this.BackColor = System.Drawing.Color.Transparent; |
66 | 66 | this.Controls.Add(this.label); |
67 | + this.DoubleBuffered = true; | |
68 | + this.MinimumSize = new System.Drawing.Size(3, 3); | |
67 | 69 | this.Name = "BitSwitch"; |
68 | 70 | this.Size = new System.Drawing.Size(12, 24); |
69 | 71 | this.SizeChanged += new System.EventHandler(this.BitSwitch_SizeChanged); |
@@ -18,17 +18,34 @@ namespace Fugashi | ||
18 | 18 | { |
19 | 19 | public partial class BitSwitch : UserControl |
20 | 20 | { |
21 | + #region fields | |
21 | 22 | private bool state; |
22 | 23 | private bool isExponential; |
23 | 24 | private static Bitmap normal; |
24 | 25 | private static Bitmap exponent; |
25 | 26 | private static Bitmap hover; |
27 | + #endregion | |
26 | 28 | |
27 | - [Category("プロパティ変更")] | |
29 | + #region constructor | |
30 | + public BitSwitch() | |
31 | + { | |
32 | + InitializeComponent(); | |
33 | + State = false; | |
34 | + if (BorderColor.IsEmpty) | |
35 | + { | |
36 | + BorderColor = Color.FromArgb(0xD5, 0xDF, 0xE5); | |
37 | + } | |
38 | + UpdateBackgroundImage(); | |
39 | + } | |
40 | + #endregion | |
41 | + | |
42 | + #region properties | |
43 | + | |
44 | + [Category("Behavior")] | |
28 | 45 | public event System.EventHandler StateChanged; |
29 | 46 | |
30 | 47 | |
31 | - [Category("データ")] | |
48 | + [Category("Data")] | |
32 | 49 | [DefaultValue(typeof(bool), "True")] |
33 | 50 | public bool State |
34 | 51 | { |
@@ -43,7 +60,7 @@ namespace Fugashi | ||
43 | 60 | } |
44 | 61 | } |
45 | 62 | |
46 | - [Category("表示")] | |
63 | + [Category("Appearance")] | |
47 | 64 | [DefaultValue(typeof(Color), "LightSteelBlue")] |
48 | 65 | public Color BorderColor |
49 | 66 | { |
@@ -51,6 +68,8 @@ namespace Fugashi | ||
51 | 68 | set; |
52 | 69 | } |
53 | 70 | |
71 | + [CategoryAttribute("Data")] | |
72 | + [DefaultValue(typeof(bool), "False")] | |
54 | 73 | public bool IsExponential |
55 | 74 | { |
56 | 75 | get |
@@ -64,17 +83,54 @@ namespace Fugashi | ||
64 | 83 | } |
65 | 84 | } |
66 | 85 | |
67 | - public BitSwitch() | |
86 | + #endregion | |
87 | + | |
88 | + #region event handlers | |
89 | + private void label_Click(object sender, EventArgs e) | |
68 | 90 | { |
69 | - InitializeComponent(); | |
70 | - State = false; | |
71 | - if (BorderColor.IsEmpty) | |
91 | + Focus(); | |
92 | + State = !state; | |
93 | + } | |
94 | + | |
95 | + private void label_MouseLeave(object sender, EventArgs e) | |
96 | + { | |
97 | + BackgroundImage = IsExponential ? exponent : normal; | |
98 | + Update(); | |
99 | + } | |
100 | + | |
101 | + private void label_MouseEnter(object sender, EventArgs e) | |
102 | + { | |
103 | + BackgroundImage = hover; | |
104 | + Update(); | |
105 | + } | |
106 | + | |
107 | + private void label_Paint(object sender, PaintEventArgs e) | |
108 | + { | |
109 | + if (!Enabled) | |
72 | 110 | { |
73 | - BorderColor = Color.FromArgb(0xD5, 0xDF, 0xE5); | |
111 | + e.Graphics.FillRectangle( | |
112 | + Brushes.LightGray, 0, 0, Width, Height); | |
113 | + } | |
114 | + using (Pen p = new Pen(BorderColor, 1)) | |
115 | + { | |
116 | + int width = Tag != null ? Width - 1 : Width; | |
117 | + e.Graphics.DrawRectangle(p, 0, 0, width, Height - 1); | |
118 | + } | |
119 | + } | |
120 | + | |
121 | + private void BitSwitch_SizeChanged(object sender, EventArgs e) | |
122 | + { | |
123 | + if (Width <= MinimumSize.Width || Height <= MinimumSize.Height) | |
124 | + { | |
125 | + return; | |
74 | 126 | } |
75 | 127 | UpdateBackgroundImage(); |
76 | 128 | } |
77 | 129 | |
130 | + #endregion | |
131 | + | |
132 | + #region private methods | |
133 | + | |
78 | 134 | private void CreateNormalBackgroundImage() |
79 | 135 | { |
80 | 136 | if (normal is Bitmap && normal.Size == Size) |
@@ -108,15 +164,19 @@ namespace Fugashi | ||
108 | 164 | private Bitmap CreateBackGroundImage( |
109 | 165 | Color hilight, Color light, Color face, Color dark) |
110 | 166 | { |
111 | - Bitmap bmp = new Bitmap(Width, Height); | |
167 | + if (Width < MinimumSize.Width || Height < MinimumSize.Height) | |
168 | + { | |
169 | + return null; | |
170 | + } | |
171 | + Bitmap bmp = new Bitmap(Width, Height); | |
112 | 172 | Graphics g = Graphics.FromImage(bmp); |
113 | 173 | int border = (int)(Height * 0.48); |
114 | 174 | Rectangle upper = new Rectangle(0, 0, Width, border); |
115 | 175 | Rectangle lower = new Rectangle(0, border, Width, Height); |
116 | - LinearGradientBrush brushL = | |
176 | + LinearGradientBrush brushL = | |
117 | 177 | new LinearGradientBrush(upper, hilight, light, |
118 | 178 | LinearGradientMode.Vertical); |
119 | - LinearGradientBrush brushD = | |
179 | + LinearGradientBrush brushD = | |
120 | 180 | new LinearGradientBrush(lower, face, dark, |
121 | 181 | LinearGradientMode.Vertical); |
122 | 182 | Pen edge = new Pen(hilight, 1); |
@@ -130,52 +190,15 @@ namespace Fugashi | ||
130 | 190 | return bmp; |
131 | 191 | } |
132 | 192 | |
133 | - private void label_Click(object sender, EventArgs e) | |
134 | - { | |
135 | - Focus(); | |
136 | - State = !state; | |
137 | - } | |
138 | - | |
139 | - private void label_MouseLeave(object sender, EventArgs e) | |
140 | - { | |
141 | - BackgroundImage = IsExponential? exponent : normal; | |
142 | - Update(); | |
143 | - } | |
144 | - | |
145 | - private void label_MouseEnter(object sender, EventArgs e) | |
146 | - { | |
147 | - BackgroundImage = hover; | |
148 | - Update(); | |
149 | - } | |
150 | - | |
151 | - private void label_Paint(object sender, PaintEventArgs e) | |
152 | - { | |
153 | - if (!Enabled) | |
154 | - { | |
155 | - e.Graphics.FillRectangle( | |
156 | - Brushes.LightGray, 0, 0, Width, Height); | |
157 | - } | |
158 | - using (Pen p = new Pen(BorderColor, 1)) | |
159 | - { | |
160 | - int width = Tag != null ? Width - 1 : Width; | |
161 | - e.Graphics.DrawRectangle(p, 0, 0, width, Height - 1); | |
162 | - } | |
163 | - } | |
164 | - | |
165 | 193 | public void SetStateWithoutEvent(bool state) |
166 | 194 | { |
167 | 195 | this.state = state; |
168 | 196 | label.Text = state ? "1" : "0"; |
169 | 197 | label.ForeColor = state ? Color.DarkSlateGray : Color.SteelBlue; |
170 | - label.Font = new Font(label.Font, | |
198 | + label.Font = new Font(label.Font, | |
171 | 199 | state ? FontStyle.Bold : FontStyle.Regular); |
172 | 200 | } |
173 | 201 | |
174 | - private void BitSwitch_SizeChanged(object sender, EventArgs e) | |
175 | - { | |
176 | - UpdateBackgroundImage(); | |
177 | - } | |
178 | - | |
179 | 202 | private void UpdateBackgroundImage() |
180 | 203 | { |
181 | 204 | bool mouseOver = BackgroundImage == hover; |
@@ -191,5 +214,7 @@ namespace Fugashi | ||
191 | 214 | BackgroundImage = hover; |
192 | 215 | } |
193 | 216 | } |
217 | + | |
218 | + #endregion | |
194 | 219 | } |
195 | 220 | } |
@@ -44,9 +44,10 @@ | ||
44 | 44 | | System.Windows.Forms.AnchorStyles.Right))); |
45 | 45 | this.label.Font = new System.Drawing.Font("Tahoma", 8F); |
46 | 46 | this.label.ForeColor = System.Drawing.Color.MidnightBlue; |
47 | - this.label.Location = new System.Drawing.Point(28, 0); | |
47 | + this.label.Location = new System.Drawing.Point(34, 0); | |
48 | + this.label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); | |
48 | 49 | this.label.Name = "label"; |
49 | - this.label.Size = new System.Drawing.Size(23, 13); | |
50 | + this.label.Size = new System.Drawing.Size(28, 16); | |
50 | 51 | this.label.TabIndex = 38; |
51 | 52 | this.label.Text = "0"; |
52 | 53 | this.label.TextAlign = System.Drawing.ContentAlignment.BottomRight; |
@@ -64,11 +65,12 @@ | ||
64 | 65 | this.table.Controls.Add(this.b2, 1, 0); |
65 | 66 | this.table.Controls.Add(this.b0, 3, 0); |
66 | 67 | this.table.Controls.Add(this.b1, 2, 0); |
67 | - this.table.Location = new System.Drawing.Point(0, 16); | |
68 | + this.table.Location = new System.Drawing.Point(0, 19); | |
69 | + this.table.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); | |
68 | 70 | this.table.Name = "table"; |
69 | 71 | this.table.RowCount = 1; |
70 | 72 | this.table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); |
71 | - this.table.Size = new System.Drawing.Size(47, 25); | |
73 | + this.table.Size = new System.Drawing.Size(56, 30); | |
72 | 74 | this.table.TabIndex = 39; |
73 | 75 | // |
74 | 76 | // b3 |
@@ -83,8 +85,9 @@ | ||
83 | 85 | this.b3.IsExponential = false; |
84 | 86 | this.b3.Location = new System.Drawing.Point(0, 0); |
85 | 87 | this.b3.Margin = new System.Windows.Forms.Padding(0); |
88 | + this.b3.MinimumSize = new System.Drawing.Size(4, 4); | |
86 | 89 | this.b3.Name = "b3"; |
87 | - this.b3.Size = new System.Drawing.Size(11, 25); | |
90 | + this.b3.Size = new System.Drawing.Size(14, 30); | |
88 | 91 | this.b3.State = false; |
89 | 92 | this.b3.TabIndex = 3; |
90 | 93 | // |
@@ -98,10 +101,11 @@ | ||
98 | 101 | this.b2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; |
99 | 102 | this.b2.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229))))); |
100 | 103 | this.b2.IsExponential = false; |
101 | - this.b2.Location = new System.Drawing.Point(11, 0); | |
104 | + this.b2.Location = new System.Drawing.Point(14, 0); | |
102 | 105 | this.b2.Margin = new System.Windows.Forms.Padding(0); |
106 | + this.b2.MinimumSize = new System.Drawing.Size(4, 4); | |
103 | 107 | this.b2.Name = "b2"; |
104 | - this.b2.Size = new System.Drawing.Size(11, 25); | |
108 | + this.b2.Size = new System.Drawing.Size(14, 30); | |
105 | 109 | this.b2.State = false; |
106 | 110 | this.b2.TabIndex = 2; |
107 | 111 | // |
@@ -115,10 +119,11 @@ | ||
115 | 119 | this.b0.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; |
116 | 120 | this.b0.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229))))); |
117 | 121 | this.b0.IsExponential = false; |
118 | - this.b0.Location = new System.Drawing.Point(33, 0); | |
122 | + this.b0.Location = new System.Drawing.Point(42, 0); | |
119 | 123 | this.b0.Margin = new System.Windows.Forms.Padding(0); |
124 | + this.b0.MinimumSize = new System.Drawing.Size(4, 4); | |
120 | 125 | this.b0.Name = "b0"; |
121 | - this.b0.Size = new System.Drawing.Size(11, 25); | |
126 | + this.b0.Size = new System.Drawing.Size(14, 30); | |
122 | 127 | this.b0.State = false; |
123 | 128 | this.b0.TabIndex = 0; |
124 | 129 | this.b0.Tag = "true"; |
@@ -133,21 +138,23 @@ | ||
133 | 138 | this.b1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; |
134 | 139 | this.b1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229))))); |
135 | 140 | this.b1.IsExponential = false; |
136 | - this.b1.Location = new System.Drawing.Point(22, 0); | |
141 | + this.b1.Location = new System.Drawing.Point(28, 0); | |
137 | 142 | this.b1.Margin = new System.Windows.Forms.Padding(0); |
143 | + this.b1.MinimumSize = new System.Drawing.Size(4, 4); | |
138 | 144 | this.b1.Name = "b1"; |
139 | - this.b1.Size = new System.Drawing.Size(11, 25); | |
145 | + this.b1.Size = new System.Drawing.Size(14, 30); | |
140 | 146 | this.b1.State = false; |
141 | 147 | this.b1.TabIndex = 1; |
142 | 148 | // |
143 | 149 | // BitSwitches4 |
144 | 150 | // |
145 | - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); | |
151 | + this.AutoScaleDimensions = new System.Drawing.SizeF(115F, 115F); | |
146 | 152 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; |
147 | 153 | this.Controls.Add(this.table); |
148 | 154 | this.Controls.Add(this.label); |
155 | + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); | |
149 | 156 | this.Name = "BitSwitches4"; |
150 | - this.Size = new System.Drawing.Size(50, 43); | |
157 | + this.Size = new System.Drawing.Size(60, 52); | |
151 | 158 | this.SizeChanged += new System.EventHandler(this.BitSwitches4_SizeChanged); |
152 | 159 | this.table.ResumeLayout(false); |
153 | 160 | this.ResumeLayout(false); |
@@ -1,4 +1,11 @@ | ||
1 | -using System; | |
1 | +/* | |
2 | + * Fugashi Project | |
3 | + * | |
4 | + * This software is distributed under a BSD-style license. | |
5 | + * See license.txt for more information. | |
6 | + */ | |
7 | + | |
8 | +using System; | |
2 | 9 | using System.Collections.Generic; |
3 | 10 | using System.ComponentModel; |
4 | 11 | using System.Drawing; |
@@ -10,13 +17,20 @@ namespace Fugashi | ||
10 | 17 | { |
11 | 18 | public partial class BitSwitches4 : UserControl |
12 | 19 | { |
20 | + #region fields | |
13 | 21 | private int startBit; |
22 | + #endregion | |
23 | + | |
24 | + #region constructor | |
25 | + | |
14 | 26 | public BitSwitches4() |
15 | 27 | { |
16 | 28 | InitializeComponent(); |
17 | 29 | } |
30 | + #endregion | |
18 | 31 | |
19 | - [Category("データ")] | |
32 | + #region properties | |
33 | + [CategoryAttribute("Data")] | |
20 | 34 | [DefaultValue(typeof(int), "-1")] |
21 | 35 | public int StartBit |
22 | 36 | { |
@@ -62,7 +76,9 @@ namespace Fugashi | ||
62 | 76 | return b3; |
63 | 77 | } |
64 | 78 | } |
79 | + #endregion | |
65 | 80 | |
81 | + #region private methods | |
66 | 82 | private void Coordinate() |
67 | 83 | { |
68 | 84 | int y = startBit < 32 ? label.Size.Height : 0; |
@@ -81,6 +97,6 @@ namespace Fugashi | ||
81 | 97 | int y = startBit < 32 ? label.Size.Height : 0; |
82 | 98 | table.Location = new Point(table.Location.X, y); |
83 | 99 | } |
84 | - | |
100 | + #endregion | |
85 | 101 | } |
86 | 102 | } |
@@ -120,42 +120,42 @@ | ||
120 | 120 | <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
121 | 121 | <data name="b3.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
122 | 122 | <value> |
123 | - iVBORw0KGgoAAAANSUhEUgAAAAsAAAAZCAYAAADnstS2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
124 | - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE+VztEK | |
125 | - gzAQRNHp//+imiiVpiIiiIi11u5s8pyNC5d5OYQ8LjmU3nmSlx2O46eSa4V9j5hrhW2L/+BaYV0j5lph | |
126 | - WSLmWmGev4q5VpimiLlWGMdDMdcKwxAx1wohfBRzrVBVlWKuFeq6Vsy1EuwSdoLzCfYJe8H50DStYq6V | |
127 | - 4C7hTnA+OPdUzLW6i/v0ci8v54P3L8VcK8Eh4SA4n+C34pJD2w5XaX9xMuf+td64xAAAAABJRU5ErkJg | |
128 | - gg== | |
123 | + iVBORw0KGgoAAAANSUhEUgAAAA4AAAAeCAYAAAAcni9KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
124 | + YQUAAAAJcEhZcwAAEa8AABGvAff9S4QAAADKSURBVDhPnc5pCsJgDIThuf8Zu7vVFhFRRFq3Sb4cINPA | |
125 | + y/x6IPhtPHw+2yTW9evSVgnLUqCtEl6v8qutEp7PAm2V8HgUaKuE+71AWyXcbm+Htkq4Xgu0VcLlUqCt | |
126 | + EuZ5dWirhGkq0FYJ47g4tFVCVVUObZVQ17VDWyXCJmBDmI+wDdgS5iPsAnaE+dA0vUNbJcIh4ECYD227 | |
127 | + c2irRLgPuCfMR3gIeCDMR3gMeCTMh647ObRVIhwDjoT5CM8Bz4T5CCeH6qHv59+W/p0oMG24BjG/AAAA | |
128 | + AElFTkSuQmCC | |
129 | 129 | </value> |
130 | 130 | </data> |
131 | 131 | <data name="b2.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
132 | 132 | <value> |
133 | - iVBORw0KGgoAAAANSUhEUgAAAAsAAAAZCAYAAADnstS2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
134 | - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE+VztEK | |
135 | - gzAQRNHp//+imiiVpiIiiIi11u5s8pyNC5d5OYQ8LjmU3nmSlx2O46eSa4V9j5hrhW2L/+BaYV0j5lph | |
136 | - WSLmWmGev4q5VpimiLlWGMdDMdcKwxAx1wohfBRzrVBVlWKuFeq6Vsy1EuwSdoLzCfYJe8H50DStYq6V | |
137 | - 4C7hTnA+OPdUzLW6i/v0ci8v54P3L8VcK8Eh4SA4n+C34pJD2w5XaX9xMuf+td64xAAAAABJRU5ErkJg | |
138 | - gg== | |
133 | + iVBORw0KGgoAAAANSUhEUgAAAA4AAAAeCAYAAAAcni9KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
134 | + YQUAAAAJcEhZcwAAEa8AABGvAff9S4QAAADKSURBVDhPnc5pCsJgDIThuf8Zu7vVFhFRRFq3Sb4cINPA | |
135 | + y/x6IPhtPHw+2yTW9evSVgnLUqCtEl6v8qutEp7PAm2V8HgUaKuE+71AWyXcbm+Htkq4Xgu0VcLlUqCt | |
136 | + EuZ5dWirhGkq0FYJ47g4tFVCVVUObZVQ17VDWyXCJmBDmI+wDdgS5iPsAnaE+dA0vUNbJcIh4ECYD227 | |
137 | + c2irRLgPuCfMR3gIeCDMR3gMeCTMh647ObRVIhwDjoT5CM8Bz4T5CCeH6qHv59+W/p0oMG24BjG/AAAA | |
138 | + AElFTkSuQmCC | |
139 | 139 | </value> |
140 | 140 | </data> |
141 | 141 | <data name="b0.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
142 | 142 | <value> |
143 | - iVBORw0KGgoAAAANSUhEUgAAAAsAAAAZCAYAAADnstS2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
144 | - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE+VztEK | |
145 | - gzAQRNHp//+imiiVpiIiiIi11u5s8pyNC5d5OYQ8LjmU3nmSlx2O46eSa4V9j5hrhW2L/+BaYV0j5lph | |
146 | - WSLmWmGev4q5VpimiLlWGMdDMdcKwxAx1wohfBRzrVBVlWKuFeq6Vsy1EuwSdoLzCfYJe8H50DStYq6V | |
147 | - 4C7hTnA+OPdUzLW6i/v0ci8v54P3L8VcK8Eh4SA4n+C34pJD2w5XaX9xMuf+td64xAAAAABJRU5ErkJg | |
148 | - gg== | |
143 | + iVBORw0KGgoAAAANSUhEUgAAAA4AAAAeCAYAAAAcni9KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
144 | + YQUAAAAJcEhZcwAAEa8AABGvAff9S4QAAADKSURBVDhPnc5pCsJgDIThuf8Zu7vVFhFRRFq3Sb4cINPA | |
145 | + y/x6IPhtPHw+2yTW9evSVgnLUqCtEl6v8qutEp7PAm2V8HgUaKuE+71AWyXcbm+Htkq4Xgu0VcLlUqCt | |
146 | + EuZ5dWirhGkq0FYJ47g4tFVCVVUObZVQ17VDWyXCJmBDmI+wDdgS5iPsAnaE+dA0vUNbJcIh4ECYD227 | |
147 | + c2irRLgPuCfMR3gIeCDMR3gMeCTMh647ObRVIhwDjoT5CM8Bz4T5CCeH6qHv59+W/p0oMG24BjG/AAAA | |
148 | + AElFTkSuQmCC | |
149 | 149 | </value> |
150 | 150 | </data> |
151 | 151 | <data name="b1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
152 | 152 | <value> |
153 | - iVBORw0KGgoAAAANSUhEUgAAAAsAAAAZCAYAAADnstS2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
154 | - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKtJREFUOE+VztEK | |
155 | - gzAQRNHp//+imiiVpiIiiIi11u5s8pyNC5d5OYQ8LjmU3nmSlx2O46eSa4V9j5hrhW2L/+BaYV0j5lph | |
156 | - WSLmWmGev4q5VpimiLlWGMdDMdcKwxAx1wohfBRzrVBVlWKuFeq6Vsy1EuwSdoLzCfYJe8H50DStYq6V | |
157 | - 4C7hTnA+OPdUzLW6i/v0ci8v54P3L8VcK8Eh4SA4n+C34pJD2w5XaX9xMuf+td64xAAAAABJRU5ErkJg | |
158 | - gg== | |
153 | + iVBORw0KGgoAAAANSUhEUgAAAA4AAAAeCAYAAAAcni9KAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 | |
154 | + YQUAAAAJcEhZcwAAEa8AABGvAff9S4QAAADKSURBVDhPnc5pCsJgDIThuf8Zu7vVFhFRRFq3Sb4cINPA | |
155 | + y/x6IPhtPHw+2yTW9evSVgnLUqCtEl6v8qutEp7PAm2V8HgUaKuE+71AWyXcbm+Htkq4Xgu0VcLlUqCt | |
156 | + EuZ5dWirhGkq0FYJ47g4tFVCVVUObZVQ17VDWyXCJmBDmI+wDdgS5iPsAnaE+dA0vUNbJcIh4ECYD227 | |
157 | + c2irRLgPuCfMR3gIeCDMR3gMeCTMh647ObRVIhwDjoT5CM8Bz4T5CCeH6qHv59+W/p0oMG24BjG/AAAA | |
158 | + AElFTkSuQmCC | |
159 | 159 | </value> |
160 | 160 | </data> |
161 | 161 | </root> |
\ No newline at end of file |
@@ -47,8 +47,8 @@ namespace Fugashi | ||
47 | 47 | this.radio4B = new System.Windows.Forms.RadioButton(); |
48 | 48 | this.radio2B = new System.Windows.Forms.RadioButton(); |
49 | 49 | this.radio1B = new System.Windows.Forms.RadioButton(); |
50 | - this.textValue = new System.Windows.Forms.TextBox(); | |
51 | - this.textHex = new System.Windows.Forms.TextBox(); | |
50 | + this.textValue = new System.Windows.Forms.MaskedTextBox(); | |
51 | + this.textHex = new System.Windows.Forms.MaskedTextBox(); | |
52 | 52 | this.buttonLsh = new System.Windows.Forms.Button(); |
53 | 53 | this.buttonRsh = new System.Windows.Forms.Button(); |
54 | 54 | this.buttonInc = new System.Windows.Forms.Button(); |
@@ -217,25 +217,29 @@ namespace Fugashi | ||
217 | 217 | // |
218 | 218 | // textValue |
219 | 219 | // |
220 | + this.textValue.AsciiOnly = true; | |
220 | 221 | this.textValue.Font = new System.Drawing.Font("MS UI Gothic", 10.01739F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); |
222 | + this.textValue.ImeMode = System.Windows.Forms.ImeMode.Disable; | |
221 | 223 | this.textValue.Location = new System.Drawing.Point(57, 33); |
222 | 224 | this.textValue.Name = "textValue"; |
223 | 225 | this.textValue.Size = new System.Drawing.Size(255, 23); |
224 | 226 | this.textValue.TabIndex = 87; |
225 | 227 | this.textValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
226 | - this.textValue.TextChanged += new System.EventHandler(this.textValue_TextChanged); | |
227 | 228 | this.textValue.Leave += new System.EventHandler(this.textValue_Leave); |
229 | + this.textValue.TextChanged += new System.EventHandler(this.textValue_TextChanged); | |
228 | 230 | // |
229 | 231 | // textHex |
230 | 232 | // |
233 | + this.textHex.AsciiOnly = true; | |
231 | 234 | this.textHex.Font = new System.Drawing.Font("MS UI Gothic", 10.01739F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); |
235 | + this.textHex.ImeMode = System.Windows.Forms.ImeMode.Disable; | |
232 | 236 | this.textHex.Location = new System.Drawing.Point(57, 64); |
233 | 237 | this.textHex.Name = "textHex"; |
234 | 238 | this.textHex.Size = new System.Drawing.Size(255, 23); |
235 | 239 | this.textHex.TabIndex = 88; |
236 | 240 | this.textHex.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
237 | - this.textHex.TextChanged += new System.EventHandler(this.textHex_TextChanged); | |
238 | 241 | this.textHex.Leave += new System.EventHandler(this.textHex_Leave); |
242 | + this.textHex.TextChanged += new System.EventHandler(this.textHex_TextChanged); | |
239 | 243 | // |
240 | 244 | // buttonLsh |
241 | 245 | // |
@@ -612,8 +616,8 @@ namespace Fugashi | ||
612 | 616 | private System.Windows.Forms.RadioButton radio4B; |
613 | 617 | private System.Windows.Forms.RadioButton radio2B; |
614 | 618 | private System.Windows.Forms.RadioButton radio1B; |
615 | - private System.Windows.Forms.TextBox textValue; | |
616 | - private System.Windows.Forms.TextBox textHex; | |
619 | + private System.Windows.Forms.MaskedTextBox textValue; | |
620 | + private System.Windows.Forms.MaskedTextBox textHex; | |
617 | 621 | private System.Windows.Forms.Label labelValue; |
618 | 622 | private System.Windows.Forms.Label labelHex; |
619 | 623 | private BitSwitches4 bits0; |
@@ -17,9 +17,12 @@ namespace Fugashi | ||
17 | 17 | { |
18 | 18 | public partial class MainForm : Form |
19 | 19 | { |
20 | + #region fields | |
20 | 21 | private BitSwitch[] bits; |
21 | 22 | private int length = 4; |
23 | + #endregion | |
22 | 24 | |
25 | + #region constructor | |
23 | 26 | public MainForm() |
24 | 27 | { |
25 | 28 | InitializeComponent(); |
@@ -47,6 +50,28 @@ namespace Fugashi | ||
47 | 50 | |
48 | 51 | PerformAutoScale(); |
49 | 52 | } |
53 | + #endregion | |
54 | + | |
55 | + #region event handlers | |
56 | + | |
57 | + private void MainForm_KeyDown(object sender, KeyEventArgs e) | |
58 | + { | |
59 | + if (e.Alt) | |
60 | + { | |
61 | + switch (e.KeyCode) | |
62 | + { | |
63 | + case Keys.V: | |
64 | + textValue.Focus(); | |
65 | + break; | |
66 | + case Keys.H: | |
67 | + textHex.Focus(); | |
68 | + break; | |
69 | + default: | |
70 | + return; | |
71 | + } | |
72 | + e.SuppressKeyPress = true; | |
73 | + } | |
74 | + } | |
50 | 75 | |
51 | 76 | private void radioUint_CheckedChanged(object sender, EventArgs e) |
52 | 77 | { |
@@ -92,75 +117,6 @@ namespace Fugashi | ||
92 | 117 | BitChanged(null, null); |
93 | 118 | } |
94 | 119 | |
95 | - private void SetForFloatingPoint(bool isDouble) | |
96 | - { | |
97 | - for (int i = 23; i < 31; ++i) | |
98 | - { | |
99 | - bits[i].IsExponential = !isDouble; | |
100 | - } | |
101 | - for (int i = 52; i < 63; ++i) | |
102 | - { | |
103 | - bits[i].IsExponential = isDouble; | |
104 | - } | |
105 | - } | |
106 | - | |
107 | - private void SetForInteger() | |
108 | - { | |
109 | - for (int i = 0; i < 64; ++i) | |
110 | - { | |
111 | - bits[i].IsExponential = false; | |
112 | - } | |
113 | - } | |
114 | - | |
115 | - private byte[] GetBytes() | |
116 | - { | |
117 | - byte[] b = new Byte[8]; | |
118 | - int i = 0; | |
119 | - for (int j = 0; j < 8; ++j) | |
120 | - { | |
121 | - b[j] = 0; | |
122 | - i += 8; | |
123 | - for (int k = 0; k < 8; ++k) | |
124 | - { | |
125 | - b[j] = (byte)(b[j] << 1 | (bits[--i].State ? 1 : 0)); | |
126 | - } | |
127 | - i += 8; | |
128 | - } | |
129 | - return b; | |
130 | - } | |
131 | - | |
132 | - private long ToInt64(byte[] bytes) | |
133 | - { | |
134 | - switch (length) | |
135 | - { | |
136 | - case 1: | |
137 | - return (sbyte)bytes[0]; | |
138 | - case 2: | |
139 | - return BitConverter.ToInt16(bytes, 0); | |
140 | - case 4: | |
141 | - return BitConverter.ToInt32(bytes, 0); | |
142 | - case 8: | |
143 | - return BitConverter.ToInt64(bytes, 0); | |
144 | - } | |
145 | - return 0; | |
146 | - } | |
147 | - | |
148 | - private ulong ToUInt64(byte[] bytes) | |
149 | - { | |
150 | - switch (length) | |
151 | - { | |
152 | - case 1: | |
153 | - return bytes[0]; | |
154 | - case 2: | |
155 | - return BitConverter.ToUInt16(bytes, 0); | |
156 | - case 4: | |
157 | - return BitConverter.ToUInt32(bytes, 0); | |
158 | - case 8: | |
159 | - return BitConverter.ToUInt64(bytes, 0); | |
160 | - } | |
161 | - return 0; | |
162 | - } | |
163 | - | |
164 | 120 | private void radio8B_CheckedChanged(object sender, EventArgs e) |
165 | 121 | { |
166 | 122 | if (radio8B.Checked) |
@@ -204,88 +160,112 @@ namespace Fugashi | ||
204 | 160 | } |
205 | 161 | } |
206 | 162 | |
207 | - private void SetLength(int length) | |
163 | + | |
164 | + private void buttonInc_Click(object sender, EventArgs e) | |
208 | 165 | { |
209 | - this.length = length; | |
210 | - int b = length * 8; | |
211 | - for (int i = 8; i < b; ++i) | |
212 | - { | |
213 | - bits[i].Enabled = true; | |
214 | - } | |
215 | - for (int i = b; i < 64; ++i) | |
216 | - { | |
217 | - bits[i].Enabled = false; | |
218 | - } | |
219 | 166 | if (radioFloat.Checked) |
220 | 167 | { |
221 | - textValue_TextChanged(null, null); | |
168 | + if (length == 4) | |
169 | + { | |
170 | + int value = BitConverter.ToInt32(GetBytes(), 0); | |
171 | + if (value == -0x80000000) | |
172 | + { | |
173 | + value = 0; | |
174 | + } | |
175 | + else | |
176 | + { | |
177 | + value += value >= 0 ? 1 : -1; | |
178 | + } | |
179 | + UpdateAll(BitConverter.GetBytes(value)); | |
180 | + } | |
181 | + else | |
182 | + { | |
183 | + long value = BitConverter.ToInt64(GetBytes(), 0); | |
184 | + if (value == (1L << 63)) | |
185 | + { | |
186 | + value = 0; | |
187 | + } | |
188 | + else | |
189 | + { | |
190 | + value += value >= 0 ? 1 : -1; | |
191 | + } | |
192 | + UpdateAll(BitConverter.GetBytes(value)); | |
193 | + } | |
222 | 194 | } |
223 | 195 | else |
224 | 196 | { |
225 | - BitChanged(null, null); | |
197 | + ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
198 | + UpdateAll(BitConverter.GetBytes(++value)); | |
226 | 199 | } |
227 | 200 | } |
228 | 201 | |
229 | - private void BitChanged(object sender, EventArgs e) | |
230 | - { | |
231 | - byte[] b = GetBytes(); | |
232 | - UpdateValue(b); | |
233 | - UpdateHex(b); | |
234 | - } | |
235 | - | |
236 | - private void UpdateValue(byte[] bytes) | |
202 | + private void buttonDec_Click(object sender, EventArgs e) | |
237 | 203 | { |
238 | - if (radioUint.Checked) | |
239 | - { | |
240 | - textValue.Text = ToUInt64(bytes).ToString(); | |
241 | - } | |
242 | - else if (radioInt.Checked) | |
243 | - { | |
244 | - textValue.Text = ToInt64(bytes).ToString(); | |
245 | - } | |
246 | - else if (radioFloat.Checked) | |
204 | + if (radioFloat.Checked) | |
247 | 205 | { |
248 | 206 | if (length == 4) |
249 | 207 | { |
250 | - float value = BitConverter.ToSingle(bytes, 0); | |
251 | - textValue.Text = value.ToString("g8"); | |
208 | + int value = BitConverter.ToInt32(GetBytes(), 0); | |
209 | + if (value == 0) | |
210 | + { | |
211 | + value = 1 << 31; | |
212 | + } | |
213 | + else | |
214 | + { | |
215 | + value -= value >= 0 ? 1 : -1; | |
216 | + } | |
217 | + UpdateAll(BitConverter.GetBytes(value)); | |
252 | 218 | } |
253 | 219 | else |
254 | 220 | { |
255 | - double value = BitConverter.ToDouble(bytes, 0); | |
256 | - textValue.Text = value.ToString("g17"); | |
221 | + long value = BitConverter.ToInt64(GetBytes(), 0); | |
222 | + if (value == 0) | |
223 | + { | |
224 | + value = 1L << 63; | |
225 | + } | |
226 | + else | |
227 | + { | |
228 | + value -= value >= 0 ? 1 : -1; | |
229 | + } | |
230 | + UpdateAll(BitConverter.GetBytes(value)); | |
257 | 231 | } |
258 | 232 | } |
233 | + else | |
234 | + { | |
235 | + ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
236 | + UpdateAll(BitConverter.GetBytes(--value)); | |
237 | + } | |
259 | 238 | } |
260 | 239 | |
261 | - private void UpdateHex(byte[] bytes) | |
240 | + private void buttonClr_Click(object sender, EventArgs e) | |
262 | 241 | { |
263 | - textHex.Text = ""; | |
264 | - for (int i = length - 1; i >= 0; --i) | |
265 | - { | |
266 | - textHex.Text += bytes[i].ToString("X2"); | |
267 | - } | |
242 | + UpdateAll(BitConverter.GetBytes((ulong)0)); | |
268 | 243 | } |
269 | 244 | |
270 | - private void UpdateBits(byte[] bytes) | |
245 | + private void buttonNot_Click(object sender, EventArgs e) | |
271 | 246 | { |
272 | - int i = 0; | |
273 | - for (int j = 0; j < length; ++j) | |
274 | - { | |
275 | - int mask = 1; | |
276 | - for (int k = 0; k < 8; ++k) | |
277 | - { | |
278 | - bits[i++].SetStateWithoutEvent((bytes[j] & mask) != 0); | |
279 | - mask <<= 1; | |
280 | - } | |
281 | - } | |
247 | + ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
248 | + UpdateAll(BitConverter.GetBytes(~value)); | |
282 | 249 | } |
283 | 250 | |
284 | - private void UpdateAll(byte[] bytes) | |
251 | + private void buttonLsh_Click(object sender, EventArgs e) | |
285 | 252 | { |
286 | - UpdateBits(bytes); | |
287 | - UpdateValue(bytes); | |
288 | - UpdateHex(bytes); | |
253 | + ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
254 | + UpdateAll(BitConverter.GetBytes(value << 1)); | |
255 | + } | |
256 | + | |
257 | + private void buttonRsh_Click(object sender, EventArgs e) | |
258 | + { | |
259 | + if (radioInt.Checked) | |
260 | + { | |
261 | + long value = ToInt64(GetBytes()); | |
262 | + UpdateAll(BitConverter.GetBytes(value >> 1)); | |
263 | + } | |
264 | + else | |
265 | + { | |
266 | + ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
267 | + UpdateAll(BitConverter.GetBytes(value >> 1)); | |
268 | + } | |
289 | 269 | } |
290 | 270 | |
291 | 271 | private void textHex_TextChanged(object sender, EventArgs e) |
@@ -342,140 +322,175 @@ namespace Fugashi | ||
342 | 322 | UpdateHex(b); |
343 | 323 | } |
344 | 324 | |
345 | - private void buttonInc_Click(object sender, EventArgs e) | |
325 | + private void textValue_Leave(object sender, EventArgs e) | |
346 | 326 | { |
347 | - if (radioFloat.Checked) | |
327 | + UpdateValue(GetBytes()); | |
328 | + } | |
329 | + | |
330 | + private void textHex_Leave(object sender, EventArgs e) | |
331 | + { | |
332 | + UpdateHex(GetBytes()); | |
333 | + } | |
334 | + | |
335 | + private void BitChanged(object sender, EventArgs e) | |
336 | + { | |
337 | + byte[] b = GetBytes(); | |
338 | + UpdateValue(b); | |
339 | + UpdateHex(b); | |
340 | + } | |
341 | + | |
342 | + #endregion | |
343 | + | |
344 | + #region private methods | |
345 | + | |
346 | + private void SetForFloatingPoint(bool isDouble) | |
347 | + { | |
348 | + for (int i = 23; i < 31; ++i) | |
348 | 349 | { |
349 | - if (length == 4) | |
350 | - { | |
351 | - int value = BitConverter.ToInt32(GetBytes(), 0); | |
352 | - if (value == -0x80000000) | |
353 | - { | |
354 | - value = 0; | |
355 | - } | |
356 | - else | |
357 | - { | |
358 | - value += value >= 0 ? 1 : -1; | |
359 | - } | |
360 | - UpdateAll(BitConverter.GetBytes(value)); | |
361 | - } | |
362 | - else | |
363 | - { | |
364 | - long value = BitConverter.ToInt64(GetBytes(), 0); | |
365 | - if (value == (1L << 63)) | |
366 | - { | |
367 | - value = 0; | |
368 | - } | |
369 | - else | |
370 | - { | |
371 | - value += value >= 0 ? 1 : -1; | |
372 | - } | |
373 | - UpdateAll(BitConverter.GetBytes(value)); | |
374 | - } | |
350 | + bits[i].IsExponential = !isDouble; | |
375 | 351 | } |
376 | - else | |
352 | + for (int i = 52; i < 63; ++i) | |
377 | 353 | { |
378 | - ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
379 | - UpdateAll(BitConverter.GetBytes(++value)); | |
354 | + bits[i].IsExponential = isDouble; | |
380 | 355 | } |
356 | + textValue.ValidatingType = typeof(Double); | |
381 | 357 | } |
382 | 358 | |
383 | - private void buttonDec_Click(object sender, EventArgs e) | |
359 | + private void SetForInteger() | |
384 | 360 | { |
385 | - if (radioFloat.Checked) | |
386 | - { | |
387 | - if (length == 4) | |
388 | - { | |
389 | - int value = BitConverter.ToInt32(GetBytes(), 0); | |
390 | - if (value == 0) | |
391 | - { | |
392 | - value = 1 << 31; | |
393 | - } | |
394 | - else | |
395 | - { | |
396 | - value -= value >= 0 ? 1 : -1; | |
397 | - } | |
398 | - UpdateAll(BitConverter.GetBytes(value)); | |
399 | - } | |
400 | - else | |
401 | - { | |
402 | - long value = BitConverter.ToInt64(GetBytes(), 0); | |
403 | - if (value == 0) | |
404 | - { | |
405 | - value = 1L << 63; | |
406 | - } | |
407 | - else | |
408 | - { | |
409 | - value -= value >= 0 ? 1 : -1; | |
410 | - } | |
411 | - UpdateAll(BitConverter.GetBytes(value)); | |
412 | - } | |
413 | - } | |
414 | - else | |
361 | + for (int i = 0; i < 64; ++i) | |
415 | 362 | { |
416 | - ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
417 | - UpdateAll(BitConverter.GetBytes(--value)); | |
363 | + bits[i].IsExponential = false; | |
418 | 364 | } |
365 | + textValue.ValidatingType = typeof(long); | |
419 | 366 | } |
420 | 367 | |
421 | - private void buttonClr_Click(object sender, EventArgs e) | |
368 | + private byte[] GetBytes() | |
422 | 369 | { |
423 | - UpdateAll(BitConverter.GetBytes((ulong)0)); | |
370 | + byte[] b = new Byte[8]; | |
371 | + int i = 0; | |
372 | + for (int j = 0; j < 8; ++j) | |
373 | + { | |
374 | + b[j] = 0; | |
375 | + i += 8; | |
376 | + for (int k = 0; k < 8; ++k) | |
377 | + { | |
378 | + b[j] = (byte)(b[j] << 1 | (bits[--i].State ? 1 : 0)); | |
379 | + } | |
380 | + i += 8; | |
381 | + } | |
382 | + return b; | |
424 | 383 | } |
425 | 384 | |
426 | - private void buttonNot_Click(object sender, EventArgs e) | |
385 | + private long ToInt64(byte[] bytes) | |
427 | 386 | { |
428 | - ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
429 | - UpdateAll(BitConverter.GetBytes(~value)); | |
387 | + switch (length) | |
388 | + { | |
389 | + case 1: | |
390 | + return (sbyte)bytes[0]; | |
391 | + case 2: | |
392 | + return BitConverter.ToInt16(bytes, 0); | |
393 | + case 4: | |
394 | + return BitConverter.ToInt32(bytes, 0); | |
395 | + case 8: | |
396 | + return BitConverter.ToInt64(bytes, 0); | |
397 | + } | |
398 | + return 0; | |
430 | 399 | } |
431 | 400 | |
432 | - private void buttonLsh_Click(object sender, EventArgs e) | |
401 | + private ulong ToUInt64(byte[] bytes) | |
433 | 402 | { |
434 | - ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
435 | - UpdateAll(BitConverter.GetBytes(value << 1)); | |
403 | + switch (length) | |
404 | + { | |
405 | + case 1: | |
406 | + return bytes[0]; | |
407 | + case 2: | |
408 | + return BitConverter.ToUInt16(bytes, 0); | |
409 | + case 4: | |
410 | + return BitConverter.ToUInt32(bytes, 0); | |
411 | + case 8: | |
412 | + return BitConverter.ToUInt64(bytes, 0); | |
413 | + } | |
414 | + return 0; | |
436 | 415 | } |
437 | 416 | |
438 | - private void buttonRsh_Click(object sender, EventArgs e) | |
417 | + private void SetLength(int length) | |
439 | 418 | { |
440 | - if (radioInt.Checked) | |
419 | + this.length = length; | |
420 | + int b = length * 8; | |
421 | + for (int i = 8; i < b; ++i) | |
441 | 422 | { |
442 | - long value = ToInt64(GetBytes()); | |
443 | - UpdateAll(BitConverter.GetBytes(value >> 1)); | |
423 | + bits[i].Enabled = true; | |
424 | + } | |
425 | + for (int i = b; i < 64; ++i) | |
426 | + { | |
427 | + bits[i].Enabled = false; | |
428 | + } | |
429 | + if (radioFloat.Checked) | |
430 | + { | |
431 | + textValue_TextChanged(null, null); | |
444 | 432 | } |
445 | 433 | else |
446 | 434 | { |
447 | - ulong value = BitConverter.ToUInt64(GetBytes(), 0); | |
448 | - UpdateAll(BitConverter.GetBytes(value >> 1)); | |
435 | + BitChanged(null, null); | |
449 | 436 | } |
450 | 437 | } |
451 | 438 | |
452 | - private void textValue_Leave(object sender, EventArgs e) | |
439 | + private void UpdateValue(byte[] bytes) | |
453 | 440 | { |
454 | - UpdateValue(GetBytes()); | |
441 | + if (radioUint.Checked) | |
442 | + { | |
443 | + textValue.Text = ToUInt64(bytes).ToString(); | |
444 | + } | |
445 | + else if (radioInt.Checked) | |
446 | + { | |
447 | + textValue.Text = ToInt64(bytes).ToString(); | |
448 | + } | |
449 | + else if (radioFloat.Checked) | |
450 | + { | |
451 | + if (length == 4) | |
452 | + { | |
453 | + float value = BitConverter.ToSingle(bytes, 0); | |
454 | + textValue.Text = value.ToString("g8"); | |
455 | + } | |
456 | + else | |
457 | + { | |
458 | + double value = BitConverter.ToDouble(bytes, 0); | |
459 | + textValue.Text = value.ToString("g17"); | |
460 | + } | |
461 | + } | |
455 | 462 | } |
456 | 463 | |
457 | - private void textHex_Leave(object sender, EventArgs e) | |
464 | + private void UpdateHex(byte[] bytes) | |
458 | 465 | { |
459 | - UpdateHex(GetBytes()); | |
466 | + textHex.Text = ""; | |
467 | + for (int i = length - 1; i >= 0; --i) | |
468 | + { | |
469 | + textHex.Text += bytes[i].ToString("X2"); | |
470 | + } | |
460 | 471 | } |
461 | 472 | |
462 | - private void MainForm_KeyDown(object sender, KeyEventArgs e) | |
473 | + private void UpdateBits(byte[] bytes) | |
463 | 474 | { |
464 | - if (e.Alt) | |
475 | + int i = 0; | |
476 | + for (int j = 0; j < length; ++j) | |
465 | 477 | { |
466 | - switch (e.KeyCode) | |
467 | - { | |
468 | - case Keys.V: | |
469 | - textValue.Focus(); | |
470 | - break; | |
471 | - case Keys.H: | |
472 | - textHex.Focus(); | |
473 | - break; | |
474 | - default: | |
475 | - return; | |
478 | + int mask = 1; | |
479 | + for (int k = 0; k < 8; ++k) | |
480 | + { | |
481 | + bits[i++].SetStateWithoutEvent((bytes[j] & mask) != 0); | |
482 | + mask <<= 1; | |
476 | 483 | } |
477 | - e.SuppressKeyPress = true; | |
478 | 484 | } |
479 | 485 | } |
486 | + | |
487 | + private void UpdateAll(byte[] bytes) | |
488 | + { | |
489 | + UpdateBits(bytes); | |
490 | + UpdateValue(bytes); | |
491 | + UpdateHex(bytes); | |
492 | + } | |
493 | + | |
494 | + #endregion | |
480 | 495 | } |
481 | 496 | } |
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | 32 | // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を |
33 | 33 | // 既定値にすることができます: |
34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("0.0.0.0")] | |
36 | -[assembly: AssemblyFileVersion("0.0.0.0")] | |
35 | +[assembly: AssemblyVersion("0.0.0.1")] | |
36 | +[assembly: AssemblyFileVersion("0.0.0.1")] |