Option Strict Off
Option Explicit On
'------------------------------------ 2024/04/10 ------------------------------------
Public Class frmDlgBtnsFontColor

#Region "宣言"
    Event 設定メニューのテキストをください(ByRef wmnu00 As String, ByRef wmnu01 As String, ByRef wmnu02 As String, ByRef wmnu03 As String, ByRef wmnu04 As String, ByRef wmnu05 As String, ByRef wmnu06 As String, ByRef wmnu07 As String, ByRef wmnu08 As String)
    Event 設定メニューがクリックされました(ByRef w呼び出し元に設定する As Boolean, ByRef wmnu00_08 As String, ByRef rwFontName As String, ByRef rwFontSizeIdx_0_4 As Integer, ByRef rwFontBold As Boolean, ByRef rwBackColorUP As Integer, ByRef rwForeColorUP As Integer, ByRef rwBackColorDN As Integer, ByRef rwForeColorDN As Integer)
    Event フォント名とサイズと色のデーターをください(ByRef wFontName As String, ByRef wFontSizeIdx_0_4 As Integer, ByRef wFontBold As Boolean, ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer)
    Event フォント名とサイズと色を設定してください(ByVal rFontName As String, ByVal rFontSizeIdx_0_4 As Integer, ByRef rFontBold As Boolean, ByVal rBackColorUP As Integer, ByVal rForeColorUP As Integer, ByVal rBackColorDN As Integer, ByVal rForeColorDN As Integer)
    Private mNew実行中 As Boolean = True
    Private mLoading As Boolean
    Private mUse設定メニュー As Boolean = False
    '**************************************************************************
    '宣言
    Private WithEvents o色見本 As 五clsColorSetUa = Nothing
    Private flg_o色見本Loading As Boolean = True
#End Region

#Region "Form イベント"
    Friend Function aaダイアログ_色とフォント設定_Show1(ByVal rOwner As Form, Optional ByVal rDlgText As String = "", Optional ByVal rShowPosX As Integer = 0, Optional ByVal rShowPosY As Integer = 0, Optional ByVal 設定メニュー使用 As Boolean = False) As Boolean
        mNew実行中 = False
        mLoading = True
        Try
            '********************************************
            o色見本 = New 五clsColorSetUa(flg_o色見本Loading, Me, lblColorBoxTMP)
            '********************************************
            If lstフォント名.Items.Count = 0 Then
                lstフォント名.Items.Clear()
                Dim wFonts() As String = {""}
                Dim n As Integer = Ⅹフォントコンボ簡易リスト作成(wFonts, Nothing, "", "", True)
                gggint = Ⅹリストボックスに_文配列からリストを入れる(lstフォント名, wFonts, True, -1, -1)
            End If
            '********************************************
            mLoading = False
            Dim wFontName As String = "", wFontSizeIdx_0_4 As Integer, wBackColorUP As Integer, wFontBold As Boolean, wForeColorUP As Integer, wBackColorDN As Integer, wForeColorDN As Integer
            RaiseEvent フォント名とサイズと色のデーターをください(wFontName, wFontSizeIdx_0_4, wFontBold, wBackColorUP, wForeColorUP, wBackColorDN, wForeColorDN)
            If wFontName = "" Then GoTo UnLoadPos
            mUse設定メニュー = 設定メニュー使用
            If mUse設定メニュー Then
                Dim wmnu00 As String = "", wmnu01 As String = "", wmnu02 As String = "", wmnu03 As String = "", wmnu04 As String = "", wmnu05 As String = "", wmnu06 As String = "", wmnu07 As String = "", wmnu08 As String = ""
                RaiseEvent 設定メニューのテキストをください(wmnu00, wmnu01, wmnu02, wmnu03, wmnu04, wmnu05, wmnu06, wmnu07, wmnu08)
                mnu00.Text = wmnu00 : mnu01.Text = wmnu01 : mnu02.Text = wmnu02 : mnu03.Text = wmnu03 : mnu04.Text = wmnu04 : mnu05.Text = wmnu05 : mnu06.Text = wmnu06 : mnu07.Text = wmnu07 : mnu08.Text = wmnu08
                mnu00.Visible = (mnu00.Text <> "") : mnu01.Visible = (mnu01.Text <> "") : mnu02.Visible = (mnu02.Text <> "") : mnu03.Visible = (mnu03.Text <> "") : mnu04.Visible = (mnu04.Text <> "")
                mnu05.Visible = (mnu05.Text <> "") : mnu06.Visible = (mnu06.Text <> "") : mnu07.Visible = (mnu07.Text <> "") : mnu08.Visible = (mnu08.Text <> "")
                mnu04.Visible = False
                mnuPop.Items.Insert(4, New ToolStripSeparator)
            End If
            '********************************************
            lstフォント名.SelectedIndex = Ⅹリストボックスから_文のリストを探して_インデックスを返す(lstフォント名, wFontName, True)
            cboフォントサイズ.SelectedIndex = wFontSizeIdx_0_4
            chk太字.Checked = wFontBold
            lblSmpUP.BackColor = ⅩColor構造体_from_色値(wBackColorUP) : lblSmpUP.ForeColor = ⅩColor構造体_from_色値(wForeColorUP)
            lblSmpDN.BackColor = ⅩColor構造体_from_色値(wBackColorDN) : lblSmpDN.ForeColor = ⅩColor構造体_from_色値(wForeColorDN)
            '********************************************
            radUP.Checked = True       '2023/10/19  順番が大事
            rbt背景の色.Checked = True  '2023/10/19  順番が大事
            '********************************************
            Dim x, y As Integer
            If rShowPosX = 0 And rShowPosY = 0 Then
                Dim pt As Point = System.Windows.Forms.Cursor.Position : x = pt.X : y = pt.Y
            ElseIf rShowPosX = -1 And rShowPosY = -1 Then
                Me.StartPosition = FormStartPosition.CenterParent
            Else
                x = rShowPosX : y = rShowPosY
            End If
            Me.SetBounds(x, y, 0, 0, BoundsSpecified.Location)
            Me.Text = IIf(rDlgText <> "", rDlgText, "フォントと色の設定")
            Me.Icon = rOwner.Icon
            gggint = ⅩFormMove(gcoフォームをスクリーン内に移動, Me)
            Me.ShowDialog(rOwner)
            '********************************************
        Catch ex As Exception
            Call ⅩMsgBox_OK_情報("aaダイアログ_色とフォント設定_Show1()" & gggCR2 & ex.ToString)
        End Try
        mLoading = False
        Return True
