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

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