public static void EndRecord(string ext) { if (currentPasteResult == null) { return; } string[] exts = isExist ? currentPasteResult.UserHistoryExts : currentPasteResult.AnalyzeResultExts; // No change if (exts.Length == 0 || exts[0] == ext) { return; } List <string> extList = new List <string>(exts); extList.Remove(ext); extList.Insert(0, ext); currentPasteResult.UserHistoryExts = extList.ToArray(); if (!isExist) { pasteResultHistory.Add(currentPasteResult); } if (currentPasteResult.UserHistoryExts.SequenceEqual(currentPasteResult.AnalyzeResultExts)) { pasteResultHistory.Remove(currentPasteResult); } currentPasteResult = null; // to json File.WriteAllText(extHistoryFilePath, pasteResultHistory.ToJSONString()); }
public PasteResult Clone() { PasteResult newObj = new PasteResult(); newObj.CopySourceName = this.CopySourceName; newObj.ClipboardFormats = this.ClipboardFormats; newObj.AnalyzeResultExts = this.AnalyzeResultExts; newObj.UserHistoryExts = this.UserHistoryExts; return(newObj); }
public PasteResult Find(PasteResult res) { string key = res.Key; if (History.ContainsKey(key)) { return(History[key]); } return(null); }
public static string[] GetUserHistoryExts(string[] exts) { if (currentPasteResult != null) { currentPasteResult.AnalyzeResultExts = exts; PasteResult foundRes = pasteResultHistory.Find(currentPasteResult); if (foundRes != null) { isExist = true; currentPasteResult = foundRes; return(foundRes.UserHistoryExts); } else { isExist = false; } } return(exts); }
public static void StartRecord(string[] formats) { isExist = false; currentPasteResult = new PasteResult(formats); }
public void Remove(PasteResult res) { History.Remove(res.Key); }
public void Add(PasteResult res) { History.Add(res.Key, res); }