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)); }
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")); } }
private void tmiRestoreSetting_Click(object sender, EventArgs e) { Utility.restoreDefaultSetting(); MessageBox.Show(RuntimeLocalizer.getString(mRM, "msgDefaultSetting"), RuntimeLocalizer.getString(mRM, "strInfoTitle"), MessageBoxButtons.OK, MessageBoxIcon.Information); }