Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            _siteList = PreferredSiteList.Load();

            if (_siteList.Sites.Length == 0)
            {
                _http.Server            = DefaultValues.Server;
                _http.StartingPoint     = DefaultValues.StartingPoint;
                _http.Username          = DefaultValues.Username;
                _http.Password          = DefaultValues.Password;
                chkSavePassword.Checked = true;
                //chkAutoConnect.Checked = false;
            }
            else
            {
                _http.AddSites(_siteList.Sites);
                //In case the site was removed...
                try { _http.SetPreferredSite(_siteList.PreferedSite); }
                catch { }
                //chkAutoConnect.Checked = _siteList.AutoConnect;
            }

            _http.SiteList = _siteList;

            base.OnLoad(e);
            rdHttp.Checked = true;

            var isNativeApiAvailable = false;
            var isLocalApiAvailable  = false;
            var providers            = ConnectionProviderRegistry.GetProviders();

            foreach (var prv in providers)
            {
                if (prv.Name.ToUpper().Equals("MAESTRO.LOCALNATIVE")) //NOXLATE
                {
                    isNativeApiAvailable = true;
                    break;
                }
                else if (prv.Name.ToUpper().Equals("MAESTRO.LOCAL")) //NOXLATE
                {
                    isLocalApiAvailable = true;
                    break;
                }
            }
            //Mono = No LocalNativeConnection for you (for now...)
            if (Platform.IsRunningOnMono || !isNativeApiAvailable)
            {
                rdTcpIp.Enabled = false;
            }

            if (Platform.IsRunningOnMono || !isLocalApiAvailable)
            {
                rdLocal.Enabled = false;
            }
        }
        /// <summary>
        /// Sets the active culture based on the culture specified in the preferred sites
        /// </summary>
        public static string InitCulture()
        {
            try
            {
                PreferredSiteList sites = PreferredSiteList.Load();
                if (!string.IsNullOrEmpty(sites.GUILanguage))
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture   =
                        System.Threading.Thread.CurrentThread.CurrentCulture =
                            System.Globalization.CultureInfo.GetCultureInfo(sites.GUILanguage);
                }
            }
            catch
            {
            }

            return(System.Threading.Thread.CurrentThread.CurrentUICulture.Name);
        }