/// <summary> /// 页面国际化 /// </summary> private void Internationalization(string language) { //国际化 DefaultLanguage = !string.IsNullOrWhiteSpace(language) ? language : "zh-CN"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(language); ResourceCulture.SetCurrentCulture(language); lblAppName.Text = ResourceCulture.GetString("AppName"); //lblAppName.Location = language == "zh-CN" ? new Point(413, 155) : new Point(360, 155); this.langChineseTool.ForeColor = DefaultLanguage == "en-US" ? Color.White : Color.FromArgb(192, 192, 255); this.langEnglishTool.ForeColor = DefaultLanguage == "en-US" ? Color.FromArgb(192, 192, 255) : Color.White; btnLogin.Text = ResourceCulture.GetString("Login"); chxUser.Text = ResourceCulture.GetString("RememberUser"); chxPassword.Text = ResourceCulture.GetString("RememberPassword"); //chxPassword.Location = language == "zh-CN" ? new Point(440, 485) : new Point(460, 485); lblBtnChangePwd.Text = ResourceCulture.GetString("ChangePassword"); lblCopyRight.Text = ResourceCulture.GetString("CopyRight"); }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //DPI 适配 //SetProcessDPIAware(); ReleaseType = ConfigurationManager.AppSettings["RELEASE_TYPE"].Trim().ToUpper(); #region MessageBox 按钮国际化 string language = ConfigurationManager.AppSettings["DEFAULT_LANGUAGE"].Trim(); Thread.CurrentThread.CurrentUICulture = new CultureInfo(language); ResourceCulture.SetCurrentCulture(language); //Set button text from resources MessageBoxEx.OK = ResourceCulture.GetString("MsgBox_OK"); // LocalResource.OK; MessageBoxEx.Cancel = ResourceCulture.GetString("MsgBox_Cancel"); // LocalResource.Cancel; MessageBoxEx.Retry = ResourceCulture.GetString("MsgBox_Retry"); // LocalResource.Retry; MessageBoxEx.Ignore = ResourceCulture.GetString("MsgBox_Ignore"); // LocalResource.Ignore; MessageBoxEx.Abort = ResourceCulture.GetString("MsgBox_Abort"); // LocalResource.Abort; MessageBoxEx.Yes = ResourceCulture.GetString("MsgBox_Yes"); // LocalResource.Yes; MessageBoxEx.No = ResourceCulture.GetString("MsgBox_No"); // LocalResource.No; //Register manager MessageBoxEx.Register(); #endregion #region 保证同时只有一个客户端在运行 bool noRun = false; Run = new System.Threading.Mutex(true, "BDOSecurityPortal", out noRun); if (!noRun) { Process instance = RunningInstance(); string productName = ResourceCulture.GetString("AppName"); //Application.ProductName string exMsg = string.Format(ResourceCulture.GetString("GeneralMsg_AppAlreadyRun"), productName); MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error); HandleRunningInstance(instance); return; } #endregion #region 检测软锁(hasplms)服务 ServiceController[] localServices = ServiceController.GetServices(); var hasplmsServices = localServices.SingleOrDefault(s => s.ServiceName == "hasplms"); if (hasplmsServices == null)//软锁服务未安装成功 { MessageBox.Show(ResourceCulture.GetString("GeneralMsg_HasplmsNotExist"), ResourceCulture.GetString("GeneralTitle_Prompt")); Application.Exit(); return; } if (hasplmsServices.Status != ServiceControllerStatus.Running) { hasplmsServices.Start(); } #endregion #region 检测网络连接是否正常 if (!CommonService.IsConnectInternet()) { string productName = ResourceCulture.GetString("AppName"); //Application.ProductName string exMsg = string.Format(ResourceCulture.GetString("GeneralMsg_NetworkOffline"), Application.ProductName); MessageBox.Show(exMsg, productName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion #region 序升级 string localVersion = string.Empty, serverVersion = string.Empty; var shouldUpdateApp = ShouldUpdateApp(out localVersion, out serverVersion); if (shouldUpdateApp) { Process.Start(Application.StartupPath + @"\AutoUpdate.exe"); //Application.Exit(); Environment.Exit(0); return; } #endregion //SetProcessDPIAware(); // 不兼容XP //IntPtr hUser32 = GetModuleHandle("user32.dll"); //IntPtr addrSetProcessDPIAware = GetProcAddress(hUser32, "SetProcessDPIAware"); //if (addrSetProcessDPIAware != IntPtr.Zero) //{ // FarProc SetProcessDPIAware = (FarProc)Marshal.GetDelegateForFunctionPointer(addrSetProcessDPIAware, typeof(FarProc)); // SetProcessDPIAware(); //} //// C#的原有代码 //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); } catch (Exception ex) { string exMsg = ResourceCulture.GetString("GeneralMsg_AppException"); if (ReleaseType == "DEBUG") { exMsg = ex.Message + ex.StackTrace; } MessageBox.Show(exMsg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); //Application.Exit(); Environment.Exit(0); } }