Пример #1
0
        private void FormAutoNotes_FormClosing(object sender, FormClosingEventArgs e)
        {
            //store the current node expanded state for this user
            List <long> listExpandedDefNums = treeNotes.Nodes.OfType <TreeNode>()
                                              .SelectMany(x => AutoNoteL.GetNodeAndChildren(x, true))
                                              .Where(x => x.IsExpanded)
                                              .Select(x => ((Def)x.Tag).DefNum)
                                              .Where(x => x > 0).ToList();

            if (_userOdCurPref == null)
            {
                UserOdPrefs.Insert(new UserOdPref()
                {
                    UserNum     = Security.CurUser.UserNum,
                    FkeyType    = UserOdFkeyType.AutoNoteExpandedCats,
                    ValueString = string.Join(",", listExpandedDefNums)
                });
            }
            else
            {
                _userOdCurPref.ValueString = string.Join(",", listExpandedDefNums);
                UserOdPrefs.Update(_userOdCurPref);
            }
        }
Пример #2
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.AutoNoteQuickNoteEdit))
            {
                return;
            }
            long selectedDefNum = 0;

            if (treeNotes.SelectedNode?.Tag is Def)
            {
                selectedDefNum = ((Def)treeNotes.SelectedNode.Tag).DefNum;
            }
            else if (treeNotes.SelectedNode?.Tag is AutoNote)
            {
                selectedDefNum = ((AutoNote)treeNotes.SelectedNode.Tag).Category;
            }
            FormAutoNoteEdit FormA = new FormAutoNoteEdit();

            FormA.IsNew       = true;
            FormA.AutoNoteCur = new AutoNote()
            {
                Category = selectedDefNum
            };
            FormA.ShowDialog();
            if (FormA.DialogResult != DialogResult.OK)
            {
                return;
            }
            treeNotes.SelectedNode?.Expand();              //expanding an AutoNote has no effect, and if nothing selected nothing to expand
            AutoNoteL.FillListTree(treeNotes, _userOdCurPref);
            if ((FormA.AutoNoteCur?.AutoNoteNum ?? 0) > 0) //select the newly added note in the tree
            {
                treeNotes.SelectedNode = treeNotes.Nodes.OfType <TreeNode>().SelectMany(x => AutoNoteL.GetNodeAndChildren(x)).Where(x => x.Tag is AutoNote)
                                         .FirstOrDefault(x => ((AutoNote)x.Tag).AutoNoteNum == FormA.AutoNoteCur.AutoNoteNum);
                treeNotes.SelectedNode?.EnsureVisible();
                treeNotes.Focus();
            }
        }