Option Strict Off
Option Explicit On
'------------------------------------ 2024/03/23 ------------------------------------
Public Class frmDlgColorSet

#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, ByRef wmnu09 As String, ByRef wmnu10 As String)
    Event 色のデーターをください(ByRef wmnu00_10 As String, ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer)
    Event 色を設定してください(ByRef wmnu00_10 As String, ByVal rBackColorUP As Integer, ByVal rForeColorUP As Integer, ByVal rBackColorDN As Integer, ByVal rForeColorDN As Integer)
    Event aaeイベント_FormClosed_の最後に呼び出しています()
    '**************************************************************************
    Private mNew実行中 As Boolean = True : Private mLoading As Boolean = False
    Private mnu色の読込 As Integer = 2     '2 = Use Non  /  0 = 色の読込  /  1= 色の設定
    Private WithEvents o色見本 As 五clsColorSetUa = Nothing : Private flg_o色見本Loading As Boolean = True
    Private m色の読み込み直後 As Boolean = False
#End Region

#Region "Form イベント"
    Friend Function aaダイアログ_色設定_Show0(ByVal rOwner As Form, Optional ByVal rDlgText As String = "", Optional ByVal rShowPosX As Integer = 0, Optional ByVal rShowPosY As Integer = 0) As Boolean
        mNew実行中 = False
        mLoading = True
        Try
            '********************************************
            o色見本 = New 五clsColorSetUa(flg_o色見本Loading, Me, lblColorBoxTMP)
            '********************************************
            pnl個別設定.Visible = False
            lbl個別色読込.SetBounds(pnl個別設定.Left, pnl個別設定.Top, 0, 0, BoundsSpecified.Location)
            lbl個別色読込.Visible = False
            mLoading = False
            '********************************************
            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 = "", wmnu09 As String = "", wmnu10 As String = ""
            RaiseEvent 設定メニューのテキストをください(wmnu00, wmnu01, wmnu02, wmnu03, wmnu04, wmnu05, wmnu06, wmnu07, wmnu08, wmnu09, wmnu10)
            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 : mnu09.Text = wmnu09 : mnu10.Text = wmnu10
            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 <> "")
            '********************************************
            Dim wBackColorUP As Integer, wForeColorUP As Integer, wBackColorDN As Integer, wForeColorDN As Integer
            RaiseEvent 色のデーターをください(mnu00.Text, wBackColorUP, wForeColorUP, wBackColorDN, wForeColorDN)
            Call zz色の読込の後処理(wBackColorUP, wForeColorUP, wBackColorDN, wForeColorDN)
            '********************************************
            Dim x, y As Integer
            With rOwner
                x = (.Left + .Right) \ 2 - (Me.Width \ 2)
                y = .Top
            End With
            Me.SetBounds(x, y, 0, 0, BoundsSpecified.Location)
            Me.Text = IIf(rDlgText <> "", rDlgText, "色の設定")
            Me.Icon = rOwner.Icon
            gggint = ⅩFormMove(gcoフォームをスクリーン内に移動, Me)
            Me.Show(rOwner)
            gggDlgColor_BtnCurReading = 0
            '********************************************
        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 frmDlgColorSet_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        gggint = zzAppIniFileOp(0)      'INI ファイルが存在しない場合に、何もしないコード。
    End Sub
    Private Sub frmDlgColorSet_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate
        If gggDlgColor_BtnCurReading = 1 Then
            gggDlgColor_BtnCurReading = 2
        Else
            gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
        End If
    End Sub
    Private Sub frmDlgColorSet_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        gggint = zzAppIniFileOp(1)  '必ず呼び出します。
        o色見本.Dispose()
        gggDlgColor_BtnCurReading = 0
    End Sub
    Private Sub frmDlgColorSet_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        RaiseEvent aaeイベント_FormClosed_の最後に呼び出しています()
    End Sub
    Private Sub frmDlgColorSet_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        qqqqq("frmDlgColorSet_Disposed")
    End Sub

    '▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼
    'フォームサイズと位置だけを保存する場合の、簡易_共通処理
    '各フォームに記入する。
    Private Function zzAppIniFileOp(ByVal Load_0_QueryUnload_1_Resize_2_DoIniSave_3 As Long) As Boolean
        '読出し時に　INI ファイルが存在しない場合は　False　を返します。
        If gggAppIniFile Is Nothing Then Return False
        Return gggAppIniFile.aaAppIniFileOp_フォームサイズと位置だけ_共通処理(Load_0_QueryUnload_1_Resize_2_DoIniSave_3, Me, "固有の識別文")
    End Function
    '▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
#End Region

#Region "ボタン イベント　ダイアログ内での整合性"
    Private Sub btn閉じる_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn閉じる.Click
        Me.Close()
    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 btn上へコピー_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn上へコピー.Click
        gggbol = ⅩObjColorFontCopy(lblSmpDN, lblSmpUP)
    End Sub
#End Region

