示例#1
0
        /// <summary>
        /// Registers the activation callback function to a specific entry.
        /// </summary>
        /// <param name="entry">The entry to observe for activation.</param>
        /// <param name="callback">The callback function to call after activation.</param>
        /// <returns><c>true</c> if the callback could be registered; otherwise, <c>false</c>.</returns>
        public static bool RegisterActivationCallbackToEntry(DialogEntry entry, EntryActivation callback)
        {
            bool success = false;

            if (entry != null && callback != null)
            {
                _callbackForwarderList.Add(new EntryCallbackSender(entry, callback));
                return(true);
            }
            return(success);
        }
示例#2
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing,
 /// releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     // clean up references
     entry    = null;
     callback = null;
     unregisterToEvents();
     try
     {
         _callbackForwarderList.Remove(this);
     }
     catch { }
 }
示例#3
0
        /// <summary>
        /// Builds a specialized dialog entry, based on the given <see cref="DialogEntryType"/>.
        /// </summary>
        /// <param name="type">The type of the entry.</param>
        /// <param name="id">The unique identifier.
        /// If an <see cref="Dialog"/> was set, the id is checked and adapted
        /// to be unique. So check after returning the element if you are
        /// not 100% sure that the id is unique.</param>
        /// <param name="title">The title of the entry (text that is displayed).</param>
        /// <param name="help">The help text for the entry. Giving details about the function or the behavior of the entry.</param>
        /// <param name="status">The initial status of the entry.</param>
        /// <param name="parent">The parent group if exist.</param>
        /// <param name="dialog">The dialog this entry should bee added.</param>
        /// <param name="callback">The callback function to call after activation.</param>
        /// <returns>An specialized <see cref="DialogEntryType"/>.</returns>
        public static DialogEntry BuildDialogEntry(
            DialogEntryType type,
            String id,
            String title,
            String help = "...",
            DialogEntryStatus status = DialogEntryStatus.Normal,
            DialogEntry parent       = null,
            Dialog dialog            = null,
            EntryActivation callback = null
            )
        {
            DialogEntry entry = null;

            if (dialog == null && parent != null && parent.ParentDialog != null)
            {
                dialog = parent.ParentDialog;
            }

            id = check4uniqueID(id, parent, dialog);

            switch (type)
            {
            //case DialogEntryType.Unknown:
            //    break;
            //case DialogEntryType.Activation:
            //    break;
            //case DialogEntryType.Submenu:
            //    break;
            case DialogEntryType.Group:
                entry = new Group_DialogEntry(id, title, help, parent, dialog);
                break;

            //case DialogEntryType.Checkbox:
            //    break;
            case DialogEntryType.RadioButton:
                entry = new RadioButton_DialogEntry(id, title, help, status, parent, dialog);
                break;

            //case DialogEntryType.Button:
            //    break;
            //case DialogEntryType.EditField:
            //    break;
            default:
                entry = new SelfRenderingDialogEntry(id, title, help, type, status, parent, dialog);
                break;
            }

            if (entry == null)
            {
                return(null);
            }

            RegisterActivationCallbackToEntry(entry, callback);

            // parent handling
            if (parent != null)
            {
                parent.AddChild(entry);
            }

            return(entry);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntryCallbackSender"/> class.
 /// </summary>
 /// <param name="_entry">The entry to observe for activation.</param>
 /// <param name="_callback">The callback function to call after activation.</param>
 public EntryCallbackSender(DialogEntry _entry, EntryActivation _callback)
 {
     entry    = _entry;
     callback = _callback;
     registerToEvents();
 }