Esempio n. 1
0
        /// <summary>
        /// Retrieves the item at the specified flat index.
        /// </summary>
        /// <param name="index">The flat index.</param>
        /// <returns>The item or null if not found.</returns>
        public ToolbarItem FlatIndexItem(int index)
        {
            if (index >= 0)
            {
                foreach (ToolbarItem item in List)
                {
                    if (item is ToolbarCheckGroup)
                    {
                        ToolbarCheckGroup group = (ToolbarCheckGroup)item;
                        if (index < group.Items.Count)
                        {
                            // The item is within the group
                            return(group.Items[index]);
                        }
                        else
                        {
                            // The item is outside the group
                            index -= group.Items.Count;
                        }
                    }
                    else
                    {
                        index--;

                        if (index < 0)
                        {
                            return(item);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Sets the parent checkgroup when one was not initially available.
        /// </summary>
        /// <param name="parentCheckGroup"></param>
        internal void SetParent(ToolbarCheckGroup parentCheckGroup)
        {
            _Parent = parentCheckGroup;

            foreach (ToolbarCheckButton item in this)
            {
                SetItemProperties(item);
            }
        }
        /// <summary>
        /// Adjusts the selected button after inserting an item.
        /// </summary>
        /// <param name="index">The index of the item</param>
        /// <param name="value">The item inserted</param>
        protected override void OnInsertComplete(int index, object value)
        {
            base.OnInsertComplete(index, value);

            ToolbarCheckGroup group = ParentCheckGroup;

            if (!Reloading && (group != null) && ((IStateManager)this).IsTrackingViewState)
            {
                group.ResolveSelectedItems();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a copy of this instance.</returns>
        public override object Clone()
        {
            ToolbarCheckGroup copy = (ToolbarCheckGroup)base.Clone();

            copy.ButtonClick = this.ButtonClick;
            copy.CheckChange = this.CheckChange;

            copy._Items = (ToolbarCheckButtonCollection)this._Items.Clone();
            copy._Items.SetParent(copy);
            copy._HoverStyle    = (CssCollection)this._HoverStyle.Clone();
            copy._SelectedStyle = (CssCollection)this._SelectedStyle.Clone();


            return(copy);
        }
        /// <summary>
        /// Cleans up SelectedCheckButton property
        /// </summary>
        /// <param name="index">The index of the object that was removed.</param>
        /// <param name="value">The object that was removed.</param>
        protected override void OnRemoveComplete(int index, object value)
        {
            base.OnRemoveComplete(index, value);

            ToolbarCheckButton oldBtn = (ToolbarCheckButton)value;
            ToolbarCheckGroup  group  = ParentCheckGroup;

            if (!Reloading && (group != null) && oldBtn.Selected)
            {
                // The selected button was removed
                group.ResolveSelectedItems();
            }

            oldBtn.SetParentCheckGroup(null);
            oldBtn.SetParentToolbar(null);
        }
Esempio n. 6
0
        /// <summary>
        /// The "flat" index of an item.
        /// Example:
        /// Toolbar: Button1 Group1[CheckBtn1, CheckBtn2] Button2
        ///              Flat   IndexOf
        ///   Button1    0      0
        ///   Group1     -1     1
        ///   CheckBtn1  1      -1
        ///   CheckBtn2  2      -1
        ///   Button2    3      2
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int FlatIndexOf(ToolbarItem item)
        {
            if (item is ToolbarCheckGroup)
            {
                return(-1);
            }

            int index = 0;

            foreach (ToolbarItem testItem in List)
            {
                if (testItem.Equals(item))
                {
                    return(index);
                }

                if (testItem is ToolbarCheckGroup)
                {
                    ToolbarCheckGroup group = (ToolbarCheckGroup)testItem;
                    int innerIndex          = (item is ToolbarCheckButton) ? group.Items.IndexOf((ToolbarCheckButton)item) : -1;
                    if (innerIndex >= 0)
                    {
                        return(index + innerIndex);
                    }
                    else
                    {
                        index += group.Items.Count;
                    }
                }
                else
                {
                    index++;
                }
            }

            return(-1);
        }
Esempio n. 7
0
        /// <summary>
        /// Perform the bubbling necessary in firing the ButtonClick event.
        /// </summary>
        /// <param name="item">The source ToolbarItem.</param>
        private void PostButtonClickEvent(ToolbarItem item)
        {
            bool      bBubble   = true;
            EventArgs eventArgs = new EventArgs();

            if (item is ToolbarButton)
            {
                bBubble = ((ToolbarButton)item).OnButtonClick(eventArgs);
            }

            if (bBubble && (item is ToolbarCheckButton))
            {
                ToolbarCheckGroup group = ((ToolbarCheckButton)item).Group;
                if (group != null)
                {
                    bBubble = group.OnButtonClick(item, eventArgs);
                }
            }

            if (bBubble)
            {
                OnButtonClick(item, eventArgs);
            }
        }
 /// <summary>
 /// Initializes a new instance of a ToolbarCheckButtonCollection.
 /// </summary>
 /// <param name="parent">The parent Toolbar of this collection.</param>
 public ToolbarCheckButtonCollection(ToolbarCheckGroup parent) : base()
 {
     _Parent = parent;
 }
Esempio n. 9
0
        /// <summary>
        /// Raises the DataBinding event. This notifies a control to perform any data binding logic that is associated with it.
        /// </summary>
        /// <param name="e">An EventArgs object that contains the event data.</param>
        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            if (_DataSource != null)
            {
                Items.Clear();
                _ClearChildViewState = true;

                string szCurGroup = String.Empty;
                ToolbarCheckGroup group = null;

                foreach (Object dataItem in _DataSource)
                {
                    String type = null;
                    String text = null;
                    String imageUrl = null;
                    String selected = null;
                    String groupname = null;

                    if (DataTypeField != String.Empty)
                        type = DataBinder.GetPropertyValue(dataItem, DataTypeField, null);
                    if (DataTextField != String.Empty)
                        text = DataBinder.GetPropertyValue(dataItem, DataTextField, null);
                    if (DataImageUrlField != String.Empty)
                        imageUrl = DataBinder.GetPropertyValue(dataItem, DataImageUrlField, null);
                    if (DataSelectedField != String.Empty)
                        selected = DataBinder.GetPropertyValue(dataItem, DataSelectedField, null);
                    if (DataGroupnameField != String.Empty)
                        groupname = DataBinder.GetPropertyValue(dataItem, DataGroupnameField, null);

                    ToolbarItem item = MakeToolbarItem(type);

                    if (item == null)
                        continue;

                    bool bEndPrevGroup = (group != null);
                    bool bMakeNewGroup = false;

                    if (item is ToolbarCheckButton)
                    {
                        bEndPrevGroup =
                            (group != null) &&
                            ((groupname == null) || (groupname != szCurGroup));
                        bMakeNewGroup = ((groupname != null) && (groupname != szCurGroup));
                    }

                    if (bEndPrevGroup)
                    {
                        group = null;
                        szCurGroup = String.Empty;
                    }

                    if (bMakeNewGroup)
                    {
                        group = new ToolbarCheckGroup();
                        Items.Add(group);
                        szCurGroup = groupname;
                    }

                    if (group != null)
                    {
                        group.Items.Add((ToolbarCheckButton)item);
                    }
                    else
                    {
                        Items.Add(item);
                    }

                    if (item is ToolbarButton)
                    {
                        ToolbarButton btn = (ToolbarButton)item;
                        if (text != null)
                            btn.Text = text;
                        if (imageUrl != null)
                            btn.ImageUrl = imageUrl;
                    }

                    if (item is ToolbarLabel)
                    {
                        ToolbarLabel label = (ToolbarLabel)item;
                        if (text != null)
                            label.Text = text;
                        if (imageUrl != null)
                            label.ImageUrl = imageUrl;
                    }

                    if (item is ToolbarCheckButton)
                    {
                        ToolbarCheckButton btn = (ToolbarCheckButton)item;
                        if (selected != null)
                            btn.SetSelected(selected.ToLower() == "true");
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of a ToolbarCheckButtonCollection.
 /// </summary>
 /// <param name="parent">The parent Toolbar of this collection.</param>
 public ToolbarCheckButtonCollection(ToolbarCheckGroup parent)
     : base()
 {
     _Parent = parent;
 }
        /// <summary>
        /// Sets the parent checkgroup when one was not initially available.
        /// </summary>
        /// <param name="parentCheckGroup"></param>
        internal void SetParent(ToolbarCheckGroup parentCheckGroup)
        {
            _Parent = parentCheckGroup;

            foreach (ToolbarCheckButton item in this)
            {
                SetItemProperties(item);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Raises the DataBinding event. This notifies a control to perform any data binding logic that is associated with it.
        /// </summary>
        /// <param name="e">An EventArgs object that contains the event data.</param>
        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            if (_DataSource != null)
            {
                Items.Clear();
                _ClearChildViewState = true;

                string            szCurGroup = String.Empty;
                ToolbarCheckGroup group      = null;

                foreach (Object dataItem in _DataSource)
                {
                    String type      = null;
                    String text      = null;
                    String imageUrl  = null;
                    String selected  = null;
                    String groupname = null;

                    if (DataTypeField != String.Empty)
                    {
                        type = DataBinder.GetPropertyValue(dataItem, DataTypeField, null);
                    }
                    if (DataTextField != String.Empty)
                    {
                        text = DataBinder.GetPropertyValue(dataItem, DataTextField, null);
                    }
                    if (DataImageUrlField != String.Empty)
                    {
                        imageUrl = DataBinder.GetPropertyValue(dataItem, DataImageUrlField, null);
                    }
                    if (DataSelectedField != String.Empty)
                    {
                        selected = DataBinder.GetPropertyValue(dataItem, DataSelectedField, null);
                    }
                    if (DataGroupnameField != String.Empty)
                    {
                        groupname = DataBinder.GetPropertyValue(dataItem, DataGroupnameField, null);
                    }

                    ToolbarItem item = MakeToolbarItem(type);

                    if (item == null)
                    {
                        continue;
                    }

                    bool bEndPrevGroup = (group != null);
                    bool bMakeNewGroup = false;

                    if (item is ToolbarCheckButton)
                    {
                        bEndPrevGroup =
                            (group != null) &&
                            ((groupname == null) || (groupname != szCurGroup));
                        bMakeNewGroup = ((groupname != null) && (groupname != szCurGroup));
                    }

                    if (bEndPrevGroup)
                    {
                        group      = null;
                        szCurGroup = String.Empty;
                    }

                    if (bMakeNewGroup)
                    {
                        group = new ToolbarCheckGroup();
                        Items.Add(group);
                        szCurGroup = groupname;
                    }

                    if (group != null)
                    {
                        group.Items.Add((ToolbarCheckButton)item);
                    }
                    else
                    {
                        Items.Add(item);
                    }

                    if (item is ToolbarButton)
                    {
                        ToolbarButton btn = (ToolbarButton)item;
                        if (text != null)
                        {
                            btn.Text = text;
                        }
                        if (imageUrl != null)
                        {
                            btn.ImageUrl = imageUrl;
                        }
                    }

                    if (item is ToolbarLabel)
                    {
                        ToolbarLabel label = (ToolbarLabel)item;
                        if (text != null)
                        {
                            label.Text = text;
                        }
                        if (imageUrl != null)
                        {
                            label.ImageUrl = imageUrl;
                        }
                    }

                    if (item is ToolbarCheckButton)
                    {
                        ToolbarCheckButton btn = (ToolbarCheckButton)item;
                        if (selected != null)
                        {
                            btn.SetSelected(selected.ToLower() == "true");
                        }
                    }
                }
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Sets the checkgroup that this checkbutton belongs to.
 /// </summary>
 /// <param name="group">The checkgroup that this checkbutton belongs to.</param>
 internal void SetParentCheckGroup(ToolbarCheckGroup group)
 {
     _Group = group;
 }
Esempio n. 14
0
 /// <summary>
 /// Sets the checkgroup that this checkbutton belongs to.
 /// </summary>
 /// <param name="group">The checkgroup that this checkbutton belongs to.</param>
 internal void SetParentCheckGroup(ToolbarCheckGroup group)
 {
     _Group = group;
 }