private void ConfigForm_Shown(object sender, EventArgs e) { IPTextBox.Focus(); #region SSD DisableMove(); #endregion }
private Server GetServerDetailsFromUI() { Server server = new Server(); if (Uri.CheckHostName(server.server = IPTextBox.Text.Trim()) == UriHostNameType.Unknown) { MessageBox.Show(I18N.GetString("Invalid server address")); IPTextBox.Focus(); return(null); } if (!int.TryParse(ServerPortTextBox.Text, out server.server_port)) { MessageBox.Show(I18N.GetString("Illegal port number format")); ServerPortTextBox.Focus(); return(null); } server.password = PasswordTextBox.Text; server.method = EncryptionSelect.Text; server.plugin = PluginTextBox.Text; server.plugin_opts = PluginOptionsTextBox.Text; server.plugin_args = PluginArgumentsTextBox.Text; server.remarks = RemarksTextBox.Text; if (!int.TryParse(TimeoutTextBox.Text, out server.timeout)) { MessageBox.Show(I18N.GetString("Illegal timeout format")); TimeoutTextBox.Focus(); return(null); } return(server); }
private void ShowWindow() { this.Opacity = 1; this.Show(); IPTextBox.Focus(); PictureQRcode.Visible = false; //隐藏二维码 }
private bool SaveOldSelectedServer() { try { if (_lastSelectedIndex == -1 || _lastSelectedIndex >= _modifiedConfiguration.configs.Count) { return(true); } var server = new ServerObject { v = "10" }; if (Uri.CheckHostName(server.add = IPTextBox.Text.Trim()) == UriHostNameType.Unknown) { MessageBox.Show(I18N.GetString("Invalid server address")); IPTextBox.Focus(); return(false); } var old = _modifiedConfiguration.configs[_lastSelectedIndex]; server.port = (int)ServerPortNum.Value; server.aid = (int)AlterIdNum.Value; server.ps = RemarksTextBox.Text; server.id = IDTextBox.Text; server.net = TPSelect.SelectedItem.ToString(); server.type = CTSelect.SelectedItem.ToString(); server.host = CDTextBox.Text; server.path = PathTextBox.Text; server.tls = SecuritySelect?.SelectedItem?.ToString() ?? ""; var localPort = (int)LocalPortNum.Value; var corePort = (int)CorePortNum.Value; Configuration.CheckServer(server.add); Configuration.CheckLocalPort(localPort); if (old != null) { server.group = old.group; } _modifiedConfiguration.configs[_lastSelectedIndex] = server; _modifiedConfiguration.localPort = localPort; _modifiedConfiguration.corePort = corePort; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(false); }
private bool SaveOldSelectedServer() { try { if (_lastSelectedIndex == -1 || _lastSelectedIndex >= _modifiedConfiguration.configs.Count) { return(true); } Server server = new Server(); if (Uri.CheckHostName(server.server = IPTextBox.Text.Trim()) == UriHostNameType.Unknown) { MessageBox.Show(I18N.GetString("Invalid server address")); IPTextBox.Focus(); return(false); } if (!int.TryParse(ServerPortTextBox.Text, out server.server_port)) { MessageBox.Show(I18N.GetString("Illegal port number format")); ServerPortTextBox.Focus(); return(false); } server.password = PasswordTextBox.Text; server.method = EncryptionSelect.Text; server.use_kcp = UseKcpCheckBox.Checked; server.kcp_argument = KcpArgumentTextBox.Text; if (!int.TryParse(KcpRemotePortTextBox.Text, out server.kcp_remote_port)) { MessageBox.Show(I18N.GetString("Illegal kcp remote port number format")); ServerPortTextBox.Focus(); return(false); } server.remarks = RemarksTextBox.Text; if (!int.TryParse(TimeoutTextBox.Text, out server.timeout)) { MessageBox.Show(I18N.GetString("Illegal timeout format")); TimeoutTextBox.Focus(); return(false); } int localPort = int.Parse(ProxyPortTextBox.Text); Configuration.CheckServer(server); Configuration.CheckLocalPort(localPort); _modifiedConfiguration.configs[_lastSelectedIndex] = server; _modifiedConfiguration.localPort = localPort; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(false); }
private bool?CheckIPTextBox(out string address, bool isSave, bool isCopy) { address = null; string outAddress; if (Uri.CheckHostName(outAddress = IPTextBox.Text.Trim()) == UriHostNameType.Unknown) { if (!isSave && !isCopy && ServersListBox.Items.Count > 1 && I18N.GetString("New server").Equals(ServersListBox.Items[_lastSelectedIndex].ToString())) { DialogResult result = MessageBox.Show(I18N.GetString("Whether to discard unconfigured servers"), I18N.GetString("Operation failure"), MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { return(null); } } else if (isChange && !isSave && !isCopy) { var result = MessageBox.Show(I18N.GetString("Invalid server address, Cannot automatically save or discard changes"), I18N.GetString("Auto save failed"), MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return(false); } else { address = _modifiedConfiguration.configs[_lastSelectedIndex].server; return(true); } } else { MessageBox.Show(I18N.GetString("Invalid server address"), I18N.GetString("Operation failure")); IPTextBox.Focus(); } return(false); } else { address = outAddress; } return(true); }
private void CheckBoxClicked(object sender, RoutedEventArgs e) { if ((bool)passwordRequired.IsChecked) { passwordBox = new PasswordBox(); passwordBox.Name = "passwordBox"; passwordBox.Margin = new Thickness(3, 4, 0, -7); passwordBox.KeyDown += new System.Windows.Input.KeyEventHandler(IPTextBoxKeyDown); passwordBox.ToolTipOpening += new ToolTipEventHandler(PasswordBoxToolTipOpening); passwordBox.MaxLength = 40; passwordBox.MaxWidth = 180; passwordGrid.Children.Add(passwordBox); Grid.SetColumn(passwordBox, 1); passwordBox.SelectAll(); passwordBox.Focus(); } else { passwordGrid.Children.Remove(passwordBox); passwordBox = null; IPTextBox.SelectAll(); IPTextBox.Focus(); } }
private void ConfigForm_Shown(object sender, EventArgs e) { IPTextBox.Focus(); }
private void ShowWindow() { this.Opacity = 1; this.Show(); IPTextBox.Focus(); }
public ManuallyConnectDialog(string IP = null, string nick = null, string message = null) { InitializeComponent(); if (message != null) { Grid.SetRow(responsePanel, 3); Label _messageLabel = new Label(); _messageLabel.Content = message; _messageLabel.Foreground = Brushes.Red; _messageLabel.HorizontalContentAlignment = HorizontalAlignment.Center; _messageLabel.Margin = new Thickness(0, 10, 0, -10); mainGrid.Children.Add(_messageLabel); Grid.SetRow(_messageLabel, 2); } if (IP != null) { IPTextBox.Text = IP; IPTextBox.IsEnabled = false; passwordRequired.IsChecked = true; passwordRequired.IsEnabled = false; passwordBox = new PasswordBox(); passwordBox.Name = "passwordBox"; passwordBox.Margin = new Thickness(3, 4, 0, -7); passwordBox.MaxLength = 40; passwordBox.MaxWidth = 180; passwordBox.KeyDown += new System.Windows.Input.KeyEventHandler(IPTextBoxKeyDown); passwordBox.ToolTipOpening += new ToolTipEventHandler(PasswordBoxToolTipOpening); passwordGrid.Children.Add(passwordBox); Grid.SetColumn(passwordBox, 1); passwordBox.SelectAll(); passwordBox.Focus(); } if (nick != null) { IPTextBox.Width = 150; Label _label = new Label(); if (nick.Length > 10) { nick = nick.Substring(0, 8) + ".."; } nick = "(" + nick + ")"; _label.Content = nick; _label.Width = 1000; IPPanel.Children.Add(_label); Grid.SetColumnSpan(IPTextBox, 1); Grid.SetColumn(_label, 1); passwordRequired.IsChecked = true; passwordRequired.IsEnabled = false; passwordBox = new PasswordBox(); passwordBox.Name = "passwordBox"; passwordBox.Margin = new Thickness(3, 4, 0, -7); passwordBox.MaxWidth = 180; passwordBox.KeyDown += new System.Windows.Input.KeyEventHandler(IPTextBoxKeyDown); passwordBox.ToolTipOpening += new ToolTipEventHandler(PasswordBoxToolTipOpening); passwordGrid.Children.Add(passwordBox); passwordBox.MaxLength = 40; Grid.SetColumn(passwordBox, 1); passwordBox.SelectAll(); passwordBox.Focus(); } else { IPTextBox.Text = "Enter IP Address"; IPTextBox.SelectAll(); IPTextBox.Focus(); } IPTextBox.Style = Resources["noError"] as Style; }
private void IPLabel_Click(object sender, EventArgs e) { IPTextBox.Focus(); }
private void ShowWindow() { Opacity = 1; Show(); IPTextBox.Focus(); }