Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
RadItemOwnerCollection.cs
Upload User: jqzhiye
Upload Date: 2013-01-31
Package Size: 22692k
Code Size: 5k
Category:
CSharp
Development Platform:
C#
- using System;
- using System.Collections.Generic;
- using System.Drawing.Design;
- using System.Text;
- using System.Collections;
- namespace Telerik.WinControls
- {
- /// <summary>
- /// <para>
- /// A collection that stores <see cref='Telerik.WinControls.RadItem'/> objects.
- /// </para>
- /// </summary>
- /// <seealso cref='RadItemCollection'/>
- public class RadItemOwnerCollection : RadItemCollection
- {
- private RadElement owner;
- /// <summary>
- /// <para>
- /// Initializes a new instance of <see cref='RadItemCollection'/>.
- /// </para>
- /// </summary>
- public RadItemOwnerCollection(RadElement owner)
- {
- this.owner = owner;
- }
- /// <summary>Initializes a new instance of the RadItemCollection class.</summary>
- public RadItemOwnerCollection()
- {
- }
- /// <summary>
- /// <para>
- /// Initializes a new instance of <see cref='Telerik.WinControls.RadItemCollection'/> based on another <see cref='Telerik.WinControls.RadItemCollection'/>.
- /// </para>
- /// </summary>
- /// <param name='value'>
- /// A <see cref='Telerik.WinControls.RadItemCollection'/> from which the contents are copied
- /// </param>
- public RadItemOwnerCollection(RadItemOwnerCollection value) : base(value)
- {
- }
- /// <summary>
- /// <para>
- /// Initializes a new instance of <see cref='Telerik.WinControls.RadItemCollection'/> containing any array of <see cref='Telerik.WinControls.RadItem'/> objects.
- /// </para>
- /// </summary>
- /// <param name='value'>
- /// A array of <see cref='Telerik.WinControls.RadItem'/> objects with which to intialize the collection
- /// </param>
- public RadItemOwnerCollection(RadItem[] value) : base(value)
- {
- }
- /// <summary>
- /// Gets or sets the owner of the collection.
- /// </summary>
- public RadElement Owner
- {
- get
- {
- return owner;
- }
- set
- {
- if (this.owner == value)
- {
- return;
- }
- if (this.owner != null)
- {
- this.RemoveAllFromOwner();
- }
- this.owner = value;
- if (this.owner != null)
- {
- this.SynchronizeAllWithOwner();
- }
- }
- }
- private void SynchronizeAllWithOwner()
- {
- if (!this.Owner.UseNewLayoutSystem)
- this.Owner.SuspendLayout();
- foreach (RadItem element in this)
- {
- if (!this.Owner.Children.Contains(element))
- {
- this.Owner.Children.Add(element);
- }
- }
- if (!this.Owner.UseNewLayoutSystem)
- this.Owner.ResumeLayout(true);
- }
- private void RemoveAllFromOwner()
- {
- if (!this.Owner.UseNewLayoutSystem)
- this.Owner.SuspendLayout();
- foreach (RadItem element in this)
- {
- int index = this.Owner.Children.IndexOf(element);
- if (index >= 0 )
- this.Owner.Children.RemoveAt(index);
- }
- if (!this.Owner.UseNewLayoutSystem)
- this.Owner.ResumeLayout(true);
- }
- protected override void OnSetComplete(int index, object oldValue, object newValue)
- {
- if (this.Owner != null)
- {
- int childIndex = this.owner.Children.IndexOf((RadItem)oldValue);
- if (childIndex >= 0)
- {
- this.owner.Children[childIndex] = (RadItem)newValue;
- }
- else
- {
- this.owner.Children.Add((RadItem)newValue);
- }
- }
- base.OnSetComplete(index, oldValue, newValue);
- }
- protected override void OnClear()
- {
- base.OnClear();
- //Clear all the corresponding items from the children collection
- if (this.Owner != null)
- {
- this.RemoveAllFromOwner();
- }
- }
- protected override void OnInsertComplete(int index, object value)
- {
- if (this.Owner != null)
- {
- int newIndex= index;
- if (newIndex > this.Owner.Children.Count)
- newIndex = this.Owner.Children.Count;
- this.Owner.Children.Insert(newIndex, (RadItem)value);
- }
- base.OnInsertComplete(index, value);
- }
- protected override void OnRemoveComplete(int index, object value)
- {
- if (this.Owner != null)
- {
- this.Owner.Children.Remove((RadItem)value);
- }
- base.OnRemoveComplete(index, value);
- }
- protected override void OnSortComplete()
- {
- if (this.Owner != null)
- this.owner.ChangeCollection(null, ItemsChangeOperation.Sorted);
- base.OnSortComplete();
- }
- }
- }