private void connectBtn_Click(object sender, RoutedEventArgs e) { NetworkCard nic = TryGetNic(); HavokNet.OSI.IPv4StackConfiguration config = new HavokNet.OSI.IPv4StackConfiguration(); config.IpAddress = new IPv4Address(ipAddrTxtBox.Text); config.SubnetMask = new IPv4Address(subnetMaskTxtBox.Text); config.DnsServers = new IPv4Address[1] { new IPv4Address(dnsServerTxtBox.Text) }; config.DefaultGateway = new IPv4Address(gatewayTxtBox.Text); config.MacAddress = new MacAddress(macAddrTxtBox.Text); NetClient client = new NetClient(nic, config); switch (sessionCombobox.SelectedIndex) { case 0: client.NetworkFirewall = new HavokNet.Firewall.SimpleFirewall(true, true); break; case 1: client.NetworkFirewall = new HavokNet.Firewall.SimpleFirewall(false, false); break; case 2: break; } ChoosenClient = client; DidChoose = true; this.Close(); }
static void Main(string[] args) { PrintTitle("Starting Havok NetClient Test Suite...", true); var nic = NetworkCard.GetFirstDevice(); client = new NetClient(nic, nic.Config); client.NetworkFirewall = new HavokNet.Firewall.SimpleFirewall(true, true); client.Start(); Console.WriteLine("Client started."); Console.WriteLine(); Console.WriteLine("Layer 2 Configuration:"); Console.WriteLine("\tMAC Address : " + client.Configuration.MacAddress.AsString); Console.WriteLine(); Console.WriteLine("Layer 3 Configuration: "); Console.WriteLine("\tIP Address : " + client.Configuration.IpAddress.AsString); Console.WriteLine("\tSubnet Mask : " + client.Configuration.SubnetMask.AsString); Console.WriteLine("\tDefault Gateway : " + client.Configuration.DefaultGateway.AsString); for (int i = 0; i < client.Configuration.DnsServers.Length; i++) { Console.WriteLine("\tDNS Server " + (i + 1).ToString() + " : " + client.Configuration.DnsServers[i].AsString); } Console.WriteLine("\tNetwork Address : " + client.Configuration.NetworkAddress.AsString); Console.WriteLine("\tBroadcast Address : " + client.Configuration.BroadcastAddress.AsString); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Starting tests..."); // Give us a second to read the text System.Threading.Thread.Sleep(1500); RunTests(); }
private void LoadDevices() { Interfaces = NetworkCard.GetAllAvailableDevices(); this.Dispatcher.Invoke(() => { deviceCombobox.ItemsSource = Interfaces; deviceCombobox.SelectedIndex = 0; }); }
private object ConvertRightSide(object value, IEntityCollection data) { var networkCard = new NetworkCard(); networkCard.MacAddress = value as string; var key = ""; Properties.TryGetValue("IP Address", out key); object ipAddress; data.Entities.TryGetValue(key, out ipAddress); networkCard.IPAddress = ipAddress as string; return(networkCard); }
private void copyDevLayer2Config_Click(object sender, RoutedEventArgs e) { if (deviceCombobox.SelectedIndex == -1) { return; } try { int index = deviceCombobox.SelectedIndex; NetworkCard nic = Interfaces[index]; macAddrTxtBox.Text = nic.Config.MacAddress.AsString; } catch { } }
static void Main(string[] args) { Console.WriteLine("Starting Havok NetClient...", true); var nic = NetworkCard.GetFirstDevice(); IPv4StackConfiguration config = new IPv4StackConfiguration() { IpAddress = new IPv4Address("192.168.1.66"), MacAddress = new MacAddress("7C:7A:91:73:3F:25"), SubnetMask = new IPv4Address("255.255.255.0"), DefaultGateway = new IPv4Address("192.168.1.254"), DnsServers = new IPv4Address[1] { new IPv4Address("192.168.1.254") } }; client = new NetClient(nic, config); client.NetworkFirewall = new HavokNet.Firewall.SimpleFirewall(true, true); client.Start(); Console.WriteLine("Ready to send. Press any key..."); Console.ReadKey(); //client.Tcp.Connect("www.google.com", 80); //return; HttpResponse response = client.Http.Get("http://www.reddit.com"); client.Stop(); Console.WriteLine(); Console.WriteLine("HTTP/" + response.HttpVersion.ToString() + " " + response.Code.ToString()); foreach (KeyValuePair <string, string[]> pair in response.Headers) { Console.WriteLine(pair.Key + ": " + string.Join(",", pair.Value)); } if (response.Code == HttpResponseCode.Ok) { string html = response.DataAsString; string file = @"C:\Users\john.davis\Desktop\osi.html"; System.IO.File.WriteAllText(file, html); System.Diagnostics.Process.Start(file); } Console.ReadKey(); }
private void copyDevLayer3Config_Click(object sender, RoutedEventArgs e) { if (deviceCombobox.SelectedIndex == -1) { return; } try { int index = deviceCombobox.SelectedIndex; NetworkCard nic = Interfaces[index]; dhcpRadioButton.IsChecked = false; staticRadioButton.IsChecked = true; ipAddrTxtBox.Text = nic.Config.IpAddress.AsString; subnetMaskTxtBox.Text = nic.Config.SubnetMask.AsString; dnsServerTxtBox.Text = nic.Config.DnsServers[0].AsString; gatewayTxtBox.Text = nic.Config.DefaultGateway.AsString; } catch { } }
public Part CreatePart(PartType type) { Part part = null; switch (type) { case PartType.Case: part = new Case(Manufacturer.Lenovo, 130); break; case PartType.GraphicsCard: part = new GraphicsCard(Manufacturer.Lenovo, 275); break; case PartType.Memory: part = new Memory(Manufacturer.Lenovo, 85); break; case PartType.Motherboard: part = new Motherboard(Manufacturer.Lenovo, 170); break; case PartType.NetworkCard: part = new NetworkCard(Manufacturer.Lenovo, 60); break; case PartType.Processor: part = new Processor(Manufacturer.Lenovo, 320); break; default: throw new NotImplementedException(); } return(part); }
static void Main(string[] args) { while (true) { Console.WriteLine("1 - Вывести список компонентов"); Console.WriteLine("2 - Купить готовый набор"); Console.WriteLine("---Собрать свой ПК---"); Console.WriteLine("3 - Собрать свою комплектацию"); Console.WriteLine("4 - Выход"); int chouse = IntParser(1, 4); switch (chouse) { case 1: ShowComponentList(); Console.WriteLine("\nНажмите на любую клавишу..."); Console.Read(); Console.Read(); Console.Clear(); break; case 2: Console.WriteLine(); Console.WriteLine("\t1 - Купить базовую комплектацию"); Console.WriteLine("\t2 - Купить полную комплектацию"); Console.WriteLine("\t3 - Назад"); chouse = IntParser(1, 3); if (chouse == 1) { Director director = new Director(); ComputerComplectation computerComplectation = new ComputerComplectation(); director.Builder = computerComplectation; director.Basic(); Console.WriteLine("\tВ комплектацию входит:"); Console.WriteLine(computerComplectation.GetComplectation().ListParts()); Computer computer = new Processor(); Body body = new Body(computer); MainCard mainCard = new MainCard(body); AudioCard audioCard = new AudioCard(mainCard); NetworkCard networkCard = new NetworkCard(audioCard); HDD hdd = new HDD(networkCard); Console.WriteLine("\tОбщяя стоимость: " + hdd.GetCost()); Console.WriteLine("\n\t1 - Продолжить покупку"); Console.WriteLine("\t2 - В главное меню"); chouse = IntParser(1, 2); if (chouse == 1) { Console.WriteLine("\tТовар успешно куплен!"); Console.WriteLine("\nНажмите на любую клавишу..."); Console.Read(); return; } Console.Clear(); } else if (chouse == 2) { Director director = new Director(); ComputerComplectation computerComplectation = new ComputerComplectation(); director.Builder = computerComplectation; director.Full(); Console.WriteLine("\tВ комплектацию входит:"); Console.WriteLine(computerComplectation.GetComplectation().ListParts()); Computer computer = new Processor(); Body body = new Body(computer); MainCard mainCard = new MainCard(body); AudioCard audioCard = new AudioCard(mainCard); NetworkCard networkCard = new NetworkCard(audioCard); HDD hdd = new HDD(networkCard); VideoCard videoCard = new VideoCard(hdd); SSD ssd = new SSD(videoCard); Mouse mouse = new Mouse(ssd); Keyboard keyboard = new Keyboard(mouse); Console.WriteLine("\tОбщяя стоимость: " + keyboard.GetCost()); Console.WriteLine("\n\t1 - Продолжить покупку"); Console.WriteLine("\t2 - В главное меню"); chouse = IntParser(1, 2); if (chouse == 1) { Console.WriteLine("\tТовар успешно куплен!"); Console.WriteLine("\nНажмите на любую клавишу..."); Console.Read(); return; } Console.Clear(); } break; case 3: CollectComplectation(); break; case 4: return; } } }