public override string Execute() { ReportInfo.Clear(); AHelper.InstructionHistory.Insert(0, Instruction); try { string output = AHelper.ExecuteCommand(Instruction.Substring(1).Trim()); // cd detect List <string> cmdParts = new List <string>(Instruction.Split(' ')); cmdParts.RemoveAt(0); // Remove symbol '>' if (cmdParts.Count > 1 && "cd" == cmdParts[0]) { System.IO.Directory.SetCurrentDirectory(cmdParts[1]); } reportType = ReportType.OK; return(output); } catch (Exception exception) { reportType = ReportType.ERROR; return(exception.Message); } }
/// <summary> /// 获取补全 /// </summary> /// <param name="part"></param> /// <returns></returns> public static string GetCompletion(string part) { List <string> list = new List <string>(); foreach (ConstInstruction ci in GetConstInstrcutionItemList()) { list.Add(ci.constInstructionName); } return(AHelper.FindCompletion(list, part)); }
/// <summary> /// 获取补全 /// </summary> /// <param name="part"></param> /// <returns></returns> public static string GetCompletion(string part) { List <string> list = new List <string>(); foreach (ConstQuoteItem ciList in GetConstQuoteItems()) { list.Add(ciList.constQuoteName); } return(AInstruction.SYMBOL_CONST + AHelper.FindCompletion(list, part.Substring(1))); }
public static List <FileInfo> GetFilesDiffer() { List <FileInfo> differFiles = new List <FileInfo>(); foreach (FileInfo remoteFile in GetRemoteFileList()) { string localFileMd5 = AHelper.GetFileMd5(remoteFile.FileRoute + remoteFile.FileName).ToLower(); if (!localFileMd5.Equals(remoteFile.FileMd5.ToLower())) { differFiles.Add(remoteFile); } } return(differFiles); }
/// <summary> /// /// </summary> /// <param name="startupName">启动名</param> /// <param name="targetPath">目标路径</param> /// <exception cref="FileNotFoundException"></exception> public static void Add(string startupName, string targetPath) { if (!System.IO.File.Exists(targetPath)) { if (!Directory.Exists(targetPath)) { if (!Exists(targetPath)) { throw new FileNotFoundException(); } else { Copy(startupName, targetPath); return; } } } AHelper.CreateShortcut(AFile.APATH_PATH + @"\" + startupName + AFile.LNK_EXTENTION, targetPath); }
private void ExecuteMacroRestart() => AHelper.Restart();
/// <summary> /// 获取补全 /// </summary> /// <param name="part"></param> /// <returns></returns> public static string GetCompletion(string part) => SYMBOL_MACRO + AHelper.FindCompletion(new List <string> { "add", "del", "new", "set", "update", "restart", "locate" }, part.Substring(1));
public MainWindow() { /* * TODO: Automatically initialize default startup items for users who first use Alterful. * foreach (AHelper.SoftwareInstalled software in AHelper.GetInstalledSoftwareList()) * { * Console.WriteLine(software.DisplayName + " (" + software.InstallLocation + ")"); * } */ if (!GotMutex) { AHelper.ShowANotification("Alterful 已在运行中", "Alterful is already running"); Environment.Exit(1);//退出程序 } // Global Initialization. InitializeComponent(); AHelper.Initialize(delegate(string content, AInstruction.ReportType type) { // InstructionTextBox 被主线程占用,利用 Dispatcher 进行操作 TestRichTextbox.Dispatcher.BeginInvoke((Action)(() => { switch (type) { case AInstruction.ReportType.NONE: AppendRTBLine(TestRichTextbox, content, themeConfig.ForegroundOutput, themeConfig.BackgroundOutput); break; case AInstruction.ReportType.WARNING: AppendRTBLine(TestRichTextbox, content, themeConfig.ForegroundOutputWarning, themeConfig.BackgroundOutputWarning); break; case AInstruction.ReportType.OK: AppendRTBLine(TestRichTextbox, content, themeConfig.ForegroundOutputOk, themeConfig.BackgroundOutputOk); break; case AInstruction.ReportType.ERROR: AppendRTBLine(TestRichTextbox, content, themeConfig.ForegroundOutputError, themeConfig.BackgroundOutputError); break; } InstructionTextBox.Text = ""; UpdateMaxWidth(content); Resize(); })); }); InitializeGUI(ATheme.GetThemeConfig(), !AHelper.IS_FIRST_START && !AHelper.HAS_ANEW); InitializePipe(); CheckCommandLine(); appendStringDelegate = AppendStringFunction; Thread thread = new Thread(new ThreadStart(CheckUpdate)); thread.Start(); // If is first startup, give user some tips. if (AHelper.IS_FIRST_START) { string outInfo = "欢迎来到 Alterful,以下是初次上手帮助!\n- 在[指令框输入框]按 Alt 来隐藏/显示回显框;\n- 使用组合键 [Alt+A] 来唤醒/隐藏指令框;\n- 右键任意文件/文件夹来将其添加为启动项;\n- 在指令输入框键入启动项名并回车来启动它;\n- 需要时键入波浪号(~)并回车来结束 Alterful;\n- 前往 help.alterful.com 了解详细功能和使用技巧。"; TestRichTextbox.Dispatcher.BeginInvoke((Action)(() => { UpdateMaxWidth(outInfo); AppendRTBLine(TestRichTextbox, outInfo, themeConfig.ForegroundOutputWarning, themeConfig.BackgroundOutputWarning); Visibility = Visibility.Visible; showOutput = true; Resize(); })); } // Instruction Test. // MainTest(); // Close(); }