public static void Add( ShiftSetting shift = ShiftSetting.False, FastSetting fast = FastSetting.False) { if (IsUserAdministrator()) { try { UnRegister(fast); } catch { } try { Register(shift, fast); MessageBox.Show(Resources.Strings.TipRegister, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + Resources.Strings.TipRunAsAdmin, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { string cmd = "/reg"; if (shift == ShiftSetting.True) { cmd += " /shift"; } if (fast == FastSetting.True) { cmd += " /fast"; } StartSelf(cmd); } }
public static void Add( ShiftSetting shift = ShiftSetting.False, QuickSetting quick = QuickSetting.False) { if (ApplicationHelper.IsUserAdministrator()) { try { UnRegister(quick); } catch { } try { Register(shift, quick); MessageBox.Show(Resources.Strings.TipRegister, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + Resources.Strings.TipRunAsAdmin, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { string cmd = CLIHelper.GenerateCmdReg(shift, quick); ApplicationHelper.StartSelf(cmd, true); } }
private static void Register( ShiftSetting shift = ShiftSetting.False, FastSetting fast = FastSetting.False) { // Background var key = Registry.ClassesRoot.OpenSubKey("Directory").OpenSubKey("Background").OpenSubKey("shell", true).CreateSubKey(GetLastSubKeyName(fast)); var cmdKey = key.CreateSubKey("command"); key.SetValue("Icon", Application.ExecutablePath); if (shift == ShiftSetting.True) { key.SetValue("Extended", ""); } if (fast == FastSetting.False) { key.SetValue("", Resources.Strings.MenuPasteAsFile); cmdKey.SetValue("", Application.ExecutablePath + " \"%V\""); } else { key.SetValue("", Resources.Strings.MenuQuickPasteAsFile); cmdKey.SetValue("", Application.ExecutablePath + " /q \"%V\""); } // shell key = Registry.ClassesRoot.OpenSubKey("Directory").OpenSubKey("shell", true).CreateSubKey(GetLastSubKeyName(fast)); cmdKey = key.CreateSubKey("command"); key.SetValue("Icon", Application.ExecutablePath); if (shift == ShiftSetting.True) { key.SetValue("Extended", ""); } if (fast == FastSetting.False) { key.SetValue("", Resources.Strings.MenuPasteAsFile); cmdKey.SetValue("", Application.ExecutablePath + " \"%1\""); } else { key.SetValue("", Resources.Strings.MenuQuickPasteAsFile); cmdKey.SetValue("", Application.ExecutablePath + " /q \"%1\""); } }
public static int VerifyShiftSetting(string sEnrollNumber, DateTime dtDate, DateTime dtTime, ShiftSetting shiftSetting) { int iSet = 0; //if (!dtDate.Equals(shiftSetting.DTHolidayDate)) //{ if ((dtTime >= shiftSetting.DTTimeInAM_Interval01) && (dtTime <= shiftSetting.DTTimeInAM_Interval02)) { //TO DO -> put in the TimeInAM iSet = 1; } else if ((dtTime >= shiftSetting.DTTimeOutAM_Interval01) && (dtTime <= shiftSetting.DTTimeOutAM_Interval02)) { //TO DO -> put in the TimeOutAM iSet = 2; } else if ((dtTime >= shiftSetting.DTTimeInPM_Interval01) && (dtTime <= shiftSetting.DTTimeInPM_Interval02)) { //TO DO -> put in the TimeInPM iSet = 3; } else if ((dtTime >= shiftSetting.DTTimeOutPM_Interval01) && (dtTime <= shiftSetting.DTTimeOutPM_Interval02)) { //TO DO -> put in the TimeOutPM iSet = 4; } else if ((dtTime >= shiftSetting.DTOverTimeIn_Interval01) && (dtTime <= shiftSetting.DTOverTimeIn_Interval02)) { //TO DO -> put in the OverTimeIn iSet = 5; } else if ((dtTime >= shiftSetting.DTOverTimeOut_Interval01) && (dtTime <= shiftSetting.DTOverTimeOut_Interval02)) { //TO DO -> put in the OverTimeOut iSet = 6; } else { iSet = 7; } //} return(iSet); }
public static string GenerateCmdReg( ShiftSetting shift = ShiftSetting.False, QuickSetting quick = QuickSetting.False) { string cmd = CLIParams.REG + " "; if (quick == QuickSetting.True) { cmd += CLIParams.QUICK; } else { cmd += CLIParams.NORMAL; } if (shift == ShiftSetting.True) { cmd += " " + CLIParams.SHIFT; } return(cmd); }