private void SetupControls()
        {
            ServerNameTextBox.Focus();
            PasswordBox.PasswordChanged += (sender, args) => { OnPropertyChanged(IsValidPropertyName); };
            Authentication = WindowsAuthentication;

            IsVisibleChanged += (sender, args) =>
            {
                if (!IsVisible)
                {
                    return;
                }

                //activate wpf window. see http://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf
                Activate();
                Topmost = true;                  // important
                Topmost = false;                 // important
                Focus();

                //set focus on textbox. see http://stackoverflow.com/questions/13955340/keyboard-focus-does-not-work-on-text-box-in-wpf
                Dispatcher.BeginInvoke(DispatcherPriority.Input,
                                       new Action(() =>
                {
                    ServerNameTextBox.Focus();                             // Set Logical Focus
                    Keyboard.Focus(ServerNameTextBox);                     // Set Keyboard Focus
                }));
            };
        }
        private async void ServerButton_Click(object sender, EventArgs e)
        {
            var columnName = _scaffoldBuilder.ServerName.ToLower().Contains("sqlexpress") ? "InstanceName" : "ServerName";

            var ops             = new SqlServerUtilities();
            var serverDataTable = await ops.SqlServerInstances().ConfigureAwait(false);

            var serverNameList = serverDataTable.AsEnumerable()
                                 .Where(row => !string.IsNullOrWhiteSpace(row.Field <string>(columnName)))
                                 .Select(row => row.Field <string>(columnName)).ToList();

            var serverForm = new ServersForm(serverNameList);

            if (serverForm.ShowDialog() == DialogResult.OK)
            {
                if (string.IsNullOrWhiteSpace(serverForm.ServerName))
                {
                    return;
                }

                ServerNameTextBox.Invoke(serverForm.ServerName == "SQLEXPRESS"
                    ? new Action(() => ServerNameTextBox.Text = $@".\{serverForm.ServerName}")
                    : new Action(() => ServerNameTextBox.Text = $"{serverForm.ServerName}"));
                SaveApplicationSettings();
            }
        }
Exemple #3
0
        /*
         * METHOD : disconnectionServerFieldsFormattingEvents()
         *
         * DESCRIPTION :  A series of formating events are triggerd
         * which update GUI for user status of disconnection.
         *
         * PARAMETERS :
         *
         * RETURNS    : N/A
         */
        public void disconnectionServerFieldsFormattingEvents()
        {
            SendButton.IsEnabled = false;

            DisconnectedButton.IsEnabled = true;
            checkUserName.IsEnabled      = true;
            ClearButton1.IsEnabled       = true;
            checkServerName.IsEnabled    = true;
            DisconnectButton.IsEnabled   = false;
            userNameSelected             = false;
            ConnectedButton.IsEnabled    = false;
            ServerNameTextBox.IsReadOnly = false;
            userNameTextBox.IsReadOnly   = false;

            selectAllButton.IsEnabled = false;
            selectButton.IsEnabled    = false;
            Deselect.IsEnabled        = false;


            ServerNameTextBox.Background = SystemColors.WindowBrush;
            userNameTextBox.Background   = SystemColors.WindowBrush;
            ServerNameTextBox.Foreground = Brushes.Black;
            userNameTextBox.Foreground   = Brushes.Black;
            userNameTextBox.Clear();
            ServerNameTextBox.Clear(); //
            ServerNameTextBox.TextAlignment = TextAlignment.Left;
            userNameTextBox.TextAlignment   = TextAlignment.Left;
            userNameTextBox.Focus();
        }
Exemple #4
0
 /*
  * EVENT : client_button_Click()
  *
  * DESCRIPTION : This event is activated when user inputs a
  * client name. If the user name is not activated it will trigger a series of
  * formatting events to the GUI.
  * PARAMETERS : object : sender
  *            : RoutedEventArgs : e
  *
  * RETURNS    : N/A
  */
 private void client_button_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(userNameTextBox.Text))
     {
         userNameConnectionFormatingEvents();
         ServerNameTextBox.Focus();
     }
     else
     {
         MessageBox.Show("Please input a proper user name (Ex: JohnnyUtah30)");
     }
 }
Exemple #5
0
        public Settings(double WindowLeft, double WindowTop)
        {
            InitializeComponent();

            DataContext = App.Settings;

            ServerNameTextBox.Focus();

            // Window position
            Left = WindowLeft + 20;
            Top  = WindowTop + 20;
        }
Exemple #6
0
        private void ServerNameTextBox_OnKeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter)
            {
                if (FocusManager.GetFocusedElement() == ServerNameTextBox)
                {
                    var isTabStop = ServerNameTextBox.IsTabStop;
                    ServerNameTextBox.IsTabStop = false;
                    ServerNameTextBox.IsEnabled = false;
                    ServerNameTextBox.IsEnabled = true;
                    ServerNameTextBox.IsTabStop = isTabStop;

                    ServerNameTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();

                    ApplyButton.Command?.Execute(null);

                    e.Handled = true;
                }
            }
        }
Exemple #7
0
 /*
  * EVENT : ServerNameTextBox_TextChanged()
  *
  * DESCRIPTION : This method is as a safegaurd/validator for the servername (machine name) to not
  * contain any of the same characters as packet message. As empty space, |, and , all
  * are used as delimiters for packet message.
  *
  * PARAMETERS : object : sender
  *            : RoutedEventArgs : e
  *
  * RETURNS    : N/A
  */
 private void ServerNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (ServerNameTextBox.Text.Contains(" "))
     {
         MessageBox.Show("No ' spaces ' in user name.");
         ServerNameTextBox.Clear();
         ServerNameTextBox.Focus();
     }
     else if (ServerNameTextBox.Text.Contains("|"))
     {
         MessageBox.Show("No ' | ' in user name.");
         ServerNameTextBox.Clear();
         ServerNameTextBox.Focus();
     }
     else if (ServerNameTextBox.Text.Contains(","))
     {
         MessageBox.Show("No ' , ' in user name.");
         ServerNameTextBox.Clear();
         ServerNameTextBox.Focus();
     }
 }
Exemple #8
0
        private void ClearButton_Click(object sender, EventArgs e)
        {
            //Form title is changed to "Welcome to Sult".
            this.Text = "Welcome to Sult";

            //Hiding the controls that are to be hidden from the user.
            PizzaMenuGroupBox.Visible      = false;
            OrderSummaryGroupBox.Visible   = false;
            LogoPictureBox.Visible         = false;
            CompanySummaryGroupBox.Visible = false;
            OrderPanel.Visible             = false;

            //showing Start butten Panel
            StartPanel.Visible = true;

            ServerNameTextBox.Text = "";
            TableNoTextBox.Text    = "";

            MargheritaPizzaQuantityTextBox.Text = "0";
            PepperoniPizzaQuanityTextBox.Text   = "0";
            HamPineappleQuantityTextBox.Text    = "0";

            ServerNameTextBox.Focus();
        }