#Region "基本色　読み込み　設定　Menu イベント"
    Private Sub btn色の読込_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn色の読込.Click
        mnu色の読込 = 0
        mnuOpStr.Text = "●ウインドウから色を読み込みます"
        btn色の読込.ContextMenuStrip = mnuPop
        mnuPop.Show(btn色の読込, 0, 0)
    End Sub
    Private Sub btn色の設定_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn色の設定.Click
        mnu色の読込 = 1
        mnuOpStr.Text = "●ウインドウに色を設定します"
        btn色の設定.ContextMenuStrip = mnuPop
        mnuPop.Show(btn色の設定, 0, 0)
    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, mnu09.Click, mnu10.Click
        With lblSmpUP
            If TypeOf sender Is ToolStripMenuItem Then
                Dim mmm As ToolStripMenuItem = sender
                Dim ttt As String = mmm.Text
                Dim rwBackColorUP, rwForeColorUP, rwBackColorDN, rwForeColorDN As Integer
                If mnu色の読込 = 0 Then   '"●ウインドウから色を読み込みます"
                    o色見本.CboxMainPich234 = 4
                    RaiseEvent 色のデーターをください(ttt, rwBackColorUP, rwForeColorUP, rwBackColorDN, rwForeColorDN)
                    Call zz色の読込の後処理(rwBackColorUP, rwForeColorUP, rwBackColorDN, rwForeColorDN)
                Else                     '"●ウインドウに色を設定します"
                    Call zz色の書き込みデーター取得処理(rwBackColorUP, rwForeColorUP, rwBackColorDN, rwForeColorDN)
                    RaiseEvent 色を設定してください(ttt, rwBackColorUP, rwForeColorUP, rwBackColorDN, rwForeColorDN)
                End If
            End If
        End With
    End Sub
    Friend Function aaGet_CurSetMode_CurColors(ByRef wCurMode_RetDef_0_SetCustm_1 As Integer, ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer) As Boolean
        If pnl個別設定.Visible = False Then
            Call AppfMyBeep()
            gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
            Return False
        End If
        wCurMode_RetDef_0_SetCustm_1 = IIf(radボタンの色をグループの色に戻す.Checked, 0, 1)
        Call zz色の書き込みデーター取得処理(wBackColorUP, wForeColorUP, wBackColorDN, wForeColorDN)
        Return True
    End Function
#End Region

#Region "個別色　読み込み　設定　イベント"
    Private Sub btn個別設定_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn個別設定.Click
        pnl個別設定.Visible = Not pnl個別設定.Visible
        gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
    End Sub
    Private Sub btn個別読込_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn個別読込.Click
        If pnl個別設定.Visible Then Call btn個別設定_Click(Nothing, Nothing)
        gggDlgColor_BtnCurReading = 1 : lbl個別色読込.Visible = True : btn個別読込.Visible = False
        o色見本.CboxMainPich234 = 4
    End Sub
#End Region

#Region "o色見本 イベント"
    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 m色の読み込み直後 Then
            m色の読み込み直後 = False : Return
        End If
        If mLoading Then Return
        If flg_o色見本Loading Then Return
        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

#Region "内部ヘルパー"
    Private Sub zz色の読込の後処理(ByVal rBackColorUP As Integer, ByVal rForeColorUP As Integer, ByVal rBackColorDN As Integer, ByVal rForeColorDN As Integer)
        With lblSmpUP
            lblSmpUP.BackColor = ⅩColor構造体_from_色値(rBackColorUP) : lblSmpUP.ForeColor = ⅩColor構造体_from_色値(rForeColorUP)
            lblSmpDN.BackColor = ⅩColor構造体_from_色値(rBackColorDN) : lblSmpDN.ForeColor = ⅩColor構造体_from_色値(rForeColorDN)
            radUP.Checked = True
            rbt背景の色.Checked = True
            Call radDN_radUP_rbt文字の色_rbt背景の色_CheckedChanged_COM()
        End With
    End Sub
    Private Sub zz色の書き込みデーター取得処理(ByRef wBackColorUP As Integer, ByRef wForeColorUP As Integer, ByRef wBackColorDN As Integer, ByRef wForeColorDN As Integer)
        With lblSmpUP
            wBackColorUP = ⅩColor構造体_to_色値(lblSmpUP.BackColor) : wForeColorUP = ⅩColor構造体_to_色値(lblSmpUP.ForeColor)
            wBackColorDN = ⅩColor構造体_to_色値(lblSmpDN.BackColor) : wForeColorDN = ⅩColor構造体_to_色値(lblSmpDN.ForeColor)
        End With
    End Sub
#End Region

#Region "外部インターフェイス"
    Friend Function aaErrorClick_Not_CellColorExUsing() As Boolean
        gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
    End Function
    Friend Function aaボタンクリックできる状態です() As Boolean
        Return (pnl個別設定.Visible = False) And (gggDlgColor_BtnCurReading = 0)
    End Function
    Friend Function aaGet_CurRead_CurColors_個別色(ByRef rBackColorUP As Integer, ByRef rForeColorUP As Integer, ByRef rBackColorDN As Integer, ByRef rForeColorDN As Integer) As Boolean
        If gggDlgColor_BtnCurReading <> 2 Then
            Call AppfMyBeep()
            gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
            Return False
        End If
        Call zz色の読込の後処理(rBackColorUP, rForeColorUP, rBackColorDN, rForeColorDN)
        gggDlgColor_BtnCurReading = 0 : lbl個別色読込.Visible = False : btn個別読込.Visible = True
        Return True
    End Function
#End Region


End Class