コード例 #1
0
ファイル: Thumbnail.cs プロジェクト: Fernir/cleanLayer
        private void InitialiseThumbnail(IntPtr source)
        {
            if (IntPtr.Zero != thumb)
            {
                // release the old thumbnail
                ReleaseThumbnail();
            }

            if (IntPtr.Zero != source)
            {
                // find our parent hwnd
                target = (HwndSource)HwndSource.FromVisual(this);

                // if we have one, we can attempt to register the thumbnail
                if (target != null && 0 == DWM.DwmRegisterThumbnail(target.Handle, source, out this.thumb))
                {
                    DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
                    props.Visible = false;
                    props.SourceClientAreaOnly = this.ClientAreaOnly;
                    props.Opacity = (byte)(255 * this.Opacity);
                    props.Flags   = DWM.ThumbnailFlags.Visible | DWM.ThumbnailFlags.SourceClientAreaOnly
                                    | DWM.ThumbnailFlags.Opacity;
                    DWM.DwmUpdateThumbnailProperties(thumb, ref props);
                }
            }
        }
コード例 #2
0
ファイル: Thumbnail.cs プロジェクト: Fernir/cleanLayer
        // this is where the magic happens
        private void Thumbnail_LayoutUpdated(object sender, EventArgs e)
        {
            if (IntPtr.Zero == thumb)
            {
                InitialiseThumbnail(this.Source);
            }

            if (IntPtr.Zero != thumb)
            {
                if (!target.RootVisual.IsAncestorOf(this))
                {
                    //we are no longer in the visual tree
                    ReleaseThumbnail();
                    return;
                }

                GeneralTransform transform = TransformToAncestor(target.RootVisual);
                Point            a         = transform.Transform(new Point(0, 0));
                Point            b         = transform.Transform(new Point(this.ActualWidth, this.ActualHeight));

                DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
                props.Visible     = true;
                props.Destination = new DWM.Rect(
                    (int)Math.Ceiling(a.X), (int)Math.Ceiling(a.Y),
                    (int)Math.Ceiling(b.X), (int)Math.Ceiling(b.Y));
                props.Flags = DWM.ThumbnailFlags.Visible | DWM.ThumbnailFlags.RectDetination;
                DWM.DwmUpdateThumbnailProperties(thumb, ref props);
            }
        }
コード例 #3
0
ファイル: Thumbnail.cs プロジェクト: Fernir/cleanLayer
 private void UpdateThumbnail()
 {
     if (IntPtr.Zero != thumb)
     {
         DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
         props.SourceClientAreaOnly = this.ClientAreaOnly;
         props.Opacity = (byte)(255 * this.Opacity);
         props.Flags   = DWM.ThumbnailFlags.SourceClientAreaOnly | DWM.ThumbnailFlags.Opacity;
         DWM.DwmUpdateThumbnailProperties(thumb, ref props);
     }
 }
コード例 #4
0
ファイル: Thumbnail.cs プロジェクト: Vipeax/cleanLayer
 private void UpdateThumbnail()
 {
     if (IntPtr.Zero != thumb)
     {
         DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
         props.SourceClientAreaOnly = this.ClientAreaOnly;
         props.Opacity = (byte)(255 * this.Opacity);
         props.Flags = DWM.ThumbnailFlags.SourceClientAreaOnly | DWM.ThumbnailFlags.Opacity;
         DWM.DwmUpdateThumbnailProperties(thumb, ref props);
     }
 }
コード例 #5
0
ファイル: Thumbnail.cs プロジェクト: Vipeax/cleanLayer
        // this is where the magic happens
        private void Thumbnail_LayoutUpdated(object sender, EventArgs e)
        {
            if (IntPtr.Zero == thumb)
            {
                InitialiseThumbnail(this.Source);
            }

            if (IntPtr.Zero != thumb)
            {
                if (!target.RootVisual.IsAncestorOf(this))
                {
                    //we are no longer in the visual tree
                    ReleaseThumbnail();
                    return;
                }

                GeneralTransform transform = TransformToAncestor(target.RootVisual);
                Point a = transform.Transform(new Point(0, 0));
                Point b = transform.Transform(new Point(this.ActualWidth, this.ActualHeight));

                DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
                props.Visible = true;
                props.Destination = new DWM.Rect(
                    (int)Math.Ceiling(a.X), (int)Math.Ceiling(a.Y),
                    (int)Math.Ceiling(b.X), (int)Math.Ceiling(b.Y));
                props.Flags = DWM.ThumbnailFlags.Visible | DWM.ThumbnailFlags.RectDetination;
                DWM.DwmUpdateThumbnailProperties(thumb, ref props);
            }
        }
コード例 #6
0
ファイル: Thumbnail.cs プロジェクト: Vipeax/cleanLayer
        private void InitialiseThumbnail(IntPtr source)
        {
            if (IntPtr.Zero != thumb)
            {
                // release the old thumbnail
                ReleaseThumbnail();
            }

            if (IntPtr.Zero != source)
            {
                // find our parent hwnd
                target = (HwndSource)HwndSource.FromVisual(this);

                // if we have one, we can attempt to register the thumbnail
                if (target != null && 0 == DWM.DwmRegisterThumbnail(target.Handle, source, out this.thumb))
                {
                    DWM.ThumbnailProperties props = new DWM.ThumbnailProperties();
                    props.Visible = false;
                    props.SourceClientAreaOnly = this.ClientAreaOnly;
                    props.Opacity = (byte)(255 * this.Opacity);
                    props.Flags = DWM.ThumbnailFlags.Visible | DWM.ThumbnailFlags.SourceClientAreaOnly
                    | DWM.ThumbnailFlags.Opacity;
                    DWM.DwmUpdateThumbnailProperties(thumb, ref props);
                }
            }
        }