Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media3D / ModelVisual3D.cs / 1305600 / ModelVisual3D.cs
//----------------------------------------------------------------------------
//
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Description:
//
// History:
// 6/9/2005 : [....] - Created
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Internal.Media;
using MS.Internal.Media3D;
using System;
using System.Diagnostics;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Media3D
{
///
/// ModelVisual3D is a Visual3D which draws the given Model3D.
/// ModelVisual3D is usable from Xaml.
///
[ContentProperty("Children")]
public class ModelVisual3D : Visual3D, IAddChild
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Default ctor
///
public ModelVisual3D()
{
_children = new Visual3DCollection(this);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Derived class must implement to support Visual children. The method must return
/// the child at the specified index. Index must be between 0 and GetVisualChildrenCount-1.
///
/// By default a Visual does not have any children.
///
/// Remark:
/// During this virtual call it is not valid to modify the Visual tree.
///
protected sealed override Visual3D GetVisual3DChild(int index)
{
//VisualCollection does the range check for index
return _children[index];
}
///
/// Derived classes override this property to enable the Visual code to enumerate
/// the Visual children. Derived classes need to return the number of children
/// from this method.
///
/// By default a Visual does not have any children.
///
/// Remark: During this virtual method the Visual tree must not be modified.
///
protected sealed override int Visual3DChildrenCount
{
get { return _children.Count; }
}
void IAddChild.AddChild(Object value)
{
if( value == null )
{
throw new System.ArgumentNullException("value");
}
Visual3D visual3D = value as Visual3D;
if (visual3D == null)
{
throw new System.ArgumentException(SR.Get(SRID.Collection_BadType, this.GetType().Name, value.GetType().Name, typeof(Visual3D).Name));
}
Children.Add(visual3D);
}
void IAddChild.AddText(string text)
{
// The only text we accept is whitespace, which we ignore.
foreach (char c in text)
{
if (!Char.IsWhiteSpace(c))
{
throw new System.InvalidOperationException(SR.Get(SRID.AddText_Invalid, this.GetType().Name));
}
}
}
///
/// Children of this Visual3D
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Visual3DCollection Children
{
get
{
VerifyAPIReadOnly();
return _children;
}
}
///
/// DependencyProperty which backs the ModelVisual3D.Content property.
///
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(
"Content",
/* propertyType = */ typeof(Model3D),
/* ownerType = */ typeof(ModelVisual3D),
new PropertyMetadata(ContentPropertyChanged),
(ValidateValueCallback) delegate { return MediaContext.CurrentMediaContext.WriteAccessEnabled; });
private static void ContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ModelVisual3D owner = ((ModelVisual3D) d);
// if it's not a subproperty change, then we need to change the protected Model property of Visual3D
if (!e.IsASubPropertyChange)
{
owner.Visual3DModel = (Model3D)e.NewValue;
}
}
///
/// The Model3D to render
///
public Model3D Content
{
get
{
return (Model3D) GetValue(ContentProperty);
}
set
{
SetValue(ContentProperty, value);
}
}
/// For binary compatability we need to keep the Transform DP and proprety here
public static new readonly DependencyProperty TransformProperty = Visual3D.TransformProperty;
///
/// Transform for this Visual3D.
///
public new Transform3D Transform
{
get
{
return (Transform3D) GetValue(TransformProperty);
}
set
{
SetValue(TransformProperty, value);
}
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private readonly Visual3DCollection _children;
#endregion Private Fields
//-----------------------------------------------------
//
// Internal Fields
//
//------------------------------------------------------
#region Internal Fields
#endregion Internal Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------------
//
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Description:
//
// History:
// 6/9/2005 : [....] - Created
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Internal.Media;
using MS.Internal.Media3D;
using System;
using System.Diagnostics;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media.Media3D
{
///
/// ModelVisual3D is a Visual3D which draws the given Model3D.
/// ModelVisual3D is usable from Xaml.
///
[ContentProperty("Children")]
public class ModelVisual3D : Visual3D, IAddChild
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Default ctor
///
public ModelVisual3D()
{
_children = new Visual3DCollection(this);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Derived class must implement to support Visual children. The method must return
/// the child at the specified index. Index must be between 0 and GetVisualChildrenCount-1.
///
/// By default a Visual does not have any children.
///
/// Remark:
/// During this virtual call it is not valid to modify the Visual tree.
///
protected sealed override Visual3D GetVisual3DChild(int index)
{
//VisualCollection does the range check for index
return _children[index];
}
///
/// Derived classes override this property to enable the Visual code to enumerate
/// the Visual children. Derived classes need to return the number of children
/// from this method.
///
/// By default a Visual does not have any children.
///
/// Remark: During this virtual method the Visual tree must not be modified.
///
protected sealed override int Visual3DChildrenCount
{
get { return _children.Count; }
}
void IAddChild.AddChild(Object value)
{
if( value == null )
{
throw new System.ArgumentNullException("value");
}
Visual3D visual3D = value as Visual3D;
if (visual3D == null)
{
throw new System.ArgumentException(SR.Get(SRID.Collection_BadType, this.GetType().Name, value.GetType().Name, typeof(Visual3D).Name));
}
Children.Add(visual3D);
}
void IAddChild.AddText(string text)
{
// The only text we accept is whitespace, which we ignore.
foreach (char c in text)
{
if (!Char.IsWhiteSpace(c))
{
throw new System.InvalidOperationException(SR.Get(SRID.AddText_Invalid, this.GetType().Name));
}
}
}
///
/// Children of this Visual3D
///
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Visual3DCollection Children
{
get
{
VerifyAPIReadOnly();
return _children;
}
}
///
/// DependencyProperty which backs the ModelVisual3D.Content property.
///
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(
"Content",
/* propertyType = */ typeof(Model3D),
/* ownerType = */ typeof(ModelVisual3D),
new PropertyMetadata(ContentPropertyChanged),
(ValidateValueCallback) delegate { return MediaContext.CurrentMediaContext.WriteAccessEnabled; });
private static void ContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ModelVisual3D owner = ((ModelVisual3D) d);
// if it's not a subproperty change, then we need to change the protected Model property of Visual3D
if (!e.IsASubPropertyChange)
{
owner.Visual3DModel = (Model3D)e.NewValue;
}
}
///
/// The Model3D to render
///
public Model3D Content
{
get
{
return (Model3D) GetValue(ContentProperty);
}
set
{
SetValue(ContentProperty, value);
}
}
/// For binary compatability we need to keep the Transform DP and proprety here
public static new readonly DependencyProperty TransformProperty = Visual3D.TransformProperty;
///
/// Transform for this Visual3D.
///
public new Transform3D Transform
{
get
{
return (Transform3D) GetValue(TransformProperty);
}
set
{
SetValue(TransformProperty, value);
}
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private readonly Visual3DCollection _children;
#endregion Private Fields
//-----------------------------------------------------
//
// Internal Fields
//
//------------------------------------------------------
#region Internal Fields
#endregion Internal Fields
}
}
// 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
- EventSource.cs
- NotifyParentPropertyAttribute.cs
- SelectiveScrollingGrid.cs
- PointLight.cs
- XPathNodeList.cs
- RTLAwareMessageBox.cs
- TimerElapsedEvenArgs.cs
- Label.cs
- EmptyEnumerable.cs
- AVElementHelper.cs
- Compress.cs
- httpapplicationstate.cs
- DoubleUtil.cs
- SqlDataSourceFilteringEventArgs.cs
- TemplateLookupAction.cs
- HwndAppCommandInputProvider.cs
- BaseTemplateParser.cs
- Transform.cs
- MobileTextWriter.cs
- ConnectionStringSettings.cs
- CompositeClientFormatter.cs
- MenuCommand.cs
- SafeTokenHandle.cs
- Environment.cs
- ViewManager.cs
- PointUtil.cs
- DetailsViewInsertedEventArgs.cs
- PauseStoryboard.cs
- TextAdaptor.cs
- WindowsFont.cs
- SafeNativeMethodsOther.cs
- BlurEffect.cs
- PolyLineSegment.cs
- OdbcConnectionFactory.cs
- TemplateControlParser.cs
- TypeLibConverter.cs
- XmlBinaryReader.cs
- TableProviderWrapper.cs
- RelationshipDetailsCollection.cs
- COM2ExtendedUITypeEditor.cs
- NetworkInformationException.cs
- TraceInternal.cs
- VectorCollectionValueSerializer.cs
- NoResizeHandleGlyph.cs
- ProviderUtil.cs
- SHA512Cng.cs
- CompoundFileIOPermission.cs
- StructuralObject.cs
- DefaultValueAttribute.cs
- DataViewManager.cs
- Trace.cs
- SpellerStatusTable.cs
- MenuItemAutomationPeer.cs
- EventMemberCodeDomSerializer.cs
- Filter.cs
- coordinatorscratchpad.cs
- Vector3D.cs
- DbParameterHelper.cs
- COM2ExtendedBrowsingHandler.cs
- MenuItem.cs
- InternalCache.cs
- SoapMessage.cs
- DatagridviewDisplayedBandsData.cs
- Site.cs
- SchemaManager.cs
- ViewCellRelation.cs
- CacheRequest.cs
- XmlSchema.cs
- DataGridViewCellFormattingEventArgs.cs
- ProfileInfo.cs
- CapabilitiesRule.cs
- BuildProvider.cs
- DrawingVisualDrawingContext.cs
- SequentialOutput.cs
- ModulesEntry.cs
- DataGridViewElement.cs
- ThousandthOfEmRealDoubles.cs
- ToolTip.cs
- ConstructorBuilder.cs
- SafeLibraryHandle.cs
- FacetChecker.cs
- __Filters.cs
- OwnerDrawPropertyBag.cs
- InfoCardKeyedHashAlgorithm.cs
- figurelengthconverter.cs
- MenuItem.cs
- TagMapCollection.cs
- ContextInformation.cs
- ListViewAutomationPeer.cs
- EntityReference.cs
- SqlProviderServices.cs
- AsyncDataRequest.cs
- TextDpi.cs
- CollectionChangeEventArgs.cs
- XmlReflectionMember.cs
- HuffCodec.cs
- SplitContainer.cs
- TableMethodGenerator.cs
- DataServiceCollectionOfT.cs
- HandleScope.cs