﻿using System;
using System.Text;

namespace CollectionConditions
{
    public partial class ChannelSetting : Form
    {
        ushort m_InputType;
        ushort m_AiChannels;
        ushort[] m_ChannelNo;
        byte[] m_ChName;
        ushort[] m_Range;
        ushort[] m_ScaleEnable;
        float[] m_MinData;
        float[] m_MaxData;
        float[] m_MinScale;
        float[] m_MaxScale;
        public ushort m_sequence_num;
        ushort[] m_AiRange;

        ComboBox[] m_combobox_Hwch;
        TextBox[] m_textbox_Chname;
        ComboBox[] m_combobox_Range;
        ComboBox[] m_combobox_ScaleEnable;
        TextBox[] m_textbox_MinData;
        TextBox[] m_textbox_MaxData;
        TextBox[] m_textbox_MinScale;
        TextBox[] m_textbox_MaxScale;

        public ChannelSetting()
        {
            InitializeComponent();
            int i;
            m_sequence_num = 4;
            m_ChannelNo = new ushort[m_sequence_num];
            m_ChName = new byte[m_sequence_num * 256];
            m_Range = new ushort[m_sequence_num];
            m_ScaleEnable = new ushort[m_sequence_num];
            m_MinData = new float[m_sequence_num];
            m_MaxData = new float[m_sequence_num];
            m_MinScale = new float[m_sequence_num];
            m_MaxScale = new float[m_sequence_num];
            m_combobox_Hwch = new ComboBox[m_sequence_num];
            m_textbox_Chname = new TextBox[m_sequence_num];
            m_combobox_Range = new ComboBox[m_sequence_num];
            m_combobox_ScaleEnable = new ComboBox[m_sequence_num];
            m_textbox_MinData = new TextBox[m_sequence_num];
            m_textbox_MaxData = new TextBox[m_sequence_num];
            m_textbox_MinScale = new TextBox[m_sequence_num];
            m_textbox_MaxScale = new TextBox[m_sequence_num];
            m_AiRange = new ushort[] {  (ushort)CLoggerConst.PM10,      // ±10V
                                        (ushort)CLoggerConst.PM5,       // ±5V
                                        (ushort)CLoggerConst.PM25,      // ±2.5V
                                        (ushort)CLoggerConst.PM125,     // ±1.15V
                                        (ushort)CLoggerConst.P10,       // 0～10V
                                        (ushort)CLoggerConst.P5,        // 0～5V
                                        (ushort)CLoggerConst.P25,       // 0～2.5V
                                        (ushort)CLoggerConst.P125,      // 0～1.25V
                                        (ushort)CLoggerConst.P20MA,     // 0～20mA
                                        (ushort)CLoggerConst.P4TO20MA,  // 4～20mA
                                        (ushort)CLoggerConst.PM20MA,    // ±20mA
                                        (ushort)CLoggerConst.P1TO5};    // 1～5V
            for (i = 0; i < m_sequence_num; i++)
            {
                switch (i)
                {
                    case 0:
                        m_combobox_Hwch[i] = comboBox_ChannelNo1;
                        m_textbox_Chname[i] = textBox_ChName1;
                        m_combobox_Range[i] = comboBox_Range1;
                        m_combobox_ScaleEnable[i] = comboBox_ScaleEnable1;
                        m_textbox_MinData[i] = textBox_MinData1;
                        m_textbox_MaxData[i] = textBox_MaxData1;
                        m_textbox_MinScale[i] = textBox_MinScale1;
                        m_textbox_MaxScale[i] = textBox_MaxScale1;
                        break;
                    case 1:
                        m_combobox_Hwch[i] = comboBox_ChannelNo2;
                        m_textbox_Chname[i] = textBox_ChName2;
                        m_combobox_Range[i] = comboBox_Range2;
                        m_combobox_ScaleEnable[i] = comboBox_ScaleEnable2;
                        m_textbox_MinData[i] = textBox_MinData2;
                        m_textbox_MaxData[i] = textBox_MaxData2;
                        m_textbox_MinScale[i] = textBox_MinScale2;
                        m_textbox_MaxScale[i] = textBox_MaxScale2;
                        break;
                    case 2:
                        m_combobox_Hwch[i] = comboBox_ChannelNo3;
                        m_textbox_Chname[i] = textBox_ChName3;
                        m_combobox_Range[i] = comboBox_Range3;
                        m_combobox_ScaleEnable[i] = comboBox_ScaleEnable3;
                        m_textbox_MinData[i] = textBox_MinData3;
                        m_textbox_MaxData[i] = textBox_MaxData3;
                        m_textbox_MinScale[i] = textBox_MinScale3;
                        m_textbox_MaxScale[i] = textBox_MaxScale3;
                        break;
                    case 3:
                        m_combobox_Hwch[i] = comboBox_ChannelNo4;
                        m_textbox_Chname[i] = textBox_ChName4;
                        m_combobox_Range[i] = comboBox_Range4;
                        m_combobox_ScaleEnable[i] = comboBox_ScaleEnable4;
                        m_textbox_MinData[i] = textBox_MinData4;
                        m_textbox_MaxData[i] = textBox_MaxData4;
                        m_textbox_MinScale[i] = textBox_MinScale4;
                        m_textbox_MaxScale[i] = textBox_MaxScale4;
                        break;
                    default:
                        m_combobox_Hwch[i] = comboBox_ChannelNo1;
                        m_textbox_Chname[i] = textBox_ChName1;
                        m_combobox_Range[i] = comboBox_Range1;
                        m_combobox_ScaleEnable[i] = comboBox_ScaleEnable1;
                        m_textbox_MinData[i] = textBox_MinData1;
                        m_textbox_MaxData[i] = textBox_MaxData1;
                        m_textbox_MinScale[i] = textBox_MinScale1;
                        m_textbox_MaxScale[i] = textBox_MaxScale1;
                        break;
                }
            }
        }

