コード例 #1
0
        private void initializeMainUIAfterLogin()
        {
            LoggedInUser = UserLoginResult.LoggedInUser;
            //TODO for future: logout also...
            buttonLogin.Invoke(new Action(() => this.buttonLogin.Hide()));
            mainTitleLabel.Invoke(new Action(() => this.mainTitleLabel.Text = string.Format("{0} {1}{2}", "Welcome",
                                                                                            LoggedInUser.FirstName,
                                                                                            Environment.NewLine)));
            mainTitleLabel.Invoke(new Action(() => this.mainTitleLabel.Left -= LoggedInUser.FirstName.Length * 20));
            this.roundedUserPictureBox.LoadAsync(LoggedInUser.PictureNormalURL);

            if (TextToSpeachStatus && !string.IsNullOrEmpty(LoggedInUser.Name))
            {
                AnnouncerObject.MessageAnnouncement(string.Format("Welcome {0}!", LoggedInUser.Name));
            }
        }
コード例 #2
0
        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);
            }
        }