public static CtrlMain GetInstance() { if (ctrlMain == null) { ctrlMain = new CtrlMain(); } return(ctrlMain); }
/// <summary> /// Initialise une nouvelle Instance du form CollaborateurListForm /// S'abonne aux événements FormClosing, CreatingCollabo and SelectingCollabo /// Affiche le form /// </summary> private void Init() { collaborateurListForm = new CollaborateurListForm(collaborateurList); collaborateurListForm.FormClosing += new FormClosingEventHandler(this.OnClosedForm); collaborateurListForm.CreatingCollabo += new EventHandler(this.OnCreatedCollabo); collaborateurListForm.SelectingCollabo += new SelectingHandler(this.OnSelectedCollabo); collaborateurListForm.MdiParent = CtrlMain.GetInstance().GetMainApp(); collaborateurListForm.Show(); }
/// <summary> /// Constructor /// Takes a collaborateur as argument /// initialize a new instanciate of the class CollaborateurForm /// Listen to the event EditingCollabo and FormClosing of the collaborateurForm /// instanciate the CtrlListContrat /// </summary> /// <param name="collaborateur"></param> public CtrlDetailCollaborateur(Collaborateur collaborateur) { this.collaborateur = collaborateur; if (!openedFormList.ContainsKey(collaborateur.Id)) { collaborateurForm = new CollaborateurForm(false); collaborateurForm.SetCollaborateur(collaborateur); collaborateurForm.EditingCollabo += new CollaboHandler(this.OnEditedCollabo); collaborateurForm.FormClosing += new FormClosingEventHandler(this.OnClosedForm); collaborateurForm.Size = new System.Drawing.Size(950, 530); collaborateurForm.MdiParent = CtrlMain.GetInstance().GetMainApp(); CtrlListContrat clc = new CtrlListContrat(collaborateur); clc.UpdatinCollabo += new CollaboHandler(this.OnUpdatedCollabo); ContratListForm contratListForm = clc.GetContratListForm(); contratListForm.FormBorderStyle = FormBorderStyle.None; contratListForm.TopLevel = false; contratListForm.AutoScroll = true; contratListForm.Show(); collaborateurForm.panelContrat.Controls.Add(contratListForm); openedFormList.Add(collaborateur.Id, collaborateurForm); } else { this.collaborateurForm = openedFormList[collaborateur.Id]; if (collaborateurForm.WindowState == FormWindowState.Minimized) { collaborateurForm.WindowState = FormWindowState.Normal; } else { collaborateurForm.Activate(); } } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(CtrlMain.GetInstance().GetMainApp()); }
/// <summary> /// Method called when the event FormClosing is called /// set the collaborateurListForm to null /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnClosedForm(object sender, FormClosingEventArgs e) { collaborateurListForm = null; CtrlMain.GetInstance().CloseCtrlListCollaborateur();; }