        //================================================================================
        // データの受け渡し（設定）
        //================================================================================
        internal void channel_data_set(ushort InputType, ushort AiChannels, ushort[] ChannelNo, byte[] ChName, ushort[] Range, ushort[] ScaleEnable, float[] MinData, float[] MaxData, float[] MinScale, float[] MaxScale)
        {
            m_InputType = InputType;
            m_AiChannels = AiChannels;
            m_ChannelNo = ChannelNo;
            m_ChName = ChName;
            m_Range = Range;
            m_ScaleEnable = ScaleEnable;
            m_MinData = MinData;
            m_MaxData = MaxData;
            m_MinScale = MinScale;
            m_MaxScale = MaxScale;
        }

        //================================================================================
        // データの受け渡し（取得）
        //================================================================================
        internal void channel_data_get(ref ushort InputType, ref ushort AiChannels, ref ushort[] ChannelNo, ref byte[] ChName, ref ushort[] Range, ref ushort[] ScaleEnable, ref float[] MinData, ref float[] MaxData, ref float[] MinScale, ref float[] MaxScale)
        {
            InputType = m_InputType;
            AiChannels = m_AiChannels;
            ChannelNo = m_ChannelNo;
            ChName = m_ChName;
            Range = m_Range;
            ScaleEnable = m_ScaleEnable;
            MinData = m_MinData;
            MaxData = m_MaxData;
            MinScale = m_MinScale;
            MaxScale = m_MaxScale;
        }

