本文整理汇总了C#中System.Windows.Freezable类的典型用法代码示例。如果您正苦于以下问题:C# Freezable类的具体用法?C# Freezable怎么用?C# Freezable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Freezable类属于System.Windows命名空间,在下文中一共展示了Freezable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CloneCurrentValueCore
/// <summary>
/// Copies data into a cloned instance.
/// </summary>
/// <param name="source">
/// The original instance to copy data from.
/// </param>
/// <remarks>
/// When a Freezable's "current value" is cloned, WPF will make
/// deep clones of the "current values" of all writable,
/// locally-set properties. This has the effect of resolving
/// expressions to their values. WPF skips read only DPs.
///
/// If you derive from this class and have additional non-DP state
/// that should be transfered to copies, you should override the
/// CopyCommon method.
/// </remarks>
protected sealed override void CloneCurrentValueCore(Freezable source)
{
base.CloneCurrentValueCore(source);
CustomBitmap customBitmapSource = (CustomBitmap)source;
CopyCore(customBitmapSource, /*useCurrentValue*/ true, /*willBeFrozen*/ false);
}
开发者ID:NightmareX1337,项目名称:lfs,代码行数:23,代码来源:CustomBitmap.cs
示例2: FreezableBasicTest
public void FreezableBasicTest()
{
int resourcesChangedCount = 0;
object resourceValue;
Freezable freezable = new Freezable();
freezable.ResourcesChanged += (sender, e) => resourcesChangedCount++;
FrameworkElement element = new FrameworkElement();
element.DataContext = "data-context";
element.Resources = new ResourceDictionary();
element.Resources.Add("key1", "value1");
Assert.AreNotEqual("data-context", freezable.GetValue(FrameworkElement.DataContextProperty));
Assert.IsFalse(freezable.TryGetResource("key1", out resourceValue));
element.SetValue(ValueProperty, freezable);
Assert.AreEqual("data-context", freezable.GetValue(FrameworkElement.DataContextProperty));
Assert.AreEqual(1, resourcesChangedCount);
Assert.IsTrue(freezable.TryGetResource("key1", out resourceValue));
Assert.AreEqual("value1", resourceValue);
element.Resources.Add("key2", "value2");
Assert.AreEqual(2, resourcesChangedCount);
Assert.IsTrue(freezable.TryGetResource("key2", out resourceValue));
Assert.AreEqual("value2", resourceValue);
}
开发者ID:highzion,项目名称:Granular,代码行数:27,代码来源:FreezableTest.cs
示例3: FreezableDefaultValueFactory
/// <summary>
/// Stores a frozen copy of defaultValue
/// </summary>
internal FreezableDefaultValueFactory(Freezable defaultValue)
{
Debug.Assert(defaultValue != null,
"Null can not be made mutable. Do not use FreezableDefaultValueFactory.");
Debug.Assert(defaultValue.CanFreeze,
"The defaultValue prototype must be freezable.");
_defaultValuePrototype = defaultValue.GetAsFrozen();
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:12,代码来源:FreezableDefaultValueFactory.cs
示例4: GetAsFrozen
/// <summary>
/// Semantically equivilent to Freezable.Clone().Freeze() except that
/// GetAsFrozen avoids copying any portions of the Freezable graph
/// which are already frozen.
/// </summary>
public static Freezable GetAsFrozen(Freezable freezable)
{
if (freezable == null)
{
return null;
}
return freezable.GetAsFrozen();
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:FreezableOperations.cs
示例5: Clone
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
/// <summary>
/// A null-safe wrapper around Freezable.Clone(). (If a null
/// is encountered it returns null.)
/// </summary>
internal static Freezable Clone(Freezable freezable)
{
if (freezable == null)
{
return null;
}
return freezable.Clone();
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:27,代码来源:FreezableOperations.cs
示例6: CloneCore
/// <summary/>
protected override void CloneCore(Freezable sourceFreezable) {
base.CloneCore(sourceFreezable);
//TODO: Investigate why the following loop is needed. From the API docs, the Children collection should have cloned itself.
var sourceCollection = ((CompositeEffect)sourceFreezable).Children;
foreach (var child in sourceCollection) {
Children.Add((Effect)child.Clone());
}
}
开发者ID:borkaborka,项目名称:gmit,代码行数:10,代码来源:CompositeEffect.cs
示例7: FreezableProxyCommand
public FreezableProxyCommand(Freezable freezable, string name)
: base(null, name)
{
_freezable = freezable;
var evt = _freezable.GetType().GetEvent("InheritanceContextChanged",
BindingFlags.Instance | BindingFlags.NonPublic);
var addMethod = evt.GetAddMethod(true);
addMethod.Invoke(freezable, new[] {new EventHandler(OnInheritanceContextChanged)});
SetFrameworkElementFromInheritanceContext();
}
开发者ID:ArildF,项目名称:PTB,代码行数:12,代码来源:ResolveCommandExtension.cs
示例8: GetAsFrozenIfPossible
/// <summary>
/// If freezable is already frozen, it returns freezable
/// If freezable is not frozen, it returns a copy that is frozen if possible
/// </summary>
internal static Freezable GetAsFrozenIfPossible(Freezable freezable)
{
if (freezable == null)
{
return null;
}
if (freezable.CanFreeze)
{
freezable = freezable.GetAsFrozen();
}
return freezable;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:18,代码来源:FreezableOperations.cs
示例9: FreezableCollectionBasicTest
public void FreezableCollectionBasicTest()
{
int resources1ChangedCount = 0;
object resourceValue;
Freezable freezable1 = new Freezable();
freezable1.ResourcesChanged += (sender, e) => resources1ChangedCount++;
FreezableCollection<Freezable> freezableCollection = new FreezableCollection<Freezable> { freezable1 };
FrameworkElement element = new FrameworkElement();
element.DataContext = "data-context";
element.Resources = new ResourceDictionary();
element.Resources.Add("key1", "value1");
Assert.IsNull(freezable1.GetValue(FrameworkElement.DataContextProperty));
Assert.IsFalse(freezable1.TryGetResource("key1", out resourceValue));
element.SetValue(ValueProperty, freezableCollection);
Assert.AreEqual("data-context", freezable1.GetValue(FrameworkElement.DataContextProperty));
Assert.AreEqual(2, resources1ChangedCount);
Assert.IsTrue(freezable1.TryGetResource("key1", out resourceValue));
Assert.AreEqual("value1", resourceValue);
Freezable freezable2 = new Freezable();
freezableCollection.Add(freezable2);
Assert.AreEqual("data-context", freezable2.GetValue(FrameworkElement.DataContextProperty));
Assert.IsTrue(freezable2.TryGetResource("key1", out resourceValue));
Assert.AreEqual("value1", resourceValue);
freezableCollection.Clear();
Assert.AreNotEqual("data-context", freezable1.GetValue(FrameworkElement.DataContextProperty));
Assert.AreNotEqual("data-context", freezable2.GetValue(FrameworkElement.DataContextProperty));
Assert.AreEqual(3, resources1ChangedCount);
Assert.IsFalse(freezable1.TryGetResource("key1", out resourceValue));
Assert.IsFalse(freezable2.TryGetResource("key1", out resourceValue));
}
开发者ID:highzion,项目名称:Granular,代码行数:37,代码来源:FreezableTest.cs
示例10: GetCurrentValueAsFrozenCore
protected override void GetCurrentValueAsFrozenCore (Freezable sourceFreezable)
{
throw new NotImplementedException ();
}
开发者ID:alesliehughes,项目名称:olive,代码行数:4,代码来源:StringKeyFrameCollection.cs
示例11: GetCurrentValueAsFrozenCore
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
base.GetCurrentValueAsFrozenCore(sourceFreezable);
CloneCommon(sourceFreezable);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:6,代码来源:D3DImage.cs
示例12: GetCurrentValueAsFrozenCore
/// <summary>
/// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>.
/// </summary>
protected override void GetCurrentValueAsFrozenCore(Freezable source)
{
CharAnimationUsingKeyFrames sourceAnimation = (CharAnimationUsingKeyFrames) source;
base.GetCurrentValueAsFrozenCore(source);
CopyCommon(sourceAnimation, /* isCurrentValueClone = */ true);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:10,代码来源:CharAnimationUsingKeyFrames.cs
示例13: GetAsFrozenCore
/// <summary>
/// Implementation of <see cref="System.Windows.Freezable.GetAsFrozenCore(Freezable)">Freezable.GetAsFrozenCore</see>.
/// </summary>
protected override void GetAsFrozenCore(Freezable source)
{
DecimalAnimationUsingKeyFrames sourceAnimation = (DecimalAnimationUsingKeyFrames) source;
base.GetAsFrozenCore(source);
CopyCommon(sourceAnimation, /* isCurrentValueClone = */ false);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:10,代码来源:DecimalAnimationUsingKeyFrames.cs
示例14: AddChangedHandler
public void AddChangedHandler(Freezable resource)
{
// If _resource already exists, unhook the event handler.
if (_resource != null)
{
RemoveChangedHandler();
}
_resource = resource;
Debug.Assert(!_resource.IsFrozen);
_resource.Changed += new EventHandler(this.InvalidateTargetSubProperty);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:13,代码来源:ResourceReferenceExpression.cs
示例15: CloneCore
/// <summary>
/// Implementation of Freezable.CloneCore()
/// </summary>
protected override void CloneCore(Freezable source)
{
base.CloneCore(source);
StreamGeometry sourceStream = (StreamGeometry) source;
if ((sourceStream._data != null) && (sourceStream._data.Length > 0))
{
_data = new byte[sourceStream._data.Length];
sourceStream._data.CopyTo(_data, 0);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:StreamGeometry.cs
示例16: CloneCurrentValueCore
protected override void CloneCurrentValueCore(Freezable source)
{
Invariant.Assert(false);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:RenderData.cs
示例17: GetCurrentValueAsFrozenCore
protected override void GetCurrentValueAsFrozenCore(Freezable source)
{
Invariant.Assert(false);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:4,代码来源:RenderData.cs
示例18: GetCurrentValueAsFrozenCore
/// <summary>
/// Implementation of Freezable.GetCurrentValueAsFrozenCore()
/// </summary>
protected override void GetCurrentValueAsFrozenCore(Freezable source)
{
base.GetCurrentValueAsFrozenCore(source);
StreamGeometry sourceStream = (StreamGeometry) source;
if ((sourceStream._data != null) && (sourceStream._data.Length > 0))
{
_data = new byte[sourceStream._data.Length];
sourceStream._data.CopyTo(_data, 0);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:StreamGeometry.cs
示例19: CloneCurrentValueCore
/// <summary>
/// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>.
/// </summary>
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
QuaternionAnimationUsingKeyFrames sourceAnimation = (QuaternionAnimationUsingKeyFrames) sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(sourceAnimation, /* isCurrentValueClone = */ true);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:10,代码来源:QuaternionAnimationUsingKeyFrames.cs
示例20: CloneCurrentValueCore
/// <summary>
/// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>.
/// </summary>
/// <param name="sourceFreezable"></param>
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
GeneralTransform2DTo3DTo2D transform = (GeneralTransform2DTo3DTo2D)sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(transform);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:10,代码来源:GeneralTransform2DTo3DTo2D.cs
注:本文中的System.Windows.Freezable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论