Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / TableLayoutStyleCollection.cs / 1 / TableLayoutStyleCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Windows.Forms.Layout;
using System.Reflection;
///
[Editor("System.Windows.Forms.Design.StyleCollectionEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor))]
public abstract class TableLayoutStyleCollection : IList {
private IArrangedElement _owner;
private ArrayList _innerList = new ArrayList();
internal TableLayoutStyleCollection(IArrangedElement owner) {
_owner = owner;
}
internal IArrangedElement Owner {
get { return _owner; }
}
internal virtual string PropertyName {
get { return null; }
}
///
///
int IList.Add(object style) {
EnsureNotOwned((TableLayoutStyle)style);
((TableLayoutStyle)style).Owner = this.Owner;
int index = _innerList.Add(style);
PerformLayoutIfOwned();
return index;
}
///
///
public int Add(TableLayoutStyle style) {
return ((IList)this).Add(style);
}
///
///
void IList.Insert(int index, object style) {
EnsureNotOwned((TableLayoutStyle)style);
((TableLayoutStyle)style).Owner = this.Owner;
_innerList.Insert(index, style);
PerformLayoutIfOwned();
}
///
///
object IList.this[int index] {
get { return _innerList[index]; }
set {
TableLayoutStyle style = (TableLayoutStyle) value;
EnsureNotOwned(style);
style.Owner = this.Owner;
_innerList[index] = style;
PerformLayoutIfOwned();
}
}
///
///
public TableLayoutStyle this[int index] {
get { return (TableLayoutStyle)((IList)this)[index]; }
set { ((IList)this)[index] = value; }
}
///
///
void IList.Remove(object style) {
((TableLayoutStyle)style).Owner = null;
_innerList.Remove(style);
PerformLayoutIfOwned();
}
///
public void Clear() {
foreach(TableLayoutStyle style in _innerList) {
style.Owner = null;
}
_innerList.Clear();
PerformLayoutIfOwned();
}
///
public void RemoveAt(int index) {
TableLayoutStyle style = (TableLayoutStyle) _innerList[index];
style.Owner = null;
_innerList.RemoveAt(index);
PerformLayoutIfOwned();
}
// These methods just forward to _innerList.
bool IList.Contains(object style) { return _innerList.Contains(style); }
int IList.IndexOf(object style) { return _innerList.IndexOf(style); }
// These properties / methods just forward to _innerList and are item-type agnostic.
bool IList.IsFixedSize { get {return _innerList.IsFixedSize;} }
bool IList.IsReadOnly { get {return _innerList.IsReadOnly;} }
void ICollection.CopyTo(System.Array array, int startIndex) { _innerList.CopyTo(array, startIndex); }
///
public int Count { get { return _innerList.Count; }}
bool ICollection.IsSynchronized { get{ return _innerList.IsSynchronized; }}
object ICollection.SyncRoot { get { return _innerList.SyncRoot; }}
IEnumerator IEnumerable.GetEnumerator() { return _innerList.GetEnumerator(); }
private void EnsureNotOwned(TableLayoutStyle style) {
if(style.Owner != null) {
throw new ArgumentException(SR.GetString(SR.OnlyOneControl, style.GetType().Name), "style");
}
}
internal void EnsureOwnership(IArrangedElement owner) {
_owner = owner;
for (int i = 0; i < Count; i++) {
this[i].Owner = owner;
}
}
private void PerformLayoutIfOwned() {
if (this.Owner != null) {
LayoutTransaction.DoLayout(this.Owner, this.Owner, PropertyName);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms {
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
using System.Windows.Forms.Layout;
using System.Reflection;
///
[Editor("System.Windows.Forms.Design.StyleCollectionEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor))]
public abstract class TableLayoutStyleCollection : IList {
private IArrangedElement _owner;
private ArrayList _innerList = new ArrayList();
internal TableLayoutStyleCollection(IArrangedElement owner) {
_owner = owner;
}
internal IArrangedElement Owner {
get { return _owner; }
}
internal virtual string PropertyName {
get { return null; }
}
///
///
int IList.Add(object style) {
EnsureNotOwned((TableLayoutStyle)style);
((TableLayoutStyle)style).Owner = this.Owner;
int index = _innerList.Add(style);
PerformLayoutIfOwned();
return index;
}
///
///
public int Add(TableLayoutStyle style) {
return ((IList)this).Add(style);
}
///
///
void IList.Insert(int index, object style) {
EnsureNotOwned((TableLayoutStyle)style);
((TableLayoutStyle)style).Owner = this.Owner;
_innerList.Insert(index, style);
PerformLayoutIfOwned();
}
///
///
object IList.this[int index] {
get { return _innerList[index]; }
set {
TableLayoutStyle style = (TableLayoutStyle) value;
EnsureNotOwned(style);
style.Owner = this.Owner;
_innerList[index] = style;
PerformLayoutIfOwned();
}
}
///
///
public TableLayoutStyle this[int index] {
get { return (TableLayoutStyle)((IList)this)[index]; }
set { ((IList)this)[index] = value; }
}
///
///
void IList.Remove(object style) {
((TableLayoutStyle)style).Owner = null;
_innerList.Remove(style);
PerformLayoutIfOwned();
}
///
public void Clear() {
foreach(TableLayoutStyle style in _innerList) {
style.Owner = null;
}
_innerList.Clear();
PerformLayoutIfOwned();
}
///
public void RemoveAt(int index) {
TableLayoutStyle style = (TableLayoutStyle) _innerList[index];
style.Owner = null;
_innerList.RemoveAt(index);
PerformLayoutIfOwned();
}
// These methods just forward to _innerList.
bool IList.Contains(object style) { return _innerList.Contains(style); }
int IList.IndexOf(object style) { return _innerList.IndexOf(style); }
// These properties / methods just forward to _innerList and are item-type agnostic.
bool IList.IsFixedSize { get {return _innerList.IsFixedSize;} }
bool IList.IsReadOnly { get {return _innerList.IsReadOnly;} }
void ICollection.CopyTo(System.Array array, int startIndex) { _innerList.CopyTo(array, startIndex); }
///
public int Count { get { return _innerList.Count; }}
bool ICollection.IsSynchronized { get{ return _innerList.IsSynchronized; }}
object ICollection.SyncRoot { get { return _innerList.SyncRoot; }}
IEnumerator IEnumerable.GetEnumerator() { return _innerList.GetEnumerator(); }
private void EnsureNotOwned(TableLayoutStyle style) {
if(style.Owner != null) {
throw new ArgumentException(SR.GetString(SR.OnlyOneControl, style.GetType().Name), "style");
}
}
internal void EnsureOwnership(IArrangedElement owner) {
_owner = owner;
for (int i = 0; i < Count; i++) {
this[i].Owner = owner;
}
}
private void PerformLayoutIfOwned() {
if (this.Owner != null) {
LayoutTransaction.DoLayout(this.Owner, this.Owner, PropertyName);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FileLoadException.cs
- Compilation.cs
- MasterPageCodeDomTreeGenerator.cs
- Events.cs
- DotExpr.cs
- TreeBuilderBamlTranslator.cs
- ModelUIElement3D.cs
- StandardOleMarshalObject.cs
- SystemIPv6InterfaceProperties.cs
- WinFormsSpinner.cs
- ContentFileHelper.cs
- MetadataArtifactLoaderResource.cs
- ProcessRequestArgs.cs
- ProfilePropertySettingsCollection.cs
- SafeHandle.cs
- CodeObjectCreateExpression.cs
- SplineKeyFrames.cs
- DataGridCaption.cs
- PeekCompletedEventArgs.cs
- EventHandlersStore.cs
- TextTreeExtractElementUndoUnit.cs
- BridgeDataReader.cs
- RuntimeCompatibilityAttribute.cs
- WebBrowserNavigatedEventHandler.cs
- SecurityPolicySection.cs
- Property.cs
- ErrorWebPart.cs
- ProfilePropertySettings.cs
- XmlAttributeOverrides.cs
- ZipIOModeEnforcingStream.cs
- ConnectorSelectionGlyph.cs
- NativeMethodsCLR.cs
- DataSourceControlBuilder.cs
- DropShadowBitmapEffect.cs
- cache.cs
- LateBoundBitmapDecoder.cs
- SqlDataSourceView.cs
- DataReceivedEventArgs.cs
- NativeMethods.cs
- NominalTypeEliminator.cs
- ExpressionReplacer.cs
- MatrixTransform.cs
- HtmlInputReset.cs
- UnaryNode.cs
- RegexGroupCollection.cs
- SR.cs
- VersionValidator.cs
- OrthographicCamera.cs
- PerspectiveCamera.cs
- ReturnType.cs
- TypeUsageBuilder.cs
- SubMenuStyleCollectionEditor.cs
- SqlSelectStatement.cs
- CodeNamespaceImportCollection.cs
- XmlBindingWorker.cs
- CellConstantDomain.cs
- DataRecordObjectView.cs
- ObjectDataSourceChooseTypePanel.cs
- LogicalExpressionEditor.cs
- GeneralTransform3DCollection.cs
- PageCatalogPart.cs
- OdbcTransaction.cs
- LZCodec.cs
- Int16AnimationUsingKeyFrames.cs
- RelOps.cs
- NativeMethods.cs
- ObjectParameterCollection.cs
- XamlTypeMapper.cs
- SafeCryptHandles.cs
- DesignTimeDataBinding.cs
- Win32Exception.cs
- SynchronizedDispatch.cs
- Matrix.cs
- AxWrapperGen.cs
- MethodToken.cs
- XamlSerializationHelper.cs
- XmlSchemaSimpleTypeRestriction.cs
- BindMarkupExtensionSerializer.cs
- CurrentTimeZone.cs
- RecordConverter.cs
- RandomNumberGenerator.cs
- Camera.cs
- HttpCacheVary.cs
- Bits.cs
- SoapFormatterSinks.cs
- SqlRecordBuffer.cs
- TraceHandler.cs
- base64Transforms.cs
- HtmlControl.cs
- DataFormats.cs
- ErrorRuntimeConfig.cs
- ProviderBase.cs
- BindingValueChangedEventArgs.cs
- ToolboxItem.cs
- RangeBaseAutomationPeer.cs
- ItemCollection.cs
- KeyValueInternalCollection.cs
- AddInDeploymentState.cs
- IImplicitResourceProvider.cs
- ApplicationDirectory.cs