private void tsbDelete_Click(object sender, EventArgs e) { if (TabProfiles.SelectedIndex == 0) { try{ if (lstProfiles.SelectedValue != null) { ProfileHelper profileHelper = new ProfileHelper(); Profile profile = new Profile { IdProfile = Int32.Parse(lstProfiles.SelectedValue.ToString()) }; DialogResult r = MessageBox.Show(this, String.Format(TranslateUtil.GetMsgConfirmDelete(), ((Profile)lstProfiles.SelectedItem).ProfileName), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { profileHelper.Delete(profile); profileSelected = null; LoadProfiles(); } } else { MessageBox.Show(this, TranslateUtil.GetMsgSelectProfile(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }catch {} } }
private void LoadNew() { ControlUtil.Clear(txtGateway, txtDNSServer, txtProfile, txtIPSubnet, txtIPAddress); rdbDNSAutomatically.Checked = true; rdbIpAutomatically.Checked = true; txtProfile.Text = TranslateUtil.GetProfileTxt(); txtProfile.SelectionStart = 0; txtProfile.SelectionLength = txtProfile.Text.Length; txtProfile.Focus(); }
private void tsmEnglish_Click(object sender, EventArgs e) { //Test Radio button on menu... tsmLSpanish.Checked = (sender == tsmLSpanish); tsmLEnglish.Checked = (sender == tsmLEnglish); SaveSetting(); TranslateUtil.InitLanguage(); ReloadLanguage(); }
private void LoadProfiles() { lblIPAddress.Text = TranslateUtil.GetSeparator(); lblDNSServer.Text = TranslateUtil.GetSeparator(); lblGateway.Text = TranslateUtil.GetSeparator(); ChangeIPAddressLibrary.Core.ProfileHelper dbProfiles = new ChangeIPAddressLibrary.Core.ProfileHelper(); profiles = dbProfiles.GetAll(); this.lstProfiles.DataSource = profiles; this.lstProfiles.DisplayMember = ChangeIPAddressLibrary.Base.Profile.FPROFILE; this.lstProfiles.ValueMember = ChangeIPAddressLibrary.Base.Profile.FIDPROFILE; }
private void tsbApply_Click(object sender, EventArgs e) { if (TabProfiles.SelectedTab == tabProfile) { try { if (lstProfiles.SelectedValue != null) { bool error = false; if (!profileSelected.DhcpEnabled) { if (!(NetworkInterfaceHelper.SetIP(profileSelected.MacAddress, profileSelected.IpAddress, profileSelected.IpSubnet, profileSelected.DefaultIpGateway))) { MessageBox.Show(this, TranslateUtil.GetMsgErrorNetworkInterface(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); error = true; } } else { new Thread(StartDHCPRenew).Start(); } if (!profileSelected.DnsServerSearchOrder.Trim().Equals(String.Empty)) { if (!(NetworkInterfaceHelper.SetDNS(profileSelected.MacAddress, profileSelected.DnsServerSearchOrder))) { MessageBox.Show(this, TranslateUtil.GetMsgErrorDNSNetworkInterface(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); error = true; } } else { NetworkInterfaceHelper.SetDNSAutomatically(profileSelected.MacAddress); } if (!error && !profileSelected.DhcpEnabled) { MessageBox.Show(this, String.Format(TranslateUtil.GetMsgAppliedProfile(), ((Profile)lstProfiles.SelectedItem).ProfileName), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); txtConsole.Text = NetworkInterfaceHelper.GetActiveConnection(); } } else { MessageBox.Show(this, TranslateUtil.GetMsgSelectProfile(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show(this, TranslateUtil.GetMsgErrorSetting(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void tsbSave_Click(object sender, EventArgs e) { try { if (TabProfiles.SelectedIndex == 1) { Profile p = new Profile(); ProfileHelper pHelper = new ProfileHelper(); NetworkInterface ni = NetworkInterfaceHelper.GetByMACNetworkInterface(cmbInterfaces.SelectedValue.ToString()); p.Caption = ni.Caption; p.Description = ni.Description; p.ProfileName = txtProfile.Text; p.ServiceName = ni.ServiceName; p.SettingId = ni.SettingID; p.DhcpEnabled = this.rdbIpAutomatically.Checked; p.MacAddress = ni.MACAddress; if (!p.DhcpEnabled) { p.DefaultIpGateway = txtGateway.Text; p.IpSubnet = txtIPSubnet.Text; p.IpAddress = txtIPAddress.Text; } if (!rdbDNSAutomatically.Checked) { p.DnsServerSearchOrder = txtDNSServer.Text; } pHelper.Add(p); LoadProfiles(); LoadNew(); MessageBox.Show(this, TranslateUtil.GetMsgSavedProfile(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show(this, TranslateUtil.GetMsgErrorProfile(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void StartDHCPRenew() { NetworkInterfaceHelper.SetEnabledDHCP(profileSelected.MacAddress); MessageBox.Show(this, String.Format(TranslateUtil.GetMsgAppliedProfile(), ((Profile)lstProfiles.SelectedItem).ProfileName), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); txtConsole.Text = NetworkInterfaceHelper.GetActiveConnection(); }
private void lstProfiles_Click(object sender, EventArgs e) { try { profileSelected = profiles[Int32.Parse(lstProfiles.SelectedIndex.ToString())]; lblIPAddress.Text = !profileSelected.IpAddress.Trim().Equals(String.Empty) ? profileSelected.IpAddress : TranslateUtil.GetAutomaticallyTxt(); lblDNSServer.Text = !profileSelected.DnsServerSearchOrder.Trim().Equals(String.Empty) ? profileSelected.DnsServerSearchOrder : TranslateUtil.GetAutomaticallyTxt(); lblGateway.Text = !profileSelected.DefaultIpGateway.Trim().Equals(String.Empty) ? profileSelected.DefaultIpGateway : TranslateUtil.GetAutomaticallyTxt(); if (profileSelected.Description.Length > 25) { lblNetworkInterface.Text = profileSelected.Description.Substring(0, 23) + "..."; } else { lblNetworkInterface.Text = profileSelected.Description; } } catch { //MessageBox.Show(TranslateUtil.GetMsgSelectProfile()); } }