Пример #1
0
        public void NewCategory(object o, EventArgs e)
        {
            SnippetCategory s = new SnippetCategory();

            s.Name = "New Category";
            SnippetCategories.Add(s);
        }
Пример #2
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);
            }
        }
Пример #3
0
        public void DeleteCategory(object o, EventArgs e)
        {
            ContextMenu     cm = (ContextMenu)ItemsControl.ItemsControlFromItemContainer(o as MenuItem);
            TabItem         t  = (TabItem)cm.PlacementTarget;
            SnippetCategory s  = (SnippetCategory)t.DataContext;

            if (MessageBox.Show("Are you sure you want to delete the category " + s.Name + " and all associated snippets?", "Delete Category?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                SnippetCategories.Remove(s);
                WriteValues();
            }
        }
Пример #4
0
        public void MoveCategoryUp(object o, EventArgs e)
        {
            ContextMenu     cm = (ContextMenu)ItemsControl.ItemsControlFromItemContainer(o as MenuItem);
            TabItem         t  = (TabItem)cm.PlacementTarget;
            SnippetCategory s  = (SnippetCategory)t.DataContext;

            int index = SnippetCategories.IndexOf(s);

            if (index > 0)
            {
                SnippetCategories.Move(index, index - 1);
            }
        }