Inheritance: System.Windows.Media.CacheMode
Beispiel #1
0
        private static void EnableClearTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BitmapCache target = ((BitmapCache)d);


            target.PropertyChanged(EnableClearTypeProperty);
        }
Beispiel #2
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        private static void RenderAtScalePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BitmapCache target = ((BitmapCache)d);


            target.PropertyChanged(RenderAtScaleProperty);
        }
Beispiel #3
0
        private static void SnapsToDevicePixelsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            BitmapCache target = ((BitmapCache)d);


            target.PropertyChanged(SnapsToDevicePixelsProperty);
        }
Beispiel #4
0
        internal override void ReleaseOnChannelCore(DUCE.Channel channel)
        {
            Debug.Assert(_duceResource.IsOnChannel(channel));

            if (_duceResource.ReleaseOnChannel(channel))
            {
                Transform vTransform = Transform;
                if (vTransform != null)
                {
                    ((DUCE.IResource)vTransform).ReleaseOnChannel(channel);
                }
                Transform vRelativeTransform = RelativeTransform;
                if (vRelativeTransform != null)
                {
                    ((DUCE.IResource)vRelativeTransform).ReleaseOnChannel(channel);
                }
                BitmapCache vBitmapCache = BitmapCache;
                if (vBitmapCache != null)
                {
                    ((DUCE.IResource)vBitmapCache).ReleaseOnChannel(channel);
                }
                Visual vInternalTarget = InternalTarget;
                if (vInternalTarget != null)
                {
                    vInternalTarget.ReleaseOnChannelForCyclicBrush(this, channel);
                }
                ReleaseOnChannelAnimations(channel);
            }
        }
Beispiel #5
0
        internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel)
        {
            if (_duceResource.CreateOrAddRefOnChannel(this, channel, System.Windows.Media.Composition.DUCE.ResourceType.TYPE_BITMAPCACHEBRUSH))
            {
                Transform vTransform = Transform;
                if (vTransform != null)
                {
                    ((DUCE.IResource)vTransform).AddRefOnChannel(channel);
                }
                Transform vRelativeTransform = RelativeTransform;
                if (vRelativeTransform != null)
                {
                    ((DUCE.IResource)vRelativeTransform).AddRefOnChannel(channel);
                }
                BitmapCache vBitmapCache = BitmapCache;
                if (vBitmapCache != null)
                {
                    ((DUCE.IResource)vBitmapCache).AddRefOnChannel(channel);
                }
                Visual vInternalTarget = InternalTarget;
                if (vInternalTarget != null)
                {
                    vInternalTarget.AddRefOnChannelForCyclicBrush(this, channel);
                }
                AddRefOnChannelAnimations(channel);


                UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */);
            }

            return(_duceResource.GetHandle(channel));
        }
Beispiel #6
0
 private void chkCache_Click(object sender, RoutedEventArgs e)
 {
     if (chkCache.IsChecked == true)
     {
         BitmapCache bitmapCache = new BitmapCache();
         pathBackground.CacheMode = new BitmapCache();
     }
     else
     {
         pathBackground.CacheMode = null;                
     }
 }
     /// <summary>
     /// Parse - this method is called by the type converter to parse a CacheMode's string 
     /// (provided in "value").
     /// </summary>
     /// <returns>
     /// A CacheMode which was created by parsing the "value" argument.
     /// </returns>
     /// <param name="value"> String representation of a CacheMode. Cannot be null/empty. </param>
     internal static CacheMode Parse(string value)
     {
         CacheMode cacheMode = null;
         if (value == "BitmapCache")
         {
             cacheMode = new BitmapCache();
         }
         else
         {
             throw new FormatException(SR.Get(SRID.Parsers_IllegalToken));
         }
 
         return cacheMode;
     }
