public static DialogResult getConfirmMsgResult(ResourceManager res, int mode) { string msg = String.Empty; string title = RuntimeLocalizer.getString(res, "strWarningTitle"); if (mode == (int)MainForm.PowerOptions.SHUTDOWN) { msg = RuntimeLocalizer.getString(res, "strConfirmShutdown"); } else if (mode == (int)MainForm.PowerOptions.REBOOT) { msg = RuntimeLocalizer.getString(res, "strConfirmReboot"); } else if (mode == (int)MainForm.PowerOptions.LOGOFF) { msg = RuntimeLocalizer.getString(res, "strConfirmLogoff"); } else if (mode == (int)MainForm.PowerOptions.LOCK) { msg = RuntimeLocalizer.getString(res, "strConfirmLock"); } else if (mode == (int)MainForm.PowerOptions.SLEEP) { msg = RuntimeLocalizer.getString(res, "strConfirmSleep"); } else if (mode == (int)MainForm.PowerOptions.HIBERNATE) { msg = RuntimeLocalizer.getString(res, "strConfirmHibernate"); } return(MessageBox.Show(msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question)); }
private void tmiZH_Click(object sender, EventArgs e) { RuntimeLocalizer.ChangeCulture(this, "zh-HK"); Utility.updateSetting("lang", "zh-HK"); foreach (ToolStripDropDownItem item in tmiLang.DropDownItems) { if (item.GetType() == typeof(ToolStripMenuItem)) { ((ToolStripMenuItem)item).Checked = false; } } initToolTip(); tmiZH.Checked = true; }
private void tmiEng_Click(object sender, EventArgs e) { RuntimeLocalizer.ChangeCulture(this, "en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Utility.updateSetting("lang", "en-US"); foreach (ToolStripDropDownItem item in tmiLang.DropDownItems) { if (item.GetType() == typeof(ToolStripMenuItem)) { ((ToolStripMenuItem)item).Checked = false; } } initToolTip(); tmiEng.Checked = true; }
protected void powerManagement(int option) { if (mcWin32 == null) { initWMI(); } mcWin32.Scope.Options.EnablePrivileges = true; string classPath = String.Empty; ManagementBaseObject mboShutdownParams = null; if (Utility.isNT6OrAbove(getOSInfo(OSInfo.Version))) { // See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394057(v=vs.85).aspx classPath = ShutdownClassPath.NT6; string comment = String.Empty; mboShutdownParams = mcWin32.GetMethodParameters(classPath); mboShutdownParams["Flags"] = option.ToString(); mboShutdownParams["ReasonCode"] = "0"; if (option == (int)PowerOptions.REBOOT) { comment = RuntimeLocalizer.getString(mRM, "strRebootComment"); } else if (option == (int)PowerOptions.SHUTDOWN) { comment = RuntimeLocalizer.getString(mRM, "strShutdownComment"); } mboShutdownParams["Comment"] = comment; mboShutdownParams["Timeout"] = cbxWaitTime.SelectedItem.ToString(); } else { // See: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394058(v=vs.85).aspx classPath = ShutdownClassPath.NT5; mboShutdownParams = mcWin32.GetMethodParameters(classPath); mboShutdownParams["Flags"] = option.ToString(); mboShutdownParams["Reserved"] = "0"; } foreach (ManagementObject manObj in mcWin32.GetInstances()) { mboShutdown = manObj.InvokeMethod(classPath, mboShutdownParams, null); } }
protected void initToolTip() { toolTip.SetToolTip(btnShutDown, RuntimeLocalizer.getString(mRM, "tsShutdown")); toolTip.SetToolTip(btnRestart, RuntimeLocalizer.getString(mRM, "tsReboot")); toolTip.SetToolTip(btnLogOff, RuntimeLocalizer.getString(mRM, "tsLogoff")); toolTip.SetToolTip(btnSleep, RuntimeLocalizer.getString(mRM, "tsSleep")); toolTip.SetToolTip(btnHibernate, RuntimeLocalizer.getString(mRM, "tsHibernate")); toolTip.SetToolTip(btnLock, RuntimeLocalizer.getString(mRM, "tsLock")); toolTip.SetToolTip(cbxShowConfirmMsg, RuntimeLocalizer.getString(mRM, "tsConfirmMsg")); if (Utility.isNT6OrAbove(Utility.getOSInfoByKey("Version"))) { toolTip.SetToolTip(cbxWaitTime, RuntimeLocalizer.getString(mRM, "tsTimeout")); toolTip.SetToolTip(lblWaitTime, RuntimeLocalizer.getString(mRM, "tsTimeout")); } else { toolTip.SetToolTip(cbxWaitTime, RuntimeLocalizer.getString(mRM, "tsSupportVistaAbove")); toolTip.SetToolTip(lblWaitTime, RuntimeLocalizer.getString(mRM, "tsSupportVistaAbove")); } }
protected void initForm() { cbxShowConfirmMsg.Checked = (bool)Utility.getSettingValue("showConfirm"); string lang = (string)Utility.getSettingValue("lang"); if (lang.Equals("zh-HK")) { tmiZH.Checked = true; tmiEng.Checked = false; } else { tmiZH.Checked = false; tmiEng.Checked = true; } if (IsPwrHibernateAllowed()) { btnHibernate.Enabled = true; } else { btnHibernate.Enabled = false; } if (IsPwrSuspendAllowed()) { btnSleep.Enabled = true; } else { btnSleep.Enabled = false; } RuntimeLocalizer.ChangeCulture(this, lang); }
private void tmiRestoreSetting_Click(object sender, EventArgs e) { Utility.restoreDefaultSetting(); MessageBox.Show(RuntimeLocalizer.getString(mRM, "msgDefaultSetting"), RuntimeLocalizer.getString(mRM, "strInfoTitle"), MessageBoxButtons.OK, MessageBoxIcon.Information); }