/// <summary>
 /// 單一實體
 /// </summary>
 /// <returns>返來實體</returns>
 public static Basic_HTB_Info GetInstance()
 {
     if (instance == null)
     {
         instance = new Basic_HTB_Info();
         instanceCNT++;
     }
     return instance;
 }
        public FormTimeTableMDI()
        {
            InitializeComponent();
            htbs = Basic_HTB_Info.GetInstance();
            htbs.log("½Ð¡yÀɮסz:¡y¸ü¤J¤W¦¸¦sÀÉ ¡z¡C");
            MsgBox msb = new MsgBox(Basic_HTB_Info.GetInstance().logToArray());
            msb.MdiParent = this;
            msb.Show();

            MainMenu fmainMenu = new MainMenu();
            MenuItem initdata_msys = fmainMenu.MenuItems.Add("A.ªì©l¤Æ¸ê®Æ");
   
            initdata_msys.MenuItems.Add(new MenuItem("Teacher.dat", (sender, e) =>
            {
                Process notePad = new Process();
                notePad.StartInfo.FileName = "notepad.exe";
                String path_ = Basic_HTB_Info.baseFilePath + @"\BasicInfo\Teacher.dat";
                notePad.StartInfo.Arguments = path_;
                notePad.Start();
            }));
            initdata_msys.MenuItems.Add(new MenuItem("Subject.dat", (sender, e) =>
            {
                Process notePad = new Process();
                notePad.StartInfo.FileName = "notepad.exe";
                String path_ = Basic_HTB_Info.baseFilePath + @"\BasicInfo\Subject.dat";
                notePad.StartInfo.Arguments = path_;
                notePad.Start();
            }));
            initdata_msys.MenuItems.Add(new MenuItem("Class.dat", (sender, e) =>
            {
                Process notePad = new Process();
                notePad.StartInfo.FileName = "notepad.exe";
                String path_ = Basic_HTB_Info.baseFilePath + @"\BasicInfo\Class.dat";
                notePad.StartInfo.Arguments = path_;
                notePad.Start();
            }));

            initdata_msys.MenuItems.Add(new MenuItem("ClassMaster.dat", (sender, e) =>
            {
                Process notePad = new Process();
                notePad.StartInfo.FileName = "notepad.exe";
                String path_ = Basic_HTB_Info.baseFilePath + @"\BasicInfo\ClassMaster.dat";
                notePad.StartInfo.Arguments = path_;
                notePad.Start();
            }));
            initdata_msys.MenuItems.Add("¥H¤W¥\¯à»Ý­n­«±Òµ{¦¡");
            initdata_msys.MenuItems.Add("-");


            initdata_msys.MenuItems.Add(new MenuItem("A4.½Òµ{¤À°tªí®æ_¶×¥X¡y³Ì¤p¥ô½Ò³æ¦ì Def Unit->file¡zCourse Assig Grid", (sender, e) =>
            {
                FormCourseAssignGrid fcg = new FormCourseAssignGrid(new C_FormCourseAssignGridForSubjectUnit());
                fcg.ShowDialog();
            }));
            initdata_msys.MenuItems.Add(new MenuItem("A5.±Ð®v¥ð®§ªí_Teacher_Week_Take_Rest_Grid", (sender, e) =>
            {
                FormCourseAssignGrid fcg = new FormCourseAssignGrid(new C_FormCourseAssignGridForTeacherRest());
                fcg.ShowDialog();
            }));

            initdata_msys.MenuItems.Add("-");
            initdata_msys.MenuItems.Add(new MenuItem("A6.¦Û°Ê¤À°t½Òªíµ¦²¤", (sender, e) =>
            {
                FormAssgControl fac = new FormAssgControl();
                fac.ShowDialog();
            }));
            
            


            MenuItem msys = fmainMenu.MenuItems.Add("B.ÀÉ®×");


            msys.MenuItems.Add(new MenuItem("B1.¸ü¤J¤W½Ò³æ¦ìªí_Load Lesson Unit", this.menuLoadLessonUnitItem_click));
            msys.MenuItems.Add(new MenuItem("B2.¸ü¤J±Ð®v¥ð®§ªíLoad Teacher Rest TimeTable", this.menuLoadTeacherRestimeTableItem_click));
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("B3.À˵ø¤À°t½Òµ{¤jªíAssig Subject Grid TimeTable", this.menuAssigSubjectGrid));
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("B4.¸ü¤J¤W¦¸¦sÀÉ Load old TimeTable", this.menuLoadOldTimeTableItem_click));
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("B5.¦sÀÉ",(sender, e)=>{  SaveTiemTableGridOut();        } ));
            

            MenuItem subj_With = fmainMenu.MenuItems.Add("C ¤À°t¦Cªí");
            MenuItem subj_With_Class = subj_With.MenuItems.Add("C1.«ö¯Z");
            MenuItem subj_With_Teacher = subj_With.MenuItems.Add("C2.«ö±Ð®v");

            msys = fmainMenu.MenuItems.Add("D.¤À°t¯Zªí");
            
            for (int i = 1; i <= htbs.htbIDClass.Count; i++)
            {
                msys.MenuItems.Add(new MenuItem(string.Format("{0}.{1}", i, htbs.htbIDClass[i]), this.menuClassNoItem_click));
                subj_With_Class.MenuItems.Add(new MenuItem(string.Format("{0}.{1} Subject_List", i, htbs.htbIDClass[i]), this.menuFormClassNoTimeTableDoubleClick));
            }
            msys.MenuItems.Add("All", this.menuAllClassNoItem_Click);
            msys = fmainMenu.MenuItems.Add("E.±Ð®vªí");
            
            msys.MenuItems.Add(new MenuItem("±Ð®v", (sender, e) =>{
                TeachernoInput ti = new TeachernoInput("Teacher Name:");
                if (ti.ShowDialog() == DialogResult.OK )
                {
                    String[] stra = ti.out_res.Split(',');
                    foreach (String s in stra)
                    {
                        if (Basic_HTB_Info.GetInstance().htbTeacherID.ContainsKey(s))
                        {
                            int akey = int.Parse(Basic_HTB_Info.GetInstance().htbTeacherID[s].ToString());
                            
                            FormClassNoTimeTableDoubleClick_Action aTT = new FormClassNoTimeTableDoubleClick_Action(""+akey+"."+s, new C_FormClassNoTimeTableDoubleClick_Teacher(akey));
                            aTT.MdiParent = this;
                            aTT.updateList();
                            aTT.button_ADD.Enabled = false;
                            aTT.Show();
                        }
                    }
                }
            }));
            for (int i = 1; i <= htbs.htbIDTeacher.Count; i++)
            {
                msys.MenuItems.Add(new MenuItem(string.Format("{0}.{1}", i, htbs.htbIDTeacher[i]), this.menuTeacherNoItem_click));
                subj_With_Teacher.MenuItems.Add(new MenuItem(string.Format("{0}.{1} Subject_List", i, htbs.htbIDTeacher[i]), this.menuFormClassNoTimeTableDoubleClick_Teacher));
            }
           
            msys = fmainMenu.MenuItems.Add("F.³øªí");
            msys.MenuItems.Add("F1.±Ð®v½Òµ{¦w±ÆReport Teacher TimeTable", mnuReport_Teacher_TimeTable);
            msys.MenuItems.Add("F2.¯Z¯Å½Òµ{¦w±ÆReport Class TimeTable", mnuReport_Class_TimeTable);
            msys.MenuItems.Add("-");
            msys.MenuItems.Add("F3.½Òµ{¦w±ÆReport ClassSubjectTeacherCrosorTable", mnuReport_Cross_Table);
            msys.MenuItems.Add("F4.½Òµ{©P¸`¦w±ÆReport ClassSubjectWeekLessonCrosorTable", mnuReport_Cross_Week_Table);
            msys.MenuItems.Add("-");
            msys.MenuItems.Add("F5.©P/¸`/(¯Z¯Å¬Y½Òµ{)Report Class TimeTable", mnuReport_WeekDay_Course_TimeTable);
            msys.MenuItems.Add("-");
            msys.MenuItems.Add("F6.¤W¶Ç³ø¦Ü¦øªA¾¹", mnuReport_UploadTo250);

            
            
            msys = fmainMenu.MenuItems.Add("G.µ¡¤f");
            msys.MenuItems.Add("G1 ¦P¨BDATA", mnuSynFormData_click);
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("±Æ¦C¹Ï¼Ð", this.mnuIcons_click));
            msys.MenuItems.Add(new MenuItem("¼h¼hÅ|Å|", this.mnuCascade_click));
            msys.MenuItems.Add(new MenuItem("¤ô¥­¾Q¥­", this.mnuTileHorizontal_click));
            msys.MenuItems.Add(new MenuItem("««ª½¾Q¥­", this.mnuTileVertical_click));
            msys.MenuItems.Add(new MenuItem("Ãö³¬©Ò¦³¤lµ¡¤f", this.CloseAllSubForm_click));
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("¦rÅé¤@", (sender, e) => { adjustFont(16f); }));
            msys.MenuItems.Add(new MenuItem("¦rÅé¤G", (sender, e) => { adjustFont(12f); }));
            msys.MenuItems.Add(new MenuItem("¦rÅé¤T", (sender, e) => { adjustFont(8f); }));
            msys.MenuItems.Add(new MenuItem("¦rÅé¥|", (sender, e) => { adjustFont(7f); }));
            msys.MenuItems.Add(new MenuItem("¦rÅé¤j¤p", this.mnuFontNum_click));

            msys = fmainMenu.MenuItems.Add("H.¸ê°T");
            msys.MenuItems.Add("Ū§Ú", mnuReadMe);
            msys.MenuItems.Add("À˵øLast Errors", mnuLastError);
            msys.MenuItems.Add("²M°£Clear Erros List", mnuClrError);
            msys.MenuItems.Add("-");
            msys.MenuItems.Add(new MenuItem("­«¸m¦r¨åªí Clear HTBS", this.menuClearHtbs));

            this.Menu = fmainMenu;
            this.FormClosing += (sender, e) => { SaveTiemTableGridOut(); };
        }