Beispiel #8
0
        public RadarCanvas()
        {
            CacheMode = new BitmapCache();
            ClipToBounds = true;

            CanvasData.OnCanvasSizeChanged += (before, after) =>
            {
                // Scene drawings are specific to a canvas size.
                // Changing canvas size means we have to redraw them all.
                Drawings.Relative.Clear();
                Drawings.Static.Clear();
                Clip = CanvasData.ClipRegion;
            };
        }
        /// <summary>
        /// Parse - this method is called by the type converter to parse a CacheMode's string
        /// (provided in "value").
        /// </summary>
        /// <returns>
        /// A CacheMode which was created by parsing the "value" argument.
        /// </returns>
        /// <param name="value"> String representation of a CacheMode. Cannot be null/empty. </param>
        internal static CacheMode Parse(string value)
        {
            CacheMode cacheMode = null;

            if (value == "BitmapCache")
            {
                cacheMode = new BitmapCache();
            }
            else
            {
                throw new FormatException(SR.Get(SRID.Parsers_IllegalToken));
            }

            return(cacheMode);
        }
Beispiel #10
0
 private void chkCache_Click(object sender, RoutedEventArgs e)
 {
     if (chkCache.IsChecked == true)
     {
         BitmapCache bitmapCache = new BitmapCache();
         bitmapCache.RenderAtScale = 5;
         cmd.CacheMode = bitmapCache;
         img.CacheMode = new BitmapCache();
     }
     else
     {
         cmd.CacheMode = null;
         img.CacheMode = null;
     }
 }
Beispiel #11
0
        private static void BitmapCachePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The first change to the default value of a mutable collection property (e.g. GeometryGroup.Children)
            // will promote the property value from a default value to a local value. This is technically a sub-property
            // change because the collection was changed and not a new collection set (GeometryGroup.Children.
            // Add versus GeometryGroup.Children = myNewChildrenCollection). However, we never marshalled
            // the default value to the compositor. If the property changes from a default value, the new local value
            // needs to be marshalled to the compositor. We detect this scenario with the second condition
            // e.OldValueSource != e.NewValueSource. Specifically in this scenario the OldValueSource will be
            // Default and the NewValueSource will be Local.
            if (e.IsASubPropertyChange &&
                (e.OldValueSource == e.NewValueSource))
            {
                return;
            }


            BitmapCacheBrush target = ((BitmapCacheBrush)d);


            BitmapCache oldV = (BitmapCache)e.OldValue;
            BitmapCache newV = (BitmapCache)e.NewValue;

            System.Windows.Threading.Dispatcher dispatcher = target.Dispatcher;

            if (dispatcher != null)
            {
                DUCE.IResource targetResource = (DUCE.IResource)target;
                using (CompositionEngineLock.Acquire())
                {
                    int channelCount = targetResource.GetChannelCount();

                    for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
                    {
                        DUCE.Channel channel = targetResource.GetChannel(channelIndex);
                        Debug.Assert(!channel.IsOutOfBandChannel);
                        Debug.Assert(!targetResource.GetHandle(channel).IsNull);
                        target.ReleaseResource(oldV, channel);
                        target.AddRefResource(newV, channel);
                    }
                }
            }

            target.PropertyChanged(BitmapCacheProperty);
        }
Beispiel #12
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal override void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
        {
            // If we're told we can skip the channel check, then we must be on channel
            Debug.Assert(!skipOnChannelCheck || _duceResource.IsOnChannel(channel));

            if (skipOnChannelCheck || _duceResource.IsOnChannel(channel))
            {
                base.UpdateResource(channel, skipOnChannelCheck);

                // Read values of properties into local variables
                Transform   vTransform         = Transform;
                Transform   vRelativeTransform = RelativeTransform;
                BitmapCache vBitmapCache       = BitmapCache;
                Visual      vInternalTarget    = InternalTarget;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hTransform;
                if (vTransform == null ||
                    Object.ReferenceEquals(vTransform, Transform.Identity)
                    )
                {
                    hTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hTransform = ((DUCE.IResource)vTransform).GetHandle(channel);
                }
                DUCE.ResourceHandle hRelativeTransform;
                if (vRelativeTransform == null ||
                    Object.ReferenceEquals(vRelativeTransform, Transform.Identity)
                    )
                {
                    hRelativeTransform = DUCE.ResourceHandle.Null;
                }
                else
                {
                    hRelativeTransform = ((DUCE.IResource)vRelativeTransform).GetHandle(channel);
                }
                DUCE.ResourceHandle hBitmapCache = vBitmapCache != null ? ((DUCE.IResource)vBitmapCache).GetHandle(channel) : DUCE.ResourceHandle.Null;

                // Obtain handles for properties that implement DUCE.IResource
                DUCE.ResourceHandle hInternalTarget = vInternalTarget != null ? ((DUCE.IResource)vInternalTarget).GetHandle(channel) : DUCE.ResourceHandle.Null;

                // Obtain handles for animated properties
                DUCE.ResourceHandle hOpacityAnimations = GetAnimationResourceHandle(OpacityProperty, channel);

                // Pack & send command packet
                DUCE.MILCMD_BITMAPCACHEBRUSH data;
                unsafe
                {
                    data.Type   = MILCMD.MilCmdBitmapCacheBrush;
                    data.Handle = _duceResource.GetHandle(channel);
                    if (hOpacityAnimations.IsNull)
                    {
                        data.Opacity = Opacity;
                    }
                    data.hOpacityAnimations = hOpacityAnimations;
                    data.hTransform         = hTransform;
                    data.hRelativeTransform = hRelativeTransform;
                    data.hBitmapCache       = hBitmapCache;
                    data.hInternalTarget    = hInternalTarget;

                    // Send packed command structure
                    channel.SendCommand(
                        (byte *)&data,
                        sizeof(DUCE.MILCMD_BITMAPCACHEBRUSH));
                }
            }
        }
