Merge pull request #38 from HandyOrg/add-ChatBubble

Add chat bubble
This commit is contained in:
NaBian authored and GitHub committed 2019-01-29 20:13:27 +08:00
commit ca9bd5239d
51 files changed
+744 -60

No files matched your search

@@ -1,6 +1,5 @@
using System.Windows;
using System.Windows.Media;
using HandyControl.Data;
namespace HandyControl.Controls
{
+6 -4
View File
@@ -34,31 +34,33 @@ namespace HandyControl.Controls
if (!IsSelected)
{
IsSelected = true;
RaiseEvent(new RoutedEventArgs(SelectedEvent, this));
OnSelected(new RoutedEventArgs(SelectedEvent, this));
}
else if (CanDeselect)
{
IsSelected = false;
RaiseEvent(new RoutedEventArgs(DeselectedEvent, this));
OnSelected(new RoutedEventArgs(DeselectedEvent, this));
}
}
else
{
if (CanDeselect)
{
RaiseEvent(IsSelected
OnSelected(IsSelected
? new RoutedEventArgs(DeselectedEvent, this)
: new RoutedEventArgs(SelectedEvent, this));
}
else
{
RaiseEvent(new RoutedEventArgs(SelectedEvent, this));
OnSelected(new RoutedEventArgs(SelectedEvent, this));
}
}
_isMouseLeftButtonDown = false;
}
}
protected virtual void OnSelected(RoutedEventArgs e) => RaiseEvent(e);
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
"IsSelected", typeof(bool), typeof(SelectableItem), new PropertyMetadata(ValueBoxes.FalseBox));
+1
View File
@@ -39,6 +39,7 @@ namespace HandyControl.Controls
if (_textBox != null)
{
_textBox.TextChanged -= TextBox_TextChanged;
_textBox.KeyDown -= TextBox_KeyDown;
}
base.OnApplyTemplate();
+52
View File
@@ -0,0 +1,52 @@
using System;
using System.Windows;
using HandyControl.Data;
namespace HandyControl.Controls
{
public class ChatBubble : SelectableItem
{
public static readonly DependencyProperty RoleProperty = DependencyProperty.Register(
"Role", typeof(ChatRoleType), typeof(ChatBubble), new PropertyMetadata(default(ChatRoleType)));
public ChatRoleType Role
{
get => (ChatRoleType) GetValue(RoleProperty);
set => SetValue(RoleProperty, value);
}
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
"Type", typeof(ChatMessageType), typeof(ChatBubble), new PropertyMetadata(default(ChatMessageType)));
public ChatMessageType Type
{
get => (ChatMessageType) GetValue(TypeProperty);
set => SetValue(TypeProperty, value);
}
public static readonly DependencyProperty IsReadProperty = DependencyProperty.Register(
"IsRead", typeof(bool), typeof(ChatBubble), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsRead
{
get => (bool) GetValue(IsReadProperty);
set => SetValue(IsReadProperty, value);
}
public static void SetMaxWidth(DependencyObject element, double value)
=> element.SetValue(MaxWidthProperty, value);
public static double GetMaxWidth(DependencyObject element)
=> (double) element.GetValue(MaxWidthProperty);
public Action<object> ReadAction { get; set; }
protected override void OnSelected(RoutedEventArgs e)
{
base.OnSelected(e);
IsRead = true;
ReadAction?.Invoke(Content);
}
}
}
+1 -1
View File
@@ -289,7 +289,7 @@ namespace HandyControl.Controls
throw new InvalidEnumArgumentException(nameof(defaultResult), (int)defaultResult, typeof(MessageBoxResult));
}
var ownerWindow = owner ?? Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
var ownerWindow = owner ?? VisualHelper.GetActiveWindow();
var ownerIsNull = ownerWindow is null;
return new MessageBox
+10
View File
@@ -0,0 +1,10 @@
namespace HandyControl.Data
{
public enum ChatMessageType
{
String,
Image,
Audio,
Custom
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace HandyControl.Data
{
public enum ChatRoleType
{
Sender,
Receiver
}
}
+11
View File
@@ -110,6 +110,7 @@
<Compile Include="Controls\Button\ContextMenuToggleButton.cs" />
<Compile Include="Controls\Other\Carousel.cs" />
<Compile Include="Controls\Cover\CoverView\CoverView.cs" />
<Compile Include="Controls\Other\ChatBubble.cs" />
<Compile Include="Controls\Transfer\Transfer.cs" />
<Compile Include="Controls\Transfer\TransferGroup.cs" />
<Compile Include="Controls\Transfer\TransferItem.cs" />
@@ -156,6 +157,8 @@
<Compile Include="Controls\Window\BlurWindow.cs" />
<Compile Include="Controls\Window\MessageBox.cs" />
<Compile Include="Data\Args\CancelRoutedEventArgs.cs" />
<Compile Include="Data\Enum\ChatMessageType.cs" />
<Compile Include="Data\Enum\ChatRoleType.cs" />
<Compile Include="Data\Enum\InfoType.cs" />
<Compile Include="Data\Enum\ResultType.cs" />
<Compile Include="Data\Enum\SkinType.cs" />
@@ -356,6 +359,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\ChatBubbleBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\CheckBoxBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -408,6 +415,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ChatBubble.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\CoverFlow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -23,6 +23,8 @@
<Geometry x:Key="WindowMinGeometry">M0,4 L10,4 L10,5 L0,5 z</Geometry>
<Geometry x:Key="WindowRestoreGeometry">M1,3 L1,9 L7,9 L7,3 z M3,1 L3,2 L8,2 L8,7 L9,7 L9,1 z M2,0 L10,0 L10,8 L8,8 L8,10 L0,10 L0,2 L2,2 z</Geometry>
<Geometry x:Key="WindowMaxGeometry">M1,1 L1,9 L9,9 L9,1 z M0,0 L10,0 L10,10 L0,10 z</Geometry>
<Geometry x:Key="AudioGeometry">M627.52666696 962L550.66666696 890.47999971c116.82-92.99999971 191.09999971-230.94 191.09999971-385.2 0-146.99999971-67.61999971-279-174.96-371.57999942L643.84666667 62C770.86666638 172.99999971 850.66666667 330.2 850.66666667 505.09999971c0 182.27999971-86.58 345.42-223.13999971 456.90000029zM405.64666638 782l-76.32-77.22a227.88 227.88 0 0 0 116.40000058-199.26A228.06 228.06 0 0 0 347.86666638 317.84000029L422.86666696 242A334.37999971 334.37999971 0 0 1 550.66666696 505.52 334.62 334.62 0 0 1 405.64666638 782zM205.66666638 596.6C164.26666638 596.6 130.66666667 562.51999971 130.66666667 520.64 130.66666667 478.76000029 164.26666638 444.79999971 205.66666638 444.79999971s74.99999971 33.95999971 75.00000058 75.90000058c0 41.87999971-33.59999971 75.84000029-75.00000058 75.83999942z</Geometry>
<Geometry x:Key="BubbleTailGeometry">M0,0L28,0 28,14.0000006258488 28,15.0010000765324 28.0151405334473,15.0010000765324 28.0455417633057,15.8010965883732C28.4084091186524,22.9596563875675,30.92209815979,29.5507589876652,34.9532623291016,34.9410597383976L34.9984359741211,34.9999815523624 34.0966339111328,34.9885679781437C15.1841707229614,34.5094191133976,2.0535663480814E-07,19.0279375612736,0,0z</Geometry>
<Geometry x:Key="StarGeometry">M535.9 165.2l96.5 195.4c3.9 7.9 11.4 13.3 20.1 14.6l215.7 31.3c21.9 3.2 30.6 30 14.8 45.5L726.8 604.1c-6.3 6.1-9.1 14.9-7.7 23.6L756 842.5c3.7 21.8-19.1 38.4-38.7 28.1L524.4 769.2c-7.8-4.1-17-4.1-24.8 0L306.7 870.6c-19.6 10.3-42.4-6.3-38.7-28.1l36.8-214.8c1.5-8.6-1.4-17.5-7.7-23.6L141.1 452c-15.8-15.4-7.1-42.3 14.8-45.5l215.7-31.3c8.7-1.3 16.2-6.7 20.1-14.6l96.5-195.4c9.7-19.9 37.9-19.9 47.7 0z</Geometry>
<Geometry x:Key="AddGeometry">M938.666667 426.666667h-341.333334V85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333s-85.333333 38.4-85.333333 85.333333v341.333334H85.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333h341.333334v341.333334c0 46.933333 38.4 85.333333 85.333333 85.333333s85.333333-38.4 85.333333-85.333333v-341.333334h341.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333z</Geometry>
<Geometry x:Key="SubGeometry">M62.5797 488.9508c0.2632 42.5185 34.985 77.2116 77.5035 77.5035l743.0216-0.6728c42.5185 0.3215 76.7437-33.9333 76.4518-76.4805l0 0c-0.2918-42.5175-34.985-77.2106-77.5045-77.5035l-743.0216-0.087C96.513 411.4473 62.2879 446.4323 62.5797 488.9508L62.5797 488.9508z</Geometry>
@@ -0,0 +1,165 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Basic/Converters.xaml"/>
<ResourceDictionary Source="../../Basic/Geometries.xaml"/>
<ResourceDictionary Source="../../Basic/Sizes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="ChatBubbleStringBaseTemplate" TargetType="controls:ChatBubble">
<Grid>
<Path Name="Tail" Data="{StaticResource BubbleTailGeometry}" Fill="{TemplateBinding Background}" HorizontalAlignment="Right" Stretch="Uniform" VerticalAlignment="Bottom" Width="15" Height="15" RenderTransformOrigin="0.5,0.5"/>
<Border Name="Body" Background="{TemplateBinding Background}" CornerRadius="15" Margin="0,0,3,0">
<TextBlock TextWrapping="Wrap" Text="{TemplateBinding Content}" VerticalAlignment="Center" Margin="{TemplateBinding Padding}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Role" Value="Receiver">
<Setter TargetName="Tail" Property="HorizontalAlignment" Value="Left"/>
<Setter TargetName="Tail" Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter TargetName="Body" Property="Margin" Value="3,0,0,0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="ChatBubbleImageBaseTemplate" TargetType="controls:ChatBubble">
<Grid>
<Path Name="Tail" Data="{StaticResource BubbleTailGeometry}" Fill="{TemplateBinding Background}" HorizontalAlignment="Right" Stretch="Uniform" VerticalAlignment="Bottom" Width="15" Height="15" RenderTransformOrigin="0.5,0.5"/>
<Border Name="Body" Background="{TemplateBinding Background}" CornerRadius="15" Margin="0,0,3,0">
<Grid>
<Image Margin="{TemplateBinding Padding}" VerticalAlignment="Center" Source="{TemplateBinding Content}"/>
<Border BorderThickness="{TemplateBinding Padding}" BorderBrush="{TemplateBinding Background}" Background="{x:Null}" CornerRadius="15"/>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Role" Value="Receiver">
<Setter TargetName="Tail" Property="HorizontalAlignment" Value="Left"/>
<Setter TargetName="Tail" Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter TargetName="Body" Property="Margin" Value="3,0,0,0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="ChatBubbleAudioBaseTemplate" TargetType="controls:ChatBubble">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="12" Name="Definition1"/>
<ColumnDefinition Name="Definition2"/>
</Grid.ColumnDefinitions>
<Ellipse Name="Dot" VerticalAlignment="Top" Fill="{DynamicResource DangerBrush}" Width="6" Height="6" Visibility="{TemplateBinding IsRead,Converter={StaticResource Boolean2BooleanReConverter}}" Margin="0,0,6,0"/>
<Path Name="Tail" Grid.Column="1" Data="{StaticResource BubbleTailGeometry}" Fill="{TemplateBinding Background}" HorizontalAlignment="Right" Stretch="Uniform" VerticalAlignment="Bottom" Width="15" Height="15" RenderTransformOrigin="0.5,0.5"/>
<Border Name="Body" Grid.Column="1" Background="{TemplateBinding Background}" CornerRadius="15" Margin="0,0,3,0">
<Grid VerticalAlignment="Center" Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ContentPresenter Name="Presenter" VerticalAlignment="Center"/>
<Path Name="Audio" Grid.Column="1" Data="{StaticResource AudioGeometry}" Fill="{TemplateBinding Foreground}" Width="16" Height="16" Margin="6,0,0,0" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Role" Value="Receiver">
<Setter TargetName="Tail" Property="HorizontalAlignment" Value="Left"/>
<Setter TargetName="Tail" Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter TargetName="Tail" Property="Grid.Column" Value="0"/>
<Setter TargetName="Dot" Property="Grid.Column" Value="1"/>
<Setter TargetName="Dot" Property="Margin" Value="6,0,0,0"/>
<Setter TargetName="Body" Property="Margin" Value="3,0,0,0"/>
<Setter TargetName="Body" Property="Grid.Column" Value="0"/>
<Setter TargetName="Definition1" Property="Width" Value="Auto"/>
<Setter TargetName="Definition2" Property="Width" Value="12"/>
<Setter TargetName="Audio" Property="Grid.Column" Value="0"/>
<Setter TargetName="Audio" Property="Margin" Value="0,0,6,0"/>
<Setter TargetName="Audio" Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="1"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter TargetName="Presenter" Property="Grid.Column" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="ChatBubbleCustomBaseTemplate" TargetType="controls:ChatBubble">
<Grid>
<Path Name="Tail" Data="{StaticResource BubbleTailGeometry}" Fill="{TemplateBinding Background}" HorizontalAlignment="Right" Stretch="Uniform" VerticalAlignment="Bottom" Width="15" Height="15" RenderTransformOrigin="0.5,0.5"/>
<Border Name="Body" Background="{TemplateBinding Background}" CornerRadius="15" Margin="0,0,3,0">
<ContentPresenter VerticalAlignment="Center" Margin="{TemplateBinding Padding}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Role" Value="Receiver">
<Setter TargetName="Tail" Property="HorizontalAlignment" Value="Left"/>
<Setter TargetName="Tail" Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter TargetName="Body" Property="Margin" Value="3,0,0,0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ChatBubbleBaseStyle" TargetType="controls:ChatBubble">
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="Background" Value="{DynamicResource DarkPrimaryBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Margin" Value="10"/>
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="Template" Value="{StaticResource ChatBubbleStringBaseTemplate}"/>
<Setter Property="IsRead" Value="{Binding IsSelected,RelativeSource={RelativeSource Self}}"/>
<Setter Property="MaxWidth" Value="280"/>
<Style.Triggers>
<Trigger Property="Role" Value="Receiver">
<Setter Property="Background" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Trigger>
<Trigger Property="Type" Value="Image">
<Setter Property="Template" Value="{StaticResource ChatBubbleImageBaseTemplate}"/>
<Setter Property="MaxHeight" Value="280"/>
</Trigger>
<Trigger Property="Type" Value="Audio">
<Setter Property="Template" Value="{StaticResource ChatBubbleAudioBaseTemplate}"/>
</Trigger>
<Trigger Property="Type" Value="Custom">
<Setter Property="Template" Value="{StaticResource ChatBubbleCustomBaseTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
@@ -13,14 +13,14 @@
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="CanDeselect" Value="True"/>
<Setter Property="SelfManage" Value="True"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Padding" Value="10, 0"/>
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="Margin" Value="5,0,5,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TransferItem">
<Border x:Name="BorderRoot" Background="{DynamicResource RegionBrush}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
<ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource AncestorType=controls:TransferGroup}}"/>
<ContentPresenter x:Name="ContentPresenter" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource AncestorType=controls:TransferGroup}}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
+16 -1
View File
@@ -9,7 +9,22 @@
<ResourceDictionary Source="ListBox.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:Carousel" BasedOn="{StaticResource StackPanelListBox}">
<Style x:Key="CarouselListBoxItemStyle" BasedOn="{StaticResource ListBoxItemCustom}" TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=ItemsControl}}"/>
</Style>
<ItemsPanelTemplate x:Key="CarouselListBoxItemPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal" HorizontalAlignment="Left"/>
</ItemsPanelTemplate>
<Style x:Key="CarouselListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource CarouselListBoxItemPanelTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource CarouselListBoxItemStyle}"/>
</Style>
<Style TargetType="controls:Carousel" BasedOn="{StaticResource CarouselListBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Carousel">
@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/ChatBubbleBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource ChatBubbleBaseStyle}" TargetType="controls:ChatBubble"/>
</ResourceDictionary>
+26 -13
View File
@@ -8,7 +8,7 @@
<!--默认样式-->
<Style BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox"/>
<Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
<Style x:Key="ListBoxItemCustom" TargetType="ListBoxItem">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Padding" Value="0"/>
@@ -26,28 +26,41 @@
</Setter>
</Style>
<Style x:Key="ListBoxItemFullStyle" BasedOn="{StaticResource ListBoxItemStyle}" TargetType="ListBoxItem">
<Style x:Key="ListBoxCustom" TargetType="ListBox">
<Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemCustom}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=ItemsControl}}"/>
</Style>
<ItemsPanelTemplate x:Key="WrapPanelItemsPanelTemplate">
<ItemsPanelTemplate x:Key="WrapPanelHorizontalItemsPanelTemplate">
<WrapPanel FocusVisualStyle="{x:Null}"/>
</ItemsPanelTemplate>
<Style x:Key="WrapPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource WrapPanelItemsPanelTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemStyle}"/>
<Style x:Key="WrapPanelHorizontalListBox" BasedOn="{StaticResource ListBoxCustom}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource WrapPanelHorizontalItemsPanelTemplate}"/>
</Style>
<ItemsPanelTemplate x:Key="StackPanelItemsPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal" HorizontalAlignment="Left"/>
<ItemsPanelTemplate x:Key="WrapPanelVerticalItemsPanelTemplate">
<WrapPanel FocusVisualStyle="{x:Null}" Orientation="Vertical"/>
</ItemsPanelTemplate>
<Style x:Key="StackPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource StackPanelItemsPanelTemplate}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItemFullStyle}"/>
<Style x:Key="WrapPanelVerticalListBox" BasedOn="{StaticResource ListBoxCustom}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource WrapPanelVerticalItemsPanelTemplate}"/>
</Style>
<ItemsPanelTemplate x:Key="StackPanelHorizontalItemsPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal"/>
</ItemsPanelTemplate>
<Style x:Key="StackPanelHorizontalListBox" BasedOn="{StaticResource ListBoxCustom}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource StackPanelHorizontalItemsPanelTemplate}"/>
</Style>
<ItemsPanelTemplate x:Key="StackPanelVerticalItemsPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
<Style x:Key="StackPanelVerticalListBox" BasedOn="{StaticResource ListBoxCustom}" TargetType="ListBox">
<Setter Property="ItemsPanel" Value="{StaticResource StackPanelVerticalItemsPanelTemplate}"/>
</Style>
</ResourceDictionary>
+1
View File
@@ -56,6 +56,7 @@
<ResourceDictionary Source="CoverFlow.xaml"/>
<ResourceDictionary Source="ProgressButton.xaml"/>
<ResourceDictionary Source="Transfer.xaml"/>
<ResourceDictionary Source="ChatBubble.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
+4 -4
View File
@@ -56,15 +56,15 @@
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="NonClientAreaBackground" Value="White"/>
<Setter Property="NonClientAreaForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="NonClientAreaForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="CloseButtonBackground" Value="Transparent"/>
<Setter Property="CloseButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="CloseButtonForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="CloseButtonHoverBackground" Value="#e81123"/>
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonBackground" Value="Transparent"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Window">
+5 -3
View File
@@ -4,9 +4,9 @@ using System.Windows.Media;
namespace HandyControl.Tools
{
internal class VisualHelper
public class VisualHelper
{
public static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName)
internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName)
{
var root = GetImplementationRoot(dependencyObject);
if (root == null)
@@ -20,11 +20,13 @@ namespace HandyControl.Tools
.FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
}
public static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject)
internal static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject)
{
return 1 == VisualTreeHelper.GetChildrenCount(dependencyObject)
? VisualTreeHelper.GetChild(dependencyObject, 0) as FrameworkElement
: null;
}
public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
}
}