private void PhotosFormButtonLoader_Click(object sender, EventArgs e) { string buttonClickedName = (sender as Button).Name; CurrentAlbum = albumBindingSource.Current as Album; Form subForm = SubFormFactory.CreateSubForm(buttonClickedName, m_LoggedInUser, CurrentAlbum, MainFormRef); subForm.ShowDialog(); }
private void SidePannelButton_Click(object sender, EventArgs e) { const string k_ErrorMessage = "You're Not Logged In!"; Form subForm = null; if (IsLoggedIn) { string buttonClickedName = (sender as Button).Name; string classTypeStringBefore = buttonClickedName.Split(new[] { "button" }, StringSplitOptions.None)[1]; //string classTypeStringAfter = string.Format("{0}{1}", // classTypeStringBefore.Substring(0, 1).ToUpper(), // classTypeStringBefore.Substring(1)); Type formType = typeof(AppMainForm); try { formType = Type.GetType(string.Format("{0}.{1}", formType.Namespace, classTypeStringBefore)); subForm = FormsRepository.Instance.GetReference(formType); } catch (KeyNotFoundException) { subForm = SubFormFactory.CreateSubForm(buttonClickedName, LoggedInUser, null, this); FormsRepository.Instance.AddPrototype(subForm, formType); } finally { this.labelFormDescription.Text = string.Format("{0}'s {1}", LoggedInUser.Name, (sender as Button).Text.Trim()); contextPannelHandler(subForm); } } else { if (TextToSpeachStatus) { AnnouncerObject.MessageAnnouncement(k_ErrorMessage); } MessageBox.Show(k_ErrorMessage); } }