public static void Delete(FastSetting fast = FastSetting.False) { if (ApplicationHelper.IsUserAdministrator()) { try { UnRegister(fast); MessageBox.Show(Resources.Strings.TipUnRegister, 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 = "/unreg"; if (fast == FastSetting.True) { cmd += " /fast"; } ApplicationHelper.StartSelf(cmd, true); } }
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 void NoParamStart() { // Client.Start(); if (!RightMenu.Init()) { return; } if (Properties.Settings.Default.DefaultStartupMonitorModeEnabled) { // Monitor Mode Entrance 2 ApplicationHelper.StartSelf(CLIParams.MONITOR, false); return; } else { Application.Run(new FormMain()); } }
public void Execute() { if (action == CLIParams.REG) { RightMenu.ShiftSetting shift = HasThisParam(CLIParams.SHIFT) ? RightMenu.ShiftSetting.True : RightMenu.ShiftSetting.False; RightMenu.QuickSetting quick = HasThisParam(CLIParams.QUICK) ? RightMenu.QuickSetting.True : RightMenu.QuickSetting.False; RightMenu.Add(shift, quick); } else if (action == CLIParams.UNREG) { RightMenu.QuickSetting quick = HasThisParam(CLIParams.QUICK) ? RightMenu.QuickSetting.True : RightMenu.QuickSetting.False; RightMenu.Delete(quick); } else if (action == CLIParams.MONITOR) { if (ApplicationHelper.IsPasteExMonitorModeProcessExist()) { CommandLine.Error(Resources.Strings.TipMonitorProcessExisted); MessageBox.Show(Resources.Strings.TipMonitorProcessExisted, Resources.Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Monitor mode Application.Run(new FormMain(null)); } else if (action == CLIParams.PASTE) { if (HasThisParam(CLIParams.QUICK)) { // Quick paste mode bool forceOverWrite = HasThisParam(CLIParams.FORCE); if (File.Exists(path)) { string directory = Path.GetDirectoryName(path); if (string.IsNullOrEmpty(directory)) { Console.WriteLine(Resources.Strings.TipTargetPathNotExist); MessageBox.Show(Resources.Strings.TipTargetPathNotExist, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } ModeController.QuickPasteEx(directory, Path.GetFileName(path), forceOverWrite); } else if (Directory.Exists(path)) { ModeController.QuickPasteEx(path, null, forceOverWrite); } else { string directory = Path.GetDirectoryName(path); if (string.IsNullOrEmpty(directory)) { Console.WriteLine(Resources.Strings.TipTargetPathNotExist); MessageBox.Show(Resources.Strings.TipTargetPathNotExist, Resources.Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } ModeController.QuickPasteEx(directory, Path.GetFileName(path), forceOverWrite); } } else { if (!string.IsNullOrEmpty(path)) { // Start the main interface with path Application.Run(new FormMain(path)); } else { // Client.Start(); if (!RightMenu.Init()) { return; } if (Properties.Settings.Default.DefaultStartupMonitorModeEnabled) { // Monitor Mode Entrance 2 ApplicationHelper.StartSelf(CLIParams.MONITOR, false); return; } else { Application.Run(new FormMain()); } } } } else { Application.Run(new FormMain()); } }