Esempio n. 1
0
        public void RenameSnippet(object o, EventArgs e)
        {
            ContextMenu cm  = (ContextMenu)ItemsControl.ItemsControlFromItemContainer(o as MenuItem);
            ListBoxItem lbi = (ListBoxItem)cm.PlacementTarget;
            Snippet     s   = (Snippet)lbi.DataContext;

            if (SnippetHidden == null)
            {
                SnippetHidden = DoSnippetHidden;
            }
            _TextBoxOverlay.Hidden += SnippetHidden;

            // HACK: i'm handling the offset here rather than in the style
            _TextBoxOverlay.Show((lbi as FrameworkElement), new Rect(new Point(14, 0), new Size(lbi.ActualWidth - 14, lbi.ActualHeight)), s.Name);

            WriteValues();
        }
Esempio n. 2
0
        public void DoDrop(object o, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(Snippet)))
            {
                SnippetCategory sc = (SnippetCategory)(o as FrameworkElement).DataContext;
                Snippet         s  = (Snippet)(e.Data.GetData(typeof(Snippet)));

                // make sure we're not dragging into the same category
                if (s.Category == sc)
                {
                    return;
                }

                // otherwise, consider this a move so remove from the previous category
                // and add to the new one

                // remove from old category
                s.Category.Snippets.Remove(s);

                // add to the new one
                sc.Snippets.Add(s);

                // update the category
                s.Category = sc;

                // save the changes
                WriteValues();
            }
            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                string          Text = (string)e.Data.GetData(DataFormats.Text);
                SnippetCategory sc   = (SnippetCategory)(o as FrameworkElement).DataContext;
                sc.AddSnippet("New Snippet", "", Text);

                // write the xaml file
                WriteValues();
            }

            // if the drop target is a TabItem, then expand it
            if (o.GetType() == typeof(TabItem))
            {
                TabItem ti = (TabItem)o;
                ti.IsSelected = true;
            }
        }
Esempio n. 3
0
        public void AddSnippet(string name, string shortcut, string text)
        {
            Snippet s = new Snippet(name, shortcut, text, this);

            Snippets.Add(s);
        }
Esempio n. 4
0
 public SnippetCompletionData(string description, string text, Snippet snippet)
 {
     _Description = description;
     _Text        = text;
     _Snippet     = snippet;
 }