Exemplo n.º 1
0
 /// <summary>
 /// Dialog zum bearbeiten einer bestehenden Kategorie
 /// </summary>
 /// <param name="category"></param>
 public CategoryDialog(Category category)
 {
     InitializeComponent();
     RegisterForEvents();
     _selectedCategory = category;
     Title = CategoryDialogRes.EditTitle;
     CategoryTextBox.Text = category.Name;
     UpdateButtonState();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Löscht eine bestehende Kategorie und deren Links
        /// </summary>
        /// <param name="category"></param>
        public static void DeleteCategory(Category category)
        {
            var result = MessageBox.Show(CommonText.CategoryDeleteQuestion, CommonText.CategoryDeleteTitle,MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
                return;

            var categoryLinks = DataStore.Instance.Links.Where(li => li.Category.Id.Equals(category.Id)).ToList();
            DataStore.Instance.OnLinksDeleted(categoryLinks);

            if (DataStore.Instance.Categories.Any(cat => cat.Guid.Equals(category.Guid)))
                DataStore.Instance.OnCategoriesDeleted(category.WrapInList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Erstellt das Kontextmenü für Kategorien
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public ContextMenu BuildCategoryContextMenu(Category category)
        {
            var cm = new ContextMenu();
            cm.HasDropShadow = true;

            var addLink = new MenuItem();
            addLink.Header = CommonText.AddLink;
            addLink.Click += (o, e) => CommandStore.OpenAddLinkDialog(category);
            cm.Items.Add(addLink);

            cm.Items.Add(new Separator());

            var edit = new MenuItem();
            edit.Header = CommonText.Edit;
            edit.Click += (o, e) => CommandStore.OpenEditCategoryDialog(category);
            cm.Items.Add(edit);

            var delete = new MenuItem();
            delete.Header = CommonText.Delete;
            delete.Click += (o, e) => CommandStore.DeleteCategory(category);
            cm.Items.Add(delete);

            cm.Items.Add(new Separator());

            var expandAll = new MenuItem();
            expandAll.Header = CommonText.ExpandAll;
            expandAll.Click += (o, e) => CommandStore.ExpandAllCategories(true);
            cm.Items.Add(expandAll);

            var collapseAll = new MenuItem();
            collapseAll.Header = CommonText.CollapseAll;
            collapseAll.Click += (o, e) => CommandStore.ExpandAllCategories(false);
            cm.Items.Add(collapseAll);

            return cm;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Ändert eine bestehende Kategorie
 /// </summary>
 /// <param name="category"></param>
 public static void EditCategory(Category category)
 {
     if (DataStore.Instance.Categories.Any(cat => cat.Guid.Equals(category.Guid)))
         DataStore.Instance.OnCategoriesChanged(category.WrapInList());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Fügt eine Kategorie hinzu
 /// </summary>
 /// <param name="category"></param>
 public static void AddCategory(Category category)
 {
     if (!DataStore.Instance.Categories.Any(cat => cat.Name.Equals(category.Name)))
             DataStore.Instance.OnCategoriesAdded(category.WrapInList());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Öffnet den Dialog zum Bearbeiten einer Kategorie (modal)
 /// </summary>
 /// <param name="category"></param>
 public static void OpenEditCategoryDialog(Category category)
 {
     var dialog = new CategoryDialog(category);
     dialog.ShowDialog();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Öffnet den Dialog zum Anlegen eines Links
 /// </summary>
 public static void OpenAddLinkDialog(Category category)
 {
     var dialog = new LinkDialog(category);
     dialog.ShowDialog();
 }
Exemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="category"></param>
        /// <param name="isExpanded"></param>
        private void SetCategoryViewState(Category category, bool isExpanded)
        {
            if (category.IsExpanded == isExpanded)
                return;

            category.IsExpanded = isExpanded;
            DataStore.Instance.OnCategoriesChanged(category.WrapInList());
        }
Exemplo n.º 9
0
 /// <summary>
 /// Speichert die neue Kategorie oder die Änderungen
 /// </summary>
 private void Save()
 {
     if (_selectedCategory != null && _selectedCategory.Name != CategoryTextBox.Text)
     {
         _selectedCategory.Name = CategoryTextBox.Text;
         CommandStore.EditCategory(_selectedCategory);
     }
     else
     {
         var newCategory = new Category();
         newCategory.Name = CategoryTextBox.Text;
         newCategory.IsExpanded = true;
         CommandStore.AddCategory(newCategory);
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Leerer Dialog zum Erstellen eines neuen Links
 /// </summary>
 public LinkDialog(Category category)
 {
     InitWindow();
     CategoryComboBox.SelectedValue = category.Name;
 }