Esempio n. 1
0
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            StatusItem    item        = null;
            IDesignerHost h           = (IDesignerHost)GetService(typeof(IDesignerHost));
            int           i           = 0;

            //If the user is removing a button
            if (e.Component is StatusItem)
            {
                item = (StatusItem)e.Component;
                if (Parent.Items.Contains(item))
                {
                    c.OnComponentChanging(Parent, null);
                    Parent.Items.Remove(item);
                    c.OnComponentChanged(Parent, null, null, null);
                    return;
                }
            }

            //If the user is removing the control itself
            if (object.ReferenceEquals(e.Component, Parent))
            {
                for (i = Parent.Items.Count - 1; i >= 0; i += -1)
                {
                    item = Parent.Items[i];
                    c.OnComponentChanging(Parent, null);
                    Parent.Items.Remove(item);
                    h.DestroyComponent(item);
                    c.OnComponentChanged(Parent, null, null, null);
                }
            }

            Parent.DrawItems();
        }
Esempio n. 2
0
        // Adds a new statusitem to the collection
        public int Add(StatusItem item)
        {
            int i = 0;

            i           = List.Add(item);
            item.Parent = Parent;
            Parent.DrawItems();

            return(i);
        }