• R/O
  • HTTP
  • SSH
  • HTTPS

fugashi: Commit

Fugashi Bit Viewer


Commit MetaInfo

Revision238d2d7fea9b67e10da3c04d488ba525cece2ee9 (tree)
Time2011-01-10 09:10:43
Authorkimikage <kimikage_ceo@hotm...>
Commiterkimikage

Log Message

最小化時に落ちる不具合の修正,#regionの設定

Change Summary

Incremental Difference

--- a/Fugashi/BitSwitch.Designer.cs
+++ b/Fugashi/BitSwitch.Designer.cs
@@ -64,6 +64,8 @@ namespace Fugashi
6464 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
6565 this.BackColor = System.Drawing.Color.Transparent;
6666 this.Controls.Add(this.label);
67+ this.DoubleBuffered = true;
68+ this.MinimumSize = new System.Drawing.Size(3, 3);
6769 this.Name = "BitSwitch";
6870 this.Size = new System.Drawing.Size(12, 24);
6971 this.SizeChanged += new System.EventHandler(this.BitSwitch_SizeChanged);
--- a/Fugashi/BitSwitch.cs
+++ b/Fugashi/BitSwitch.cs
@@ -18,17 +18,34 @@ namespace Fugashi
1818 {
1919 public partial class BitSwitch : UserControl
2020 {
21+ #region fields
2122 private bool state;
2223 private bool isExponential;
2324 private static Bitmap normal;
2425 private static Bitmap exponent;
2526 private static Bitmap hover;
27+ #endregion
2628
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")]
2845 public event System.EventHandler StateChanged;
2946
3047
31- [Category("データ")]
48+ [Category("Data")]
3249 [DefaultValue(typeof(bool), "True")]
3350 public bool State
3451 {
@@ -43,7 +60,7 @@ namespace Fugashi
4360 }
4461 }
4562
46- [Category("表示")]
63+ [Category("Appearance")]
4764 [DefaultValue(typeof(Color), "LightSteelBlue")]
4865 public Color BorderColor
4966 {
@@ -51,6 +68,8 @@ namespace Fugashi
5168 set;
5269 }
5370
71+ [CategoryAttribute("Data")]
72+ [DefaultValue(typeof(bool), "False")]
5473 public bool IsExponential
5574 {
5675 get
@@ -64,17 +83,54 @@ namespace Fugashi
6483 }
6584 }
6685
67- public BitSwitch()
86+ #endregion
87+
88+ #region event handlers
89+ private void label_Click(object sender, EventArgs e)
6890 {
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)
72110 {
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;
74126 }
75127 UpdateBackgroundImage();
76128 }
77129
130+ #endregion
131+
132+ #region private methods
133+
78134 private void CreateNormalBackgroundImage()
79135 {
80136 if (normal is Bitmap && normal.Size == Size)
@@ -108,15 +164,19 @@ namespace Fugashi
108164 private Bitmap CreateBackGroundImage(
109165 Color hilight, Color light, Color face, Color dark)
110166 {
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);
112172 Graphics g = Graphics.FromImage(bmp);
113173 int border = (int)(Height * 0.48);
114174 Rectangle upper = new Rectangle(0, 0, Width, border);
115175 Rectangle lower = new Rectangle(0, border, Width, Height);
116- LinearGradientBrush brushL =
176+ LinearGradientBrush brushL =
117177 new LinearGradientBrush(upper, hilight, light,
118178 LinearGradientMode.Vertical);
119- LinearGradientBrush brushD =
179+ LinearGradientBrush brushD =
120180 new LinearGradientBrush(lower, face, dark,
121181 LinearGradientMode.Vertical);
122182 Pen edge = new Pen(hilight, 1);
@@ -130,52 +190,15 @@ namespace Fugashi
130190 return bmp;
131191 }
132192
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-
165193 public void SetStateWithoutEvent(bool state)
166194 {
167195 this.state = state;
168196 label.Text = state ? "1" : "0";
169197 label.ForeColor = state ? Color.DarkSlateGray : Color.SteelBlue;
170- label.Font = new Font(label.Font,
198+ label.Font = new Font(label.Font,
171199 state ? FontStyle.Bold : FontStyle.Regular);
172200 }
173201
174- private void BitSwitch_SizeChanged(object sender, EventArgs e)
175- {
176- UpdateBackgroundImage();
177- }
178-
179202 private void UpdateBackgroundImage()
180203 {
181204 bool mouseOver = BackgroundImage == hover;
@@ -191,5 +214,7 @@ namespace Fugashi
191214 BackgroundImage = hover;
192215 }
193216 }
217+
218+ #endregion
194219 }
195220 }
--- a/Fugashi/BitSwitches4.Designer.cs
+++ b/Fugashi/BitSwitches4.Designer.cs
@@ -44,9 +44,10 @@
4444 | System.Windows.Forms.AnchorStyles.Right)));
4545 this.label.Font = new System.Drawing.Font("Tahoma", 8F);
4646 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);
4849 this.label.Name = "label";
49- this.label.Size = new System.Drawing.Size(23, 13);
50+ this.label.Size = new System.Drawing.Size(28, 16);
5051 this.label.TabIndex = 38;
5152 this.label.Text = "0";
5253 this.label.TextAlign = System.Drawing.ContentAlignment.BottomRight;
@@ -64,11 +65,12 @@
6465 this.table.Controls.Add(this.b2, 1, 0);
6566 this.table.Controls.Add(this.b0, 3, 0);
6667 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);
6870 this.table.Name = "table";
6971 this.table.RowCount = 1;
7072 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);
7274 this.table.TabIndex = 39;
7375 //
7476 // b3
@@ -83,8 +85,9 @@
8385 this.b3.IsExponential = false;
8486 this.b3.Location = new System.Drawing.Point(0, 0);
8587 this.b3.Margin = new System.Windows.Forms.Padding(0);
88+ this.b3.MinimumSize = new System.Drawing.Size(4, 4);
8689 this.b3.Name = "b3";
87- this.b3.Size = new System.Drawing.Size(11, 25);
90+ this.b3.Size = new System.Drawing.Size(14, 30);
8891 this.b3.State = false;
8992 this.b3.TabIndex = 3;
9093 //
@@ -98,10 +101,11 @@
98101 this.b2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
99102 this.b2.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229)))));
100103 this.b2.IsExponential = false;
101- this.b2.Location = new System.Drawing.Point(11, 0);
104+ this.b2.Location = new System.Drawing.Point(14, 0);
102105 this.b2.Margin = new System.Windows.Forms.Padding(0);
106+ this.b2.MinimumSize = new System.Drawing.Size(4, 4);
103107 this.b2.Name = "b2";
104- this.b2.Size = new System.Drawing.Size(11, 25);
108+ this.b2.Size = new System.Drawing.Size(14, 30);
105109 this.b2.State = false;
106110 this.b2.TabIndex = 2;
107111 //
@@ -115,10 +119,11 @@
115119 this.b0.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
116120 this.b0.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229)))));
117121 this.b0.IsExponential = false;
118- this.b0.Location = new System.Drawing.Point(33, 0);
122+ this.b0.Location = new System.Drawing.Point(42, 0);
119123 this.b0.Margin = new System.Windows.Forms.Padding(0);
124+ this.b0.MinimumSize = new System.Drawing.Size(4, 4);
120125 this.b0.Name = "b0";
121- this.b0.Size = new System.Drawing.Size(11, 25);
126+ this.b0.Size = new System.Drawing.Size(14, 30);
122127 this.b0.State = false;
123128 this.b0.TabIndex = 0;
124129 this.b0.Tag = "true";
@@ -133,21 +138,23 @@
133138 this.b1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
134139 this.b1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(213)))), ((int)(((byte)(223)))), ((int)(((byte)(229)))));
135140 this.b1.IsExponential = false;
136- this.b1.Location = new System.Drawing.Point(22, 0);
141+ this.b1.Location = new System.Drawing.Point(28, 0);
137142 this.b1.Margin = new System.Windows.Forms.Padding(0);
143+ this.b1.MinimumSize = new System.Drawing.Size(4, 4);
138144 this.b1.Name = "b1";
139- this.b1.Size = new System.Drawing.Size(11, 25);
145+ this.b1.Size = new System.Drawing.Size(14, 30);
140146 this.b1.State = false;
141147 this.b1.TabIndex = 1;
142148 //
143149 // BitSwitches4
144150 //
145- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
151+ this.AutoScaleDimensions = new System.Drawing.SizeF(115F, 115F);
146152 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
147153 this.Controls.Add(this.table);
148154 this.Controls.Add(this.label);
155+ this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
149156 this.Name = "BitSwitches4";
150- this.Size = new System.Drawing.Size(50, 43);
157+ this.Size = new System.Drawing.Size(60, 52);
151158 this.SizeChanged += new System.EventHandler(this.BitSwitches4_SizeChanged);
152159 this.table.ResumeLayout(false);
153160 this.ResumeLayout(false);
--- a/Fugashi/BitSwitches4.cs
+++ b/Fugashi/BitSwitches4.cs
@@ -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;
29 using System.Collections.Generic;
310 using System.ComponentModel;
411 using System.Drawing;
@@ -10,13 +17,20 @@ namespace Fugashi
1017 {
1118 public partial class BitSwitches4 : UserControl
1219 {
20+ #region fields
1321 private int startBit;
22+ #endregion
23+
24+ #region constructor
25+
1426 public BitSwitches4()
1527 {
1628 InitializeComponent();
1729 }
30+ #endregion
1831
19- [Category("データ")]
32+ #region properties
33+ [CategoryAttribute("Data")]
2034 [DefaultValue(typeof(int), "-1")]
2135 public int StartBit
2236 {
@@ -62,7 +76,9 @@ namespace Fugashi
6276 return b3;
6377 }
6478 }
79+ #endregion
6580
81+ #region private methods
6682 private void Coordinate()
6783 {
6884 int y = startBit < 32 ? label.Size.Height : 0;
@@ -81,6 +97,6 @@ namespace Fugashi
8197 int y = startBit < 32 ? label.Size.Height : 0;
8298 table.Location = new Point(table.Location.X, y);
8399 }
84-
100+ #endregion
85101 }
86102 }
--- a/Fugashi/BitSwitches4.resx
+++ b/Fugashi/BitSwitches4.resx
@@ -120,42 +120,42 @@
120120 <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
121121 <data name="b3.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
122122 <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
129129 </value>
130130 </data>
131131 <data name="b2.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
132132 <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
139139 </value>
140140 </data>
141141 <data name="b0.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
142142 <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
149149 </value>
150150 </data>
151151 <data name="b1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
152152 <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
159159 </value>
160160 </data>
161161 </root>
\ No newline at end of file
--- a/Fugashi/MainForm.Designer.cs
+++ b/Fugashi/MainForm.Designer.cs
@@ -47,8 +47,8 @@ namespace Fugashi
4747 this.radio4B = new System.Windows.Forms.RadioButton();
4848 this.radio2B = new System.Windows.Forms.RadioButton();
4949 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();
5252 this.buttonLsh = new System.Windows.Forms.Button();
5353 this.buttonRsh = new System.Windows.Forms.Button();
5454 this.buttonInc = new System.Windows.Forms.Button();
@@ -217,25 +217,29 @@ namespace Fugashi
217217 //
218218 // textValue
219219 //
220+ this.textValue.AsciiOnly = true;
220221 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;
221223 this.textValue.Location = new System.Drawing.Point(57, 33);
222224 this.textValue.Name = "textValue";
223225 this.textValue.Size = new System.Drawing.Size(255, 23);
224226 this.textValue.TabIndex = 87;
225227 this.textValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
226- this.textValue.TextChanged += new System.EventHandler(this.textValue_TextChanged);
227228 this.textValue.Leave += new System.EventHandler(this.textValue_Leave);
229+ this.textValue.TextChanged += new System.EventHandler(this.textValue_TextChanged);
228230 //
229231 // textHex
230232 //
233+ this.textHex.AsciiOnly = true;
231234 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;
232236 this.textHex.Location = new System.Drawing.Point(57, 64);
233237 this.textHex.Name = "textHex";
234238 this.textHex.Size = new System.Drawing.Size(255, 23);
235239 this.textHex.TabIndex = 88;
236240 this.textHex.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
237- this.textHex.TextChanged += new System.EventHandler(this.textHex_TextChanged);
238241 this.textHex.Leave += new System.EventHandler(this.textHex_Leave);
242+ this.textHex.TextChanged += new System.EventHandler(this.textHex_TextChanged);
239243 //
240244 // buttonLsh
241245 //
@@ -612,8 +616,8 @@ namespace Fugashi
612616 private System.Windows.Forms.RadioButton radio4B;
613617 private System.Windows.Forms.RadioButton radio2B;
614618 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;
617621 private System.Windows.Forms.Label labelValue;
618622 private System.Windows.Forms.Label labelHex;
619623 private BitSwitches4 bits0;
--- a/Fugashi/MainForm.cs
+++ b/Fugashi/MainForm.cs
@@ -17,9 +17,12 @@ namespace Fugashi
1717 {
1818 public partial class MainForm : Form
1919 {
20+ #region fields
2021 private BitSwitch[] bits;
2122 private int length = 4;
23+ #endregion
2224
25+ #region constructor
2326 public MainForm()
2427 {
2528 InitializeComponent();
@@ -47,6 +50,28 @@ namespace Fugashi
4750
4851 PerformAutoScale();
4952 }
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+ }
5075
5176 private void radioUint_CheckedChanged(object sender, EventArgs e)
5277 {
@@ -92,75 +117,6 @@ namespace Fugashi
92117 BitChanged(null, null);
93118 }
94119
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-
164120 private void radio8B_CheckedChanged(object sender, EventArgs e)
165121 {
166122 if (radio8B.Checked)
@@ -204,88 +160,112 @@ namespace Fugashi
204160 }
205161 }
206162
207- private void SetLength(int length)
163+
164+ private void buttonInc_Click(object sender, EventArgs e)
208165 {
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- }
219166 if (radioFloat.Checked)
220167 {
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+ }
222194 }
223195 else
224196 {
225- BitChanged(null, null);
197+ ulong value = BitConverter.ToUInt64(GetBytes(), 0);
198+ UpdateAll(BitConverter.GetBytes(++value));
226199 }
227200 }
228201
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)
237203 {
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)
247205 {
248206 if (length == 4)
249207 {
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));
252218 }
253219 else
254220 {
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));
257231 }
258232 }
233+ else
234+ {
235+ ulong value = BitConverter.ToUInt64(GetBytes(), 0);
236+ UpdateAll(BitConverter.GetBytes(--value));
237+ }
259238 }
260239
261- private void UpdateHex(byte[] bytes)
240+ private void buttonClr_Click(object sender, EventArgs e)
262241 {
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));
268243 }
269244
270- private void UpdateBits(byte[] bytes)
245+ private void buttonNot_Click(object sender, EventArgs e)
271246 {
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));
282249 }
283250
284- private void UpdateAll(byte[] bytes)
251+ private void buttonLsh_Click(object sender, EventArgs e)
285252 {
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+ }
289269 }
290270
291271 private void textHex_TextChanged(object sender, EventArgs e)
@@ -342,140 +322,175 @@ namespace Fugashi
342322 UpdateHex(b);
343323 }
344324
345- private void buttonInc_Click(object sender, EventArgs e)
325+ private void textValue_Leave(object sender, EventArgs e)
346326 {
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)
348349 {
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;
375351 }
376- else
352+ for (int i = 52; i < 63; ++i)
377353 {
378- ulong value = BitConverter.ToUInt64(GetBytes(), 0);
379- UpdateAll(BitConverter.GetBytes(++value));
354+ bits[i].IsExponential = isDouble;
380355 }
356+ textValue.ValidatingType = typeof(Double);
381357 }
382358
383- private void buttonDec_Click(object sender, EventArgs e)
359+ private void SetForInteger()
384360 {
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)
415362 {
416- ulong value = BitConverter.ToUInt64(GetBytes(), 0);
417- UpdateAll(BitConverter.GetBytes(--value));
363+ bits[i].IsExponential = false;
418364 }
365+ textValue.ValidatingType = typeof(long);
419366 }
420367
421- private void buttonClr_Click(object sender, EventArgs e)
368+ private byte[] GetBytes()
422369 {
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;
424383 }
425384
426- private void buttonNot_Click(object sender, EventArgs e)
385+ private long ToInt64(byte[] bytes)
427386 {
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;
430399 }
431400
432- private void buttonLsh_Click(object sender, EventArgs e)
401+ private ulong ToUInt64(byte[] bytes)
433402 {
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;
436415 }
437416
438- private void buttonRsh_Click(object sender, EventArgs e)
417+ private void SetLength(int length)
439418 {
440- if (radioInt.Checked)
419+ this.length = length;
420+ int b = length * 8;
421+ for (int i = 8; i < b; ++i)
441422 {
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);
444432 }
445433 else
446434 {
447- ulong value = BitConverter.ToUInt64(GetBytes(), 0);
448- UpdateAll(BitConverter.GetBytes(value >> 1));
435+ BitChanged(null, null);
449436 }
450437 }
451438
452- private void textValue_Leave(object sender, EventArgs e)
439+ private void UpdateValue(byte[] bytes)
453440 {
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+ }
455462 }
456463
457- private void textHex_Leave(object sender, EventArgs e)
464+ private void UpdateHex(byte[] bytes)
458465 {
459- UpdateHex(GetBytes());
466+ textHex.Text = "";
467+ for (int i = length - 1; i >= 0; --i)
468+ {
469+ textHex.Text += bytes[i].ToString("X2");
470+ }
460471 }
461472
462- private void MainForm_KeyDown(object sender, KeyEventArgs e)
473+ private void UpdateBits(byte[] bytes)
463474 {
464- if (e.Alt)
475+ int i = 0;
476+ for (int j = 0; j < length; ++j)
465477 {
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;
476483 }
477- e.SuppressKeyPress = true;
478484 }
479485 }
486+
487+ private void UpdateAll(byte[] bytes)
488+ {
489+ UpdateBits(bytes);
490+ UpdateValue(bytes);
491+ UpdateHex(bytes);
492+ }
493+
494+ #endregion
480495 }
481496 }
--- a/Fugashi/Properties/AssemblyInfo.cs
+++ b/Fugashi/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
3232 // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
3333 // 既定値にすることができます:
3434 // [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")]
Show on old repository browser