public List <List <String> > GrabInfo() { List <List <String> > Complete = new List <List <String> >(); List <String> NetworkAdapters = new List <String>(); List <String> BeginAddresses = new List <String>(); List <String> EndingAddresses = new List <String>(); NetworkInterface[] Cards = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface CurrCard in Cards) //Cycle through each adapter { if (CurrCard.OperationalStatus == OperationalStatus.Up) //Check if the adapter is currently enabled { try //try incase we have a card that has a incorrect IP configuration { IPInterfaceProperties AdapterProperties = CurrCard.GetIPProperties(); //Get adapter properties foreach (UnicastIPAddressInformation ip in CurrCard.GetIPProperties().UnicastAddresses) //Cycle through Unicast info { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) //Check for internetwork info { IPAddress CurrentAddress = ip.Address; //Our IP Address IPAddress SubnetMask = ip.IPv4Mask; //Network subnet mask (we will use these to calculate the IP range) byte[] AddressBytes = CurrentAddress.GetAddressBytes(); //Grab byte format of IP Address byte[] SubnetBytes = SubnetMask.GetAddressBytes(); //Grab byte format of Subnet if (AddressBytes.Length != SubnetBytes.Length) //Ensure that Subnet and IP are the same length { //Error! IP Address length and subnet length dont match! } else { byte[] broadcastBytes = new byte[AddressBytes.Length]; //Create broadcast byte[] that will hold our starting address bytes for (int i = 0; i < broadcastBytes.Length; i++) //Cycle through each byte { broadcastBytes[i] = (byte)(AddressBytes[i] | (SubnetBytes[i] ^ 255)); //Current byte = Address Value OR Subnet value XOR 255 } //Note: I did not create this design, I learned this method a very long time ago IPAddress EndingAddress = new IPAddress(broadcastBytes); //Construct the address using the modified bytes byte[] networkBytes = new byte[AddressBytes.Length]; //Create network byte[] that will hold our ending address bytes for (int i = 0; i < networkBytes.Length; i++) //Cycle through each byte { networkBytes[i] = (byte)(AddressBytes[i] & (SubnetBytes[i])); //Current byte = Adress Value AND Subnet value } IPAddress StartingAddress = new IPAddress(networkBytes); //Construct the address using the modified bytes NetworkAdapters.Add(CurrCard.Name.ToString()); BeginAddresses.Add(StartingAddress.ToString()); EndingAddresses.Add(EndingAddress.ToString()); } } } } catch (ArgumentOutOfRangeException) { //Skips Network Adapters that dont have a gateway address } } } Complete.Add(NetworkAdapters); Complete.Add(BeginAddresses); Complete.Add(EndingAddresses); return(Complete); }
protected override void Update(GameTime gameTime) { foreach (KeyValuePair <MenuButtons, Button> KeyPair in cMenuBtns) { KeyPair.Value.Update(gameTime); } cCardsInPlay[0].Card = cMonsterDeck[0]; cCardsInPlay[1].Card = cMonsterDeck[1]; cCardsInPlay[2].Card = cMonsterDeck[2]; foreach (CardMini CurrCard in cCardsInPlay) { CurrCard.Update(gameTime); } cFullCardFrame.Update(gameTime); cDevConsole.Update(gameTime); //Use monogame update base.Update(gameTime); }
protected override void Draw(GameTime gameTime) { cGraphDevMgr.GraphicsDevice.Clear(Color.Black); foreach (KeyValuePair <MenuButtons, Button> KeyPair in cMenuBtns) { KeyPair.Value.Draw(); } cDrawBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); cDrawBatch.End(); foreach (CardMini CurrCard in cCardsInPlay) { CurrCard.Draw(); } cFullCardFrame.Draw(); cDevConsole.Draw(); //Use monogame draw base.Draw(gameTime); }