Skip to content

Instantly share code, notes, and snippets.

@mattiemonster
Last active May 5, 2018 12:11
Show Gist options
  • Save mattiemonster/454d5c86c0e0316131fb193aa312424d to your computer and use it in GitHub Desktop.
Save mattiemonster/454d5c86c0e0316131fb193aa312424d to your computer and use it in GitHub Desktop.
Some code for my wpf test app, uploaded for the sake of testing VS Gist creation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
MessageBoxButton cmbButtonType = MessageBoxButton.OK;
MessageBoxImage cmbImage = MessageBoxImage.None;
public MainWindow()
{
InitializeComponent();
MsgBoxType.SelectedIndex = 0;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
SetCMBValues();
MessageBox.Show(MessageTextInput.Text, MessageTitleInput.Text, cmbButtonType, cmbImage);
if (ClearDataToggle.IsChecked == true)
ResetCMBValues();
}
void SetCMBValues()
{
if (MsgBoxType.SelectedIndex == 0)
{
cmbImage = MessageBoxImage.None;
} else if (MsgBoxType.SelectedIndex == 1)
{
cmbImage = MessageBoxImage.Information;
} else if (MsgBoxType.SelectedIndex == 2)
{
cmbImage = MessageBoxImage.Warning;
} else if (MsgBoxType.SelectedIndex == 3)
{
cmbImage = MessageBoxImage.Error;
}
}
void ResetCMBValues()
{
cmbButtonType = MessageBoxButton.OK;
cmbImage = MessageBoxImage.None;
MessageTextInput.Clear();
MessageTitleInput.Clear();
MsgBoxType.SelectedIndex = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment