using CLoggerCs;

namespace GraphOperation
{
    public partial class Form1 : Form
    {
        //----------------------------------------
        // NXCLoggerCX^X쐬
        //----------------------------------------
        CLogger logger = new CLogger();
        //----------------------------------------
        // O[oϐ̐錾
        //----------------------------------------
        public short g_appid = 0;                             // AvANZXpID

        public Form1()
        {
            InitializeComponent();
        }

        //================================================================================
        // ݒ
        //================================================================================
        private void Form1_Load(object sender, EventArgs e)
        {
            //----------------------------------------
            // EBhETCYR{{bNX̍쐬
            //----------------------------------------
            comboBox_OpenMode.Items.Add("ŏ");
            comboBox_OpenMode.Items.Add("ʏ");
            comboBox_OpenMode.Items.Add("ő剻");
            //----------------------------------------
            // EBhETCYR{{bNX̑I
            //----------------------------------------
            comboBox_OpenMode.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_WINDOW_OFF;
            //----------------------------------------
            // EBhER{{bNX̍쐬
            //----------------------------------------
            comboBox_Operation.Items.Add("VK쐬");
            comboBox_Operation.Items.Add("");
            //----------------------------------------
            // EBhER{{bNX̑I
            //----------------------------------------
            comboBox_Operation.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_GRAPH_OPEN;
            //----------------------------------------
            // EBhEΏۃR{{bNX̍쐬
            //----------------------------------------
            comboBox_Target.Items.Add("t@C + Ot");
            comboBox_Target.Items.Add("Ot");
            //----------------------------------------
            // EBhEΏۃR{{bNX̑I
            //----------------------------------------
            comboBox_Target.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_FILE;
            //----------------------------------------
            // ʃLv` - ۑ͈̓R{{bNX̍쐬
            //----------------------------------------
            comboBox_ImageArea.Items.Add("AvS");
            comboBox_ImageArea.Items.Add("OtEBhÊ");
            //----------------------------------------
            // ʃLv` - ۑ͈̓R{{bNX̑I
            //----------------------------------------
            comboBox_ImageArea.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_AREA_ENTIRE;
            //----------------------------------------
            // OtTCYύX - R{{bNX̍쐬
            //----------------------------------------
            comboBox_ZoomAxis.Items.Add("X");
            comboBox_ZoomAxis.Items.Add("Y");
            //----------------------------------------
            // OtTCYύX - R{{bNX̑I
            //----------------------------------------
            comboBox_ZoomAxis.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_AXIS_X;
            //----------------------------------------
            // OtTCYύX - gkR{{bNX̍쐬
            //----------------------------------------
            comboBox_Zoom.Items.Add("gi2{j");
            comboBox_Zoom.Items.Add("ki1/2{j");
            //----------------------------------------
            // OtTCYύX - gkR{{bNX̑I
            //----------------------------------------
            comboBox_Zoom.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_ZOOM_IN;
            //----------------------------------------
            // Otړ - R{{bNX̍쐬
            //----------------------------------------
            comboBox_MoveAxis.Items.Add("X");
            comboBox_MoveAxis.Items.Add("Y");
            //----------------------------------------
            // Otړ - R{{bNX̑I
            //----------------------------------------
            comboBox_MoveAxis.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_AXIS_X;
            //----------------------------------------
            // Otړ - ړʕ\XV
            //----------------------------------------
            textBox_MoveDistance.Text = "1";
            //----------------------------------------
            // Otړ - ړR{{bNX̍쐬
            //----------------------------------------
            comboBox_MoveDirection.Items.Add("-");
            comboBox_MoveDirection.Items.Add("+");
            //----------------------------------------
            // Otړ - ړR{{bNX̑I
            //----------------------------------------
            comboBox_MoveDirection.SelectedIndex = 0;
            //----------------------------------------
            // `l - V[PXԍR{{bNX̍쐬
            //----------------------------------------
            comboBox_ChannelSequenceNo.Items.Add("0");
            comboBox_ChannelSequenceNo.Items.Add("1");
            comboBox_ChannelSequenceNo.Items.Add("2");
            comboBox_ChannelSequenceNo.Items.Add("3");
            //----------------------------------------
            // `l - V[PXR{{bNXԍ̑I
            //----------------------------------------
            comboBox_ChannelSequenceNo.SelectedIndex = 0;
            //----------------------------------------
            // `l - \R{{bNX̍쐬
            //----------------------------------------
            comboBox_ChannelEnable.Items.Add("");
            comboBox_ChannelEnable.Items.Add("L");
            //----------------------------------------
            // `l - \R{{bNX̑I
            //----------------------------------------
            comboBox_ChannelEnable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - ANeBuR{{bNX̍쐬
            //----------------------------------------
            comboBox_ChannelActivate.Items.Add("");
            comboBox_ChannelActivate.Items.Add("L");
            //----------------------------------------
            // `l - ANeBuR{{bNX̑I
            //----------------------------------------
            comboBox_ChannelActivate.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - hbg\R{{bNX̍쐬
            //----------------------------------------
            comboBox_ChannelDisplayDot.Items.Add("");
            comboBox_ChannelDisplayDot.Items.Add("L");
            //----------------------------------------
            // `l - hbg\R{{bNX̑I
            //----------------------------------------
            comboBox_ChannelDisplayDot.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - ԎރR{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphTimeUnit.Items.Add("Ύ");
            comboBox_GraphTimeUnit.Items.Add("Ύ");
            //----------------------------------------
            // `l - ԎރR{{bNX̑I
            //----------------------------------------
            comboBox_GraphTimeUnit.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_AXISTYPE_ABSOLUTE;
            //----------------------------------------
            // `l - _ȉR{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphDigit.Items.Add("0");
            comboBox_GraphDigit.Items.Add("1");
            comboBox_GraphDigit.Items.Add("2");
            comboBox_GraphDigit.Items.Add("3");
            comboBox_GraphDigit.Items.Add("4");
            comboBox_GraphDigit.Items.Add("5");
            //----------------------------------------
            // `l - _ȉR{{bNX̑I
            //----------------------------------------
            comboBox_GraphDigit.SelectedIndex = 0;
            //----------------------------------------
            // `l - Ot2\R{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphArea2Enable.Items.Add("");
            comboBox_GraphArea2Enable.Items.Add("L");
            //----------------------------------------
            // `l - Ot2\R{{bNX̑I
            //----------------------------------------
            comboBox_GraphArea2Enable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - Yg嗦\R{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphYaxisMagnificationEnable.Items.Add("");
            comboBox_GraphYaxisMagnificationEnable.Items.Add("L");
            //----------------------------------------
            // `l - Yg嗦\R{{bNX̑I
            //----------------------------------------
            comboBox_GraphYaxisMagnificationEnable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - `lCu\R{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphChannelDispEnable.Items.Add("");
            comboBox_GraphChannelDispEnable.Items.Add("L");
            //----------------------------------------
            // `l - `lCu\R{{bNX̑I
            //----------------------------------------
            comboBox_GraphChannelDispEnable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - OtXN[R{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphAutoScrollEnable.Items.Add("");
            comboBox_GraphAutoScrollEnable.Items.Add("L");
            //----------------------------------------
            // `l - OtXN[R{{bNX̑I
            //----------------------------------------
            comboBox_GraphAutoScrollEnable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - Ot^CgR{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphLabelTargetItem.Items.Add("X");
            comboBox_GraphLabelTargetItem.Items.Add("Y");
            comboBox_GraphLabelTargetItem.Items.Add("Ot^Cg");
            //----------------------------------------
            // `l - Ot^CgR{{bNX̑I
            //----------------------------------------
            comboBox_GraphLabelTargetItem.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_AXIS_X;
            //----------------------------------------
            // `l - \R{{bNX̍쐬
            //----------------------------------------
            comboBox_GraphLabelTitleEnable.Items.Add("");
            comboBox_GraphLabelTitleEnable.Items.Add("L");
            //----------------------------------------
            // `l - \R{{bNX̑I
            //----------------------------------------
            comboBox_GraphLabelTitleEnable.SelectedIndex = (ushort)CLoggerConst.LOGGER_PARAM_DISABLE;
            //----------------------------------------
            // `l - Ot^CgXV
            //----------------------------------------
            textBox_GraphLabelTitleText.Text = "Ot^Cg";
            return;
        }

        //================================================================================
        // LoggerOpenApplication{^NbNۂ̏ɂȂ܂
        // AvNAANZX\ɂ܂
        //================================================================================
        private void button_LoggerOpenApplication_Click(object sender, EventArgs e)
        {
            ushort  openmode;        // ʃTCY
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h

            //----------------------------------------
            // R{{bNXʃTCY擾
            //----------------------------------------
            openmode = (ushort)comboBox_OpenMode.SelectedIndex;
            //----------------------------------------
            // Av̏s
            //----------------------------------------
            ret = logger.OpenApplication("", out g_appid, openmode);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerOpenApplication = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerLoadDataFile{^NbNۂ̏ɂȂ܂
        // Wf[^ǂݍ݂܂
        //================================================================================
        private void button_LoggerLoadDataFile_Click(object sender, EventArgs e)
        {
            string  filepath;        // t@CpX
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h

            //----------------------------------------
            // eLXg{bNXۑt@CpX擾
            //----------------------------------------
            filepath = textBox_DataFile.Text;
            //----------------------------------------
            // Wf[^̓ǂݍ
            //----------------------------------------
            ret = logger.LoadDataFile(g_appid, filepath);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerLoadDataFile = {0} : {1} ", ret, error_string);
            return;
        }
        
        //================================================================================
        // ...{^NbNۂ̏ɂȂ܂ 
        // f[^t@CI_CAO\܂
        //================================================================================
        private void button_DataFile_Click(object sender, EventArgs e)
        {
            //----------------------------------------
            // t@C݂邩ǂ`FbNȂ
            //----------------------------------------
            openFileDialog1.CheckFileExists = false;
            //----------------------------------------
            // t@C̃pX݂ꍇ́At@C̃pX_CAȌpXɐݒ肵܂
            //----------------------------------------
            if (textBox_DataFile.Text.Length > 0)
            {
                openFileDialog1.InitialDirectory = textBox_DataFile.Text;
                openFileDialog1.FileName = openFileDialog1.SafeFileName;
            }
            //----------------------------------------
            // t@C̃pX݂Ȃꍇ́AMyDocuments_CAȌpXɐݒ肵܂
            //----------------------------------------
            else
            {
                openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                openFileDialog1.FileName = "";
            }
            //----------------------------------------
            // IpX\
            //----------------------------------------
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox_DataFile.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName);
            }
            return;
        }

        //================================================================================
        // LoggerGraphWindowOperation{^NbNۂ̏ɂȂ܂
        // EBhȆs܂
        //================================================================================
        private void button_LoggerGraphWindowOperation_Click(object sender, EventArgs e)
        {
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h
            ushort  target;          // Ώ
            ushort  operation;       // 

            //----------------------------------------
            // R{{bNXΏۂ擾
            //----------------------------------------
            target = (ushort)comboBox_Target.SelectedIndex;
            //----------------------------------------
            // R{{bNXEBhȆ擾
            //----------------------------------------
            operation = (ushort)comboBox_Operation.SelectedIndex;
            //----------------------------------------
            // EBhȆ
            //----------------------------------------
            ret = logger.GraphWindowOperation(g_appid, operation, target, 0);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerGraphWindowOperation = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerCaptureScreen{^NbNۂ̏ɂȂ܂
        // 摜̕ۑs܂
        //================================================================================
        private void button_LoggerCaptureScreen_Click(object sender, EventArgs e)
        {
            string  filepath;        // t@CpX
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h
            ushort  image_area;

            //----------------------------------------
            // eLXg{bNXۑt@CpX擾
            //----------------------------------------
            filepath = textBox_CaptureFile.Text;
            //----------------------------------------
            // R{{bNXۑ͈͂擾
            //----------------------------------------
            image_area = (ushort)comboBox_ImageArea.SelectedIndex;
            //----------------------------------------
            // 摜̕ۑ
            //----------------------------------------
            ret = logger.CaptureScreen(g_appid, 0, image_area, filepath);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerCaptureScreen = {0} : {1} ", ret, error_string);
            return;
        }
        
        //================================================================================
        // ...{^NbNۂ̏ɂȂ܂ 
        // 摜t@CI_CAO\܂
        //================================================================================
        private void button_CaptureFile_Click(object sender, EventArgs e)
        {
            //----------------------------------------
            // t@C݂邩ǂ`FbNȂ
            //----------------------------------------
            openFileDialog1.CheckFileExists = false;
            //----------------------------------------
            // t@C̃pX݂ꍇ́At@C̃pX_CAȌpXɐݒ肵܂
            //----------------------------------------
            if (textBox_CaptureFile.Text.Length > 0)
            {
                openFileDialog1.InitialDirectory = textBox_CaptureFile.Text;
                openFileDialog1.FileName = openFileDialog1.SafeFileName;
            }
            //----------------------------------------
            // t@C̃pX݂Ȃꍇ́AMyDocuments_CAȌpXɐݒ肵܂
            //----------------------------------------
            else
            {
                openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                openFileDialog1.FileName = "";
            }
            //----------------------------------------
            // IpX\
            //----------------------------------------
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox_CaptureFile.Text = System.IO.Path.GetFullPath(openFileDialog1.FileName);
            }
            return;
        }

        //================================================================================
        // LoggerSetGraphZoom{^NbNۂ̏ɂȂ܂
        // Ot̃Y[s܂
        //================================================================================
        private void button_LoggerSetGraphZoom_Click(object sender, EventArgs e)
        {
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h
            ushort  axis;            // 
            ushort  zoom;            // gk

            //----------------------------------------
            // R{{bNX玲擾
            //----------------------------------------
            axis = (ushort)comboBox_ZoomAxis.SelectedIndex;
            //----------------------------------------
            // R{{bNXgk擾
            //----------------------------------------
            zoom = (ushort)comboBox_Zoom.SelectedIndex;
            //----------------------------------------
            // Ot̃Y[
            //----------------------------------------
            ret = logger.SetGraphZoom(g_appid, 0, axis, zoom);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerSetGraphZoom = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerMoveGraphPos{^NbNۂ̏ɂȂ܂
        // Oẗړs܂
        //================================================================================
        private void button_LoggerMoveGraphPos_Click(object sender, EventArgs e)
        {
            int     ret;            // ߂l擾p
            string  error_string;   // G[R[h
            ushort  axis;           // 
            int     distance;       // ړ
            int     direction;      // ړ
            uint    status;         // Xe[^Xi[p

            //----------------------------------------
            // R{{bNX玲擾
            //----------------------------------------
            axis = (ushort)comboBox_MoveAxis.SelectedIndex;
            //----------------------------------------
            // eLXg{bNXړʂ擾
            //----------------------------------------
            if(int.TryParse(textBox_MoveDistance.Text, out distance) != true)
            {
                textBox_ReturnNum.Text = string.Format("ړʎ擾ُ");
                return;
            }
            //----------------------------------------
            // R{{bNXړ擾
            //----------------------------------------
            direction = (ushort)comboBox_MoveDirection.SelectedIndex;
            //----------------------------------------
            // -̏ꍇAړʂ}CiXlɕϊ
            //----------------------------------------
            if (direction == 0)
            {
                distance = distance * (-1);
            }
            //----------------------------------------
            // Oẗړ
            //----------------------------------------
            ret = logger.MoveGraphPos(g_appid, 0, axis, distance, out status);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerMoveGraphPos = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerSetGraphChannel{^NbNۂ̏ɂȂ܂
        // `l̕\؂ւ܂
        //================================================================================
        private void button_LoggerSetGraphChannel_Click(object sender, EventArgs e)
        {
            int     ret;             // ߂l擾p
            string  error_string;    // G[R[h
            ushort  sequence_no;     // V[PXԍ
            ushort  channel_enable;  // \^\
            ushort  activate;        // ANeBu
            ushort  display_dot;     // hbg\

            //----------------------------------------
            // R{{bNXV[PXԍ擾(index)
            //----------------------------------------
            sequence_no = (ushort)comboBox_ChannelSequenceNo.SelectedIndex;
            //----------------------------------------
            // R{{bNX\擾
            //----------------------------------------
            channel_enable = (ushort)comboBox_ChannelEnable.SelectedIndex;
            //----------------------------------------
            // R{{bNXANeBu擾
            //----------------------------------------
            activate = (ushort)comboBox_ChannelActivate.SelectedIndex;
            //----------------------------------------
            // R{{bNXhbg\擾
            //----------------------------------------
            display_dot = (ushort)comboBox_ChannelDisplayDot.SelectedIndex;
            //----------------------------------------
            // `l̕\؂ւ
            //----------------------------------------
            ret = logger.SetGraphChannel(g_appid, 0, sequence_no, channel_enable, activate, display_dot);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerSetGraphChannel = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerSetGraph{^NbNۂ̏ɂȂ܂
        // OtEBhȄڍׂZbg܂
        //================================================================================
        private void button_LoggerSetGraph_Click(object sender, EventArgs e)
        {
            int     ret;                            // ߂l擾p
            string  error_string;                   // G[R[h
            ushort  time_unit;                      // Ԏނ̊i[p
            ushort  digit;                          // _ȉ̊i[p
            ushort  aria2_enable;                   // Ot2\̊i[p 
            ushort  y_axis_magnification_enable;    // Yg\̊i[p
            ushort  channel_disp_enable;            // `lCu\̊i[p
            ushort  auto_scroll_enable;             // OtXN[̊i[p

            //----------------------------------------
            // R{{bNX玞Ԏނ擾
            //----------------------------------------
            time_unit = (ushort)comboBox_GraphTimeUnit.SelectedIndex;
            //----------------------------------------
            // R{{bNX珬_ȉ擾
            //----------------------------------------
            digit = (ushort)comboBox_GraphDigit.SelectedIndex;
            //----------------------------------------
            // R{{bNXOt2\擾
            //----------------------------------------
            aria2_enable = (ushort)comboBox_GraphArea2Enable.SelectedIndex;
            //----------------------------------------
            // R{{bNXYg\擾
            //----------------------------------------
            y_axis_magnification_enable = (ushort)comboBox_GraphYaxisMagnificationEnable.SelectedIndex;
            //----------------------------------------
            // R{{bNX`lCu\擾
            //----------------------------------------
            channel_disp_enable = (ushort)comboBox_GraphChannelDispEnable.SelectedIndex;
            //----------------------------------------
            // R{{bNXOtXN[擾
            //----------------------------------------
            auto_scroll_enable = (ushort)comboBox_GraphAutoScrollEnable.SelectedIndex;
            //----------------------------------------
            // OtEBhȄڍׂZbg
            //----------------------------------------
            ret = logger.SetGraph(g_appid, 0, time_unit, digit, aria2_enable, y_axis_magnification_enable, channel_disp_enable, auto_scroll_enable);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerSetGraph = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerSetGraphLabelText{^NbNۂ̏ɂȂ܂
        // OtEBhȄڍׂZbg܂
        //================================================================================
        private void button_LoggerSetGraphLabelText_Click(object sender, EventArgs e)
        {
            string  title;          // ^Cg
            int     ret;            // ߂l擾p
            string  error_string;   // G[R[h
            ushort  target_item;    // ^Cg̊i[p
            ushort  title_enable;   // \̊i[p

            //----------------------------------------
            // R{{bNX^Cg擾
            //----------------------------------------
            target_item = (ushort)comboBox_GraphLabelTargetItem.SelectedIndex;
            //----------------------------------------
            // R{{bNX\擾
            //----------------------------------------
            title_enable = (ushort)comboBox_GraphLabelTitleEnable.SelectedIndex;
            //----------------------------------------
            // eLXg{bNX^Cg擾
            //----------------------------------------
            title = textBox_GraphLabelTitleText.Text;
            //----------------------------------------
            // OtEBhEڍׂZbg
            //----------------------------------------
            ret = logger.SetGraphLabelText(g_appid, 0, target_item, title_enable, title);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerSetGraphLabelText = {0} : {1} ", ret, error_string);
            return;
        }

        //================================================================================
        // LoggerCloseApplication{^NbNۂ̏ɂȂ܂
        // Av~AANZXsɂ܂
        //================================================================================
        private void button_LoggerCloseApplication_Click(object sender, EventArgs e)
        {
            uint status = 0;        // Xe[^X
            int ret;                // ߂l擾p
            string error_string;    // G[R[h
            string status_string;   //Xe[^X

            //----------------------------------------
            // Av~AANZXs
            //----------------------------------------
            ret = logger.CloseApplication(g_appid, out status);
            //----------------------------------------
            // G[擾
            //----------------------------------------
            logger.GetErrorString(ret, out error_string);
            //----------------------------------------
            // Xe[^X擾
            //----------------------------------------
            switch (status)
            {
                case (uint)CLoggerConst.LOGGER_STATUS_SUCCESS:
                    status_string = "I";
                    break;
                case (uint)CLoggerConst.LOGGER_STATUS_FAILURE:
                    status_string = "C-LOGGERIG[";
                    break;
                default:
                    status_string = "sȃG[";
                    break;
            }
            //----------------------------------------
            // G[R[h,bZ[W\
            //----------------------------------------
            textBox_ReturnNum.Text = string.Format("LoggerCloseApplication = {0} : {1} \r\nstatus = {2} : {3}", ret, error_string, status, status_string);
            return;
        }

        //================================================================================
        // {^NbNۂ̏ɂȂ܂
        // 
        //================================================================================
        private void button_Close_Click(object sender, EventArgs e)
        {
            uint    status          = 0;      // Xe[^X
            
            //----------------------------------------
            // t@C(C-LOGGERI邱ƂlAʂmFȂ)
            //----------------------------------------
            logger.GraphWindowOperation(g_appid, (ushort)CLoggerConst.LOGGER_PARAM_GRAPH_CLOSE, (ushort)CLoggerConst.LOGGER_PARAM_FILE, 0);
            //----------------------------------------
            // Av~AANZXs
            //----------------------------------------
            logger.CloseApplication(g_appid, out status);
            //----------------------------------------
            // _CAOI
            //----------------------------------------
            this.Close();
        }
    }
}
