mirror of
https://github.com/AlexMacocian/WpfExtended.git
synced 2026-07-15 14:59:30 +00:00
Reorganized structure.
Created test project.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="WpfExtended.Test.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WpfExtended.Test"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace WpfExtended.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 MiB |
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="WpfExtended.Test.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WpfExtended.Test"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WpfExtended.Test
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public static DependencyProperty ImageSourceProperty =
|
||||
DependencyProperty.Register(nameof(ImageSource), typeof(ImageSource), typeof(MainWindow));
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Tests.Utilities
|
||||
{
|
||||
internal static class TypeCrawler
|
||||
{
|
||||
public static IEnumerable<Type> GetEffectTypes<T>()
|
||||
{
|
||||
return AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(a => a.GetTypes()
|
||||
.Where(t => t.IsAssignableTo(typeof(T))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Images\Test.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30804.86
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfExtended", "WpfExtended\WpfExtended.csproj", "{E822AE0D-5EA1-4C61-A1DC-76CF73C8A524}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfExtended.Tests", "WpfExtended.Test\WpfExtended.Tests.csproj", "{48D2B8E6-F906-40D8-952E-B7B567D76A9B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{E822AE0D-5EA1-4C61-A1DC-76CF73C8A524}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E822AE0D-5EA1-4C61-A1DC-76CF73C8A524}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E822AE0D-5EA1-4C61-A1DC-76CF73C8A524}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48D2B8E6-F906-40D8-952E-B7B567D76A9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48D2B8E6-F906-40D8-952E-B7B567D76A9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48D2B8E6-F906-40D8-952E-B7B567D76A9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48D2B8E6-F906-40D8-952E-B7B567D76A9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class ColorKeyAlphaEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class InvertColorEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class MotionBlurEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class NegativeEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
using System;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
internal static class PixelShaderUtility
|
||||
{
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using LiteWare.Wpf.ShaderEffects;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
#if SILVERLIGHT
|
||||
using UIPropertyMetadata = System.Windows.PropertyMetadata ;
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
|
||||
// All other rights reserved.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class ToonShaderEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace WpfExtended.Effects
|
||||
namespace System.Windows.Media.Extensions.Effects
|
||||
{
|
||||
public class ZoomBlurEffect : ShaderEffect
|
||||
{
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace System.Windows.Extensions
|
||||
{
|
||||
public static class DependencyObjectExtensions
|
||||
{
|
||||
public static T GetTypedValue<T>(this DependencyObject dependencyObject, DependencyProperty dependencyProperty)
|
||||
{
|
||||
dependencyObject = dependencyObject ?? throw new ArgumentNullException(nameof(dependencyObject));
|
||||
|
||||
return (T)dependencyObject.GetValue(dependencyProperty);
|
||||
}
|
||||
public static void SetTypedValue<T>(this DependencyObject dependencyObject, DependencyProperty dependencyProperty, T value)
|
||||
{
|
||||
dependencyObject = dependencyObject ?? throw new ArgumentNullException(nameof(dependencyObject));
|
||||
|
||||
dependencyObject.SetValue(dependencyProperty, value);
|
||||
}
|
||||
public static List<T> FindVisualChildren<T>(this DependencyObject obj) where T : DependencyObject
|
||||
{
|
||||
obj = obj ?? throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
List<T> children = new List<T>();
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
|
||||
{
|
||||
var o = VisualTreeHelper.GetChild(obj, i);
|
||||
if (o != null)
|
||||
{
|
||||
if (o is T t)
|
||||
children.Add(t);
|
||||
|
||||
children.AddRange(FindVisualChildren<T>(o)); // recursive
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
public static T FindUpVisualTree<T>(this DependencyObject initial) where T : DependencyObject
|
||||
{
|
||||
initial = initial ?? throw new ArgumentNullException(nameof(initial));
|
||||
|
||||
DependencyObject current = initial;
|
||||
|
||||
while (current != null && current.GetType() != typeof(T))
|
||||
{
|
||||
current = VisualTreeHelper.GetParent(current);
|
||||
}
|
||||
return current as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace System.Windows.Extensions
|
||||
{
|
||||
public static class DependencyPropertyExtensions
|
||||
{
|
||||
public static DependencyProperty Register<TOwnerType, TPropertyType>(string name, PropertyMetadata propertyMetadata = null)
|
||||
{
|
||||
return DependencyProperty.Register(name, typeof(TPropertyType), typeof(TOwnerType), propertyMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace System.Windows.Extensions
|
||||
{
|
||||
public static class FrameworkElementExtensions
|
||||
{
|
||||
public static BitmapSource RenderBitmap(this FrameworkElement frameworkElement)
|
||||
{
|
||||
frameworkElement = frameworkElement ?? throw new ArgumentNullException(nameof(frameworkElement));
|
||||
|
||||
var source = PresentationSource.FromVisual(frameworkElement);
|
||||
var dpix = 96 * source.CompositionTarget.TransformToDevice.M11;
|
||||
var dpiy = 96 * source.CompositionTarget.TransformToDevice.M22;
|
||||
var renderTargetBitmap = new RenderTargetBitmap((int)frameworkElement.ActualWidth, (int)frameworkElement.ActualHeight, dpix, dpiy, PixelFormats.Pbgra32);
|
||||
renderTargetBitmap.Render(frameworkElement);
|
||||
return renderTargetBitmap;
|
||||
}
|
||||
|
||||
public static void RemoveParent(this FrameworkElement frameworkElement)
|
||||
{
|
||||
frameworkElement = frameworkElement ?? throw new ArgumentNullException(nameof(frameworkElement));
|
||||
|
||||
if (frameworkElement.Parent is null) return;
|
||||
|
||||
switch (frameworkElement.Parent)
|
||||
{
|
||||
case Panel panel:
|
||||
panel.Children.Remove(frameworkElement);
|
||||
break;
|
||||
case Decorator decorator:
|
||||
decorator.Child = null;
|
||||
break;
|
||||
case ContentPresenter presenter:
|
||||
presenter.Content = null;
|
||||
break;
|
||||
case ContentControl contentControl:
|
||||
contentControl.Content = null;
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException($"Could not determine how to remove parent for parent type: {frameworkElement.Parent.GetType().Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<Version>0.1</Version>
|
||||
<Description>Extension library for Windows Presentation Platform.</Description>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<RepositoryUrl>https://github.com/AlexMacocian/WpfExtended</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user