コード例 #1
0
        public void UpdateAdapters()
        {
            // Get the available adapters
            m_adapters = (OpenNETCF.Net.NetworkInformation.NetworkInterface[])OpenNETCF.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
            accesspointlist.Clear();

            // Add the adapters
            foreach (OpenNETCF.Net.NetworkInformation.NetworkInterface adapter in m_adapters)
            {
                Logger.WriteLine("Adapter: " + adapter.Name);
                if (adapter.Name == "TIWLN1")
                {
                    Logger.WriteLine("found TIWLN1");
                    if (adapter.NetworkInterfaceType == OpenNETCF.Net.NetworkInformation.NetworkInterfaceType.Wireless80211)
                    {
                        ;
                    }
                    adapter.bind();
                    //the following may work or not
                    OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface wni = (OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface)adapter;
                    string currentAP = wni.AssociatedAccessPoint;
                    Logger.WriteLine("Associated with: " + currentAP);
                    accesspointlist.Add(new NearAccesPoints(wni.Name, wni.SignalStrength.Decibels, (int)(wni.WEPStatus)));
                    if (preferedSSIDs.Contains(currentAP))
                    {
                        Logger.WriteLine("device already connected to defined SSID");
                        continue; //exit foreach adapter
                    }
                }// TIWLN1
            }//adapters
        }
コード例 #2
0
        internal static SystemNetworkInterface[] GetNetworkInterfaces()
        {
            ArrayList al = new ArrayList();

            AdapterCollection ac = Networking.GetAdapters();

            foreach (Adapter a in ac)
            {
                IpAdapterInfo i = new IpAdapterInfo();
                i.index = (uint)a.Index;
                al.Add(new SystemNetworkInterface(i));
            }

            return((SystemNetworkInterface[])al.ToArray(typeof(SystemNetworkInterface)));
        }
コード例 #3
0
        private void RefreshAdapterList()
        {
            itemList.ContextMenu = adapterMenu;
            if (!propertiesFrame.Visible)
            {
                propertiesFrame.Visible = true;
                itemList.Height         = this.Height - propertiesFrame.Height - 3;
            }

            Adapter lastSelected = null;
            int     index        = 0;
            int     select       = -1;

            if ((itemList.SelectedIndex >= 0) && (itemList.SelectedIndex < m_adapters.Count))
            {
                lastSelected = m_adapters[itemList.SelectedIndex];
            }
            else
            {
                macLabel.Text = gatewayLabel.Text = dhcpLabel.Text = subnetLabel.Text = "";
                wirelessNetworkMenu.Enabled = false;
            }

            itemList.BeginUpdate();

            m_adapters = Networking.GetAdapters();

            itemList.Items.Clear();

            foreach (Adapter adapter in m_adapters)
            {
                itemList.Items.Add(new ListItem());

                if ((lastSelected != null) && (MACToString(lastSelected.MacAddress) == MACToString(adapter.MacAddress)))
                {
                    select = index;
                }
                index++;
            }

            itemList.SelectedIndex = select;

            itemList.EndUpdate();
        }
コード例 #4
0
        public void UpdateAdapters()
        {
            // Get the available adapters
            m_adapters = Networking.GetAdapters();
            accesspointlist.Clear();

            // Add the adapters
            foreach (Adapter adapter in m_adapters)
            {
                Logger.WriteLine("Adapter: " + adapter.Name);
                adapter.RebindAdapter();
                if (adapter.Name == "TIWLN1")
                {
                    Logger.WriteLine("found TIWLN1");
                    Logger.WriteLine("Associated with: " + adapter.AssociatedAccessPoint);
                    if (preferedSSIDs.Contains(adapter.AssociatedAccessPoint))
                    {
                        Logger.WriteLine("device already connected to preferred SSID");
                        continue; //exit foreach adapter
                    }
                    foreach (AccessPoint ap in adapter.NearbyAccessPoints)
                    {
                        //Logger.WriteLine("AP: " + ap.Name +":"+ ap.SignalStrengthInDecibels.ToString() + ", " +
                        //    ap.InfrastructureMode.ToString() + ", " + ap.Privacy.ToString());

                        accesspointlist.Add(new NearAccesPoints(ap.Name, ap.SignalStrengthInDecibels, ap.Privacy));

                        Logger.WriteLine("Found AP: " + ap.Name);

                        foreach (string s in preferedSSIDs)
                        {
                            if (ap.Name == s) // && adapter.AssociatedAccessPoint != s)
                            {
                                //a preferred AP is in sight and we are not connected
                                //switch network?
                                Logger.WriteLine("will switch to '" + s + "'");
                                _ssAPI.setRACprofile(s);//switch
                            }
                        }//list of preferred APs
                    } //access points
                }     // TIWLN1
            }         //adapters
        }
