CheckBox control

Feb 8, 2013 at 9:21 AM
Hi there,

First of all, thanks for the great work on this project !

I have noticed that the CheckBox control has not been implemented in the FluentRibbon API. Is it on the agenda ? Could you give me some advice as for implementing this ?

Thanks again,
Kind regards
Feb 8, 2013 at 10:16 AM
I've coded it myslef, here's the code:

CheckBoxDefinition.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace FluentRibbon.Definitions.Controls
{
    /// <summary>
    /// Simple button. Does not have inner controls.
    /// </summary>
    public class CheckBoxDefinition : ControlDefinition
    {
        internal override string Tag
        {
            get { return "CheckBox"; }
        }


        internal override void AddAttributes(XElement controlElement)
        {
            base.AddAttributes(controlElement);

            controlElement.Add(new XAttribute("LabelText", this.Title));

            if (this.ToolTip != null && !String.IsNullOrEmpty(this.ToolTip.Title))
            {
                controlElement.Add(new XAttribute("ToolTipTitle", this.ToolTip.Title));
                controlElement.Add(new XAttribute("ToolTipDescription", this.ToolTip.Description));
                controlElement.Add(new XAttribute("ToolTipHelpKeyWord", this.ToolTip.HelpKeyWord));
                controlElement.Add(new XAttribute("ToolTipShortcutKey", this.ToolTip.ShortcutKey));
            }

            if (!String.IsNullOrEmpty(this.CommandJavaScript) && controlElement.Attribute("Command") == null)
                controlElement.Add(new XAttribute("Command", this.FullId + "Command"));

        }

        internal override void Validate()
        {
            base.Validate();
            ValidationHelper.Current.CheckNotNull(this, "Title");
        }

        /// <summary>
        /// Displayable title for control. Required.
        /// </summary>
        public string Title;

        /// <summary>
        /// Control description
        /// </summary>
        [Obsolete("Description is dummy property, which never gets displayed. Use Tooltip.Description instead.")]
        public string Description = string.Empty;

        /// <summary>
        /// ToolTip
        /// </summary>
        public ToolTipDefinition ToolTip;

        /// <summary>
        /// Javascript will be run when button is pressed.
        /// Required for all types of buttons.
        /// By default, button does nothing.
        /// </summary>
        public string CommandJavaScript = string.Empty;

        /// <summary>
        /// Javascript to determine, if control is enabled or disabled.
        /// By default it is "true" (button is always enabled).
        /// </summary>
        public string CommandEnableJavaScript = "true";

    }
}
Coordinator
Feb 8, 2013 at 11:17 AM
Edited Feb 8, 2013 at 11:18 AM
Hi kwn34,

I'm sure it was on schedule, but it seems I forgot about it while implemented some other controls :)
Thus thank you very much for your contribution!

I will include the code into FluentRibbon API, test it, create some examples, update the documentation and then you'll be able to download the modified version from the 1.5 planning release page.
But I'm afraid this might take some time, so please use your code for a while.

Thanks again and good luck with your projects!
Feb 8, 2013 at 12:23 PM
Hi.

Thanks for the great work!!!
I need to use checkbox control, so I will implement code and send feedback (maybe) today later.

Thanks again.
Feb 8, 2013 at 1:46 PM
Hi.
My check box is disabled :(
Did I miss something?


My code:

new GroupDefinition()
                    {
                        Id = "OptionControlGroup",
                        Title = "Option",
                        Template = GroupTemplateLibrary.ThreeRowTemplate,
                        Controls = new ControlDefinition[]
                        {
                            new CheckBoxDefinition()
                            {
                                Id = "ChBox",
                                Title = "Checkbox1",                                    
                                CommandJavaScript = "alert('test')"
                            }
                        }

                    }
Feb 8, 2013 at 2:04 PM
Hi,
I'm currently experiencing the same issue on my checkbox control. I'm trying to make it work, but no luck for the moment. I'll keep you posted