Beispiel #1
0
 private string GetKey(AbstractSnippet snippet)
 {
     return(snippet switch
     {
         OcrTextSnippet _ => OcrSnippetsKey,
         TextSnippet _ => TextSnippetsKey,
         FileSnippet _ => FileSnippetsKey,
         _ => ""
     });
Beispiel #2
0
        public void RemoveSnippet(object sender, AbstractSnippet snippet)
        {
            if (Snippets.Remove(snippet))
            {
                AppSettings.PutAndSave(GetKey(snippet), Snippets);

                // Notify listeners that a snippet was removed
                Listeners.ForEach(listener => listener.SnippetRemoved(sender, this, snippet));
            }
        }
Beispiel #3
0
        public bool AddSnippet(object sender, AbstractSnippet snippet)
        {
            // Prevents duplicate sources
            if (Snippets.Contains(snippet))
            {
                return(false);
            }

            Snippets.Add(snippet);

            // Update settings to include newly added snippet
            var snippetsOfType = Snippets.Where(s => s.GetType() == snippet.GetType());

            AppSettings.PutAndSave(GetKey(snippet), snippetsOfType);

            // Notify listeners that a new snippet was added
            Listeners.ForEach(listener => listener.SnippetAdded(sender, this, snippet));

            return(true);
        }
Beispiel #4
0
 public SnippetQueryResult(AbstractSnippet snippet) : base(snippet.Identifier, snippet.FilePath)
 {
     _snippet = snippet;
 }