public StartupTabControl(Size size, Point location, int tabIndex, StartupForm stup, PresenterModel model, ControlEventQueue eventqueue) { this.SuspendLayout(); this.m_Startup = stup; this.m_Model = model; this.ItemSize = new System.Drawing.Size(52, 18); this.Location = location; this.Name = "tabControl"; this.SelectedIndex = 0; this.Font = Model.Viewer.ViewerStateModel.StringFont; this.Size = size; this.TabIndex = tabIndex; this.m_AdvancedTab = new AdvancedTab(this.m_Model); this.m_UDPTab = new UDPTab(this.m_Model); this.m_UDPTab.Controls.Add(this.m_Startup.m_UDPPanel); this.Controls.Add(this.m_UDPTab); this.Controls.Add(this.m_AdvancedTab); this.m_AdvancedListener = new EventQueue.PropertyEventDispatcher( this.m_Startup.m_EventQueue, new PropertyEventHandler(this.HandleAdvancedChanged)); this.m_Model.ViewerState.Changed["Advanced"].Add(this.m_AdvancedListener.Dispatcher); this.m_AdvancedListener.Dispatcher(this, null); this.ControlAdded += new ControlEventHandler(UDPTabAdded); this.ResumeLayout(); }
private bool SaveAdvancedOptions() { // Validate input. var regex = new Regex("^\\d+$"); // Validate TTL. if (!regex.IsMatch(TTL.Text) || int.Parse(TTL.Text) < 1 || int.Parse(TTL.Text) > 255) { AdvancedTab.Focus(); MessageBox.Show( "Please enter a valid TTL between 1 and 255.", "vmPing Error", MessageBoxButton.OK, MessageBoxImage.Error); TTL.Focus(); return(false); } // Apply TTL. ApplicationOptions.TTL = int.Parse(TTL.Text); // Validate packet size. if (PacketSizeOption.IsChecked == true) { if (!regex.IsMatch(PacketSize.Text) || int.Parse(PacketSize.Text) < 0 || int.Parse(PacketSize.Text) > 65500) { AdvancedTab.Focus(); MessageBox.Show( "Please enter a valid ICMP data size between 0 and 65,500.", "vmPing Error", MessageBoxButton.OK, MessageBoxImage.Error); PacketSize.Focus(); return(false); } // Apply packet size. ApplicationOptions.Buffer = new byte[int.Parse(PacketSize.Text)]; ApplicationOptions.UseCustomBuffer = false; // Fill buffer with default text. if (ApplicationOptions.Buffer.Length >= 33) { Buffer.BlockCopy(Encoding.ASCII.GetBytes(Constants.PING_DATA), 0, ApplicationOptions.Buffer, 0, 33); } } else { // Use custom packet data. ApplicationOptions.Buffer = Encoding.ASCII.GetBytes(PacketData.Text); ApplicationOptions.UseCustomBuffer = true; } // Apply fragment / don't fragment option. if (DontFragment.IsChecked == true) { ApplicationOptions.DontFragment = true; } else { ApplicationOptions.DontFragment = false; } // Update ping options (TTL / Don't fragment settings) ApplicationOptions.UpdatePingOptions(); return(true); }