add PanelElement
This commit is contained in:
1 parent
3857ac2d53
commit
15d96290ad
7 files changed
+104
-16
No files matched your search
@@ -29,11 +29,10 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void CreateTrriger(UIElement element, string link)
|
||||
{
|
||||
if (string.IsNullOrEmpty(link))
|
||||
{
|
||||
element.CommandBindings.Remove(GetCommandBinding(element));
|
||||
return;
|
||||
}
|
||||
element.CommandBindings.Remove(GetCommandBinding(element));
|
||||
element.SetCurrentValue(CommandBindingProperty, DependencyProperty.UnsetValue);
|
||||
|
||||
if (string.IsNullOrEmpty(link)) return;
|
||||
var commandBinding = new CommandBinding(ControlCommands.OpenLink, (sender, args) => Process.Start(link));
|
||||
SetCommandBinding(element, commandBinding);
|
||||
element.CommandBindings.Add(commandBinding);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Interactivity;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class PanelElement
|
||||
{
|
||||
public static readonly DependencyProperty FluidMoveBehaviorProperty = DependencyProperty.RegisterAttached(
|
||||
"FluidMoveBehavior", typeof(FluidMoveBehavior), typeof(PanelElement), new PropertyMetadata(default(FluidMoveBehavior), OnFluidMoveBehaviorChanged));
|
||||
|
||||
private static void OnFluidMoveBehaviorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is Panel panel)
|
||||
{
|
||||
var collection = Interaction.GetBehaviors(panel);
|
||||
var oldBehavior = GetTempFluidMoveBehavior(panel);
|
||||
collection.Remove(oldBehavior);
|
||||
panel.SetCurrentValue(TempFluidMoveBehaviorProperty, DependencyProperty.UnsetValue);
|
||||
|
||||
if (e.NewValue is FluidMoveBehavior behavior)
|
||||
{
|
||||
collection.Add(behavior);
|
||||
SetTempFluidMoveBehavior(panel, behavior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetFluidMoveBehavior(DependencyObject element, FluidMoveBehavior value)
|
||||
=> element.SetValue(FluidMoveBehaviorProperty, value);
|
||||
|
||||
public static FluidMoveBehavior GetFluidMoveBehavior(DependencyObject element)
|
||||
=> (FluidMoveBehavior) element.GetValue(FluidMoveBehaviorProperty);
|
||||
|
||||
private static readonly DependencyProperty TempFluidMoveBehaviorProperty = DependencyProperty.RegisterAttached(
|
||||
"TempFluidMoveBehavior", typeof(FluidMoveBehavior), typeof(PanelElement), new PropertyMetadata(default(FluidMoveBehavior)));
|
||||
|
||||
private static void SetTempFluidMoveBehavior(DependencyObject element, FluidMoveBehavior value)
|
||||
=> element.SetValue(TempFluidMoveBehaviorProperty, value);
|
||||
|
||||
private static FluidMoveBehavior GetTempFluidMoveBehavior(DependencyObject element)
|
||||
=> (FluidMoveBehavior) element.GetValue(TempFluidMoveBehaviorProperty);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
internal static object Double100Box = 100.0;
|
||||
|
||||
internal static object Double200Box = 200.0;
|
||||
|
||||
internal static object DoubleNeg1Box = -1.0;
|
||||
|
||||
internal static object Int0Box = 0;
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\Attach\LinkElement.cs" />
|
||||
<Compile Include="Controls\Attach\PanelElement.cs" />
|
||||
<Compile Include="Controls\Attach\VisualElement.cs" />
|
||||
<Compile Include="Controls\Other\AnimationPath.cs" />
|
||||
<Compile Include="Controls\Attach\BackgroundSwitchElement.cs" />
|
||||
@@ -322,6 +323,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Behaviors.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Brushes.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
|
||||
<ResourceDictionary Source="../Basic/Paths.xaml"/>
|
||||
<ResourceDictionary Source="../Basic/Sizes.xaml"/>
|
||||
<ResourceDictionary Source="../Basic/Behaviors.xaml"/>
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorXY200" x:Shared="False" AppliesTo="Children" Duration="0:0:.2">
|
||||
<interactivity:FluidMoveBehavior.EaseX>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseX>
|
||||
<interactivity:FluidMoveBehavior.EaseY>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseY>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorX200" x:Shared="False" AppliesTo="Children" Duration="0:0:.2">
|
||||
<interactivity:FluidMoveBehavior.EaseX>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseX>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorY200" x:Shared="False" AppliesTo="Children" Duration="0:0:.2">
|
||||
<interactivity:FluidMoveBehavior.EaseY>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseY>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorXY400" x:Shared="False" AppliesTo="Children" Duration="0:0:.4">
|
||||
<interactivity:FluidMoveBehavior.EaseX>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseX>
|
||||
<interactivity:FluidMoveBehavior.EaseY>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseY>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorX400" x:Shared="False" AppliesTo="Children" Duration="0:0:.4">
|
||||
<interactivity:FluidMoveBehavior.EaseX>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseX>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
<interactivity:FluidMoveBehavior x:Key="BehaviorY400" x:Shared="False" AppliesTo="Children" Duration="0:0:.4">
|
||||
<interactivity:FluidMoveBehavior.EaseY>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseY>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -14,17 +14,7 @@
|
||||
<controls:NumericUpDown x:Name="UpDownGroups" HorizontalAlignment="Center" Value="2" Minimum="1" Maximum="3" Width="200" Style="{StaticResource NumericUpDownExtend}" controls:TitleElement.Title="{x:Static langs:Lang.Groups}" controls:TitleElement.TitleWidth="50" controls:TitleElement.TitleAlignment="Left"/>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,16,0,0">
|
||||
<controls:ScrollViewer MaxHeight="300" IsEnableInertia="True">
|
||||
<controls:WaterfallPanel VerticalAlignment="Center" Width="300" Groups="{Binding Value,ElementName=UpDownGroups}">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactivity:FluidMoveBehavior AppliesTo="Children" Duration="0:0:.2">
|
||||
<interactivity:FluidMoveBehavior.EaseX>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseX>
|
||||
<interactivity:FluidMoveBehavior.EaseY>
|
||||
<PowerEase/>
|
||||
</interactivity:FluidMoveBehavior.EaseY>
|
||||
</interactivity:FluidMoveBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
<controls:WaterfallPanel VerticalAlignment="Center" Width="300" Groups="{Binding Value,ElementName=UpDownGroups}" controls:PanelElement.FluidMoveBehavior="{StaticResource BehaviorXY200}">
|
||||
<Border Height="100" Background="{DynamicResource PrimaryBrush}" Effect="{StaticResource EffectShadow1}" Margin="5">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
|
||||
Reference in new issue
Block a user