public void Create(String ssid, String key) { Message = ""; ps.Arguments = @"wlan set hostednetwork mode=allow ssid=" + ssid + " key=" + key; Execute(ps); LoggerClass.WriteLogInformation(Message); }
public void Start() { Message = ""; ps.Arguments = "wlan start hosted network"; Execute(ps); LoggerClass.WriteLogInformation(Message); }
private void ExitButton_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { ExitButtonClicked = true; LoggerClass.WriteLogInformation("Program Exited"); SetThreadExecutionState(ES_CONTINUOUS); Hotspot.Stop(); Application.Exit(); } }
private void ShareInternetButton_Click(object sender, EventArgs e) { try { Hotspot.ShareInternet(FromNetworkListComboBox.SelectedItem.ToString(), ToNetworkListComboBox.SelectedItem.ToString(), true); LoggerClass.WriteLogInformation(Hotspot.Message); MessageBox.Show("Network is Shared", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void ShareInternet(String pubConnectionName, String priConnectionName, bool isEnabled) { Message = ""; bool hasCon = false; dynamic everyConnection = null; dynamic connectionProp = null; everyConnections = netSharingManager.EnumEveryConnection; foreach (dynamic connection in everyConnections) { everyConnection = netSharingManager.INetSharingConfigurationForINetConnection(connection); connectionProp = netSharingManager.NetConnectionProps(connection); if (connectionProp.Name == pubConnectionName) { hasCon = true; this.Message += String.Format("Setting ICS Public {0} on connection: {1} \n", isEnabled, pubConnectionName); if (isEnabled) { everyConnection.EnableSharing(0); } else { everyConnection.DisableSharing(); } } if (connectionProp.Name == priConnectionName) { hasCon = true; this.Message += String.Format("Setting ICS Private {0} on connection: {1} \n", isEnabled, priConnectionName); if (isEnabled) { everyConnection.EnableSharing(1); } else { everyConnection.DisableSharing(); } } } LoggerClass.WriteLogInformation(Message); if (!hasCon) { this.Message += "No connection found!"; } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (ExitButtonClicked != true) { DialogResult result = MessageBox.Show("Are You Sure?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { LoggerClass.WriteLogInformation("Program Exited"); SetThreadExecutionState(ES_CONTINUOUS); Hotspot.Stop(); } else { e.Cancel = true; } } }
private void SaveButton_Click(object sender, EventArgs e) { Settings NewSettings = new Settings(); NewSettings.CheckValidSettings = @"OK"; NewSettings.EnableLogging = EnableLoggingCheckBox.Checked; NewSettings.StartHotspotAutomatically = StartHotspotAutomaticallyCheckBox.Checked; NewSettings.StartMinimized = StartMinimizedCheckBox.Checked; NewSettings.ShowMessageMinimized = ShowMessageMinimizedCheckBox.Checked; File.Delete(SettingsPath); String jsonSettings = JsonConvert.SerializeObject(NewSettings); File.WriteAllText(SettingsPath, jsonSettings); MainForm.ReadSettings(); UpdateSettings(); MessageBox.Show("Settings Saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); LoggerClass.WriteLogInformation("Settings Saved"); }
private void MainForm_Load(object sender, EventArgs e) { ReadSettings(); UpdateLabelsText(); ConnectedUsersTimer.Start(); ContextMenu NotificationMenu = new ContextMenu(); MenuItem Item1 = new MenuItem { Index = 0, Text = "Show Program" }; Item1.Click += Item1_Click; MenuItem Item2 = new MenuItem { Index = 1, Text = "Exit" }; Item2.Click += Item2_Click; NotificationMenu.MenuItems.Add(Item1); NotificationMenu.MenuItems.Add(Item2); notifyIcon1.ContextMenu = NotificationMenu; if (IOkey.ReadLicence() == false) { RegisterButton.PerformClick(); } else { LoggerClass.WriteLogInformation("Licence Verified" + Environment.NewLine + "Program Started"); RegisterButton.Visible = false; } if (NetworkInfo.NetworkStatus == "Started") { LoggerClass.WriteLogInformation("Hotspot Started"); } else { LoggerClass.WriteLogInformation("Hotspot Not Started"); } }
private void RegisterButton_Click(object sender, EventArgs e) { if (RegisterTextBox.Text == null) { MessageBox.Show("Provide Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ValidationKey = false; RegisterTextBox.Focus(); } else if (opr.VerifyCode(RegisterTextBox.Text) == false) { MessageBox.Show("Invalid Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ValidationKey = false; RegisterTextBox.Text = null; RegisterTextBox.Focus(); } else { MessageBox.Show("Valid Serial Key", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); ValidationKey = true; IOKey.WriteLicence(RegisterTextBox.Text); LoggerClass.WriteLogInformation("Inserted Valid Serial Key EncyptedKey=" + System.IO.File.ReadAllText(SerialKeyIOClass.LicencePath)); this.Close(); } }
public NetworkInfoClass GetNetworkInfo() { Message = ""; NetworkInfoClass Info = new NetworkInfoClass(); ps.Arguments = "wlan show hostednetwork"; Execute(ps); try { Info.NetworkStatus = (Regex.Match(Message, @"[\n\r].*Status : \s*([^\n\r]*)")).Groups[1].Value; } catch (Exception) { Info.NetworkStatus = null; } try { Info.SSID = (Regex.Match(Message, @"[\n\r].*SSID name : \s*([^\n\r]*)")).Groups[1].Value.Replace("\"", ""); } catch (Exception) { Info.SSID = null; } try { Info.NumOfClients = (Regex.Match(Message, @"[\n\r].*Number of clients : \s*([^\n\r]*)")).Groups[1].Value; } catch (Exception) { Info.NumOfClients = "0"; } try { MatchCollection Clients = Regex.Matches(Message, @"([0-9a-f]{2}(?::[0-9a-f]{2}){5})"); foreach (Match ClientMAC in Clients) { foreach (Capture CaptureMAC in ClientMAC.Captures) { Info.ConnectedClients.Add(CaptureMAC.Value); } } } catch (Exception) { Info.ConnectedClients = null; } if (WriteLog == true) { LoggerClass.WriteLogInformation(Message); } Message = ""; ps.Arguments = "wlan show hostednetwork setting=security"; Execute(ps); try { Info.Key = (Regex.Match(Message, @"[\n\r].*User security key : \s*([^\n\r]*)")).Groups[1].Value; } catch (Exception) { Info.Key = null; } if (WriteLog == true) { LoggerClass.WriteLogInformation(Message); } return(Info); }