private void button2_Click(object sender, EventArgs e)
 {
     if (Side_Surrounding.Text != string.Empty && Side_Crash.Text != string.Empty && Side_Window.Text != string.Empty && Side_Thickslice.Text != string.Empty &&
         Side_Copper.Text != string.Empty && Side_Glueline.Text != string.Empty && Side_Glueloss.Text != string.Empty && Side_Iron.Text != string.Empty &&
         Edge_Surrounding.Text != string.Empty && Edge_Crash.Text != string.Empty && Edge_Copper.Text != string.Empty)
     {
         SaveFileDialog saveFileDialog1 = new SaveFileDialog();
         string         path            = System.IO.Directory.GetCurrentDirectory() + @"\標準參數\";
         saveFileDialog1.InitialDirectory = path;
         saveFileDialog1.Filter           = "晟格設定檔(.cn)|*.cn";
         saveFileDialog1.Title            = "儲存設定檔";
         saveFileDialog1.ShowDialog();
         if (saveFileDialog1.FileName != "")
         {
             SetupIniIP.IniWriteValue("Side", "Surrounding", Side_Surrounding.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "Crash", Side_Crash.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "Window", Side_Window.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "ThickSlice", Side_Thickslice.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "Copper", Side_Copper.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "GlueLine", Side_Glueline.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "GlueLoss", Side_Glueloss.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Side", "Iron", Side_Iron.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Edge", "Surrounding", Edge_Surrounding.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Edge", "Crash", Edge_Crash.Text, saveFileDialog1.FileName);
             SetupIniIP.IniWriteValue("Edge", "Copper", Edge_Copper.Text, saveFileDialog1.FileName);
         }
     }
     else
     {
         MessageBox.Show("標準不能為空");
     }
 }
        private void button4_Click(object sender, EventArgs e)
        {
            if (Side_Surrounding.Text != string.Empty && Side_Crash.Text != string.Empty && Side_Window.Text != string.Empty && Side_Thickslice.Text != string.Empty &&
                Side_Copper.Text != string.Empty && Side_Glueline.Text != string.Empty && Side_Glueloss.Text != string.Empty && Side_Iron.Text != string.Empty &&
                Edge_Surrounding.Text != string.Empty && Edge_Crash.Text != string.Empty && Edge_Copper.Text != string.Empty)
            {
                string FileName = System.IO.Directory.GetCurrentDirectory() + @"\標準參數\OriginSetting.default";

                SetupIniIP.IniWriteValue("Side", "Surrounding", Side_Surrounding.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "Crash", Side_Crash.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "Window", Side_Window.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "ThickSlice", Side_Thickslice.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "Copper", Side_Copper.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "GlueLine", Side_Glueline.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "GlueLoss", Side_Glueloss.Text, FileName);
                SetupIniIP.IniWriteValue("Side", "Iron", Side_Iron.Text, FileName);
                SetupIniIP.IniWriteValue("Edge", "Surrounding", Edge_Surrounding.Text, FileName);
                SetupIniIP.IniWriteValue("Edge", "Crash", Edge_Crash.Text, FileName);
                SetupIniIP.IniWriteValue("Edge", "Copper", Edge_Copper.Text, FileName);
            }
            else
            {
                MessageBox.Show("標準不能為空");
            }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            SetupIniIP iniIp = new SetupIniIP();

            string filePath = "test1.ini";

            //iniIp.IniWriteValue("SEC1", "KEY", "1", filePath);
            inivalue.Text = iniIp.IniReadValue("section1", "key", filePath);
        }
        private void DefectSettings_Load(object sender, EventArgs e)
        {
            GapAreaTextBox.Text       = SetupIniIP.IniReadValue("Gap", "Area", CherngerUI.app.DefectSettingpath);
            GapDeepTextBox.Text       = SetupIniIP.IniReadValue("Gap", "Deep", CherngerUI.app.DefectSettingpath);
            CrackAreaTextBox.Text     = SetupIniIP.IniReadValue("Crack", "Area", CherngerUI.app.DefectSettingpath);
            CrackLengthTextBox.Text   = SetupIniIP.IniReadValue("Crack", "Length", CherngerUI.app.DefectSettingpath);
            CatchUpAreaTextBox.Text   = SetupIniIP.IniReadValue("CatchUp", "Area", CherngerUI.app.DefectSettingpath);
            CatchUpLengthTextBox.Text = SetupIniIP.IniReadValue("CatchUp", "Length", CherngerUI.app.DefectSettingpath);
            ODLowerBoundTextBox.Text  = SetupIniIP.IniReadValue("OD", "LowerBound", CherngerUI.app.DefectSettingpath);
            ODStandardTextBox.Text    = SetupIniIP.IniReadValue("OD", "Standard", CherngerUI.app.DefectSettingpath);
            ODUpperBoundTextBox.Text  = SetupIniIP.IniReadValue("OD", "UpperBound", CherngerUI.app.DefectSettingpath);
            IDLowerBoundTextBox.Text  = SetupIniIP.IniReadValue("ID", "LowerBound", CherngerUI.app.DefectSettingpath);
            IDStandardTextBox.Text    = SetupIniIP.IniReadValue("ID", "Standard", CherngerUI.app.DefectSettingpath);
            IDUpperBoundTextBox.Text  = SetupIniIP.IniReadValue("ID", "UpperBound", CherngerUI.app.DefectSettingpath);

            double.TryParse(GapAreaTextBox.Text, out CherngerUI.Value.GapArea);
            double.TryParse(GapDeepTextBox.Text, out CherngerUI.Value.GapDeep);

            double.TryParse(CrackAreaTextBox.Text, out CherngerUI.Value.CrackArea);
            double.TryParse(CrackLengthTextBox.Text, out CherngerUI.Value.CrackLength);

            double.TryParse(CatchUpAreaTextBox.Text, out CherngerUI.Value.CatchUpArea);
            double.TryParse(CatchUpLengthTextBox.Text, out CherngerUI.Value.CatchUpLength);

            double.TryParse(ODStandardTextBox.Text, out CherngerUI.Value.StandardOD);
            double.TryParse(ODLowerBoundTextBox.Text, out CherngerUI.Value.LowerBoundOD);
            double.TryParse(ODUpperBoundTextBox.Text, out CherngerUI.Value.UpperBoundOD);

            double.TryParse(IDStandardTextBox.Text, out CherngerUI.Value.StandardID);
            double.TryParse(IDLowerBoundTextBox.Text, out CherngerUI.Value.LowerBoundID);
            double.TryParse(IDUpperBoundTextBox.Text, out CherngerUI.Value.UpperBoundID);

            bool.TryParse(SetupIniIP.IniReadValue("Gap", "Inspect", CherngerUI.app.DefectSettingpath), out CherngerUI.Value.GapApply);
            bool.TryParse(SetupIniIP.IniReadValue("Crack", "Inspect", CherngerUI.app.DefectSettingpath), out CherngerUI.Value.CrackApply);
            bool.TryParse(SetupIniIP.IniReadValue("CatchUp", "Inspect", CherngerUI.app.DefectSettingpath), out CherngerUI.Value.CatchApply);
            bool.TryParse(SetupIniIP.IniReadValue("OD", "Inspect", CherngerUI.app.DefectSettingpath), out CherngerUI.Value.ODApply);
            bool.TryParse(SetupIniIP.IniReadValue("ID", "Inspect", CherngerUI.app.DefectSettingpath), out CherngerUI.Value.IDApply);

            GapApplyBtn.Checked     = CherngerUI.Value.GapApply;
            CrackApplyBtn.Checked   = CherngerUI.Value.CrackApply;
            CatchUpApplyBtn.Checked = CherngerUI.Value.CatchApply;
            ODApplyBtn.Checked      = CherngerUI.Value.ODApply;
            IDApplyBtn.Checked      = CherngerUI.Value.IDApply;
        }
        private void save_4_stop_config_Click(object sender, EventArgs e)
        {
            SetupIniIP.IniWriteValue("Stop1", "outer_defect_size_max", Stop1_max_outer_defect.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop1", "outer_defect_size_min", Stop1_min_outer_defect.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop1", "inner_circle_radius", Stop1_ignore_inner_circle.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop1", "inner_defect_size_min", Stop1_min_inner_defect_size.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop1", "arclength_area_ratio", Stop1_arclength_area_ratio.Text, CherngerUI.app.Image_ProcssingDefect_Config);

            SetupIniIP.IniWriteValue("Stop2", "outer_defect_size_max", Stop2_max_outer_defect.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop2", "outer_defect_size_min", Stop2_min_outer_defect.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop2", "inner_circle_radius", Stop2_ignore_inner_circle.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop2", "inner_defect_size_min", Stop2_min_inner_defect_size.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop2", "arclength_area_ratio", Stop2_arclength_area_ratio.Text, CherngerUI.app.Image_ProcssingDefect_Config);

            SetupIniIP.IniWriteValue("Stop3", "threshold_1phase", Stop3_threshold_1phase.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop3", "threshold_2phase_1", Stop3_threshold_2phase_1.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop3", "threshold_2phase_2", Stop3_threshold_2phase_2.Text, CherngerUI.app.Image_ProcssingDefect_Config);

            SetupIniIP.IniWriteValue("Stop4", "black_defect_area_min", Stop4_min_area.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop4", "black_defect_area_max", Stop4_max_area.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop4", "arclength_area_ratio", Stop4_arclength_area_ratio.Text, CherngerUI.app.Image_ProcssingDefect_Config);
            SetupIniIP.IniWriteValue("Stop4", "ignore_radius", stop4_ignore_radius.Text, CherngerUI.app.Image_ProcssingDefect_Config);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            string         path           = System.IO.Directory.GetCurrentDirectory() + @"\標準參數\";

            openFileDialog.InitialDirectory = path;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Title            = "讀取設定檔";
            openFileDialog.Filter           = "晟格設定檔(.cn)|*.cn";
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFileDialog.FileName != null)
            {
                if (Double.TryParse(SetupIniIP.IniReadValue("Side", "Surrounding", openFileDialog.FileName), out var SIDESURROUNDINGSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Crash", openFileDialog.FileName), out var SIDECRASHSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Window", openFileDialog.FileName), out var SIDEWINDOWSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "ThickSlice", openFileDialog.FileName), out var SIDETHICKSLICESIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Copper", openFileDialog.FileName), out var SIDECOPPERSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "GlueLine", openFileDialog.FileName), out var SIDEGLUELINESIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "GlueLoss", openFileDialog.FileName), out var SIDEGLUELOSSSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Iron", openFileDialog.FileName), out var SIDEIRONSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Surrounding", openFileDialog.FileName), out var EDGESURROUNDINGSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Crash", openFileDialog.FileName), out var EDGECRASHSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Copper", openFileDialog.FileName), out var EDGECOPPERSIZE))
                {
                    Side_Surrounding.Text = SIDESURROUNDINGSIZE.ToString();
                    Side_Crash.Text       = SIDECRASHSIZE.ToString();
                    Side_Window.Text      = SIDEWINDOWSIZE.ToString();
                    Side_Thickslice.Text  = SIDETHICKSLICESIZE.ToString();
                    Side_Copper.Text      = SIDECOPPERSIZE.ToString();
                    Side_Glueline.Text    = SIDEGLUELINESIZE.ToString();
                    Side_Glueloss.Text    = SIDEGLUELOSSSIZE.ToString();
                    Side_Iron.Text        = SIDEIRONSIZE.ToString();
                    Edge_Surrounding.Text = EDGESURROUNDINGSIZE.ToString();
                    Edge_Crash.Text       = EDGECRASHSIZE.ToString();
                    Edge_Copper.Text      = EDGECOPPERSIZE.ToString();
                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            string FileName = System.IO.Directory.GetCurrentDirectory() + @"\標準參數\OriginSetting.default";

            if (System.IO.File.Exists(FileName))
            {
                if (Double.TryParse(SetupIniIP.IniReadValue("Side", "Surrounding", FileName), out var SIDESURROUNDINGSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Crash", FileName), out var SIDECRASHSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Window", FileName), out var SIDEWINDOWSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "ThickSlice", FileName), out var SIDETHICKSLICESIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Copper", FileName), out var SIDECOPPERSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "GlueLine", FileName), out var SIDEGLUELINESIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "GlueLoss", FileName), out var SIDEGLUELOSSSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Side", "Iron", FileName), out var SIDEIRONSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Surrounding", FileName), out var EDGESURROUNDINGSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Crash", FileName), out var EDGECRASHSIZE) &&
                    Double.TryParse(SetupIniIP.IniReadValue("Edge", "Copper", FileName), out var EDGECOPPERSIZE))
                {
                    Side_Surrounding.Text = SIDESURROUNDINGSIZE.ToString();
                    Side_Crash.Text       = SIDECRASHSIZE.ToString();
                    Side_Window.Text      = SIDEWINDOWSIZE.ToString();
                    Side_Thickslice.Text  = SIDETHICKSLICESIZE.ToString();
                    Side_Copper.Text      = SIDECOPPERSIZE.ToString();
                    Side_Glueline.Text    = SIDEGLUELINESIZE.ToString();
                    Side_Glueloss.Text    = SIDEGLUELOSSSIZE.ToString();
                    Side_Iron.Text        = SIDEIRONSIZE.ToString();
                    Edge_Surrounding.Text = EDGESURROUNDINGSIZE.ToString();
                    Edge_Crash.Text       = EDGECRASHSIZE.ToString();
                    Edge_Copper.Text      = EDGECOPPERSIZE.ToString();
                }
            }
            else
            {
                MessageBox.Show("預設檔案遺失,請重新設定預設檔案");
            }
        }
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            SetupIniIP.IniWriteValue("Gap", "Area", GapAreaTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("Gap", "Deep", GapDeepTextBox.Text, CherngerUI.app.DefectSettingpath);
            double.TryParse(GapAreaTextBox.Text, out CherngerUI.Value.GapArea);
            double.TryParse(GapDeepTextBox.Text, out CherngerUI.Value.GapDeep);

            SetupIniIP.IniWriteValue("Crack", "Area", CrackAreaTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("Crack", "Length", CrackLengthTextBox.Text, CherngerUI.app.DefectSettingpath);
            double.TryParse(CrackAreaTextBox.Text, out CherngerUI.Value.CrackArea);
            double.TryParse(CrackLengthTextBox.Text, out CherngerUI.Value.CrackLength);

            SetupIniIP.IniWriteValue("CatchUp", "Area", CatchUpAreaTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("CatchUp", "Length", CatchUpLengthTextBox.Text, CherngerUI.app.DefectSettingpath);
            double.TryParse(CatchUpAreaTextBox.Text, out CherngerUI.Value.CatchUpArea);
            double.TryParse(CatchUpLengthTextBox.Text, out CherngerUI.Value.CatchUpLength);

            SetupIniIP.IniWriteValue("OD", "Standard", ODStandardTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("OD", "LowerBound", ODLowerBoundTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("OD", "UpperBound", ODUpperBoundTextBox.Text, CherngerUI.app.DefectSettingpath);
            double.TryParse(ODStandardTextBox.Text, out CherngerUI.Value.StandardOD);
            double.TryParse(ODLowerBoundTextBox.Text, out CherngerUI.Value.LowerBoundOD);
            double.TryParse(ODUpperBoundTextBox.Text, out CherngerUI.Value.UpperBoundOD);

            SetupIniIP.IniWriteValue("ID", "Standard", IDStandardTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("ID", "LowerBound", IDLowerBoundTextBox.Text, CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("ID", "UpperBound", IDUpperBoundTextBox.Text, CherngerUI.app.DefectSettingpath);
            double.TryParse(IDStandardTextBox.Text, out CherngerUI.Value.StandardID);
            double.TryParse(IDLowerBoundTextBox.Text, out CherngerUI.Value.LowerBoundID);
            double.TryParse(IDUpperBoundTextBox.Text, out CherngerUI.Value.UpperBoundID);

            SetupIniIP.IniWriteValue("Gap", "Inspect", GapApplyBtn.Checked.ToString(), CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("Crack", "Inspect", CrackApplyBtn.Checked.ToString(), CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("CatchUp", "Inspect", CatchUpApplyBtn.Checked.ToString(), CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("OD", "Inspect", ODApplyBtn.Checked.ToString(), CherngerUI.app.DefectSettingpath);
            SetupIniIP.IniWriteValue("ID", "Inspect", IDApplyBtn.Checked.ToString(), CherngerUI.app.DefectSettingpath);

            CherngerUI.Value.GapApply   = GapApplyBtn.Checked;
            CherngerUI.Value.CrackApply = CrackApplyBtn.Checked;
            CherngerUI.Value.CatchApply = CatchUpApplyBtn.Checked;
            CherngerUI.Value.ODApply    = ODApplyBtn.Checked;
            CherngerUI.Value.IDApply    = IDApplyBtn.Checked;

            CherngerUI.DefectValue.GapArea       = CherngerUI.Value.GapArea;                  //缺角面積
            CherngerUI.DefectValue.GapDeep       = CherngerUI.Value.GapDeep;                  //缺角深度
            CherngerUI.DefectValue.CrackArea     = CherngerUI.Value.CrackArea;                //微裂面積
            CherngerUI.DefectValue.CrackLength   = CherngerUI.Value.CrackLength;              //微裂長度
            CherngerUI.DefectValue.CatchUpArea   = CherngerUI.Value.CatchUpArea;              //髒污面積
            CherngerUI.DefectValue.CatchUpLength = CherngerUI.Value.CatchUpLength;            //髒污長度

            CherngerUI.DefectValue.StandardOD   = CherngerUI.Value.StandardOD;                //外徑標準值
            CherngerUI.DefectValue.LowerBoundOD = CherngerUI.Value.LowerBoundOD;              //外徑下界
            CherngerUI.DefectValue.UpperBoundOD = CherngerUI.Value.UpperBoundOD;              //外徑上界

            CherngerUI.DefectValue.StandardID   = CherngerUI.Value.StandardID;                //內徑標準值
            CherngerUI.DefectValue.LowerBoundID = CherngerUI.Value.LowerBoundID;              //內徑下界
            CherngerUI.DefectValue.UpperBoundID = CherngerUI.Value.UpperBoundID;              //內徑上界

            CherngerUI.DefectValue.IDRatio = CherngerUI.Value.IDRatio;                        //內徑轉換比
            CherngerUI.DefectValue.ODRatio = CherngerUI.Value.ODRatio;                        //外徑轉換比

            CherngerUI.DefectValue.GapApply   = CherngerUI.Value.GapApply;                    //缺角套用檢測
            CherngerUI.DefectValue.CatchApply = CherngerUI.Value.CatchApply;                  //髒污套用檢測
            CherngerUI.DefectValue.CrackApply = CherngerUI.Value.CrackApply;                  //微裂套用檢測
            CherngerUI.DefectValue.ODApply    = CherngerUI.Value.ODApply;                     //外徑套用檢測
            CherngerUI.DefectValue.IDApply    = CherngerUI.Value.IDApply;                     //內徑套用檢測

            BeginInvoke(new Action(() => MessageBox.Show("儲存完成", "System", MessageBoxButtons.OK, MessageBoxIcon.Information)));
        }