UnLoadPos:
        Me.Close()
        Return False
    End Function
    Private Sub frmDlgColorFontSet_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        o色見本.Dispose()
        o色見本 = Nothing
    End Sub
    Private Sub frmDlgColorFontSet_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        'qqqqq("frmDlgColorFontSet_Disposed")
        'Call frmMain.aa色とフォントの設定Dlg_Load_1_Disposed_2(2, Nothing)
    End Sub
#End Region

#Region "Controls イベント"
    Private Sub btn閉じる_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn閉じる.Click
        Me.Close()
    End Sub
    Private Sub lstフォント名_SelectedIndexChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstフォント名.SelectedIndexChanged
        If mLoading Or mNew実行中 Then Return
        Dim fn As String = lstフォント名.SelectedItem.ToString
        With lblSmpUP
            .Font = New Font(fn, .Font.Size, .Font.Style, .Font.Unit)
        End With
        lblSmpDN.Font = lblSmpUP.Font
    End Sub
    Private Sub cboフォントサイズ_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboフォントサイズ.SelectedIndexChanged
        If mLoading Or mNew実行中 Then Return
        Dim n As Integer = cboフォントサイズ.SelectedIndex  '0,1,2,3,4
        Dim c As Single = 5 + n  '3 4 5 6 7
        c = c * 2
        Dim fsty As FontStyle = lblSmpUP.Font.Style
        fsty = fsty Or IIf(chk太字.Checked = True, FontStyle.Bold, FontStyle.Regular)
        lblSmpUP.Font = New Font(lblSmpUP.Font.FontFamily, c, fsty)
        lblSmpDN.Font = lblSmpUP.Font
    End Sub
    Private Sub chk太字_CheckedChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles chk太字.CheckedChanged
        If mLoading Or mNew実行中 Then Return
        lblSmpUP.Font = New Font(lblSmpUP.Font, IIf(chk太字.Checked = True, FontStyle.Bold, FontStyle.Regular))
        lblSmpDN.Font = lblSmpUP.Font
    End Sub
    Private Sub lblSmpUP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSmpUP.Click
        radUP.Checked = True
    End Sub
    Private Sub lblSmpDN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSmpDN.Click
        radDN.Checked = True
    End Sub
    Private Sub radDN_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radDN.CheckedChanged
        Call radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
    End Sub
    Private Sub radUP_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radUP.CheckedChanged
        Call radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
    End Sub
    Private Sub rbt背景の色_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbt背景の色.CheckedChanged
        Call radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
    End Sub
    Private Sub rbt文字の色_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbt文字の色.CheckedChanged
        Call radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
    End Sub
    Private Sub radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
        If mLoading Or mNew実行中 Then Return
        Dim lbl As Label = IIf(radDN.Checked, lblSmpDN, lblSmpUP)
        If rbt文字の色.Checked Then
            o色見本.CboxCurMainColor = ⅩColor構造体_to_色値(lbl.ForeColor)
        Else
            o色見本.CboxCurMainColor = ⅩColor構造体_to_色値(lbl.BackColor)
        End If
    End Sub
    Private Sub btn下へコピー_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn下へコピー.Click
        gggbol = ⅩObjColorFontCopy(lblSmpUP, lblSmpDN)
    End Sub
    Private Sub btnUpDNに設定_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpDNに設定.Click
        If mUse設定メニュー Then
            btnUpDNに設定.ContextMenuStrip = mnuPop
            mnuPop.Show(btnUpDNに設定, 0, 0)
        Else
            With lblSmpUP
                RaiseEvent フォント名とサイズと色を設定してください(.Font.Name, cboフォントサイズ.SelectedIndex, .Font.Bold, ⅩColor構造体_to_色値(.BackColor), ⅩColor構造体_to_色値(.ForeColor), ⅩColor構造体_to_色値(lblSmpDN.BackColor), ⅩColor構造体_to_色値(lblSmpDN.ForeColor))
            End With
        End If
    End Sub
    Private Sub mnu00_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnu00.Click, mnu01.Click, mnu02.Click, mnu03.Click, mnu04.Click, mnu05.Click, mnu06.Click, mnu07.Click, mnu08.Click
        With lblSmpUP
            If TypeOf sender Is ToolStripMenuItem Then
                Dim w呼び出し元に設定する As Boolean = False
                Dim fname As String = .Font.Name
                Dim fsize As Integer = cboフォントサイズ.SelectedIndex
                Dim fbold As Boolean = .Font.Bold
                Dim BKUP As Integer = ⅩColor構造体_to_色値(.BackColor)
                'qqqqq(CStr(BKUP))
                Dim FRUP As Integer = ⅩColor構造体_to_色値(.ForeColor)
                Dim BKDN As Integer = ⅩColor構造体_to_色値(lblSmpDN.BackColor)
                Dim FRDN As Integer = ⅩColor構造体_to_色値(lblSmpDN.ForeColor)
                Dim m As ToolStripMenuItem = sender
                Dim mnutext As String = m.Text
                RaiseEvent 設定メニューがクリックされました(w呼び出し元に設定する, mnutext, fname, fsize, fbold, BKUP, FRUP, BKDN, FRDN)
                If w呼び出し元に設定する Then
                    lstフォント名.SelectedIndex = Ⅹリストボックスから_文のリストを探して_インデックスを返す(lstフォント名, fname, True)
                    cboフォントサイズ.SelectedIndex = fsize
                    chk太字.Checked = fbold
                    .BackColor = ⅩColor構造体_from_色値(BKUP)
                    'qqqqq(CStr(BKUP))
                    .ForeColor = ⅩColor構造体_from_色値(FRUP)
                    lblSmpDN.BackColor = ⅩColor構造体_from_色値(BKDN)
                    lblSmpDN.ForeColor = ⅩColor構造体_from_色値(FRDN)
                    If radDN.Checked Then
                        Call radDN_CheckedChanged(Nothing, Nothing)
                    Else
                        Call radUP_CheckedChanged(Nothing, Nothing)
                    End If
                Else
                End If
            End If
        End With
    End Sub
    Private Sub o色見本_OnCboxColorChanged(ByVal rCurMainColor As Integer, ByVal rCurColor As Integer, ByVal rChangeMode As 五clsColorSetUa.EnmColorChangeMode, ByVal rEventMouseUp As Boolean) Handles o色見本.OnCboxColorChanged
        If mLoading Then Exit Sub
        If flg_o色見本Loading Then Exit Sub
        If rCurColor >= 0 Then
            gggbol = o色見本.CboxCurColorSetIntoControlBackOrFore(IIf(radUP.Checked, lblSmpUP, lblSmpDN), (Not rbt文字の色.Checked), True)
        End If
        'Debug.Print("o色見本_OnCboxColorChanged  " + CStr(rChangeMode) + "   " + CStr(rEventMouseUp))
    End Sub

#End Region

End Class