Top Index
Yahooは検索方式が変わったせいか、うまくサイト内検索できないなぁ。つーわけでグーグルに変更。
![]() ![]() ![]() |


| 01 | Public Class ToolStripSplitColorButton | |
| 02 | Inherits System.Windows.Forms.ToolStripSplitButton | |
| 03 | ||
| 04 | Private img As System.Drawing.Bitmap | |
| 05 | Private _PaintColor As Color = Color.Black | |
| 06 | ||
| 07 | '現在設定されたカラーを取得する | |
| 08 | Public ReadOnly Property PaintColor() As Color | |
| 09 | Get | |
| 10 | Return Me._PaintColor | |
| 11 | End Get | |
| 12 | End Property | |
| 13 | ||
| 14 | 'カラーダイアログの表示 | |
| 15 | Private Sub ColorList_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DropDownOpening | |
| 16 | Dim CDialog As New ColorDialog | |
| 17 | If CDialog.ShowDialog = DialogResult.OK Then | |
| 18 | 'Private変数を更新 | |
| 19 | Me._PaintColor = CDialog.Color | |
| 20 | ||
| 21 | UpdateIcon(Me.PaintColor) | |
| 22 | Me.Parent.Refresh() | |
| 23 | ||
| 24 | '色変更をButtonClickイベントとして通知 | |
| 25 | Me.OnButtonClick(e) | |
| 26 | End If | |
| 27 | End Sub | |
| 28 | ||
| 29 | 'アイコンのカラーバーを更新 | |
| 30 | Private Sub UpdateIcon(ByVal PaintColor As Color) | |
| 31 | img = Me.Image | |
| 32 | If img.Width < 2 OrElse img.Height < 5 Then Exit Sub | |
| 33 | ||
| 34 | Try | |
| 35 | Dim x, y As Integer | |
| 36 | ||
| 37 | 'アイコンのカラーバーの更新 | |
| 38 | For x = 1 To img.Width - 2 | |
| 39 | For y = img.Height - 6 To img.Height - 2 | |
| 40 | img.SetPixel(x, y, PaintColor) | |
| 41 | Next | |
| 42 | Next | |
| 43 | ||
| 44 | '画像の差し替え | |
| 45 | Me.Image = img | |
| 46 | Catch ex As Exception | |
| 47 | Throw New Exception(ex.Message) | |
| 48 | End Try | |
| 49 | ||
| 50 | End Sub | |
| 51 | End Class |