コード例 #1
0
        public static void Read_All_Data(object frm, string User_Input_Data, bool IsFile)
        {
            //string User_Input_Data = Path.Combine(folder_path, "ASTRA_Data_Input.txt");

            string data_file = User_Input_Data;

            if (!File.Exists(data_file))
            {
                return;
            }


            List <string> file_content = new List <string>(File.ReadAllLines(data_file));

            bool IsRun_ProgressBar = file_content.Count > 9999;



            MyStrings mlist = null;
            string    kStr  = "";


            Save_FormRecord rec = new Save_FormRecord();

            rec.Clear();
            rec.AddControls(frm);
            if (IsRun_ProgressBar)
            {
                //    if (iApp != null)
                //        iApp.Progress_ON("Reading Previous Data...");
            }
            for (int i = 0; i < file_content.Count; i++)
            {
                try
                {
                    kStr = MyStrings.RemoveAllSpaces(file_content[i].Trim());
                    if (i == 0)
                    {
                        mlist = new MyStrings(kStr, ':');

                        if (mlist.Count == 3)
                        {
                            //if (mlist[2].Trim() == eDesignStandard.IndianStandard.ToString())
                            //{
                            //    iApp.DesignStandard = eDesignStandard.IndianStandard;
                            //    iApp.LiveLoads = new LiveLoadCollections(iApp.LL_TXT_Path);
                            //}
                            //if (mlist[2].Trim() == eDesignStandard.BritishStandard.ToString())
                            //{
                            //    iApp.DesignStandard = eDesignStandard.BritishStandard;
                            //    iApp.LiveLoads = new LiveLoadCollections(iApp.LL_TXT_Path);
                            //}
                            continue;
                        }
                    }

                    mlist = new MyStrings(kStr, '=');
                    if (kStr.Contains("---"))
                    {
                        continue;
                    }
                    //if (i >= 163)
                    //    mlist = new MyStrings(kStr, '=');

                    if (mlist.Count == 2)
                    {
                        try
                        {
                            Control c = rec.Controls[mlist.StringList[0]] as Control;
                            if (c != null)
                            {
                                //if (c.Name.StartsWith("txt"))
                                //    c.Text = mlist.StringList[1];
                                if (c.Name.StartsWith("cmb"))
                                {
                                    ComboBox cmb = (c as ComboBox);

                                    int row = mlist.GetInt(1);
                                    cmb.Items.Clear();
                                    string sel_text = "";
                                    for (int j = 0; j < row; j++)
                                    {
                                        i++;
                                        if (j == 0)
                                        {
                                            sel_text = file_content[i];
                                            i++;
                                        }
                                        cmb.Items.Add(file_content[i]);
                                    }
                                    //cmb.SelectedItem = mlist.StringList[1];
                                    cmb.SelectedIndex = MyStrings.StringToInt(sel_text, -1);
                                }
                                else if (c.Name.StartsWith("dgv"))
                                {
                                    DataGridView dgv = c as DataGridView;
                                    int          row = mlist.GetInt(1);
                                    dgv.Rows.Clear();
                                    for (int j = 0; j < row; j++)
                                    {
                                        i++;
                                        kStr  = MyStrings.RemoveAllSpaces(file_content[i].Trim());
                                        mlist = new MyStrings(kStr, '$');
                                        dgv.Rows.Add(mlist.StringList.ToArray());


                                        //kStr = dgv[2, dgv.Rows.Count - 1].Value.ToString(); ;
                                    }
                                }
                                else if (c.Name.StartsWith("txt"))
                                {
                                    TextBox txt = c as TextBox;
                                    int     row = mlist.GetInt(1);
                                    txt.Text = "";
                                    List <string> ln = new List <string>();

                                    for (int j = 0; j < row; j++)
                                    {
                                        i++;
                                        ln.Add(file_content[i]);
                                    }
                                    txt.Lines = ln.ToArray();
                                }
                                else if (c.Name.StartsWith("rtb"))
                                {
                                    RichTextBox txt = c as RichTextBox;
                                    int         row = mlist.GetInt(1);
                                    txt.Text = "";
                                    List <string> ln = new List <string>();

                                    for (int j = 0; j < row; j++)
                                    {
                                        i++;
                                        ln.Add(file_content[i]);
                                    }
                                    txt.Lines = ln.ToArray();
                                }
                                else if (c.Name.StartsWith("rbtn"))
                                {
                                    //ComboBox cmb = (c as ComboBox);
                                    (c as RadioButton).Checked = mlist.StringList[1] == "true";
                                }
                                else if (c.Name.StartsWith("chk"))
                                {
                                    //ComboBox cmb = (c as ComboBox);
                                    (c as CheckBox).Checked = mlist.StringList[1] == "true";
                                }
                            }
                        }
                        catch (Exception ex) { }
                    }
                    if (IsRun_ProgressBar)
                    {
                        //if (iApp != null)
                        //{
                        //    iApp.SetProgressValue(i, file_content.Count);
                        //    //Chiranjit [2013 05 15]
                        //    if (iApp.Is_Progress_Cancel) break;
                        //}
                    }
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("ERROR : " + kStr);
                }
                finally
                {
                    if (IsRun_ProgressBar)
                    {
                        //if (iApp != null) iApp.Progress_OFF();
                    }
                }
            }
        }