protected override void CopyCore(Freezable sourceFreezable) { base.CopyCore(sourceFreezable); sourceFreezable.SetValue(ByProperty, GetValue(ByProperty)); sourceFreezable.SetValue(FromProperty, GetValue(FromProperty)); sourceFreezable.SetValue(ToProperty, GetValue(ToProperty)); }
protected override void CopyCore(Freezable sourceFreezable) { base.CopyCore(sourceFreezable); if (_children == null) { return; } foreach (Timeline childTimeline in _children) { ((TimelineGroup)sourceFreezable).Children.Add(childTimeline.Copy()); } }
protected override void CopyCore(Freezable sourceFreezable) { base.CopyCore(sourceFreezable); Timeline sourceTimeline = (Timeline)sourceFreezable; sourceTimeline._accelerationRatio = _accelerationRatio; sourceTimeline._beginTime = _beginTime; sourceTimeline._cutoffTime = _cutoffTime; sourceTimeline._decelerationRatio = _decelerationRatio; sourceTimeline._duration = _duration; sourceTimeline._fillBehavior = _fillBehavior; sourceTimeline._isAutoReverse = _isAutoReverse; sourceTimeline._name = _name; sourceTimeline._repeatBehavior = _repeatBehavior; sourceTimeline._speedRatio = _speedRatio; }
bool IFreezeFreezables.TryFreeze(string value, Freezable freezable) { // We don't check FreezeFreezables since this is used only by the BrushBinary deserializer inter----ly // It will check FreezeFreezables. if (freezable.CanFreeze) { if (!freezable.IsFrozen) { freezable.Freeze(); } if (_freezeCache == null) { _freezeCache = new Dictionary<string, Freezable>(); } _freezeCache.Add(value, freezable); return true; } return false; }
// Token: 0x06007F37 RID: 32567 RVA: 0x0024110E File Offset: 0x0023F30E bool IFreezeFreezables.TryFreeze(string value, Freezable freezable) { return(this._freezer.TryFreeze(value, freezable)); }
protected override void GetCurrentValueAsFrozenCore(Freezable source) { throw new NotImplementedException(); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> /// <param name="sourceFreezable"></param> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(transform); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetAsFrozenCore(Freezable)">Freezable.GetAsFrozenCore</see>. /// </summary> protected override void GetAsFrozenCore(Freezable sourceFreezable) { BitmapFrameDecode sourceBitmapFrameDecode = (BitmapFrameDecode)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmapFrameDecode); }
// This is the internal method called to set up the listeners on both // the original and the clone. internal static void ListenToChangesOnFreezable( DependencyObject target, Freezable clone, DependencyProperty dp, Freezable original) { ChangeListener listener = new ChangeListener( target, clone, dp, original ); listener.Setup(); }
protected static bool Freeze(Freezable freezable, bool isChecking) { throw new NotImplementedException (); }
/// <summary> /// Freezable override to clone the non dependency properties /// </summary> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { base.CloneCurrentValueCore(sourceFreezable); _gesture = ((InputBinding)sourceFreezable).Gesture; }
/// <summary> /// Freezable override of GetCurrentValueAsFrozenCore /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { base.GetCurrentValueAsFrozenCore(sourceFreezable); _gesture = ((InputBinding)sourceFreezable).Gesture; }
public void Freeze_nonFreezable_object_should_throw_InvalidOperationException() { var rex = new Pet(); Assert.Throws <InvalidOperationException>(() => Freezable.Freeze(rex)); }
public static void CheckIsFrozen(Freezable f) { // if (f != null && !f.IsFrozen) // Debug.WriteLine("Performance warning: Not frozen: " + f.ToString()); }
internal static void TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack <WpfXamlFrame> stack, IStyleConnector styleConnector) { while (xamlReader.Read()) { if (shouldPassLineNumberInfo) { if (xamlLineInfo.LineNumber != 0) { xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition); } } switch (xamlReader.NodeType) { case System.Xaml.XamlNodeType.NamespaceDeclaration: xamlWriter.WriteNode(xamlReader); if (stack.Depth == 0 || stack.CurrentFrame.Type != null) { stack.PushScope(); // Need to create an XmlnsDictionary. // Look up stack to see if we have one earlier // If so, use that. Otherwise new a xmlnsDictionary WpfXamlFrame iteratorFrame = stack.CurrentFrame; while (iteratorFrame != null) { if (iteratorFrame.XmlnsDictionary != null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(iteratorFrame.XmlnsDictionary); break; } iteratorFrame = (WpfXamlFrame)iteratorFrame.Previous; } if (stack.CurrentFrame.XmlnsDictionary == null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(); } } stack.CurrentFrame.XmlnsDictionary.Add(xamlReader.Namespace.Prefix, xamlReader.Namespace.Namespace); break; case System.Xaml.XamlNodeType.StartObject: xamlWriter.WriteNode(xamlReader); // If there's a frame but no Type, that means there // was a namespace. Just set the Type if (stack.Depth != 0 && stack.CurrentFrame.Type == null) { stack.CurrentFrame.Type = xamlReader.Type; } else { // Propagate the FreezeFreezable property from the current stack frame stack.PushScope(); stack.CurrentFrame.Type = xamlReader.Type; if (stack.PreviousFrame.FreezeFreezable) { stack.CurrentFrame.FreezeFreezable = true; } } break; case System.Xaml.XamlNodeType.GetObject: xamlWriter.WriteNode(xamlReader); // If there wasn't a namespace node before this get object, need to pushScope. if (stack.CurrentFrame.Type != null) { stack.PushScope(); } stack.CurrentFrame.Type = stack.PreviousFrame.Property.Type; break; case System.Xaml.XamlNodeType.EndObject: xamlWriter.WriteNode(xamlReader); // Freeze if required if (stack.CurrentFrame.FreezeFreezable) { Freezable freezable = xamlWriter.Result as Freezable; if (freezable != null && freezable.CanFreeze) { freezable.Freeze(); } } DependencyObject dependencyObject = xamlWriter.Result as DependencyObject; if (dependencyObject != null && stack.CurrentFrame.XmlSpace.HasValue) { XmlAttributeProperties.SetXmlSpace(dependencyObject, stack.CurrentFrame.XmlSpace.Value ? "default" : "preserve"); } stack.PopScope(); break; case System.Xaml.XamlNodeType.StartMember: // ObjectWriter should NOT process PresentationOptions:Freeze directive since it is Unknown // The space directive node stream should not be written because it induces object instantiation, // and the Baml2006Reader can produce space directives prematurely. if (!(xamlReader.Member.IsDirective && xamlReader.Member == XamlReaderHelper.Freeze) && xamlReader.Member != XmlSpace.Value && xamlReader.Member != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } stack.CurrentFrame.Property = xamlReader.Member; if (skipJournaledProperties) { if (!stack.CurrentFrame.Property.IsDirective) { System.Windows.Baml2006.WpfXamlMember wpfMember = stack.CurrentFrame.Property as System.Windows.Baml2006.WpfXamlMember; if (wpfMember != null) { DependencyProperty prop = wpfMember.DependencyProperty; if (prop != null) { FrameworkPropertyMetadata metadata = prop.GetMetadata(stack.CurrentFrame.Type.UnderlyingType) as FrameworkPropertyMetadata; if (metadata != null && metadata.Journal == true) { // int count = 1; while (xamlReader.Read()) { switch (xamlReader.NodeType) { case System.Xaml.XamlNodeType.StartMember: count++; break; case System.Xaml.XamlNodeType.EndMember: count--; if (count == 0) { xamlWriter.WriteNode(xamlReader); } break; } if (count == 0) { break; } } // shouldn't this have been a XamlReader.Skip()? System.Diagnostics.Debug.Assert(count == 0, "Mismatch StartMember/EndMember"); } } } } } break; case System.Xaml.XamlNodeType.EndMember: WpfXamlFrame currentFrame = stack.CurrentFrame; XamlMember currentProperty = currentFrame.Property; // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown // The space directive node stream should not be written because it induces object instantiation, // and the Baml2006Reader can produce space directives prematurely. if (!(currentProperty.IsDirective && currentProperty == XamlReaderHelper.Freeze) && currentProperty != XmlSpace.Value && currentProperty != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } currentFrame.Property = null; break; case System.Xaml.XamlNodeType.Value: if (stack.CurrentFrame.Property.IsDirective && stack.CurrentFrame.Property == XamlLanguage.Shared) { bool isShared; if (bool.TryParse(xamlReader.Value as string, out isShared)) { if (!isShared) { if (!(xamlReader is Baml2006Reader)) { throw new XamlParseException(SR.Get(SRID.SharedAttributeInLooseXaml)); } } } } // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown if (stack.CurrentFrame.Property.IsDirective && stack.CurrentFrame.Property == XamlReaderHelper.Freeze) { bool freeze = Convert.ToBoolean(xamlReader.Value, TypeConverterHelper.InvariantEnglishUS); stack.CurrentFrame.FreezeFreezable = freeze; var bamlReader = xamlReader as System.Windows.Baml2006.Baml2006Reader; if (bamlReader != null) { bamlReader.FreezeFreezables = freeze; } } // The space directive node stream should not be written because it induces object instantiation, // and the Baml2006Reader can produce space directives prematurely. else if (stack.CurrentFrame.Property == XmlSpace.Value || stack.CurrentFrame.Property == XamlLanguage.Space) { if (typeof(DependencyObject).IsAssignableFrom(stack.CurrentFrame.Type.UnderlyingType)) { System.Diagnostics.Debug.Assert(xamlReader.Value is string, "XmlAttributeProperties.XmlSpaceProperty has the type string."); stack.CurrentFrame.XmlSpace = (string)xamlReader.Value == "default"; } } else { // Ideally we should check if we're inside FrameworkTemplate's Content and not register those. // However, checking if the instance is null accomplishes the same with a much smaller perf impact. if (styleConnector != null && stack.CurrentFrame.Instance != null && stack.CurrentFrame.Property == XamlLanguage.ConnectionId && typeof(Style).IsAssignableFrom(stack.CurrentFrame.Type.UnderlyingType)) { styleConnector.Connect((int)xamlReader.Value, stack.CurrentFrame.Instance); } xamlWriter.WriteNode(xamlReader); } break; default: xamlWriter.WriteNode(xamlReader); break; } //Only do this loop for one node if loadAsync if (onlyLoadOneNode) { return; } } }
CloneCommon( Freezable sourceFreezable ) { MediaPlayer player = (MediaPlayer)sourceFreezable; _mediaPlayerState = player._mediaPlayerState; _duceResource = player._duceResource; }
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { base.GetCurrentValueAsFrozenCore(sourceFreezable); CloneCommon(sourceFreezable); }
internal bool TryCacheFreezable(string value, Freezable freezable) { if (FreezeFreezables) { if (freezable.CanFreeze) { if (!freezable.IsFrozen) { freezable.Freeze(); } if (_freezeCache == null) { _freezeCache = new Dictionary<string, Freezable>(); } _freezeCache.Add(value, freezable); return true; } } return false; }
public void IsFreezable_should_be_false_for_objects_created_with_ctor() { var nonFreezablePet = new Pet(); Assert.False(Freezable.IsFreezable(nonFreezablePet)); }
protected override void CloneCurrentValueCore(Freezable sourceFreezable) { base.CloneCurrentValueCore(sourceFreezable); CloneCommon(sourceFreezable); }
public void IsFreezable_should_be_true_for_objects_created_with_MakeFreezable() { var freezablePet = Freezable.MakeFreezable <Pet>(); Assert.True(Freezable.IsFreezable(freezablePet)); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); }
public void Freeze_nonFreezable_object_should_throw_NotFreezableObjectException() { var rex = new Pet(); Assert.Throws <NotFreezableObjectException>(() => Freezable.Freeze(rex)); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetAsFrozenCore(Freezable)">Freezable.GetAsFrozenCore</see>. /// </summary> /// <param name="sourceFreezable"></param> protected override void GetAsFrozenCore(Freezable sourceFreezable) { GeneralTransform2DTo3D transform = (GeneralTransform2DTo3D)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(transform); }
internal static void TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack <WpfXamlFrame> stack, IStyleConnector styleConnector) { while (xamlReader.Read()) { if (shouldPassLineNumberInfo) { if (xamlLineInfo.LineNumber != 0) { xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition); } } switch (xamlReader.NodeType) { case System.Xaml.XamlNodeType.NamespaceDeclaration: xamlWriter.WriteNode(xamlReader); if (stack.Depth == 0 || stack.CurrentFrame.Type != null) { stack.PushScope(); // Need to create an XmlnsDictionary. // Look up stack to see if we have one earlier // If so, use that. Otherwise new a xmlnsDictionary WpfXamlFrame iteratorFrame = stack.CurrentFrame; while (iteratorFrame != null) { if (iteratorFrame.XmlnsDictionary != null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(iteratorFrame.XmlnsDictionary); break; } iteratorFrame = (WpfXamlFrame)iteratorFrame.Previous; } if (stack.CurrentFrame.XmlnsDictionary == null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(); } } stack.CurrentFrame.XmlnsDictionary.Add(xamlReader.Namespace.Prefix, xamlReader.Namespace.Namespace); break; case System.Xaml.XamlNodeType.StartObject: WriteStartObject(xamlReader, xamlWriter, stack); break; case System.Xaml.XamlNodeType.GetObject: xamlWriter.WriteNode(xamlReader); // If there wasn't a namespace node before this get object, need to pushScope. if (stack.CurrentFrame.Type != null) { stack.PushScope(); } stack.CurrentFrame.Type = stack.PreviousFrame.Property.Type; break; case System.Xaml.XamlNodeType.EndObject: xamlWriter.WriteNode(xamlReader); // Freeze if required if (stack.CurrentFrame.FreezeFreezable) { Freezable freezable = xamlWriter.Result as Freezable; if (freezable != null && freezable.CanFreeze) { freezable.Freeze(); } } DependencyObject dependencyObject = xamlWriter.Result as DependencyObject; if (dependencyObject != null && stack.CurrentFrame.XmlSpace.HasValue) { XmlAttributeProperties.SetXmlSpace(dependencyObject, stack.CurrentFrame.XmlSpace.Value ? "default" : "preserve"); } stack.PopScope(); break; case System.Xaml.XamlNodeType.StartMember: // ObjectWriter should NOT process PresentationOptions:Freeze directive since it is Unknown // The space directive node stream should not be written because it induces object instantiation, // and the Baml2006Reader can produce space directives prematurely. if (!(xamlReader.Member.IsDirective && xamlReader.Member == XamlReaderHelper.Freeze) && xamlReader.Member != XmlSpace.Value && xamlReader.Member != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } stack.CurrentFrame.Property = xamlReader.Member; if (skipJournaledProperties) { if (!stack.CurrentFrame.Property.IsDirective) { System.Windows.Baml2006.WpfXamlMember wpfMember = stack.CurrentFrame.Property as System.Windows.Baml2006.WpfXamlMember; if (wpfMember != null) { DependencyProperty prop = wpfMember.DependencyProperty; if (prop != null) { FrameworkPropertyMetadata metadata = prop.GetMetadata(stack.CurrentFrame.Type.UnderlyingType) as FrameworkPropertyMetadata; if (metadata != null && metadata.Journal == true) { // Ignore the BAML for this member, unless it declares a value that wasn't journaled - namely a binding or a dynamic resource int count = 1; while (xamlReader.Read()) { switch (xamlReader.NodeType) { case System.Xaml.XamlNodeType.StartMember: count++; break; case System.Xaml.XamlNodeType.StartObject: XamlType xamlType = xamlReader.Type; XamlType bindingBaseType = xamlType.SchemaContext.GetXamlType(typeof(BindingBase)); XamlType dynamicResourceType = xamlType.SchemaContext.GetXamlType(typeof(DynamicResourceExtension)); if (count == 1 && (xamlType.CanAssignTo(bindingBaseType) || xamlType.CanAssignTo(dynamicResourceType))) { count = 0; WriteStartObject(xamlReader, xamlWriter, stack); } break; case System.Xaml.XamlNodeType.EndMember: count--; if (count == 0) { xamlWriter.WriteNode(xamlReader); stack.CurrentFrame.Property = null; } break; case System.Xaml.XamlNodeType.Value: DynamicResourceExtension value = xamlReader.Value as DynamicResourceExtension; if (value != null) { WriteValue(xamlReader, xamlWriter, stack, styleConnector); } break; } if (count == 0) { break; } } System.Diagnostics.Debug.Assert(count == 0, "Mismatch StartMember/EndMember"); } } } } } break; case System.Xaml.XamlNodeType.EndMember: WpfXamlFrame currentFrame = stack.CurrentFrame; XamlMember currentProperty = currentFrame.Property; // ObjectWriter should not process PresentationOptions:Freeze directive nodes since it is unknown // The space directive node stream should not be written because it induces object instantiation, // and the Baml2006Reader can produce space directives prematurely. if (!(currentProperty.IsDirective && currentProperty == XamlReaderHelper.Freeze) && currentProperty != XmlSpace.Value && currentProperty != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } currentFrame.Property = null; break; case System.Xaml.XamlNodeType.Value: WriteValue(xamlReader, xamlWriter, stack, styleConnector); break; default: xamlWriter.WriteNode(xamlReader); break; } //Only do this loop for one node if loadAsync if (onlyLoadOneNode) { return; } } }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCore(System.Windows.Freezable)">Freezable.CloneCore</see>. /// </summary> protected override void CloneCore(Freezable sourceFreezable) { BooleanKeyFrameCollection sourceCollection = (BooleanKeyFrameCollection) sourceFreezable; base.CloneCore(sourceFreezable); int count = sourceCollection._keyFrames.Count; _keyFrames = new List< BooleanKeyFrame>(count); for (int i = 0; i < count; i++) { BooleanKeyFrame keyFrame = (BooleanKeyFrame)sourceCollection._keyFrames[i].Clone(); _keyFrames.Add(keyFrame); OnFreezablePropertyChanged(null, keyFrame); } }
private static bool TryGetImageResource(Type owningType, FieldInfo field, ResourceDictionary imageResources, string subPath) { if (string.IsNullOrEmpty(subPath)) { throw new ArgumentNullException("subPath"); } // Get Image attributes object[] attributes = field.GetCustomAttributes(typeof(ImageResourceAttribute), false); if (attributes.Length == 0) { return(false); } var attribute = (ImageResourceAttribute)attributes[0]; Freezable img = null; if (string.IsNullOrEmpty(attribute.ImageName1)) { throw new InvalidOperationException("Cannot have an image attribute whose first image name is null or empty"); } var extension = Path.GetExtension(attribute.ImageName1); if (string.IsNullOrEmpty(extension)) { throw new InvalidOperationException("Cannot have an image attribute whose first image name has no extension"); } extension = extension.ToLower(); // Generate packUri var assmName = owningType.Assembly.GetName(); var basePackUriRel = "/" + assmName + ";component/" + subPath; if (!basePackUriRel.EndsWith("/")) { basePackUriRel += "/"; } if (extension == ".xaml") { var uri = new Uri(basePackUriRel + attribute.ImageName1, UriKind.Relative); img = Application.LoadComponent(uri) as Freezable; if (img == null) { throw new InvalidOperationException("Invalid xaml image resource: " + attribute.ImageName1); } } else if (extension == ".cur") { var uri = new Uri(basePackUriRel + attribute.ImageName1, UriKind.Relative); try { var info = Application.GetResourceStream(uri); img = new FreezableCursor { Cursor = new System.Windows.Input.Cursor(info.Stream) }; } catch (IOException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } else if (extension == ".bmp" || extension == ".png" || extension == ".ico") { // First attempt to retrieve the image as an 'Embedded Resource' (ie legacy WinForms-era resource compilation) var stream = owningType.Assembly.GetManifestResourceStream(owningType + "." + attribute.ImageName1); if (stream != null) { img = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.None); } else { // image must be compiled in as a 'Linked Resource' (ie WPF-era resource compilation) var basePackUriAbs = "pack://application:,,," + basePackUriRel; var uri = new Uri(basePackUriAbs + attribute.ImageName1); try { img = new BitmapImage(uri); } catch (IOException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } else { throw new Exception( "Unrecognized extension '" + extension + "' on image resource '" + field.Name + "'"); } if (img == null) { throw new Exception("Failed to create image from image resource '" + field.Name + "'"); } // Might it be better to keep the img as a DrawingGroup and then assign to relevant Image type later? if (img is DrawingGroup) { var brush = new DrawingBrush(img as DrawingGroup); brush.Stretch = Stretch.Uniform; img = brush; } if (img.CanFreeze && !img.IsFrozen) { img.Freeze(); } object imageKey = owningType.FullName + "." + attribute.ImageName1; if (field.FieldType.IsAssignableFrom(typeof(ResourceKey))) { var componentResourceKey = new ComponentResourceKey(owningType, imageKey); s_resourceKeys[attribute.ImageName1] = componentResourceKey; imageKey = componentResourceKey; } field.SetValue(owningType, imageKey); if (!imageResources.Contains(imageKey)) { imageResources.Add(imageKey, img); } return(true); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>. /// </summary> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { BitmapSource sourceBitmap = (BitmapSource)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceBitmap); }
static void \u206B([In] Freezable obj0) { obj0.Freeze(); }
protected override void CloneCurrentValueCore(Freezable sourceFreezable) { throw new NotImplementedException(); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCore(System.Windows.Freezable)">Freezable.CloneCore</see>. /// </summary> /// <param name="sourceFreezable">The KeySpline to copy.</param> protected override void CloneCore(Freezable sourceFreezable) { KeySpline sourceKeySpline = (KeySpline) sourceFreezable; base.CloneCore(sourceFreezable); CloneCommon(sourceKeySpline); }
protected override void CloneValues(Freezable target, FreezableCloneOptions option) { base.CloneValues(target, option); this.CopyExtendedProperties(target as MetaBase); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>. /// </summary> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { MediaTimeline sourceTimeline = (MediaTimeline) sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceTimeline); }
// Token: 0x06002218 RID: 8728 RVA: 0x000AA15E File Offset: 0x000A835E bool IFreezeFreezables.TryFreeze(string value, Freezable freezable) { return(this._context.TryCacheFreezable(value, freezable)); }
bool IFreezeFreezables.TryFreeze(string value, Freezable freezable) { return _freezer.TryFreeze(value, freezable); }
protected override void CopyCore(Freezable sourceFreezable) { }
/// <summary> /// Registers any attributed resource keys found on the type</summary> /// <param name="type">Type, usually a static set of keys</param> /// <param name="resourcePath">Path to resources</param> public static void Register(Type type, string resourcePath) { if (s_registeredTypes.Contains(type)) { return; } s_registeredTypes.Add(type); // Generate packUri AssemblyName assmName = type.Assembly.GetName(); string relativePackUriBase = "/" + assmName.Name + ";component/" + resourcePath; string absolutePackUriBase = "pack://application:,,," + relativePackUriBase; ResourceDictionary imageResources = null; FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo field in fields) { // Get Image attributes object[] attributes = field.GetCustomAttributes(typeof(WpfImageResourceAttribute), false); if (attributes.Length > 0) { if (!field.FieldType.IsAssignableFrom(typeof(ResourceKey))) { System.Diagnostics.Debug.WriteLine("Warning: WpfImageResourceAttribute used on a field which is not a ResourceKey"); } var attribute = (WpfImageResourceAttribute)attributes[0]; Freezable img = null; string extension = System.IO.Path.GetExtension(attribute.ImageName).ToLower(); if (extension == ".bmp" || extension == ".png" || extension == ".ico") { var uri = new Uri(absolutePackUriBase + attribute.ImageName); try { img = new BitmapImage(uri); } catch (IOException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } else if (extension == ".xaml") { var uri = new Uri(relativePackUriBase + attribute.ImageName, UriKind.Relative); img = Application.LoadComponent(uri) as Freezable; if (img == null) { throw new InvalidOperationException("Invalid xaml image resource: " + attribute.ImageName); } } else if (extension == ".cur") { var uri = new Uri(relativePackUriBase + attribute.ImageName, UriKind.Relative); try { var info = Application.GetResourceStream(uri); img = new FreezableCursor { Cursor = new System.Windows.Input.Cursor(info.Stream) }; } catch (IOException ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } else { throw new InvalidOperationException("Unrecognized Wpf image resource file extension for file: " + attribute.ImageName); } if (img != null) { // Might it be better to keep the img as a DrawingGroup and then assign to relevant Image type later? if (img is DrawingGroup) { var brush = new DrawingBrush(img as DrawingGroup); brush.Stretch = Stretch.Uniform; img = brush; } if (img.CanFreeze && !img.IsFrozen) { img.Freeze(); } object imageKey = type.FullName + "." + attribute.ImageName; if (field.FieldType.IsAssignableFrom(typeof(ResourceKey))) { imageKey = new ComponentResourceKey(type, imageKey); } field.SetValue(type, imageKey); if (imageResources == null) { imageResources = new ResourceDictionary(); } imageResources.Add(imageKey, img); } } // Get ResourceDictionary attributes if (field.FieldType == typeof(string)) { attributes = field.GetCustomAttributes(typeof(ResourceDictionaryResourceAttribute), false); if (attributes.Length > 0) { var attribute = attributes[0] as ResourceDictionaryResourceAttribute; var dictionary = new ResourceDictionary(); string uri = absolutePackUriBase + attribute.Path; dictionary.Source = new Uri(uri, UriKind.RelativeOrAbsolute); Application.Current.Resources.MergedDictionaries.Add(dictionary); } } } if (imageResources != null) { Application.Current.Resources.MergedDictionaries.Add(imageResources); } }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(System.Windows.Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> /// <param name="sourceFreezable">The KeySpline to copy.</param> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { KeySpline sourceKeySpline = (KeySpline)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CloneCommon(sourceKeySpline); }
protected override void CloneCurrentValueCore(Freezable sourceFreezable) { InteropBitmap sourceBitmapSource = (InteropBitmap)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(sourceBitmapSource); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable source) { MediaTimeline sourceTimeline = (MediaTimeline) source; base.GetCurrentValueAsFrozenCore(source); CopyCommon(sourceTimeline); }
protected override void GetAsFrozenCore(Freezable sourceFreezable) { InteropBitmap sourceBitmapSource = (InteropBitmap)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmapSource); }
// Constructor of the object, the parameters include the property to // invalidate and the object to invalidate it on. As well as the // two Freezable objects (original and clone) that are associated // with the property on the target object. internal ChangeListener( DependencyObject target, Freezable clone, DependencyProperty property, Freezable original ) { Debug.Assert( target != null && clone != null && property != null && original != null, "Internal utility class requires non-null arguments. Check the caller of this method for an error."); _target = target; _property = property; _clone = clone; _original = original; }
// The creator of a FreezableDefaultValuePromoter should call this method // so that we can verify that the changed sender is the mutable default // value we handed out. internal void SetFreezableDefaultValue(Freezable mutableDefaultValue) { _mutableDefaultValue = mutableDefaultValue; }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCore(Freezable)">Freezable.CloneCore</see>. /// </summary> protected override void CloneCore(Freezable sourceFreezable) { throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy)); }
protected override void CloneCurrentValueCore(Freezable source) { Invariant.Assert(false); }
protected virtual void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { throw new NotImplementedException (); }
protected override void GetCurrentValueAsFrozenCore(Freezable source) { Invariant.Assert(false); }
protected virtual void CloneCurrentValueCore(Freezable sourceFreezable) { throw new NotImplementedException (); }
/// <summary> /// Makes the instance a clone (deep copy) of the specified <see cref="Freezable"/> /// using base (non-animated) property values. /// </summary> /// <param name="sourceFreezable"> /// The object to clone. /// </param> protected override sealed void CloneCore(Freezable sourceFreezable) { base.CloneCore(sourceFreezable); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>. /// </summary> /// <param name="sourceFreezable"></param> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(transform); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(System.Windows.Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { ThicknessKeyFrameCollection sourceCollection = (ThicknessKeyFrameCollection) sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); int count = sourceCollection._keyFrames.Count; _keyFrames = new List< ThicknessKeyFrame>(count); for (int i = 0; i < count; i++) { ThicknessKeyFrame keyFrame = (ThicknessKeyFrame)sourceCollection._keyFrames[i].GetCurrentValueAsFrozen(); _keyFrames.Add(keyFrame); OnFreezablePropertyChanged(null, keyFrame); } }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCore(Freezable)">Freezable.CloneCore</see>. /// </summary> protected override void CloneCore(Freezable sourceFreezable) { BitmapFrameDecode sourceBitmapFrameDecode = (BitmapFrameDecode)sourceFreezable; base.CloneCore(sourceFreezable); CopyCommon(sourceBitmapFrameDecode); }
protected override sealed void CloneCurrentValueCore(Freezable sourceFreezable) { base.CloneCurrentValueCore(sourceFreezable); }
protected override sealed void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { base.GetCurrentValueAsFrozenCore(sourceFreezable); }
/// <summary> /// Makes the instance a clone (deep copy) of the specified <see cref="Freezable"/> /// using base (non-animated) property values. /// </summary> /// <param name="sourceFreezable"> /// The object to clone. /// </param> protected sealed override void CloneCore(Freezable sourceFreezable) { base.CloneCore(sourceFreezable); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { BitmapSource sourceBitmap = (BitmapSource)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(sourceBitmap); }
// Token: 0x0600226B RID: 8811 RVA: 0x000AAF38 File Offset: 0x000A9138 internal static void TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack <WpfXamlFrame> stack, IStyleConnector styleConnector) { while (xamlReader.Read()) { if (shouldPassLineNumberInfo && xamlLineInfo.LineNumber != 0) { xamlLineInfoConsumer.SetLineInfo(xamlLineInfo.LineNumber, xamlLineInfo.LinePosition); } switch (xamlReader.NodeType) { case XamlNodeType.StartObject: WpfXamlLoader.WriteStartObject(xamlReader, xamlWriter, stack); break; case XamlNodeType.GetObject: xamlWriter.WriteNode(xamlReader); if (stack.CurrentFrame.Type != null) { stack.PushScope(); } stack.CurrentFrame.Type = stack.PreviousFrame.Property.Type; break; case XamlNodeType.EndObject: { xamlWriter.WriteNode(xamlReader); if (stack.CurrentFrame.FreezeFreezable) { Freezable freezable = xamlWriter.Result as Freezable; if (freezable != null && freezable.CanFreeze) { freezable.Freeze(); } } DependencyObject dependencyObject = xamlWriter.Result as DependencyObject; if (dependencyObject != null && stack.CurrentFrame.XmlSpace != null) { XmlAttributeProperties.SetXmlSpace(dependencyObject, stack.CurrentFrame.XmlSpace.Value ? "default" : "preserve"); } stack.PopScope(); break; } case XamlNodeType.StartMember: if ((!xamlReader.Member.IsDirective || !(xamlReader.Member == XamlReaderHelper.Freeze)) && xamlReader.Member != WpfXamlLoader.XmlSpace.Value && xamlReader.Member != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } stack.CurrentFrame.Property = xamlReader.Member; if (skipJournaledProperties && !stack.CurrentFrame.Property.IsDirective) { WpfXamlMember wpfXamlMember = stack.CurrentFrame.Property as WpfXamlMember; if (wpfXamlMember != null) { DependencyProperty dependencyProperty = wpfXamlMember.DependencyProperty; if (dependencyProperty != null) { FrameworkPropertyMetadata frameworkPropertyMetadata = dependencyProperty.GetMetadata(stack.CurrentFrame.Type.UnderlyingType) as FrameworkPropertyMetadata; if (frameworkPropertyMetadata != null && frameworkPropertyMetadata.Journal) { int num = 1; while (xamlReader.Read()) { switch (xamlReader.NodeType) { case XamlNodeType.StartObject: { XamlType type = xamlReader.Type; XamlType xamlType = type.SchemaContext.GetXamlType(typeof(BindingBase)); XamlType xamlType2 = type.SchemaContext.GetXamlType(typeof(DynamicResourceExtension)); if (num == 1 && (type.CanAssignTo(xamlType) || type.CanAssignTo(xamlType2))) { num = 0; WpfXamlLoader.WriteStartObject(xamlReader, xamlWriter, stack); } break; } case XamlNodeType.StartMember: num++; break; case XamlNodeType.EndMember: num--; if (num == 0) { xamlWriter.WriteNode(xamlReader); stack.CurrentFrame.Property = null; } break; case XamlNodeType.Value: { DynamicResourceExtension dynamicResourceExtension = xamlReader.Value as DynamicResourceExtension; if (dynamicResourceExtension != null) { WpfXamlLoader.WriteValue(xamlReader, xamlWriter, stack, styleConnector); } break; } } if (num == 0) { break; } } } } } } break; case XamlNodeType.EndMember: { WpfXamlFrame currentFrame = stack.CurrentFrame; XamlMember property = currentFrame.Property; if ((!property.IsDirective || !(property == XamlReaderHelper.Freeze)) && property != WpfXamlLoader.XmlSpace.Value && property != XamlLanguage.Space) { xamlWriter.WriteNode(xamlReader); } currentFrame.Property = null; break; } case XamlNodeType.Value: WpfXamlLoader.WriteValue(xamlReader, xamlWriter, stack, styleConnector); break; case XamlNodeType.NamespaceDeclaration: xamlWriter.WriteNode(xamlReader); if (stack.Depth == 0 || stack.CurrentFrame.Type != null) { stack.PushScope(); for (WpfXamlFrame wpfXamlFrame = stack.CurrentFrame; wpfXamlFrame != null; wpfXamlFrame = (WpfXamlFrame)wpfXamlFrame.Previous) { if (wpfXamlFrame.XmlnsDictionary != null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(wpfXamlFrame.XmlnsDictionary); break; } } if (stack.CurrentFrame.XmlnsDictionary == null) { stack.CurrentFrame.XmlnsDictionary = new XmlnsDictionary(); } } stack.CurrentFrame.XmlnsDictionary.Add(xamlReader.Namespace.Prefix, xamlReader.Namespace.Namespace); break; default: xamlWriter.WriteNode(xamlReader); break; } if (onlyLoadOneNode) { return; } } }