Inheritance: System.Collections.ReadOnlyCollectionBase
Esempio n. 1
0
 private void Remove(IComponent component, bool preserveSite)
 {
     lock (syncObj) {
         if (component == null)
         {
             return;
         }
         ISite site = component.Site;
         if (site == null || site.Container != this)
         {
             return;
         }
         if (!preserveSite)
         {
             component.Site = null;
         }
         for (int i = 0; i < siteCount; i++)
         {
             if (sites[i] == site)
             {
                 siteCount--;
                 Array.Copy(sites, i + 1, sites, i, siteCount - i);
                 sites[siteCount] = null;
                 components       = null;
                 break;
             }
         }
     }
 }
 public virtual void Add(IComponent component, string name)
 {
     lock (this.syncObj)
     {
         if (component != null)
         {
             ISite site = component.Site;
             if ((site == null) || (site.Container != this))
             {
                 if (this.sites == null)
                 {
                     this.sites = new ISite[4];
                 }
                 else
                 {
                     this.ValidateName(component, name);
                     if (this.sites.Length == this.siteCount)
                     {
                         ISite[] destinationArray = new ISite[this.siteCount * 2];
                         Array.Copy(this.sites, 0, destinationArray, 0, this.siteCount);
                         this.sites = destinationArray;
                     }
                 }
                 if (site != null)
                 {
                     site.Container.Remove(component);
                 }
                 ISite site2 = this.CreateSite(component, name);
                 this.sites[this.siteCount++] = site2;
                 component.Site  = site2;
                 this.components = null;
             }
         }
     }
 }
 private void Remove(IComponent component, bool preserveSite)
 {
     lock (this.syncObj)
     {
         if (component != null)
         {
             ISite site = component.Site;
             if ((site != null) && (site.Container == this))
             {
                 if (!preserveSite)
                 {
                     component.Site = null;
                 }
                 for (int i = 0; i < this.siteCount; i++)
                 {
                     if (this.sites[i] == site)
                     {
                         this.siteCount--;
                         Array.Copy(this.sites, i + 1, this.sites, i, this.siteCount - i);
                         this.sites[this.siteCount] = null;
                         this.components            = null;
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
        private void Remove(IComponent component, bool preserveSite)
        {
            lock (_syncObj)
            {
                ISite site = component?.Site;
                if (site == null || site.Container != this)
                {
                    return;
                }

                if (!preserveSite)
                {
                    component.Site = null;
                }

                for (int i = 0; i < _siteCount; i++)
                {
                    if (_sites[i] == site)
                    {
                        _siteCount--;
                        Array.Copy(_sites, i + 1, _sites, i, _siteCount - i);
                        _sites[_siteCount] = null;
                        _components        = null;
                        break;
                    }
                }
            }
        }
 public virtual void Add(IComponent component, string name)
 {
     lock (this.syncObj)
     {
         if (component != null)
         {
             ISite site = component.Site;
             if ((site == null) || (site.Container != this))
             {
                 if (this.sites == null)
                 {
                     this.sites = new ISite[4];
                 }
                 else
                 {
                     this.ValidateName(component, name);
                     if (this.sites.Length == this.siteCount)
                     {
                         ISite[] destinationArray = new ISite[this.siteCount * 2];
                         Array.Copy(this.sites, 0, destinationArray, 0, this.siteCount);
                         this.sites = destinationArray;
                     }
                 }
                 if (site != null)
                 {
                     site.Container.Remove(component);
                 }
                 ISite site2 = this.CreateSite(component, name);
                 this.sites[this.siteCount++] = site2;
                 component.Site = site2;
                 this.components = null;
             }
         }
     }
 }
			public ControlContainer(ICollection collection) {
				Control[] controls = new Control[collection.Count];
				int i;

				i = 0;
				foreach(Control c in collection) {
					controls[i++] = c;
				}

				col = new ComponentCollection(controls);
			}
        /// <internalonly/>
        /// <summary>
        ///    <para>Gets a collection of standard values for the reference data type.</para>
        /// </summary>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            object[] components = null;

            if (context != null)
            {
                ArrayList list = new ArrayList();
                list.Add(null);

                // Try the reference service first.
                //
                IReferenceService refSvc = (IReferenceService)context.GetService(typeof(IReferenceService));
                if (refSvc != null)
                {
                    object[] objs  = refSvc.GetReferences(_type);
                    int      count = objs.Length;

                    for (int i = 0; i < count; i++)
                    {
                        if (IsValueAllowed(context, objs[i]))
                        {
                            list.Add(objs[i]);
                        }
                    }
                }
                else
                {
                    // Now try IContainer.
                    //
                    IContainer cont = context.Container;
                    if (cont != null)
                    {
                        ComponentCollection objs = cont.Components;

                        foreach (IComponent obj in objs)
                        {
                            if (obj != null && _type.IsInstanceOfType(obj) &&
                                IsValueAllowed(context, obj))
                            {
                                list.Add(obj);
                            }
                        }
                    }
                }

                components = list.ToArray();
                Array.Sort(components, 0, components.Length, new ReferenceComparer(this));
            }

            return(new StandardValuesCollection(components));
        }
Esempio n. 8
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         lock (syncObj) {
             while (siteCount > 0)
             {
                 ISite site = sites[--siteCount];
                 site.Component.Site = null;
                 site.Component.Dispose();
             }
             sites      = null;
             components = null;
         }
     }
 }
 public void SetBtn(ComponentCollection componts, Dictionary<string, bool> dic)
 {
     var o = componts;
     for (int i = 0; i < o.Count; i++)
     {
         if (o[i] is DevExpress.XtraBars.BarManager)
         {
             var btns = ((DevExpress.XtraBars.BarManager)o[i]).Items;
             for (int k = 0; k < btns.Count; k++)
             {
                 if (dic.ContainsKey(btns[k].Name))
                     btns[k].Enabled = dic[btns[k].Name];
             }
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Gets a collection of standard values for the reference data type.
        /// </summary>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List <object> components = null;

            if (context != null)
            {
                components = new List <object> {
                    null
                };

                // Try the reference service first.
                if (context.GetService(typeof(IReferenceService)) is IReferenceService refSvc)
                {
                    object[] objs = refSvc.GetReferences(_type);
                    if (objs != null)
                    {
                        for (int i = 0; i < objs.Length; i++)
                        {
                            if (IsValueAllowed(context, objs[i]))
                            {
                                components.Add(objs[i]);
                            }
                        }
                    }
                }
                else
                {
                    // Now try IContainer.
                    IContainer cont = context.Container;
                    if (cont != null)
                    {
                        ComponentCollection objs = cont.Components;
                        foreach (IComponent obj in objs)
                        {
                            if (obj != null && _type != null && _type.IsInstanceOfType(obj) && IsValueAllowed(context, obj))
                            {
                                components.Add(obj);
                            }
                        }
                    }
                }

                components.Sort(new ReferenceComparer(this));
            }

            return(new StandardValuesCollection(components));
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         lock (this.syncObj)
         {
             while (this.siteCount > 0)
             {
                 ISite site = this.sites[--this.siteCount];
                 site.Component.Site = null;
                 site.Component.Dispose();
             }
             this.sites = null;
             this.components = null;
         }
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         lock (this.syncObj)
         {
             while (this.siteCount > 0)
             {
                 ISite site = this.sites[--this.siteCount];
                 site.Component.Site = null;
                 site.Component.Dispose();
             }
             this.sites      = null;
             this.components = null;
         }
     }
 }
        public override ComponentCollection FilterComponents(ComponentCollection components)
        {
            if (this.existService != null)
            {
                components = this.existService.FilterComponents(components);
            }

            List<IComponent> list = new List<IComponent>(components.Count);
            List<Column> columns = new List<Column>(components.Count);

            foreach (IComponent item in components)
            {
                if (item is Column == false)
                {
                    list.Add(item);
                }
                else
                {
                    Column column = item as Column;
                    if (column.Index < 0)
                    {
                        list.Add(item);
                    }
                    else
                    {
                        int index = list.IndexOf(column.GridControl);
                        if (index < 0)
                        {
                            list.Add(item);
                        }
                        else
                        {
                            columns.Add(column);
                        }
                    }
                }
            }

            foreach (Column item in columns)
            {
                int index = list.IndexOf(item.GridControl);
                list.Insert(index, item);
            }

            return new ComponentCollection(list.ToArray());
        }
Esempio n. 14
0
        // Adds a component to the container.
        /// <summary>
        ///    <para>
        ///       Adds the specified component to the <see cref='System.ComponentModel.Container'/> and assigns a name to
        ///       it.
        ///    </para>
        /// </summary>
        public virtual void Add(IComponent component, String name)
        {
            lock (_syncObj)
            {
                if (component == null)
                {
                    return;
                }

                ISite site = component.Site;

                if (site != null && site.Container == this)
                {
                    return;
                }

                if (_sites == null)
                {
                    _sites = new ISite[4];
                }
                else
                {
                    // Validate that new components
                    // have either a null name or a unique one.
                    //
                    ValidateName(component, name);

                    if (_sites.Length == _siteCount)
                    {
                        ISite[] newSites = new ISite[_siteCount * 2];
                        Array.Copy(_sites, 0, newSites, 0, _siteCount);
                        _sites = newSites;
                    }
                }

                if (site != null)
                {
                    site.Container.Remove(component);
                }

                ISite newSite = CreateSite(component, name);
                _sites[_siteCount++] = newSite;
                component.Site       = newSite;
                _components          = null;
            }
        }
Esempio n. 15
0
		public MyContainer ()
		{
			_components = new ComponentCollection (new IComponent [0]);
		}
Esempio n. 16
0
        /// <summary>
        /// An event handler called after an item has been set in the collection.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnAfterItemSet(object sender, ComponentCollection<ProgressLegendItem>.ItemSetEventArgs e)
        {
            // Remove the event handlers from the old item.
            if (e.OldItem != null)
            {
                e.OldItem.ColorChanged -= this.OnItemColorChanged;
                e.OldItem.TextChanged -= this.OnItemTextChanged;
            }
            // Add the event handler for the new item.
            if (e.NewItem != null)
            {
                e.NewItem.ColorChanged += this.OnItemColorChanged;
                e.NewItem.TextChanged += this.OnItemTextChanged;
            }

            // Raise the items changed event.
            if (this.ItemsChanged != null) this.ItemsChanged(this, new ProgressLegendEventArgs(this));
        }
Esempio n. 17
0
        /// <summary>
        /// An event handler called after an item has been inserted in the collection.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnAfterItemInserted(object sender, ComponentCollection<ProgressLegendItem>.ItemChangedEventArgs e)
        {
            // Add the item event handlers.
            if (e.Item != null)
            {
                e.Item.ColorChanged += this.OnItemColorChanged;
                e.Item.TextChanged += this.OnItemTextChanged;
            }

            // Raise the items changed event.
            if (this.ItemsChanged != null) this.ItemsChanged(this, new ProgressLegendEventArgs(this));
        }
 private void Remove(IComponent component, bool preserveSite)
 {
     lock (this.syncObj)
     {
         if (component != null)
         {
             ISite site = component.Site;
             if ((site != null) && (site.Container == this))
             {
                 if (!preserveSite)
                 {
                     component.Site = null;
                 }
                 for (int i = 0; i < this.siteCount; i++)
                 {
                     if (this.sites[i] == site)
                     {
                         this.siteCount--;
                         Array.Copy(this.sites, i + 1, this.sites, i, this.siteCount - i);
                         this.sites[this.siteCount] = null;
                         this.components = null;
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 19
0
 /// <summary>
 /// An event handler called after an item has been removed from the collection. 
 /// </summary>
 /// <param name="object">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterItemRemoved(object sender, ComponentCollection<ProgressItem>.ItemChangedEventArgs e)
 {
     // Remove the event handlers from the old item.
     this.OnItemRemoved(e.Item);
     // Remove the item from the base class items.
     base.Items.RemoveAt(e.Index);
 }
Esempio n. 20
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         lock (_syncObj)
         {
             while (_siteCount > 0)
             {
                 ISite site = _sites[--_siteCount];
                 site.Component.Site = null;
                 site.Component.Dispose();
             }
             _sites = null;
             _components = null;
         }
     }
 }
Esempio n. 21
0
        /// <summary>
        /// An event handler called after a menu item has been set.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnAfterItemSet(object sender, ComponentCollection<SideMenuItem>.ItemSetEventArgs e)
        {
            // Check that the arguments are not null.
            if (null == e.OldItem) throw new ArgumentNullException("oldItem");
            if (null == e.NewItem) throw new ArgumentNullException("newItem");

            // If the new and the old item are the same, do nothing.
            if (e.OldItem == e.NewItem) return;

            // Remove the event handlers from the old item.
            e.OldItem.TextChanged -= this.OnItemTextChanged;
            e.OldItem.SmallImageChanged -= this.OnItemSmallImageChanged;
            e.OldItem.LargeImageChanged -= this.OnItemLargeImageChanged;
            e.OldItem.ControlChanged -= this.OnItemControlChanged;
            e.OldItem.HiddenClick -= this.OnItemHiddenClick;

            // Add the event handlers to the new item.
            e.NewItem.TextChanged += this.OnItemTextChanged;
            e.NewItem.SmallImageChanged += this.OnItemSmallImageChanged;
            e.NewItem.LargeImageChanged += this.OnItemLargeImageChanged;
            e.NewItem.ControlChanged += this.OnItemControlChanged;
            e.NewItem.HiddenClick += this.OnItemHiddenClick;

            // Remove the old hidden menu item from the items list.
            this.controlMenu.Items.Remove(e.OldItem.HiddenMenuItem);
            // Add the new hidden menu item to the items list.
            this.controlMenu.Items.Add(e.NewItem.HiddenMenuItem);

            // Refresh the control.
            this.OnRefresh();
        }
Esempio n. 22
0
        /// <summary>
        /// An event handler called after an existing menu item has been removed.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnAfterItemRemoved(object sender, ComponentCollection<SideMenuItem>.ItemChangedEventArgs e)
        {
            // Remove the hidden event handler.
            e.Item.TextChanged -= this.OnItemTextChanged;
            e.Item.SmallImageChanged -= this.OnItemSmallImageChanged;
            e.Item.LargeImageChanged -= this.OnItemLargeImageChanged;
            e.Item.ControlChanged -= this.OnItemControlChanged;
            e.Item.HiddenClick -= this.OnItemHiddenClick;

            // Remove the hidden menu item.
            this.controlMenu.Items.Remove(e.Item.HiddenMenuItem);

            // If this is the selected item.
            if (this.selectedIndex == e.Index)
            {
                // If the item list is not empty.
                if (this.items.Count > 0)
                {
                    // Select the first item.
                    this.items[0].Select();
                    // Change the selected index.
                    this.selectedIndex = 0;
                }
                else
                {
                    this.selectedIndex = null;
                }
            }
            // Update the number of visible items
            this.VisibleItems = this.items.Count;
        }
Esempio n. 23
0
        /// <summary>
        /// An event handler called after a new menu item has been inserted.
        /// </summary>
        /// <param name="sender">The sender object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnAfterItemInserted(object sender, ComponentCollection<SideMenuItem>.ItemChangedEventArgs e)
        {
            // Add the item event handlers.
            e.Item.TextChanged += this.OnItemTextChanged;
            e.Item.SmallImageChanged += this.OnItemSmallImageChanged;
            e.Item.LargeImageChanged += this.OnItemLargeImageChanged;
            e.Item.ControlChanged += this.OnItemControlChanged;
            e.Item.HiddenClick += this.OnItemHiddenClick;

            // Add the hidden menu item.
            this.controlMenu.Items.Add(e.Item.HiddenMenuItem);

            // If this is the first item.
            if (this.items.Count == 1)
            {
                // Select the item.
                e.Item.Select();
                // Change the selected index.
                this.selectedIndex = 0;
            }
            // Update the number of visible items.
            this.VisibleItems = this.items.Count;
        }
 private bool FindComponent(ComponentCollection components, IComponent targetComponent)
 {
     foreach (IComponent component in components)
     {
         if (component == targetComponent)
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 25
0
        // Adds a component to the container.
        /// <summary>
        ///    <para>
        ///       Adds the specified component to the <see cref='System.ComponentModel.Container'/> and assigns a name to
        ///       it.
        ///    </para>
        /// </summary>
        public virtual void Add(IComponent component, String name)
        {
            lock (_syncObj)
            {
                if (component == null)
                {
                    return;
                }

                ISite site = component.Site;

                if (site != null && site.Container == this)
                {
                    return;
                }

                if (_sites == null)
                {
                    _sites = new ISite[4];
                }
                else
                {
                    // Validate that new components
                    // have either a null name or a unique one.
                    //
                    ValidateName(component, name);

                    if (_sites.Length == _siteCount)
                    {
                        ISite[] newSites = new ISite[_siteCount * 2];
                        Array.Copy(_sites, 0, newSites, 0, _siteCount);
                        _sites = newSites;
                    }
                }

                if (site != null)
                {
                    site.Container.Remove(component);
                }

                ISite newSite = CreateSite(component, name);
                _sites[_siteCount++] = newSite;
                component.Site = newSite;
                _components = null;
            }
        }
Esempio n. 26
0
 /// <summary>
 /// An event handler called after an item has been inserted into the collection.
 /// </summary>
 /// <param name="object">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterItemInserted(object sender, ComponentCollection<ProgressItem>.ItemChangedEventArgs e)
 {
     // Add the event handlers to the new item.
     this.OnItemAdded(e.Item);
     // Insert the item into the base class items.
     base.Items.Insert(e.Index, e.Item);
 }
 public virtual new ComponentCollection FilterComponents(ComponentCollection components)
 {
   return default(ComponentCollection);
 }
Esempio n. 28
0
 /// <summary>
 /// An event handler called after an item has been set in the collection.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="object">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterItemSet(object sender, ComponentCollection<ProgressItem>.ItemSetEventArgs e)
 {
     // Add the event handlers to the new item.
     this.OnItemAdded(e.NewItem);
     // Remove the event handlers from the old item.
     this.OnItemRemoved(e.OldItem);
     // Set the item into the base class items.
     base.Items[e.Index] = e.NewItem;
 }
Esempio n. 29
0
 public void Dispose()
 {
     _components = null;
 }
Esempio n. 30
0
 /// <summary>
 /// An event handler called after a wizard page is inserted in the collection.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterPageInserted(object sender, ComponentCollection<WizardPage>.ItemChangedEventArgs e)
 {
     // If the item is null, throw an exception.
     if (null == e.Item) throw new NullReferenceException("The wizard page cannot be null.");
     // Set the page properties.
     if (this.selectedIndex == e.Index)
         e.Item.Show();
     else
         e.Item.Hide();
     // Set the page event handlers.
     e.Item.PageChanged += OnPageChanged;
     // Add the page to the control.
     this.Controls.Add(e.Item);
     // If this is the first page, set the selected index to 0.
     if (-1 == this.selectedIndex) this.OnPageSelected(0);
 }
		public virtual ComponentCollection FilterComponents (ComponentCollection components)
		{
			// The default implementation returns the input as is.
			return components;
		}
 public virtual ComponentCollection FilterComponents(ComponentCollection components)
 {
     return components;
 }
Esempio n. 33
0
 /// <summary>
 /// An event handler called after a wizard page is removed from the collection.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterPageRemoved(object sender, ComponentCollection<WizardPage>.ItemChangedEventArgs e)
 {
     // If the item is null, throw an exception.
     if (null == e.Item) throw new NullReferenceException("The wizard page cannot be null.");
     // Remove the page from the control.
     this.Controls.Remove(e.Item);
     // If this is the last page, set the selected index to -1.
     if (this.pages.Count == 0) this.OnPageSelected(-1);
 }
Esempio n. 34
0
 /// <summary>
 /// An event handler called after a page was set in the collection.
 /// </summary>
 /// <param name="sender">The sender object.</param>
 /// <param name="e">The event arguments.</param>
 private void OnAfterPageSet(object sender, ComponentCollection<WizardPage>.ItemSetEventArgs e)
 {
     // If the old item is null, throw an exception.
     if (null == e.OldItem) throw new NullReferenceException("The old wizard page cannot be null.");
     // If the new item is null, throw an exception.
     if (null == e.NewItem) throw new NullReferenceException("The new wizard page cannot be null.");
     // If the old and new items are the same, do nothing.
     if (e.OldItem == e.NewItem) return;
     // Remove the old page from the control.
     this.Controls.Remove(e.OldItem);
     // Set the new page properties.
     if (this.selectedIndex == e.Index)
         e.NewItem.Show();
     else
         e.NewItem.Hide();
     // Add the page to the control.
     this.Controls.Add(e.NewItem);
 }
Esempio n. 35
0
 /// <summary>
 /// Registers the learn logic all components.
 /// </summary>
 /// <param name="components">The components.</param>
 /// <remarks>Documented by Dev02, 2008-04-24</remarks>
 private void RegisterLearnLogicAllComponents(ComponentCollection components)
 {
     foreach (Component component in components)
         RegisterLearnLogicObject(component);
 }
Esempio n. 36
0
 private void Remove(IComponent component, bool preserveSite)
 {
     lock (_syncObj)
     {
         if (component == null)
             return;
         ISite site = component.Site;
         if (site == null || site.Container != this)
             return;
         if (!preserveSite)
             component.Site = null;
         for (int i = 0; i < _siteCount; i++)
         {
             if (_sites[i] == site)
             {
                 _siteCount--;
                 Array.Copy(_sites, i + 1, _sites, i, _siteCount - i);
                 _sites[_siteCount] = null;
                 _components = null;
                 break;
             }
         }
     }
 }
 public virtual new ComponentCollection FilterComponents(ComponentCollection components)
 {
     return(default(ComponentCollection));
 }
Esempio n. 38
0
 public virtual ComponentCollection FilterComponents(ComponentCollection components)
 {
     // The default implementation returns the input as is.
     return(components);
 }
		private void GetInputControls(ComponentCollection components)
		{
			try
			{
				foreach (object inputControl in components)
				{
					this.AddInputControl(inputControl);
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
			}
		}
 public virtual ComponentCollection FilterComponents(ComponentCollection components)
 {
     return(components);
 }
Esempio n. 41
0
 public ControlContainer()
 {
     _components = new ComponentCollection(new IComponent[] { });
 }