示例#1
0
        private bool uncheckThis()
        {
            // check if any other entry is checked instead?
            if (ParentEntry != null)
            {
                var siblings = ParentEntry.GetChildEntryList();
                if (siblings != null)
                {
                    foreach (var sibling in siblings)
                    {
                        if (
                            sibling != null &&
                            sibling != this &&
                            sibling is DialogEntry &&
                            ((DialogEntry)sibling).Type == DialogEntryType.RadioButton &&
                            ((DialogEntry)sibling).Status.HasFlag(DialogEntryStatus.Checked)
                            )
                        { // one other sibling was found that is checked, .. so we can uncheck this
                            _status &= ~DialogEntryStatus.Checked;
                            _status |= DialogEntryStatus.Unchecked;
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditField_DialogEntry"/> class.
        /// </summary>
        /// <param name="ID">The identifier.</param>
        /// <param name="text">The text.</param>
        /// <param name="inputM">The input m.</param>
        /// <param name="eventM">The event m.</param>
        /// <param name="validator">The validator.</param>
        /// <param name="help">The help.</param>
        /// <param name="parentEntry">The parent entry.</param>
        /// <param name="parentDialog">The parent dialog.</param>
        /// <param name="status">The status.</param>
        /// <param name="minimizeType">Type of the minimize.</param>
        /// <param name="boxHeightType">Type of the box height.</param>
        public EditField_DialogEntry(
            string ID,
            string text,
            IEditField_InputManager inputM,
            IEditField_EventManager eventM,
            IEditField_Validator validator,
            string help                  = "...",
            DialogEntry parentEntry      = null,
            Dialog parentDialog          = null,
            DialogEntryStatus status     = DialogEntryStatus.Unknown,
            MinimizeTypes minimizeType   = MinimizeTypes.Unknown,
            BoxHeightTypes boxHeightType = BoxHeightTypes.Unknown,
            Boolean isGraphical          = true
            )
            : base(ID, text, help, DialogEntryType.EditField, status, parentEntry, parentDialog)
        {
            InputManager = inputM;

            InputBox = new EditField_InputBox(minimizeType, boxHeightType, isGraphical);

            EventManager = eventM;

            if (!validateForSpaces(Title))
            {
                Title = "";
            }

            Validator = validator;
        }
示例#3
0
        private void checkThis()
        {
            _status &= ~DialogEntryStatus.Unchecked;
            _status |= DialogEntryStatus.Checked;

            // TODO:
            //  -   disable the others in this group [✓]
            //  -   or dialog [?] --> RadieoButtons must be within a group!
            if (ParentEntry != null)
            {
                var siblings = ParentEntry.GetChildEntryList();
                if (siblings != null)
                {
                    foreach (var sibling in siblings)
                    {
                        if (sibling != null &&
                            sibling != this &&
                            sibling is DialogEntry &&
                            ((DialogEntry)sibling).Type == DialogEntryType.RadioButton)
                        {
                            ((DialogEntry)sibling).Status |= DialogEntryStatus.Unchecked;
                        }
                    }
                }
            }
        }
示例#4
0
            void entry_DialogEntryChanged(object sender, EntryEventArgs e)
            {
                if (callback != null && e != null && e.Entry != null)
                {
                    try
                    {
                        DialogEntryStatus status = e.Entry.Status;
                        if (status != lastStatus)
                        {
                            if (status.HasFlag(DialogEntryStatus.Disabled))
                            {
                                return;
                            }

                            // activation
                            if (status.HasFlag(DialogEntryStatus.Activated) && !lastStatus.HasFlag(DialogEntryStatus.Activated))
                            {
                                callback(e.Entry);
                            }
                            // checked
                            else if (status.HasFlag(DialogEntryStatus.Checked) && !lastStatus.HasFlag(DialogEntryStatus.Checked))
                            {
                                callback(e.Entry);
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
示例#5
0
        /// <summary>
        /// Searches for all child in the entries and child entries of
        /// an entry for entries with the given status.
        /// </summary>
        /// <param name="statusFlag">The status flag to search for.</param>
        /// <returns>All entries having set this flag or <c>null</c>.</returns>
        public List <DialogEntry> GetAllChildElementsByStatus(DialogEntryStatus statusFlag)
        {
            List <DialogEntry> children = new List <DialogEntry>();

            if (HasChildren())
            {
                {
                    lock (SyncLock)
                    {
                        try
                        {
                            foreach (var item in ChildEntries)
                            {
                                if (item != null && item is DialogEntry)
                                {
                                    if (((DialogEntry)item).Status.HasFlag(statusFlag))
                                    {
                                        children.Add(item as DialogEntry);
                                    }

                                    // child handling
                                    // if this element is another group etc ...
                                    if (((DialogEntry)item).HasChildren())
                                    {
                                        children.AddRange(((DialogEntry)item).GetAllChildElementsByStatus(statusFlag));
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
            return(children);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditField_DialogEntry" /> class.
        /// </summary>
        /// <param name="ID">The identifier.</param>
        /// <param name="text">The text.</param>
        /// <param name="help">The help.</param>
        /// <param name="parentEntry">The parent entry.</param>
        /// <param name="parentDialog">The parent dialog.</param>
        /// <param name="status">The status.</param>
        /// <param name="minimizeType">Type of the minimize.</param>
        /// <param name="boxHeightType">Type of the box height.</param>
        /// <param name="maxTextLength">Maximum length of the text.</param>
        /// <param name="characterRestriction">The character restriction.</param>
        /// <param name="directValidation">if set to <c>true</c> field will be validated directly. if <c>false</c> only when saved. Manual validation is needed!.</param>
        public EditField_DialogEntry(
            string ID,
            string text,
            string help                  = "...",
            DialogEntry parentEntry      = null,
            Dialog parentDialog          = null,
            DialogEntryStatus status     = DialogEntryStatus.Unknown,
            MinimizeTypes minimizeType   = MinimizeTypes.Unknown,
            BoxHeightTypes boxHeightType = BoxHeightTypes.Unknown,
            Boolean isGraphical          = true,
            int maxTextLength            = 20,
            InputRestrictionTypes characterRestriction = InputRestrictionTypes.Unrestricted,
            Boolean directValidation = true
            )
            : base(ID, text, help, DialogEntryType.EditField, status, parentEntry, parentDialog)
        {
            InputBox = new EditField_InputBox(minimizeType, boxHeightType, isGraphical);

            EventManager = new EditField_EventManager();

            if (!validateForSpaces(Title))
            {
                Title = "";
            }
            InputManager = new EditField_InputManager(Title);

            Validator = new EditField_Validator(maxTextLength, characterRestriction, directValidation);
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioButton_DialogEntry" /> class.
 /// </summary>
 /// <param name="ID">The unique identifier.</param>
 /// <param name="text">The text that is displayed.</param>
 /// <param name="help">The help text explaining the functionality behind this entry.</param>
 /// <param name="status">The status of the Radiobutton (should be DialogEntryStatus.Checked or DialogEntryStatus.Unchecked).</param>
 /// <param name="parentDialog">The parent dialog this entry is related to. Can be <c>null</c> - when added to a Dialog this Field will be set automatically.</param>
 /// <param name="parentEntry">The parent entry (must be some kind of group type).</param>
 public RadioButton_DialogEntry(
     string ID,
     string text,
     string help = "...",
     DialogEntryStatus status = DialogEntryStatus.Unchecked,
     DialogEntry parentEntry  = null,
     Dialog parentDialog      = null)
     : base(ID, text, help, DialogEntryType.RadioButton, status, parentEntry, parentDialog)
 {
     Status = status;
 }
        /// <summary>
        /// Searches for a child in the entries and child entries of
        /// an entry for an entry with the given status.
        /// </summary>
        /// <param name="statusFlag">The status flag to search for.</param>
        /// <returns>The first entry having set this flag or <c>null</c>.</returns>
        protected DialogEntry getChildElementByStatus(DialogEntryStatus statusFlag)
        {
            // TODO: handle children of groups ...

            if (HasChildren())
            {
                {
                    lock (SyncLock)
                    {
                        try
                        {
                            foreach (var item in ChildEntries)
                            {
                                if (item != null && item is DialogEntry)
                                {
                                    if (((DialogEntry)item).Status.HasFlag(statusFlag))
                                    {
                                        return(item as DialogEntry);
                                    }

                                    // child handling
                                    // if this element is another group etc ...
                                    if (((DialogEntry)item).Type == DialogEntryType.Group)
                                    {
                                        if (item is Group_DialogEntry)
                                        {
                                            return(((Group_DialogEntry)item).GetActiveGroupEntry());
                                        }
                                        else
                                        {
                                            foreach (var childItem in ((DialogEntry)item).GetChildEntryList())
                                            {
                                                if (childItem != null &&
                                                    childItem is DialogEntry &&
                                                    ((DialogEntry)childItem).Status.HasFlag(statusFlag))
                                                {
                                                    return(childItem as DialogEntry);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DialogEntry" /> class.
        /// </summary>
        /// <param name="ID">The unique identifier.</param>
        /// <param name="text">The text that is displayed.</param>
        /// <param name="help">The help text explaining the functionality behind this entry.</param>
        /// <param name="type">The type defining its behavior.</param>
        /// <param name="status">The initial status.</param>
        /// <param name="parentEntry">The parent entry (must be some kind of group type).</param>
        /// <param name="parentDialog">The parent dialog this entry is related to. Can be <c>null</c> - when added to a Dialog this Field will be set automatically.</param>
        public SelfRenderingDialogEntry(
            string ID,
            string text,
            string help              = "...",
            DialogEntryType type     = DialogEntryType.Activation,
            DialogEntryStatus status = DialogEntryStatus.Normal,
            DialogEntry parentEntry  = null,
            Dialog parentDialog      = null)
            : base(ID, text, help, type, status, parentEntry, parentDialog)
        {
            Renderer.Entry = this;

            if (type == DialogEntryType.EditField)
            {
                Renderer = new EditFieldRenderer();
            }
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DialogEntry" /> class.
 /// </summary>
 /// <param name="ID">The unique identifier.</param>
 /// <param name="text">The text that is displayed.</param>
 /// <param name="help">The help text explaining the functionality behind this entry.</param>
 /// <param name="type">The type defining its behavior.</param>
 /// <param name="status">The initial status.</param>
 /// <param name="parentEntry">The parent entry (must be some kind of group type).</param>
 /// <param name="parentDialog">The parent dialog this entry is related to. Can be <c>null</c> - when added to a Dialog this Field will be set automatically.</param>
 public DialogEntry(
     string ID,
     string text,
     string help              = "...",
     DialogEntryType type     = DialogEntryType.Activation,
     DialogEntryStatus status = DialogEntryStatus.Normal,
     DialogEntry parentEntry  = null,
     Dialog parentDialog      = null)
 {
     this._id          = ID;
     this._title       = text;
     this._help        = help;
     this.ParentEntry  = parentEntry;
     this.ParentDialog = parentDialog;
     this.Type         = type;
     this.Status       = status;
 }
示例#11
0
 /// <summary>
 /// Handles the minimization. Depending on new and current status.
 /// </summary>
 /// <param name="oldStatus">The old status.</param>
 /// <param name="newStatus">The new status.</param>
 internal void handleMinimization(DialogEntryStatus oldStatus, DialogEntryStatus newStatus)
 {
     if (oldStatus != null && newStatus != null && MinimizeType != null && IsMinimized != null)
     {
         if (MinimizeType == MinimizeTypes.AutoSelectionMinimize)
         {
             //Not selected, will be selected
             if (!oldStatus.HasFlag(DialogEntryStatus.Selected) && newStatus.HasFlag(DialogEntryStatus.Selected))
             {
                 if (MinimizeType == MinimizeTypes.AutoSelectionMinimize && IsMinimized)
                 {
                     IsMinimized = false;
                 }
             }
             //Selected, will be unselected
             else if (oldStatus.HasFlag(DialogEntryStatus.Selected) && !newStatus.HasFlag(DialogEntryStatus.Selected))
             {
                 if (MinimizeType != MinimizeTypes.NeverMinimize && !IsMinimized)
                 {
                     IsMinimized = true;
                 }
             }
         }
         else if (MinimizeType == MinimizeTypes.AutoActivationMinimize)
         {
             //Not editing, will be editing
             if (!oldStatus.HasFlag(DialogEntryStatus.Editing) && newStatus.HasFlag(DialogEntryStatus.Editing))
             {
                 if (MinimizeType == MinimizeTypes.AutoActivationMinimize && IsMinimized)
                 {
                     IsMinimized = false;
                 }
             }
             //Editing, will be not editing
             else if (oldStatus.HasFlag(DialogEntryStatus.Editing) && !newStatus.HasFlag(DialogEntryStatus.Editing))
             {
                 if (MinimizeType == MinimizeTypes.AutoActivationMinimize && !IsMinimized)
                 {
                     IsMinimized = true;
                 }
             }
         }
     }
 }
 /*Seperate function to handle mode changes depending on prior and current status: Abort, Start, Finish*/
 private void handleModeChanges(DialogEntryStatus status)
 {
     if (Status != null && status != null && InputBox != null && InputBox.BoxHeightType != null && InputBox.BoxHeightType != BoxHeightTypes.Unknown)
     {
         if (!Status.HasFlag(DialogEntryStatus.Editing) && status.HasFlag(DialogEntryStatus.Selected) && status.HasFlag(DialogEntryStatus.Editing))
         {
             modeInput(ModeTypes.Start);
         }
         else if (status.HasFlag(DialogEntryStatus.Aborting))
         {
             modeInput(ModeTypes.Abort);
         }
         else if (Status.HasFlag(DialogEntryStatus.Editing) && Status.HasFlag(DialogEntryStatus.Selected) && !status.HasFlag(DialogEntryStatus.Selected) && !status.HasFlag(DialogEntryStatus.Editing))
         {
             modeInput(ModeTypes.Abort);
         }
         else if (Status.HasFlag(DialogEntryStatus.Editing) && Status.HasFlag(DialogEntryStatus.Selected) && status.HasFlag(DialogEntryStatus.Selected) && !status.HasFlag(DialogEntryStatus.Editing))
         {
             modeInput(ModeTypes.Finish);
         }
     }
 }
示例#13
0
        /// <summary>
        /// Searches for a child in the entries and child entries of
        /// an entry for an entry with the given status.
        /// </summary>
        /// <param name="statusFlag">The status flag to search for.</param>
        /// <returns>The first entry having set this flag or <c>null</c>.</returns>
        public DialogEntry GetFirstChildElementByStatus(DialogEntryStatus statusFlag)
        {
            if (HasChildren())
            {
                {
                    lock (SyncLock)
                    {
                        try
                        {
                            foreach (var item in ChildEntries)
                            {
                                if (item != null && item is DialogEntry)
                                {
                                    if (((DialogEntry)item).Status.HasFlag(statusFlag))
                                    {
                                        return(item as DialogEntry);
                                    }

                                    // child handling
                                    // if this element is another group etc ...
                                    if (((DialogEntry)item).HasChildren())
                                    {
                                        var child = ((DialogEntry)item).GetFirstChildElementByStatus(statusFlag);
                                        if (child != null)
                                        {
                                            return(child);
                                        }
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }
            }
            return(null);
        }
示例#14
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);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DialogEntry_ToolStripMenuItem"/> class.
        /// </summary>
        /// <param name="dlgEntry">The dialog entry.</param>
        public DialogEntry_ToolStripMenuItem(DialogEntry dlgEntry) : base(dlgEntry)
        {
            Type = dlgEntry.Type;
            this.CheckOnClick = true;

            //Check for Types & Status, some coloring to differentiate between types for now

            switch (Type)
            {
            case DialogEntryType.Activation:
                break;

            case DialogEntryType.Button:
                this.Text         = "btn:: " + this.Text;
                this.CheckOnClick = false;
                break;

            case DialogEntryType.Checkbox:
                this.Text = "[] " + this.Text;
                break;

            case DialogEntryType.EditField:

                EditField_DialogEntry efield = (EditField_DialogEntry)dlgEntry;
                if (efield.HasLabel)
                {
                    if (efield.InputBox != null && !efield.InputBox.IsGraphical)
                    {
                        this.Text = efield.Label + this.Text;
                    }
                    else
                    {
                        this.Text = "ef:: " + efield.Label + this.Text;
                    }
                }
                else
                {
                    this.Text = "ef:: " + this.Text;
                }
                this.CheckOnClick = false;
                this.Enabled      = false;

                break;

            case DialogEntryType.Group:
                this.CheckOnClick = false;
                this.Font         = new System.Drawing.Font(this.Font, System.Drawing.FontStyle.Bold);
                break;

            case DialogEntryType.EditField_Label:
                this.CheckOnClick = false;
                this.Enabled      = false;
                this.Font         = new System.Drawing.Font(this.Font, System.Drawing.FontStyle.Italic);
                break;

            case DialogEntryType.Label:
                this.CheckOnClick = false;
                this.Enabled      = false;
                break;

            case DialogEntryType.RadioButton:
                this.Text = "() " + this.Text;
                break;

            case DialogEntryType.Unknown:
                break;

            default: break;
            }

            DialogEntryStatus itemStatus = dlgEntry.Status;

            if (itemStatus.HasFlag(DialogEntryStatus.Checked))
            {
                this.Checked = true;
            }

            if (itemStatus.HasFlag(DialogEntryStatus.Disabled))
            {
                this.Enabled = false;
                this.Text    = "xx" + this.Text;
            }

            dlgEntry.DialogEntryChanged += d_EntryChanged;
        }