Example #1
0
        private void CatEdit_Clicked(object?sender, EventArgs e)
        {
            var cat = GtkHelper.GetSelectedValue <Category?>(this.LvCategories, 3);

            if (cat.HasValue)
            {
                using var dlg = CategoryEditDialog.CreateFromGladeFile(this, this.group);
                dlg.SetCategory(cat.Value);
                dlg.Run();
                dlg.Destroy();
                if (dlg.Result)
                {
                    var cat1 = new Category
                    {
                        Name           = cat.Value.Name,
                        DisplayName    = dlg.DisplayName !,
                        DefaultFolder  = dlg.Folder !,
                        FileExtensions = new HashSet <string>(dlg.FileTypes !.Replace("\r\n", "")
                                                              .Split(',').Select(x => x.Trim()).Where(x => x.Length > 0))
                    };
                    if (LvCategories.Selection.GetSelected(out var iter))
                    {
                        categoryStore.SetValues(iter, cat1.DisplayName, string.Join(",", cat1.FileExtensions), cat1.DefaultFolder, cat1);
                    }
                }
            }
        }
Example #2
0
 private void CatAdd_Clicked(object?sender, EventArgs e)
 {
     using var dlg = CategoryEditDialog.CreateFromGladeFile(this, this.group);
     dlg.Run();
     dlg.Destroy();
     if (dlg.Result)
     {
         var cat = new Category
         {
             Name           = Guid.NewGuid().ToString(),
             DisplayName    = dlg.DisplayName !,
             DefaultFolder  = dlg.Folder !,
             FileExtensions = new HashSet <string>(dlg.FileTypes !.Replace("\r\n", "")
                                                   .Split(',').Select(x => x.Trim()).Where(x => x.Length > 0))
         };
         categoryStore.AppendValues(cat.DisplayName, string.Join(",", cat.FileExtensions), cat.DefaultFolder, cat);
     }
 }