コード例 #5
0
 internal Enumerator(AdapterCollection collection)
 {
     this.collection = collection;
     index           = -1;
 }
コード例 #6
0
ファイル: Direct3DEx.cs プロジェクト: Nezz/SharpDX
 /// <summary>	
 /// Creates an <see cref="SharpDX.Direct3D9.Direct3DEx"/> object and returns an interface to it.	
 /// </summary>	
 /// <remarks>	
 /// The <see cref="SharpDX.Direct3D9.Direct3DEx"/> object is the first object that the application creates and the last object thta the application releases. Functions for enumerating and retrieving capabilities of a device are accessible through the IDirect3D9Ex object. This enables applications to select devices without creating them.   The <see cref="SharpDX.Direct3D9.Direct3DEx"/> interface supports enumeration of active display adapters and allows the creation of IDirect3D9Ex objects. If the user dynamically adds adapters (either by adding devices to the desktop, or by hot-docking a laptop), these devices are not included in the enumeration. Creating a new IDirect3D9Ex interface will expose the new devices.   Pass the D3D_SDK_VERSION flag to this function to ensure that header files used in the compiled application match the version of the installed runtime DLLs. D3D_SDK_VERSION is changed in the runtime only when a header or another code change would require rebuilding the application. If this function fails, it indicates that the versions of the header file and the runtime DLL do not match.  Note??Direct3DCreate9Ex is supported only in Windows Vista, Windows Server 2008, and Windows 7.   Earlier versions of the D3D9.dll library do not include Direct3D9Ex and Direct3DCreate9Ex.  	
 /// </remarks>	
 /// <returns>D3DERR_NOTAVAILABLE if Direct3DEx features are not supported (no WDDM driver is installed) or if the SDKVersion does not match the version of the DLL.   D3DERR_OUTOFMEMORY if out-of-memory conditions are detected when creating the enumerator object.  S_OK if the creation of the enumerator object is successful.  </returns>
 /// <unmanaged>HRESULT Direct3DCreate9Ex([None] int SDKVersion,[None] IDirect3D9Ex** arg1)</unmanaged>
 public Direct3DEx() : base(IntPtr.Zero)
 {
     D3D9.Create9Ex(D3D9.SdkVersion, this);
     Adapters = new AdapterCollection(this);
     AdaptersEx = new AdapterExCollection(this);
 }
コード例 #7
0
ファイル: Direct3D.cs プロジェクト: alexey-bez/SharpDX
 /// <summary>	
 /// Create an IDirect3D9 object and return an interface to it.	
 /// </summary>	
 /// <remarks>	
 ///  The Direct3D object is the first Direct3D COM object that your graphical application needs to create and the last object that your application needs to release. Functions for enumerating and retrieving capabilities of a device are accessible through the Direct3D object. This enables applications to select devices without creating them. Create an IDirect3D9 object as shown here: 	
 /// <code> LPDIRECT3D9 g_pD3D = NULL; if( NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION))) return E_FAIL; </code>	
 /// 	
 ///  The IDirect3D9 interface supports enumeration of active display adapters and allows the creation of <see cref="SharpDX.Direct3D9.Device"/> objects. If the user dynamically adds adapters (either by adding devices to the desktop, or by hot-docking a laptop), those devices will not be included in the enumeration. Creating a new IDirect3D9 interface will expose the new devices. D3D_SDK_VERSION is passed to this function to ensure that the header files against which an application is compiled match the version of the runtime DLL's that are installed on the machine. D3D_SDK_VERSION is only changed in the runtime when a header change (or other code change) would require an application to be rebuilt. If this function fails, it indicates that the header file version does not match the runtime DLL version. For an example, see {{Creating a Device (Direct3D 9)}}. 	
 /// </remarks>
 public Direct3D()
 {
     FromTemp(D3D9.Create9(D3D9.SdkVersion));
     Adapters = new AdapterCollection(this);
 }