//──────────────────────────────────────── private void UsercontrolNumericUpDown_Leave(object sender, EventArgs e) { // テキストボックスがフォーカスを失ったら、 // テキストボックスを不可視化。 UsercontrolNumericUpDown ucNum = (UsercontrolNumericUpDown)sender; ucNum.customcontrolTextbox1.Visible = false; }
//──────────────────────────────────────── public Usercontrol Perform( Expression_Node_StringImpl ec_FcName, MemoryApplication owner_MemoryApplication ) { UsercontrolNumericUpDown uctNum = new UsercontrolNumericUpDown(); // 名前だけ初期設定 uctNum.Expression_Name_Control = ec_FcName; uctNum.ControlCommon.Owner_MemoryApplication = owner_MemoryApplication; return uctNum; }
//──────────────────────────────────────── private void UsercontrolNumericUpDown_MouseEnter(object sender, EventArgs e) { // マウスが領域に入ってきたら、 // テキストボックスを可視化。 UsercontrolNumericUpDown ucNum = (UsercontrolNumericUpDown)sender; if (!ucNum.customcontrolTextbox1.ReadOnly) { // 読取専門でなければ可視化。 ucNum.customcontrolTextbox1.Visible = true; } Point p1 = this.PointToClient(System.Windows.Forms.Cursor.Position); bool bRefresh = false; //「▲ボタン」をまだマウスカーソルで指していない時。 if (this.memoryUpbutton1.Bounds.Contains(p1) && !this.memoryUpbutton1.BMousePointed) { //ystem.Console.WriteLine("UcNumにマウスエンター e.GetType().Name=[" + e.GetType().Name + "] マウス位置=[" + System.Windows.Forms.Cursor.Position.X + "," + System.Windows.Forms.Cursor.Position.Y + "] this.upbtnBounds=[" + this.moUpbtn.Bounds.X + "," + this.moUpbtn.Bounds.Y + "," + this.moUpbtn.Bounds.Width + "," + this.moUpbtn.Bounds.Height + "] p1=[" + p1.X + "," + p1.Y + "] ●含む"); this.memoryUpbutton1.ForeBrush = new SolidBrush(Color.Green); this.memoryUpbutton1.BackBrush = new SolidBrush(Color.YellowGreen); // ボタンを絵で描く。 bRefresh = true; } //「▼ボタン」をまだマウスカーソルで指していない時。 if (this.memoryDownbutton1.Bounds.Contains(p1) && !this.memoryDownbutton1.BMousePointed) { this.memoryDownbutton1.ForeBrush = new SolidBrush(Color.Green); this.memoryDownbutton1.BackBrush = new SolidBrush(Color.YellowGreen); // ボタンを絵で描く。 bRefresh = true; } if (bRefresh) { this.Refresh(); } }
//──────────────────────────────────────── private void UsercontrolNumericUpDown_Paint(object sender, PaintEventArgs e) { UsercontrolNumericUpDown ucNum = (UsercontrolNumericUpDown)sender; // // テキストボックス // if (!ucNum.customcontrolTextbox1.Visible) { // 不可視のときに描画。 // 自分の内側に線を引ければよい。 Rectangle rect = new Rectangle( 0, 0, ucNum.CustomcontrolTextbox1.Width - 1, ucNum.CustomcontrolTextbox1.Height - 1 ); // 背景色 if (ucNum.customcontrolTextbox1.ReadOnly) { // 編集不可能。 e.Graphics.FillRectangle(Brushes.LightGray, rect); } else { // 編集可能。 e.Graphics.FillRectangle(Brushes.White, rect); } // 枠線 e.Graphics.DrawRectangle( Pens.Black, rect ); // テキスト表示領域は、四角の線の上下から1ドット離すように小さくします。 rect.Inflate(-2, -2); rect.Offset(-1, 1); e.Graphics.DrawString(this.customcontrolTextbox1.Text, this.customcontrolTextbox1.Font, Brushes.Black, rect); } // // 「▲ボタン」 // { // 自分の内側に線を引ければよい。 Rectangle rect = new Rectangle( this.memoryUpbutton1.Bounds.X, this.memoryUpbutton1.Bounds.Y, this.memoryUpbutton1.Bounds.Width - 1, this.memoryUpbutton1.Bounds.Height - 1 ); if (ucNum.customcontrolTextbox1.ReadOnly) { // 編集不可能。 e.Graphics.FillRectangle(Brushes.LightGray, rect); } else { // 編集可能。 e.Graphics.FillRectangle(this.memoryUpbutton1.BackBrush, rect); } // 枠線 e.Graphics.DrawRectangle(Pens.Black, rect); // 視認で位置調整。 rect.Offset(2, 1); e.Graphics.DrawString("▲", this.memoryUpbutton1.Font, this.memoryUpbutton1.ForeBrush, rect); } // // 「▼ボタン」 // { // 自分の内側に線を引ければよい。 Rectangle rect = new Rectangle( this.memoryDownbutton1.Bounds.X, this.memoryDownbutton1.Bounds.Y, this.memoryDownbutton1.Bounds.Width - 1, this.memoryDownbutton1.Bounds.Height - 1 ); if (ucNum.customcontrolTextbox1.ReadOnly) { // 編集不可能。 e.Graphics.FillRectangle(Brushes.LightGray, rect); } else { // 編集可能。 e.Graphics.FillRectangle(this.memoryDownbutton1.BackBrush, rect); } // 枠線 e.Graphics.DrawRectangle(Pens.Black, rect); // 視認で位置調整。 rect.Offset(2, 1); e.Graphics.DrawString("▼", this.memoryDownbutton1.Font, this.memoryDownbutton1.ForeBrush, rect); } }