        //================================================================================
        // 適用ボタンをクリックした際の処理になります
        // 設定値の確認
        //================================================================================
        private void button_OK_Click(object sender, EventArgs e)
        {
            int i;              // ループカウント

            //----------------------------------------
            // コンボボックスから入力方式を取得
            //----------------------------------------
            m_InputType = (ushort)comboBox_InputType.SelectedIndex;
            //----------------------------------------
            // コンボボックスからチャネル数を取得(index + 1)
            //----------------------------------------
            m_AiChannels = (ushort)(comboBox_AiChannels.SelectedIndex + 1);
            for (i = 0; i < m_sequence_num; i++)
            {
                //----------------------------------------
                // コンボボックスからHWchを取得
                //----------------------------------------
                m_ChannelNo[i] = (ushort)m_combobox_Hwch[i].SelectedIndex;
                //----------------------------------------
                // テキストボックスからチャネル名を取得
                //----------------------------------------
                byte[] bytes = Encoding.GetEncoding("shift_jis").GetBytes(m_textbox_Chname[i].Text);
                int startPos = i * 256;
                int copyLen = bytes.Length > 256 ? 256 : bytes.Length;
                Array.Clear(m_ChName, startPos, 256);
                Array.Copy(bytes, 0, m_ChName, startPos, copyLen);
                //----------------------------------------
                // コンボボックスからレンジを取得
                //----------------------------------------
                m_Range[i] = m_AiRange[m_combobox_Range[i].SelectedIndex];
                //----------------------------------------
                // コンボボックスからスケール有効／無効を取得
                //----------------------------------------
                m_ScaleEnable[i] = (ushort)m_combobox_ScaleEnable[i].SelectedIndex;
                //----------------------------------------
                // テキストボックスからデータ1を取得
                //----------------------------------------
                if (float.TryParse(m_textbox_MinData[i].Text, out m_MinData[i]) == false)
                {
                    m_MinData[i] = 0;
                }
                //----------------------------------------
                // テキストボックスからデータ2を取得
                //----------------------------------------
                if (float.TryParse(m_textbox_MaxData[i].Text, out m_MaxData[i]) == false)
                {
                    m_MaxData[i] = 0;
                }
                //----------------------------------------
                // テキストボックスから最小スケールを取得
                //----------------------------------------
                if (float.TryParse(m_textbox_MinScale[i].Text, out m_MinScale[i]) == false)
                {
                    m_MinScale[i] = 0;
                }
                //----------------------------------------
                // テキストボックスから最大スケールを取得
                //----------------------------------------
                if (float.TryParse(m_textbox_MaxScale[i].Text, out m_MaxScale[i]) == false)
                {
                    m_MaxScale[i] = 0;
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();

        }

        //================================================================================
        // キャンセルボタンをクリックした際の処理になります
        //================================================================================
        private void button_CANCEL_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        //================================================================================
        // 初期設定
        //================================================================================
        private void ChannelSetting_Load(object sender, EventArgs e)
        {
            int i, j;  // ループカウント

            //----------------------------------------
            // 入力方式コンボボックスの作成
            //----------------------------------------
            comboBox_InputType.Items.Add("シングルエンド入力");
            comboBox_InputType.Items.Add("差動入力");
            //----------------------------------------
            // 入力方式コンボボックスの選択を更新
            //----------------------------------------
            comboBox_InputType.SelectedIndex = m_InputType;
            //----------------------------------------
            // チャネル数コンボボックスのリセット
            //----------------------------------------
            comboBox_AiChannels.Items.Clear();
            //----------------------------------------
            // チャネル数コンボボックスの作成
            //----------------------------------------
            comboBox_AiChannels.Items.Add("1");
            comboBox_AiChannels.Items.Add("2");
            //----------------------------------------
            // シングルエンド入力の場合
            //----------------------------------------
            if (comboBox_InputType.SelectedIndex == (int)CLoggerConst.LOGGER_PARAM_SINGLEENDED)
            {
                comboBox_AiChannels.Items.Add("3");
                comboBox_AiChannels.Items.Add("4");
            }
            //----------------------------------------
            // チャネル数コンボボックスの選択を更新(チャネル数-1)
            //----------------------------------------
            if (m_AiChannels > 0)
            {
                comboBox_AiChannels.SelectedIndex = m_AiChannels - 1;
            }
            else
            {
                comboBox_AiChannels.SelectedIndex = 0;
            }
            for (i = 0; i < m_sequence_num; i++)
            {
                //----------------------------------------
                // HWCh用コンボボックスの作成
                //----------------------------------------
                m_combobox_Hwch[i].Items.Add("0");
                m_combobox_Hwch[i].Items.Add("1");
                m_combobox_Hwch[i].Items.Add("2");
                m_combobox_Hwch[i].Items.Add("3");
                //----------------------------------------
                // HWCh用コンボボックスの選択
                //----------------------------------------
                m_combobox_Hwch[i].SelectedIndex = m_ChannelNo[i];
                //----------------------------------------
                // チャネル名表示を更新
                //----------------------------------------
                int startPos = i * 256;
                int nullPos = Array.IndexOf(m_ChName, 0, startPos, 256);
                int copyLen = nullPos == -1 ? 256 : nullPos - startPos;
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                m_textbox_Chname[i].Text = Encoding.GetEncoding("shift_jis").GetString(m_ChName, startPos, copyLen);
                //----------------------------------------
                // アナログ入力レンジ用コンボボックスの作成
                //----------------------------------------
                m_combobox_Range[i].Items.Add("-10 - +10V");
                m_combobox_Range[i].Items.Add("-5 - +5V");
                m_combobox_Range[i].Items.Add("-2.5 - +2.5V");
                m_combobox_Range[i].Items.Add("-1.25 - +1.25V");
                m_combobox_Range[i].Items.Add("0 - +10V");
                m_combobox_Range[i].Items.Add("0 - +5V");
                m_combobox_Range[i].Items.Add("0 - +2.5V");
                m_combobox_Range[i].Items.Add("0 - +1.25V");
                m_combobox_Range[i].Items.Add("0 - +20mA");
                m_combobox_Range[i].Items.Add("4 - +20mA");
                m_combobox_Range[i].Items.Add("-20 - +20mA");
                m_combobox_Range[i].Items.Add("1 - +5V");
                //----------------------------------------
                // アナログ入力レンジ用コンボボックスの選択を変更
                //----------------------------------------
                m_combobox_Range[i].SelectedIndex = 0;
                for (j = 0; j < m_AiRange.Length; j++)
                {
                    if (m_Range[i] == m_AiRange[j])
                    {
                        m_combobox_Range[i].SelectedIndex = j;
                    }
                }
                //----------------------------------------
                // スケール有効／無効コンボボックスの作成
                //----------------------------------------
                m_combobox_ScaleEnable[i].Items.Add("無効");
                m_combobox_ScaleEnable[i].Items.Add("有効");
                //----------------------------------------
                // スケール有効／無効コンボボックスの選択を変更
                //----------------------------------------
                m_combobox_ScaleEnable[i].SelectedIndex = m_ScaleEnable[i];
                //----------------------------------------
                // データ1表示を更新
                //----------------------------------------
                m_textbox_MinData[i].Text = string.Format("{0}", m_MinData[i]);
                //----------------------------------------
                // データ2表示を更新
                //----------------------------------------
                m_textbox_MaxData[i].Text = string.Format("{0}", m_MaxData[i]);
                //----------------------------------------
                // 最小スケール表示を更新
                //----------------------------------------
                m_textbox_MinScale[i].Text = string.Format("{0}", m_MinScale[i]);
                //----------------------------------------
                // 最大スケール表示を更新
                //----------------------------------------
                m_textbox_MaxScale[i].Text = string.Format("{0}", m_MaxScale[i]);
            }
            //----------------------------------------
            // チャネル数コンボボックスの変更イベントを発生させて表示を更新
            //----------------------------------------
            comboBox_AiChannels_SelectedIndexChanged(comboBox_AiChannels, EventArgs.Empty);
        }

        //================================================================================
        // 入力方式のコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、チャネル数の設定範囲を変更します
        //================================================================================
        private void comboBox_InputType_SelectedIndexChanged(object sender, EventArgs e)
        {
            int input_type; // 入力方式の格納用

            //----------------------------------------
            // コンボボックスから入力方式の取得
            //----------------------------------------
            input_type = comboBox_InputType.SelectedIndex;
            //----------------------------------------
            // チャネル数コンボボックスのリセット
            //----------------------------------------
            comboBox_AiChannels.Items.Clear();
            //----------------------------------------
            // チャネル数コンボボックスの作成
            //----------------------------------------
            comboBox_AiChannels.Items.Add("1");
            comboBox_AiChannels.Items.Add("2");
            //----------------------------------------
            // シングルエンド入力の場合
            //----------------------------------------
            if (comboBox_InputType.SelectedIndex == (int)CLoggerConst.LOGGER_PARAM_SINGLEENDED)
            {
                comboBox_AiChannels.Items.Add("3");
                comboBox_AiChannels.Items.Add("4");
            }
            //----------------------------------------
            // チャネル数コンボボックスの選択を更新
            //----------------------------------------
            comboBox_AiChannels.SelectedIndex = 0;
            //----------------------------------------
            // チャネル数コンボボックスの変更イベントを発生させて表示を更新
            //----------------------------------------
            comboBox_AiChannels_SelectedIndexChanged(comboBox_AiChannels, EventArgs.Empty);
            return;
        }

        //================================================================================
        // チャネルのコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、チャネル数設定未満の設定の操作の有効/無効を切り替えます
        //================================================================================
        private void comboBox_AiChannels_SelectedIndexChanged(object sender, EventArgs e)
        {
            int scale_enable;                           // スケール変換の格納用
            int i;                                      // ループカウント
            bool[] sequence = new bool[m_sequence_num]; // シーケンスの有効／無効の格納用
            ushort ai_channels;                         // チャネル数

            //----------------------------------------
            // コンボボックスからチャネル数を取得(index + 1)
            //----------------------------------------
            ai_channels = (ushort)(comboBox_AiChannels.SelectedIndex + 1);
            //----------------------------------------
            // シーケンス数分ループ
            //----------------------------------------
            for (i = 0; i < m_sequence_num; i++)
            {
                //----------------------------------------
                // チャネル数設定未満の設定を操作無効
                //----------------------------------------
                if (i < ai_channels)
                {
                    sequence[i] = true;
                }
                else
                {
                    sequence[i] = false;
                }
                m_combobox_Hwch[i].Enabled = sequence[i];
                m_combobox_Range[i].Enabled = sequence[i];
                m_textbox_Chname[i].Enabled = sequence[i];
                m_combobox_ScaleEnable[i].Enabled = sequence[i];
                //----------------------------------------
                // スケール設定の操作無効
                //----------------------------------------
                if (sequence[i] == true)
                {
                    scale_enable = m_combobox_ScaleEnable[i].SelectedIndex;
                    if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_DISABLE)
                    {
                        m_textbox_MinData[i].Enabled = false;
                        m_textbox_MaxData[i].Enabled = false;
                        m_textbox_MinScale[i].Enabled = false;
                        m_textbox_MaxScale[i].Enabled = false;
                    }
                    else if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_ENABLE)
                    {
                        m_textbox_MinData[i].Enabled = true;
                        m_textbox_MaxData[i].Enabled = true;
                        m_textbox_MinScale[i].Enabled = true;
                        m_textbox_MaxScale[i].Enabled = true;
                    }
                    else
                    {
                        m_textbox_MinData[i].Enabled = true;
                        m_textbox_MaxData[i].Enabled = true;
                        m_textbox_MinScale[i].Enabled = true;
                        m_textbox_MaxScale[i].Enabled = true;
                    }
                }
                else
                {
                    m_textbox_MinData[i].Enabled = sequence[i];
                    m_textbox_MaxData[i].Enabled = sequence[i];
                    m_textbox_MinScale[i].Enabled = sequence[i];
                    m_textbox_MaxScale[i].Enabled = sequence[i];
                }
            }
        }

