/// <summary>
 /// Adds a ToolbarCheckButton to the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to add.</param>
 public void Add(ToolbarCheckButton item)
 {
     if (!Contains(item))
     {
         List.Add(item);
     }
 }
 /// <summary>
 /// Adds a ToolbarCheckButton to the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to add.</param>
 public void Add(ToolbarCheckButton item)
 {
     if (!Contains(item))
     {
         List.Add(item);
     }
 }
 /// <summary>
 /// Adds a ToolbarCheckButton to the collection at a specific index.
 /// </summary>
 /// <param name="index">The index at which to add the item.</param>
 /// <param name="item">The ToolbarCheckButton to add.</param>
 public void AddAt(int index, ToolbarCheckButton item)
 {
     if (!Contains(item))
     {
         List.Insert(index, item);
     }
 }
        /// <summary>
        /// Sets item properties on being inserted.
        /// </summary>
        /// <param name="index">The index of the item being inserted.</param>
        /// <param name="value">The item being inserted.</param>
        protected override void OnInsert(int index, object value)
        {
            ToolbarCheckButton btn = (ToolbarCheckButton)value;
            IList list             = null;

            if (btn.Group != null)
            {
                list = ((ToolbarCheckButton)btn).Group.Items;
            }
            else if (btn.ParentToolbar != null)
            {
                list = btn.ParentToolbar.Items;
            }

            if (list != null)
            {
                list.Remove(btn);
            }


            if (!Reloading && ((IStateManager)this).IsTrackingViewState &&
                (ParentCheckGroup.SelectedCheckButton != null) && (btn.Selected))
            {
                ParentCheckGroup.SelectedCheckButton.SetSelected(false);
            }

            SetItemProperties(btn);

            base.OnInsert(index, value);
        }
Ejemplo n.º 5
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()
        {
            ToolbarCheckButton copy = (ToolbarCheckButton)base.Clone();

            copy.CheckChange = this.CheckChange;

            return(copy);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Processes post back data for the server control given the data from the hidden helper.
        /// </summary>
        /// <param name="szData">The data from the hidden helper</param>
        /// <returns>true if the server control's state changes as a result of the post back; otherwise false.</returns>
        protected override bool ProcessData(string szData)
        {
            if ((szData == null) || (szData == String.Empty))
            {
                return(false);
            }

            ArrayList eventList   = ParseDataString(szData);
            ArrayList changedBtns = new ArrayList();
            ArrayList oldVals     = new ArrayList();

            // Apply the changes
            foreach (string szParam in eventList)
            {
                int         flatIndex = Convert.ToInt32(szParam.Substring(1, szParam.Length - 1));
                ToolbarItem item      = Items.FlatIndexItem(flatIndex);
                if ((item != null) && (item is ToolbarCheckButton))
                {
                    ToolbarCheckButton btn = (ToolbarCheckButton)item;

                    // If the button affects other buttons, then store those values
                    if (btn.Group != null)
                    {
                        ToolbarCheckButton affectedBtn = btn.Group.SelectedCheckButton;
                        if ((affectedBtn != null) && !changedBtns.Contains(affectedBtn))
                        {
                            changedBtns.Add(affectedBtn);
                            oldVals.Add(affectedBtn.Selected);
                        }
                    }

                    // If we haven't stored the original value, then store it
                    if (!changedBtns.Contains(btn))
                    {
                        changedBtns.Add(btn);
                        oldVals.Add(btn.Selected);
                    }

                    // Apply the change (+ means selected, - means not selected)
                    btn.Selected = ((szParam.Length > 0) && (szParam[0] == '+'));
                }
            }

            // Determine which items changed
            for (int i = 0; i < changedBtns.Count; i++)
            {
                ToolbarCheckButton btn = (ToolbarCheckButton)changedBtns[i];
                if (btn.Selected != (bool)oldVals[i])
                {
                    _Changed.Add(btn);
                }
            }

            return(_Changed.Count > 0);
        }
        /// <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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Perform the bubbling necessary in firing the CheckChange event.
        /// </summary>
        /// <param name="btn">The source ToolbarCheckButton.</param>
        protected void PostCheckChangeEvent(ToolbarCheckButton btn)
        {
            bool      bBubble   = true;
            EventArgs eventArgs = new EventArgs();

            bBubble = btn.OnCheckChange(eventArgs);

            if (bBubble && (btn.Group != null))
            {
                bBubble = btn.Group.OnCheckChange(btn, eventArgs);
            }

            if (bBubble)
            {
                OnCheckChange(btn, eventArgs);
            }
        }
 /// <summary>
 /// Adds a ToolbarCheckButton to the collection at a specific index.
 /// </summary>
 /// <param name="index">The index at which to add the item.</param>
 /// <param name="item">The ToolbarCheckButton to add.</param>
 public void AddAt(int index, ToolbarCheckButton item)
 {
     if (!Contains(item))
     {
         List.Insert(index, item);
     }
 }
 /// <summary>
 /// Removes a ToolbarCheckButton from the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to remove.</param>
 public void Remove(ToolbarCheckButton item)
 {
     List.Remove(item);
 }
 /// <summary>
 /// Determines zero-based index of a ToolbarCheckButton within the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to locate within the collection.</param>
 /// <returns>The zero-based index.</returns>
 public int IndexOf(ToolbarCheckButton item)
 {
     return(List.IndexOf(item));
 }
 /// <summary>
 /// Determines if a ToolbarCheckButton is in the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to search for.</param>
 /// <returns>true if the ToolbarCheckButton exists within the collection. false otherwise.</returns>
 public bool Contains(ToolbarCheckButton item)
 {
     return(List.Contains(item));
 }
 /// <summary>
 /// Sets properties of the ToolbarCheckButton before being added.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to be set.</param>
 private void SetItemProperties(ToolbarCheckButton item)
 {
     item.SetParentToolbar(ParentToolbar);
     item.SetParentCheckGroup(ParentCheckGroup);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Perform the bubbling necessary in firing the CheckChange event.
        /// </summary>
        /// <param name="btn">The source ToolbarCheckButton.</param>
        protected void PostCheckChangeEvent(ToolbarCheckButton btn)
        {
            bool bBubble = true;
            EventArgs eventArgs = new EventArgs();

            bBubble = btn.OnCheckChange(eventArgs);

            if (bBubble && (btn.Group != null))
            {
                bBubble = btn.Group.OnCheckChange(btn, eventArgs);
            }

            if (bBubble)
            {
                OnCheckChange(btn, eventArgs);
            }
        }
Ejemplo n.º 15
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>
 /// Determines if a ToolbarCheckButton is in the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to search for.</param>
 /// <returns>true if the ToolbarCheckButton exists within the collection. false otherwise.</returns>
 public bool Contains(ToolbarCheckButton item)
 {
     return List.Contains(item);
 }
 /// <summary>
 /// Sets properties of the ToolbarCheckButton before being added.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to be set.</param>
 private void SetItemProperties(ToolbarCheckButton item)
 {
     item.SetParentToolbar(ParentToolbar);
     item.SetParentCheckGroup(ParentCheckGroup);
 }
 /// <summary>
 /// Removes a ToolbarCheckButton from the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to remove.</param>
 public void Remove(ToolbarCheckButton item)
 {
     List.Remove(item);
 }
 /// <summary>
 /// Determines zero-based index of a ToolbarCheckButton within the collection.
 /// </summary>
 /// <param name="item">The ToolbarCheckButton to locate within the collection.</param>
 /// <returns>The zero-based index.</returns>
 public int IndexOf(ToolbarCheckButton item)
 {
     return List.IndexOf(item);
 }