Esempio n. 1
0
        void InitializeForm()
        {
            lstUsers.Items.Clear();

            //SetAppStatus();

            hostedNetworkManager = new HostedNetworkManager();
            hostedNetworkManager.ThreadedEvents             = new UiThreadedEvents(this);
            hostedNetworkManager.OnConnectionsListChanged  += HostedNetworkManagerOnConnectionsListChanged;
            hostedNetworkManager.OnSharedConnectionChanged += HostedNetworkManagerOnSharedConnectionChanged;
            hostedNetworkManager.OnWorkingStatusChanged    += HostedNetworkManagerOnWorkingStatusChanged;
            hostedNetworkManager.OnUserUpdated             += HostedNetworkManagerOnUserUpdated;
            hostedNetworkManager.OnUserConnected           += HostedNetworkManagerOnUserConnected;
            hostedNetworkManager.OnUserLeave             += HostedNetworkManagerOnUserLeave;
            hostedNetworkManager.OnFailedToEnableSharing += HostedNetworkManagerOnFailedToEnableSharing;

            // reading ICS connections list
            hostedNetworkManager.ReadNetworkConnectionsAsync();

            ReadFormSettings();

            _icsDomainNameSuffix = SystemTweak.IcsDomainSuffix();

            if (AppConfig.AppStartedFromStartup)
            {
                if (ValidateForm(false))
                {
                    SaveFormSettings();
                    hostedNetworkManager.StartAsync();
                }
            }
        }
        private void StartInternal()
        {
            try
            {
                StopInternal(false);

                Status = WorkingStatus.Starting;

                // system fixes
                SystemTweak.TweakTheSystemNotForced();

                // setting the options
                _wlanManager.SetConnectionSettings(ConfigSsid, ConfigMaxPeers);
                _wlanManager.SetSecondaryKey(ConfigPassword);

                _wlanManager.StartHostedNetwork();

                // save the network id
                _hostedNetworkInterfaceGuid = _wlanManager.HostedNetworkInterfaceGuid;

                var connection = GetIcsToShare();

                if (connection != null)
                {
                    ShareConnection(connection);
                }
                else
                {
                    DisableSharing(true);
                }

                Status = WorkingStatus.Started;
#if TRACE
                LogExceptions.LogTrace(true,
                                       "WLanStart completed, internet is: " + ((connection == null) ? "NULL" : connection.Name));
#endif
            }
            catch (Exception ex)
            {
                LogExceptions.Log(ex);
                Status = WorkingStatus.StartFailed;
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Application.ThreadException += Application_ThreadException;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplyLanguage();

            if (!WindowsCheck.IsWiressDeviceAvailable())
            {
                MessageBox.Show(Hotspoter.Language.App_NoWireless, Hotspoter.Language.App_Name,
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, AppConfig.Instance.MessageBoxOptions);
                return;
            }

            if (WindowsCheck.CheckWindowsVersion() && !IsTheAppAlreadyRunning())
            {
                bool tweakAsync = true;
                if (args != null && args.Length > 0)
                {
                    if (args[0] == AppConfig.AutoStartupKey)
                    {
                        AppConfig.AppStartedFromStartup = true;

                        // tweak the system rightaway
                        SystemTweak.TweakTheSystem();
                        tweakAsync = false;
                    }
                }

                if (tweakAsync)
                {
                    SystemTweak.TweakTheSystemAsync();
                }

                Application.Run(new frmHotspot());
            }
        }