Пример #1
0
        private void CreateUserOnClick(object sender, EventArgs eventArgs)
        {
            String profileName = nameBox.Text;

            string[] profileNames = emoEngine.GetProfileNames();
            if (!profileNames.Contains(profileName))
            {
                Match match = Regex.Match(profileName, @"^([\w ]*)$");
                if (match.Success)
                {
                    emoEngine.CreateProfile(profileName);
                    emoEngine.LoadProfile(profileName);
                    Close();
                }
                else
                {
                    //message box
                    //invalid characters
                    var messageBox = new MessageBox("Invalid Characters", "Special characters are not allowed.");
                    messageBox.Show(Screen);
                }
            }
            else
            {
                var messageBox = new MessageBox("Profile Exists", "This profile already exists.");
                messageBox.Show(Screen);
            }
        }
Пример #2
0
        private void Initialize()
        {
            StackPanel stackPanel = new StackPanel
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Orientation         = Orientation.Vertical,
            };

            Content = stackPanel;

            //create the visuals to load the screen
            var loadPanel = new StackPanel
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Orientation         = Orientation.Horizontal,
                Margin = new Vector4F(5),
            };

            //find way to override update() method
            stackPanel.Children.Add(loadPanel);

            string[] profileNames = emoEngine.GetProfileNames();
            profileList = new DropDownButton
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin            = new Vector4F(3),
                MaxDropDownHeight = 250,
            };
            loadPanel.Children.Add(profileList);

            profileList.SelectedIndex = 0;
            for (int i = 0; i < profileNames.Length; i++)
            {
                profileList.Items.Add(profileNames[i]);
                if (profileNames[i].Length >= profileNames[profileList.SelectedIndex].Length)
                {
                    profileList.SelectedIndex = i;
                }
            }


            var loadButton = new Button
            {
                Name    = "LoadUser",
                Content = new TextBlock {
                    Text = "Load User"
                },
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin             = new Vector4F(3),
                Focusable          = false,
                FocusWhenMouseOver = false,
            };

            loadButton.Click += (s, e) =>
            {
                string profileName = (string)profileList.Items[profileList.SelectedIndex];
                emoEngine.LoadProfile(profileName);
                Close();
            };
            loadPanel.Children.Add(loadButton);

            //create the visual for the option to create new user
            var createPanel = new StackPanel
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Orientation         = Orientation.Horizontal,
                Margin = new Vector4F(5),
            };

            stackPanel.Children.Add(createPanel);

            var createButton = new Button
            {
                Name    = "CreateUser",
                Content = new TextBlock {
                    Text = "New User"
                },
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin             = new Vector4F(3),
                Focusable          = false,
                FocusWhenMouseOver = false,
            };

            createButton.Click += (s, e) =>
            {
                Window createUser = new CreateUser(emoEngine);
                Screen.Children.Add(new CreateUser(emoEngine));
                Close();
            };
            createPanel.Children.Add(createButton);
        }