        //================================================================================
        // スケール変換のコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、スケール設定の有効無効を変更します
        //================================================================================
        private void comboBox_ScaleEnable1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int scale_enable;   // スケール変換の格納用

            //----------------------------------------
            // スケール変換の取得
            //----------------------------------------
            scale_enable = comboBox_ScaleEnable1.SelectedIndex;
            if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_DISABLE)
            {
                //----------------------------------------
                // 無効
                //----------------------------------------
                textBox_MinData1.Enabled = false;
                textBox_MaxData1.Enabled = false;
                textBox_MinScale1.Enabled = false;
                textBox_MaxScale1.Enabled = false;
            }
            else if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_ENABLE)
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData1.Enabled = true;
                textBox_MaxData1.Enabled = true;
                textBox_MinScale1.Enabled = true;
                textBox_MaxScale1.Enabled = true;
            }
            else
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData1.Enabled = true;
                textBox_MaxData1.Enabled = true;
                textBox_MinScale1.Enabled = true;
                textBox_MaxScale1.Enabled = true;
            }
        }

        //================================================================================
        // スケール変換のコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、スケール設定の有効無効を変更します
        //================================================================================
        private void comboBox_ScaleEnable2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int scale_enable;   // スケール変換の格納用

            //----------------------------------------
            // スケール変換の取得
            //----------------------------------------
            scale_enable = comboBox_ScaleEnable2.SelectedIndex;
            if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_DISABLE)
            {
                //----------------------------------------
                // 無効
                //----------------------------------------
                textBox_MinData2.Enabled = false;
                textBox_MaxData2.Enabled = false;
                textBox_MinScale2.Enabled = false;
                textBox_MaxScale2.Enabled = false;
            }
            else if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_ENABLE)
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData2.Enabled = true;
                textBox_MaxData2.Enabled = true;
                textBox_MinScale2.Enabled = true;
                textBox_MaxScale2.Enabled = true;
            }
            else
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData2.Enabled = true;
                textBox_MaxData2.Enabled = true;
                textBox_MinScale2.Enabled = true;
                textBox_MaxScale2.Enabled = true;
            }
        }

        //================================================================================
        // スケール変換のコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、スケール設定の有効無効を変更します
        //================================================================================
        private void comboBox_ScaleEnable3_SelectedIndexChanged(object sender, EventArgs e)
        {
            int scale_enable;   // スケール変換の格納用

            //----------------------------------------
            // スケール変換の取得
            //----------------------------------------
            scale_enable = comboBox_ScaleEnable3.SelectedIndex;
            if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_DISABLE)
            {
                //----------------------------------------
                // 無効
                //----------------------------------------
                textBox_MinData3.Enabled = false;
                textBox_MaxData3.Enabled = false;
                textBox_MinScale3.Enabled = false;
                textBox_MaxScale3.Enabled = false;
            }
            else if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_ENABLE)
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData3.Enabled = true;
                textBox_MaxData3.Enabled = true;
                textBox_MinScale3.Enabled = true;
                textBox_MaxScale3.Enabled = true;
            }
            else
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData3.Enabled = true;
                textBox_MaxData3.Enabled = true;
                textBox_MinScale3.Enabled = true;
                textBox_MaxScale3.Enabled = true;
            }
        }

        //================================================================================
        // スケール変換のコンボボックスの値を変更した際の処理になります
        // 設定値の確認し、スケール設定の有効無効を変更します
        //================================================================================
        private void comboBox_ScaleEnable4_SelectedIndexChanged(object sender, EventArgs e)
        {
            int scale_enable;   // スケール変換の格納用

            //----------------------------------------
            // スケール変換の取得
            //----------------------------------------
            scale_enable = comboBox_ScaleEnable4.SelectedIndex;
            if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_DISABLE)
            {
                //----------------------------------------
                // 無効
                //----------------------------------------
                textBox_MinData4.Enabled = false;
                textBox_MaxData4.Enabled = false;
                textBox_MinScale4.Enabled = false;
                textBox_MaxScale4.Enabled = false;
            }
            else if (scale_enable == (int)CLoggerConst.LOGGER_PARAM_ENABLE)
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData4.Enabled = true;
                textBox_MaxData4.Enabled = true;
                textBox_MinScale4.Enabled = true;
                textBox_MaxScale4.Enabled = true;
            }
            else
            {
                //----------------------------------------
                // 有効
                //----------------------------------------
                textBox_MinData4.Enabled = true;
                textBox_MaxData4.Enabled = true;
                textBox_MinScale4.Enabled = true;
                textBox_MaxScale4.Enabled = true;
            }
        }
    }
}
