Ejemplo n.º 1
0
        /// <summary>
        /// Writes notes to an IHasNotes object, returns True if notes were changed and False otherwise.
        /// </summary>
        /// <param name="objNotes"></param>
        /// <param name="treNode"></param>
        public static async ValueTask <bool> WriteNotes(this IHasNotes objNotes, TreeNode treNode)
        {
            if (objNotes == null || treNode == null)
            {
                return(false);
            }
            Form frmToUse = treNode.TreeView.FindForm() ?? Program.MainForm;

            DialogResult eResult = await frmToUse.DoThreadSafeFunc(async x =>
            {
                using (EditNotes frmItemNotes = new EditNotes(objNotes.Notes, objNotes.NotesColor))
                {
                    await frmItemNotes.ShowDialogSafeAsync(x);
                    if (frmItemNotes.DialogResult != DialogResult.OK)
                    {
                        return(frmItemNotes.DialogResult);
                    }

                    objNotes.Notes      = frmItemNotes.Notes;
                    objNotes.NotesColor = frmItemNotes.NotesColor;
                }

                treNode.ForeColor   = objNotes.PreferredColor;
                treNode.ToolTipText = objNotes.Notes.WordWrap();

                return(DialogResult.OK);
            });

            return(eResult == DialogResult.OK);
        }
Ejemplo n.º 2
0
        private async void cmdNotes_Click(object sender, EventArgs e)
        {
            using (EditNotes frmContactNotes = new EditNotes(_objContact.Notes, _objContact.NotesColor))
            {
                await frmContactNotes.ShowDialogSafeAsync(this);

                if (frmContactNotes.DialogResult != DialogResult.OK)
                {
                    return;
                }
                _objContact.Notes = frmContactNotes.Notes;
            }

            string strTooltip = await LanguageManager.GetStringAsync("Tip_Contact_EditNotes");

            if (!string.IsNullOrEmpty(_objContact.Notes))
            {
                strTooltip += Environment.NewLine + Environment.NewLine + _objContact.Notes;
            }
            cmdNotes.ToolTipText = strTooltip.WordWrap();
            ContactDetailChanged?.Invoke(this, new TextEventArgs("Notes"));
        }