示例#1
0
        public void ButtonClicked(object sender, RoutedEventArgs e)
        {
            UTMessageBoxWindow messageWindow = (UTMessageBoxWindow)Window.GetWindow(((FrameworkElement)e.Source));

            System.Windows.Controls.Button clickedButton = (System.Windows.Controls.Button)sender;

            if (clickedButton.Content.ToString() == "OK")
            {
                messageWindow.Result = MessageBoxResult.OK;
            }

            else if (clickedButton.Content.ToString() == "YES")
            {
                messageWindow.Result = MessageBoxResult.Yes;
            }

            else if (clickedButton.Content.ToString() == "NO")
            {
                messageWindow.Result = MessageBoxResult.No;
            }

            else if (clickedButton.Content.ToString() == "CANCEL")
            {
                messageWindow.Result = MessageBoxResult.Cancel;
            }

            else
            {
                messageWindow.Result = MessageBoxResult.None;
            }

            messageWindow.DialogResult = true;
            messageWindow.Close();
        }
示例#2
0
 private void KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == System.Windows.Input.Key.Z || e.Key == System.Windows.Input.Key.Enter)
     {
         UTMessageBoxWindow messageWindow = (UTMessageBoxWindow)Window.GetWindow(((FrameworkElement)e.Source));
         messageWindow.SkipMessage();
     }
 }
示例#3
0
        public static MessageBoxResult Show(string message, MessageBoxButton buttons)
        {
            UTMessageBoxWindow messageBox = new UTMessageBoxWindow(Characters.None, Constants.CharacterReactions.None, message, buttons);

            if (messageBox.ShowDialog() == true)
            {
                messageBox.IsClosing = true;
                return(messageBox.Result);
            }

            else
            {
                messageBox.IsClosing = true;
                return(MessageBoxResult.None);
            }
        }
示例#4
0
        public static MessageBoxResult Show(Characters chara, Constants.CharacterReactions react, string message, MessageBoxButton buttons)
        {
            if (XML.characterMessagesSetting == false)
            {
                chara = Characters.None;
            }

            UTMessageBoxWindow messageBox = new UTMessageBoxWindow(chara, react, message, buttons);

            if (messageBox.ShowDialog() == true)
            {
                messageBox.IsClosing = true;
                return(messageBox.Result);
            }

            else
            {
                messageBox.IsClosing = true;
                return(MessageBoxResult.None);
            }
        }
示例#5
0
        public static MessageBoxResult Show(Dictionary <Characters, string> messages, Constants.CharacterReactions react, MessageBoxButton buttons)
        {
            Characters randChara = MiscFunctions.GetRandomMessageBoxCharacter(new List <Characters>(messages.Keys));

            if (XML.characterMessagesSetting == false)
            {
                randChara = Characters.None;
            }

            UTMessageBoxWindow messageBox = new UTMessageBoxWindow(randChara, react, GetMessageForRandCharacter(randChara, messages), buttons);

            if (messageBox.ShowDialog() == true)
            {
                messageBox.IsClosing = true;
                return(messageBox.Result);
            }

            else
            {
                messageBox.IsClosing = true;
                return(MessageBoxResult.None);
            }
        }
示例#6
0
        public void MessageBoxLoaded(object sender, RoutedEventArgs e)
        {
            UTMessageBoxWindow senderBox = (UTMessageBoxWindow)sender;

            System.Windows.Controls.Button leftButton   = new System.Windows.Controls.Button();
            System.Windows.Controls.Button centreButton = new System.Windows.Controls.Button();
            System.Windows.Controls.Button rightButton  = new System.Windows.Controls.Button();

            leftButton.Click   += new RoutedEventHandler(ButtonClicked);
            centreButton.Click += new RoutedEventHandler(ButtonClicked);
            rightButton.Click  += new RoutedEventHandler(ButtonClicked);

            StackPanel buttonPanel  = (StackPanel)senderBox.Template.FindName("buttonPanel", senderBox);
            TextBlock  messageBlock = (TextBlock)senderBox.Template.FindName("messageBlock", senderBox);

            leftButton.Margin  = new Thickness(0, 0, 10, 0);
            rightButton.Margin = new Thickness(10, 0, 0, 0);

            if (senderBox.Character == Characters.None)
            {
                messageBlock.Margin = new Thickness(-65, 20, 20, 0);
            }

            else if (senderBox.Character == Characters.Papyrus)
            {
                messageBlock.FontFamily = (FontFamily)Application.Current.Resources["FontFamily.papyrusFont.Regular"];
            }

            else if (senderBox.Character == Characters.Sans)
            {
                messageBlock.FontFamily = (FontFamily)Application.Current.Resources["FontFamily.sansFont.Regular"];
            }

            if (senderBox.Buttons == MessageBoxButton.OK)
            {
                centreButton.Content = "OK";
                buttonPanel.Children.Add(centreButton);
            }

            else if (senderBox.Buttons == MessageBoxButton.OKCancel)
            {
                leftButton.Content  = "OK";
                rightButton.Content = "CANCEL";
                buttonPanel.Children.Add(leftButton);
                buttonPanel.Children.Add(rightButton);
            }

            else if (senderBox.Buttons == MessageBoxButton.YesNo)
            {
                leftButton.Content  = "YES";
                rightButton.Content = "NO";
                buttonPanel.Children.Add(leftButton);
                buttonPanel.Children.Add(rightButton);
            }

            else if (senderBox.Buttons == MessageBoxButton.YesNoCancel)
            {
                leftButton.Content   = "YES";
                centreButton.Content = "NO";
                rightButton.Content  = "CANCEL";
                buttonPanel.Children.Add(leftButton);
                buttonPanel.Children.Add(centreButton);
                buttonPanel.Children.Add(rightButton);
            }

            senderBox.BeginCharacterMessageOutput();
        }