Beispiel #1
0
        public void DoGridDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                // create a new category
                SnippetCategory sc = new SnippetCategory();
                sc.Name = "New Category";
                SnippetCategories.Add(sc);

                string Text = (string)e.Data.GetData(DataFormats.Text);
                sc.AddSnippet("New Snippet", "", Text);

                TabItem ti = (TabItem)SnippetCategoriesTabControl.ItemContainerGenerator.ContainerFromItem(sc);
                if (ti != null)
                {
                    ti.IsSelected = true;
                }

                // write the xaml file
                WriteValues();

                // don't allow drops here anymore
                MainGrid.AllowDrop = false;
                MainGrid.Drop     -= new DragEventHandler(DoGridDrop);
            }
        }
Beispiel #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;
            }
        }
Beispiel #3
0
        public void DoGridDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                // create a new category
                SnippetCategory sc = new SnippetCategory();
                sc.Name = "New Category";
                SnippetCategories.Add(sc);

                string Text = (string)e.Data.GetData(DataFormats.Text);
                sc.AddSnippet("New Snippet", "", Text);

                TabItem ti = (TabItem)SnippetCategoriesTabControl.ItemContainerGenerator.ContainerFromItem(sc);
                if (ti != null) ti.IsSelected = true;

                // write the xaml file
                WriteValues();

                // don't allow drops here anymore
                MainGrid.AllowDrop = false;
                MainGrid.Drop -= new DragEventHandler(DoGridDrop);
            }
        }