示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        public PasteResult Find(PasteResult res)
        {
            string key = res.Key;

            if (History.ContainsKey(key))
            {
                return(History[key]);
            }
            return(null);
        }
示例#4
0
 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);
 }
示例#5
0
 public static void StartRecord(string[] formats)
 {
     isExist            = false;
     currentPasteResult = new PasteResult(formats);
 }
示例#6
0
 public void Remove(PasteResult res)
 {
     History.Remove(res.Key);
 }
示例#7
0
 public void Add(PasteResult res)
 {
     History.Add(res.Key, res);
 }