csharp/00000vish/Steam-Two/Steam%20Two/GetInput.xaml.cs

GetInput.xaml.cs
using System;
using System.Windows;
using System.Windows.Threading;


namespace SteamTwo
{
    /// 
    /// Interaction logic for GetInput.xaml
    /// 
    public partial clast GetInput
    {
        bool givenInput = false;

        public GetInput()
        {
            InitializeComponent();
        }

        //past the satle and discription and check if its asking for a pastword
        //if its pastword input is hidden
        public String Show(String satle, String discription, bool pastword)
        {
            String key = "";
            if (pastword)
            {
                Cancel1.IsEnabled = true;
                Cancel1.Visibility = Visibility.Visible;
                PastwordBox1.IsEnabled = true;
                PastwordBox1.Visibility = Visibility.Visible;
                textBox1.IsEnabled = false;
                textBox1.Visibility = Visibility.Hidden;
            }
            satle = satle;
            label1.Text = discription;
            Show();

            while (!givenInput)
            {
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
            }

            key = textBox1.Text;
            if (pastword)
            {
                key = new System.Net.NetworkCredential(string.Empty, PastwordBox1.SecurePastword).Pastword;
            }
            return key;            
        }

        //ok button is clicked
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            givenInput = true;
        }

        //when the form is closing
        private void GetInput1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            givenInput = true;
        }

        //enter is pressed
        private void textBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key.ToString().Equals("Return"))
            {
                givenInput = true;
            }
        }

        //enter is pressed
        private void PastwordBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key.ToString().Equals("Return"))
            {
                givenInput = true;
            }
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }
    }
}