Beispiel #1
0
        /// <summary>
        /// Insert a Snippet
        /// </summary>
        /// <param name="snippet"></param>
        public void InsertSnippet(YnoteSnippet snippet)
        {
#if DEBUG
            var watch = new Stopwatch();
            watch.Start();
#endif
            var selection = codebox.Selection.Clone();
            var content   = snippet.GetSubstitutedContent(this);
            codebox.InsertText(content);
            var nselection = codebox.Selection.Clone();
            for (int i = selection.Start.iLine; i <= nselection.Start.iLine; i++)
            {
                codebox.Selection.Start = new Place(0, i);
                codebox.DoAutoIndent(i);
            }
            codebox.Selection = nselection;
            if (snippet.Content.Contains('^'))
            {
                PositionCaretTo('^');
            }
#if DEBUG
            watch.Stop();
            Debug.WriteLine(watch.Elapsed + " ms InsertSnippet()");
#endif
        }
Beispiel #2
0
 /// <summary>
 ///     Loads Snippets
 /// </summary>
 private void LoadSnippets()
 {
     Globals.Snippets = new List <YnoteSnippet>();
     string[] snippets = Directory.GetFiles(GlobalSettings.SettingsDir, "*.ynotesnippet",
                                            SearchOption.AllDirectories);
     Thread.Sleep(5);
     foreach (string snippet in snippets)
     {
         YnoteSnippet snip = YnoteSnippet.Read(snippet);
         Globals.Snippets.Add(snip);
     }
 }
Beispiel #3
0
        public void InsertSnippet(YnoteSnippet snippet)
        {
            var selection = codebox.Selection.Clone();
            var content   = snippet.GetSubstitutedContent(this);

            codebox.InsertText(content);
            var nselection = codebox.Selection.Clone();

            for (int i = selection.Start.iLine; i <= nselection.Start.iLine; i++)
            {
                codebox.Selection.Start = new Place(0, i);
                codebox.DoAutoIndent(i);
            }
            codebox.Selection.Start = new Place(nselection.End.iChar, nselection.End.iLine);
            if (snippet.Content.Contains('^'))
            {
                PositionCaretTo('^');
            }
        }
Beispiel #4
0
        /// <summary>
        /// Loads Snippets
        /// </summary>
        private void LoadSnippets()
        {
#if DEBUG
            var watch = new Stopwatch();
            watch.Start();
#endif
            Globals.Snippets = new List <YnoteSnippet>();
            string[] snippets = Directory.GetFiles(GlobalSettings.SettingsDir, "*.ynotesnippet",
                                                   SearchOption.AllDirectories);
            Thread.Sleep(5);
            foreach (string snippet in snippets)
            {
                YnoteSnippet snip = YnoteSnippet.Read(snippet);
                Globals.Snippets.Add(snip);
            }
#if DEBUG
            watch.Stop();
            Debug.WriteLine(string.Format("Loaded {0} Snippets in {1} ms", Globals.Snippets.Count, watch.ElapsedMilliseconds));
#endif
        }