Пример #1
0
        public override void AddChildEntry()
        {
            TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter;

            if (CurrTabIndex == -1 || parentIter.Equals(TreeIter.Zero))
            {
                return;
            }

            ComboBox cbTyp = new ComboBox(API_Contract.CategorieTextTypChildVal);

            cbTyp.Active = 0;             // Text is default
            Entry textEntry = new Entry();

            GetUserArgs[] args =
            {
                new GetUserArgs(new Label("Typ"),  cbTyp),
                new GetUserArgs(new Label("Text"), textEntry),
            };
            var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abburch", 1);

            if (diag.Run() == 0 && AssertNotEmpty(diag, textEntry))
            {
                var      treeContent = CurrTreeStore;
                string   text        = textEntry.Text;
                string   typString   = GtkHelper.ComboBoxActiveString(cbTyp);
                int      typ         = API_Contract.CategorieTextChildTypCR[typString];
                int      row;
                TreeIter firstIt;                 // Get row
                if (treeContent.IterChildren(out firstIt, parentIter))
                {
                    var lastIt = GtkHelper.GetLastIter(treeContent, firstIt);
                    row  = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang));
                    row += 1;
                }
                else
                {
                    row = 0;
                }
                // Save on UI
                treeContent.AppendValues(parentIter, row, typString, text);
                // Save on Database
                var titelName = (string)treeContent.GetValue(parentIter, (int)CategorieColumnID.Text);
                var insert    = new Table_Kategorie_Tab_Text(tabNames[CurrTabIndex],
                                                             titelName, text, typ, row);
                dbAdapter.InsertEntry(insert);
            }
            // Free memory
            diag.Destroy();
            foreach (var arg in args)
            {
                arg.Dispose();
            }
        }
Пример #2
0
        public override void AddParentEntry()
        {
            if (CurrTabIndex == -1)
            {
                return;
            }

            Entry nameEntry = new Entry();
            var   cbTyp     = new ComboBox(API_Contract.CategorieTextTypParentVal);

            cbTyp.Active = 0;
            GetUserArgs[] args =
            {
                new GetUserArgs(new Label("Titel"), nameEntry),
                new GetUserArgs(new Label("Typ"),   cbTyp),
            };
            var diag = new GetUserDataDialog(args, null, "Speichern", 0, "Abbrechen", 1);

            if (diag.Run() == 0 && AssertNotEmpty(diag, nameEntry))
            {
                var      treeContent = CurrTreeStore;
                string   text        = nameEntry.Text;
                string   typString   = GtkHelper.ComboBoxActiveString(cbTyp);
                int      typ         = API_Contract.CategorieTextParentTypCR[typString];
                int      row;
                TreeIter firstIt;
                if (treeContent.GetIterFirst(out firstIt))                   // Has childs
                {
                    var lastIt = GtkHelper.GetLastIter(treeContent, firstIt);
                    row  = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang));
                    row += 1;
                }
                else                     // Is empty
                {
                    row = 0;
                }
                // Save on UI
                treeContent.AppendValues(row, typString, text);
                // Save in Database
                var insert = new Table_Kategorie_Tab_Titel(tabNames[CurrTabIndex],
                                                           text, typ, row);
                dbAdapter.InsertEntry(insert);
            }
            // Free memory
            diag.Destroy();
            foreach (var arg in args)
            {
                arg.Dispose();
            }
        }