Beispiel #13
0
        private void RenderTile()
        {
            if (_visual != null)
                {
                    _visual = null;
                    this.RemoveVisualChild(_visual);
                    this.RemoveLogicalChild(_visual);

                }

                _visual = new DrawingVisual();
                Width = Source.Width * Scale;
                Height = Source.Height * Scale;
                var dc = _visual.RenderOpen();
                //BitmapImage test = (BitmapImage)Source;

                Width = Source.Width * Scale;
                Height = Source.Height * Scale;
                WriteableBitmap test = new WriteableBitmap((BitmapSource)Source);
                //BitmapImage test = (BitmapImage)Source;

                int w = (int)test.PixelWidth;
                int h = (int)test.PixelHeight;
                Int32Rect rect = new Int32Rect(0, 0, w, h);
                int b = test.Format.BitsPerPixel;

                Byte[] pixels = new Byte[w * h * b / 8];
                int stride = w * b / 8;
                test.CopyPixels(pixels, stride, 0);
                double sc = Scale;

                /*//if (Modified == true)
                //{
                    //Drawing DrawObj = new Drawing();
                    Byte[] output;// = pixels ;
                    //Thread MulThread = new Thread(delegate()
                    //{
                    output = Drawing.DrawImage(pixels, w, h, b, value);
                    //});
                    // MulThread.Start();

                    BitmapSource image = BitmapSource.Create(w, h, 96, 96, test.Format, null, output, stride);

                    /*MemoryStream mStream = new MemoryStream(output);
                    mStream.Seek(0, SeekOrigin.Begin);
                    BitmapImage _bitmap = new BitmapImage();
                    _bitmap.BeginInit();
                    _bitmap.StreamSource = mStream;
                    _bitmap.CacheOption = BitmapCacheOption.OnLoad;
                    _bitmap.EndInit();

                    Source = _bitmap;
                    test.WritePixels(rect, output, stride, 0);
                    //Source = test;
                    //Scale = sc;

                }*/

                dc.DrawImage(Source, new Rect(0, 0, Width, Height));

                dc.Close();

               CacheMode = new BitmapCache(1 / Scale);
               // catch (Exception e)
            // Animate opacity
            Opacity = 0;
            BeginAnimation(OpacityProperty, _opacityAnimation);
        }
Beispiel #14
0
        private void RenderTile()
        {
            _visual = new DrawingVisual();
            Width = Source.Width * Scale;
            Height = Source.Height * Scale;
            var dc = _visual.RenderOpen();
            dc.DrawImage(Source, new Rect(0, 0, Width, Height));
            dc.Close();

            CacheMode = new BitmapCache(1 / Scale);

            // Animate opacity
            Opacity = 0;
            BeginAnimation(OpacityProperty, _opacityAnimation);
        }
Beispiel #15
0
 public Animation()
 {
     //ObjectTracker.Track(this);
     CacheMode = new BitmapCache();
 }