Merge branch 'master' into enhance-input-element

This commit is contained in:
NaBian committed 2019-03-24 16:59:18 +08:00
commit 784600990e
23 files changed
+470 -189

No files matched your search

+2 -2
View File
@@ -15,12 +15,12 @@ namespace HandyControl.Controls
{ {
var collection = Interaction.GetBehaviors(panel); var collection = Interaction.GetBehaviors(panel);
var oldBehavior = GetTempFluidMoveBehavior(panel); var oldBehavior = GetTempFluidMoveBehavior(panel);
collection.Remove(oldBehavior); collection.ItemRemoved(oldBehavior);
panel.SetCurrentValue(TempFluidMoveBehaviorProperty, DependencyProperty.UnsetValue); panel.SetCurrentValue(TempFluidMoveBehaviorProperty, DependencyProperty.UnsetValue);
if (e.NewValue is FluidMoveBehavior behavior) if (e.NewValue is FluidMoveBehavior behavior)
{ {
collection.Add(behavior); collection.ItemAdded(behavior);
SetTempFluidMoveBehavior(panel, behavior); SetTempFluidMoveBehavior(panel, behavior);
} }
} }
+60 -1
View File
@@ -7,7 +7,7 @@ using HandyControl.Interactivity;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
public class SearchBar : TextBox public class SearchBar : TextBox, ICommandSource
{ {
public SearchBar() public SearchBar()
{ {
@@ -51,6 +51,16 @@ namespace HandyControl.Controls
{ {
Info = Text Info = Text
}); });
if (Command == null) return;
if (Command is RoutedCommand command)
{
command.Execute(CommandParameter, CommandTarget);
}
else
{
Command.Execute(CommandParameter);
}
} }
/// <summary> /// <summary>
@@ -67,5 +77,54 @@ namespace HandyControl.Controls
get => (bool)GetValue(IsRealTimeProperty); get => (bool)GetValue(IsRealTimeProperty);
set => SetValue(IsRealTimeProperty, value); set => SetValue(IsRealTimeProperty, value);
} }
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(SearchBar), new PropertyMetadata(default(ICommand), OnCommandChanged));
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (SearchBar)d;
if (e.OldValue is ICommand oldCommand)
{
oldCommand.CanExecuteChanged -= ctl.CanExecuteChanged;
}
if (e.NewValue is ICommand newCommand)
{
newCommand.CanExecuteChanged += ctl.CanExecuteChanged;
}
}
public ICommand Command
{
get => (ICommand) GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register(
"CommandParameter", typeof(object), typeof(SearchBar), new PropertyMetadata(default(object)));
public object CommandParameter
{
get => GetValue(CommandParameterProperty);
set => SetValue(CommandParameterProperty, value);
}
public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register(
"CommandTarget", typeof(IInputElement), typeof(SearchBar), new PropertyMetadata(default(IInputElement)));
public IInputElement CommandTarget
{
get => (IInputElement) GetValue(CommandTargetProperty);
set => SetValue(CommandTargetProperty, value);
}
private void CanExecuteChanged(object sender, EventArgs e)
{
if (Command == null) return;
IsEnabled = Command is RoutedCommand command
? command.CanExecute(CommandParameter, CommandTarget)
: Command.CanExecute(CommandParameter);
}
} }
} }
+27 -21
View File
@@ -4,7 +4,6 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading; using System.Windows.Threading;
using HandyControl.Data; using HandyControl.Data;
using HandyControl.Interactivity; using HandyControl.Interactivity;
@@ -43,11 +42,6 @@ namespace HandyControl.Controls
private int _waitTime = 6; private int _waitTime = 6;
/// <summary>
/// 消息容器
/// </summary>
public static Panel GrowlPanel { get; set; }
/// <summary> /// <summary>
/// 计数 /// 计数
/// </summary> /// </summary>
@@ -65,14 +59,21 @@ namespace HandyControl.Controls
CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick));
MouseEnter += Growl_MouseEnter;
MouseLeave += Growl_MouseLeave;
} }
private void Growl_MouseLeave(object sender, MouseEventArgs e) => _buttonClose.Collapse(); protected override void OnMouseEnter(MouseEventArgs e)
{
base.OnMouseEnter(e);
private void Growl_MouseEnter(object sender, MouseEventArgs e) => _buttonClose.Show(_showCloseButton); _buttonClose.Show(_showCloseButton);
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
_buttonClose.Collapse();
}
public override void OnApplyTemplate() public override void OnApplyTemplate()
{ {
@@ -93,6 +94,11 @@ namespace HandyControl.Controls
private Func<bool, bool> ActionBeforeClose { get; set; } private Func<bool, bool> ActionBeforeClose { get; set; }
/// <summary>
/// 消息容器
/// </summary>
public static Panel GrowlPanel { get; set; }
internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register( internal static readonly DependencyProperty CancelStrProperty = DependencyProperty.Register(
"CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string))); "CancelStr", typeof(string), typeof(Growl), new PropertyMetadata(default(string)));
@@ -120,7 +126,7 @@ namespace HandyControl.Controls
public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached( public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached(
"GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) => "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(ValueBoxes.FalseBox, (o, args) =>
{ {
if (o is Panel panel) if ((bool)args.NewValue && o is Panel panel)
{ {
SetGrowlPanel(panel); SetGrowlPanel(panel);
} }
@@ -226,14 +232,8 @@ namespace HandyControl.Controls
menuItem menuItem
} }
}; };
var behavior = new FluidMoveBehavior
{ PanelElement.SetFluidMoveBehavior(GrowlPanel, ResourceHelper.GetResource<FluidMoveBehavior>(ResourceToken.BehaviorXY400));
AppliesTo = FluidMoveScope.Children,
Duration = new Duration(TimeSpan.FromMilliseconds(400)),
EaseY = new PowerEase()
};
var collection = Interaction.GetBehaviors(GrowlPanel);
collection.Add(behavior);
} }
private void Update() private void Update()
@@ -451,7 +451,13 @@ namespace HandyControl.Controls
var transform = new TranslateTransform(); var transform = new TranslateTransform();
_gridMain.RenderTransform = transform; _gridMain.RenderTransform = transform;
var animation = AnimationHelper.CreateAnimation(MaxWidth); var animation = AnimationHelper.CreateAnimation(MaxWidth);
animation.Completed += delegate { GrowlPanel.Children.Remove(this); }; animation.Completed += (s, e) =>
{
if (Parent is Panel panel)
{
panel.Children.Remove(this);
}
};
transform.BeginAnimation(TranslateTransform.XProperty, animation); transform.BeginAnimation(TranslateTransform.XProperty, animation);
} }
+84 -38
View File
@@ -1,14 +1,12 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes;
using HandyControl.Data; using HandyControl.Data;
using HandyControl.Interactivity; using HandyControl.Interactivity;
using HandyControl.Tools; using HandyControl.Tools;
using HandyControl.Tools.Extension;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
@@ -17,14 +15,6 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
public sealed class MessageBox : Window public sealed class MessageBox : Window
{ {
#region Constants
private const string ElementImage = "PART_Image";
private const string ElementMessage = "PART_Message";
#endregion Constants
private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel; private MessageBoxResult _messageBoxResult = MessageBoxResult.Cancel;
private bool _showOk; private bool _showOk;
@@ -35,13 +25,41 @@ namespace HandyControl.Controls
private bool _showNo; private bool _showNo;
private string _message; public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
"Message", typeof(string), typeof(MessageBox), new PropertyMetadata(default(string)));
private Geometry _image; public string Message
{
get => (string) GetValue(MessageProperty);
set => SetValue(MessageProperty, value);
}
private Brush _imageBrush; public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
"Image", typeof(Geometry), typeof(MessageBox), new PropertyMetadata(default(Geometry)));
private bool _showImage; public Geometry Image
{
get => (Geometry) GetValue(ImageProperty);
set => SetValue(ImageProperty, value);
}
public static readonly DependencyProperty ImageBrushProperty = DependencyProperty.Register(
"ImageBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(default(Brush)));
public Brush ImageBrush
{
get => (Brush) GetValue(ImageBrushProperty);
set => SetValue(ImageBrushProperty, value);
}
public static readonly DependencyProperty ShowImageProperty = DependencyProperty.Register(
"ShowImage", typeof(bool), typeof(MessageBox), new PropertyMetadata(ValueBoxes.FalseBox));
public bool ShowImage
{
get => (bool) GetValue(ShowImageProperty);
set => SetValue(ShowImageProperty, value);
}
private MessageBox() private MessageBox()
{ {
@@ -67,20 +85,48 @@ namespace HandyControl.Controls
}, (s, e) => e.CanExecute = _showNo)); }, (s, e) => e.CanExecute = _showNo));
} }
protected override void OnSourceInitialized(EventArgs e) protected override void OnPreviewKeyDown(KeyEventArgs e)
{ {
base.OnSourceInitialized(e); base.OnPreviewKeyDown(e);
if (LogicalTreeHelper.FindLogicalNode(this, ElementMessage) is TextBlock message) message.Text = _message; if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C)
if (_showImage)
{ {
if (LogicalTreeHelper.FindLogicalNode(this, ElementImage) is Path image) var builder = new StringBuilder();
var line = new string('-', 27);
builder.Append(line);
builder.Append(Environment.NewLine);
builder.Append(Title);
builder.Append(Environment.NewLine);
builder.Append(line);
builder.Append(Environment.NewLine);
builder.Append(Message);
builder.Append(Environment.NewLine);
builder.Append(line);
builder.Append(Environment.NewLine);
if (_showOk)
{ {
image.Data = _image; builder.Append(Properties.Langs.Lang.Confirm);
image.Fill = _imageBrush; builder.Append(" ");
image.Show();
} }
if (_showYes)
{
builder.Append(Properties.Langs.Lang.Yes);
builder.Append(" ");
}
if (_showNo)
{
builder.Append(Properties.Langs.Lang.No);
builder.Append(" ");
}
if (_showCancel)
{
builder.Append(Properties.Langs.Lang.Cancel);
builder.Append(" ");
}
builder.Append(Environment.NewLine);
builder.Append(line);
builder.Append(Environment.NewLine);
Clipboard.SetText(builder.ToString());
} }
} }
@@ -96,9 +142,9 @@ namespace HandyControl.Controls
{ {
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
SetButtonStatus(messageBox, MessageBoxButton.OK); SetButtonStatus(messageBox, MessageBoxButton.OK);
messageBox._showImage = true; messageBox.ShowImage = true;
messageBox._image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry); messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush); messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
messageBox.ShowDialog(); messageBox.ShowDialog();
}); });
@@ -174,9 +220,9 @@ namespace HandyControl.Controls
{ {
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
SetButtonStatus(messageBox, MessageBoxButton.OK); SetButtonStatus(messageBox, MessageBoxButton.OK);
messageBox._showImage = true; messageBox.ShowImage = true;
messageBox._image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry); messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush); messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
messageBox.ShowDialog(); messageBox.ShowDialog();
}); });
@@ -217,9 +263,9 @@ namespace HandyControl.Controls
if (!string.IsNullOrEmpty(info.IconKey)) if (!string.IsNullOrEmpty(info.IconKey))
{ {
messageBox._showImage = true; messageBox.ShowImage = true;
messageBox._image = ResourceHelper.GetResource<Geometry>(info.IconKey); messageBox.Image = ResourceHelper.GetResource<Geometry>(info.IconKey);
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(info.IconBrushKey); messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(info.IconBrushKey);
} }
messageBox.Style = info.Style; messageBox.Style = info.Style;
@@ -293,9 +339,9 @@ namespace HandyControl.Controls
return new MessageBox return new MessageBox
{ {
_message = messageBoxText, Message = messageBoxText,
Owner = ownerWindow, Owner = ownerWindow,
WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner, WindowStartupLocation = WindowStartupLocation.CenterScreen,
ShowTitle = true, ShowTitle = true,
Title = caption ?? string.Empty, Title = caption ?? string.Empty,
Topmost = ownerIsNull, Topmost = ownerIsNull,
@@ -352,9 +398,9 @@ namespace HandyControl.Controls
} }
if (string.IsNullOrEmpty(iconKey)) return; if (string.IsNullOrEmpty(iconKey)) return;
messageBox._showImage = true; messageBox.ShowImage = true;
messageBox._image = ResourceHelper.GetResource<Geometry>(iconKey); messageBox.Image = ResourceHelper.GetResource<Geometry>(iconKey);
messageBox._imageBrush = ResourceHelper.GetResource<Brush>(iconBrushKey); messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(iconBrushKey);
} }
private static bool IsValidMessageBoxButton(MessageBoxButton value) private static bool IsValidMessageBoxButton(MessageBoxButton value)
+35 -58
View File
@@ -1,11 +1,9 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using HandyControl.Data; using HandyControl.Data;
using HandyControl.Tools;
using HandyControl.Tools.Extension; using HandyControl.Tools.Extension;
#if netle40 #if netle40
using Microsoft.Windows.Shell; using Microsoft.Windows.Shell;
@@ -81,14 +79,14 @@ namespace HandyControl.Controls
private bool _isFullScreen; private bool _isFullScreen;
private Thickness _actualBorderThickness;
private UIElement _nonClientArea; private UIElement _nonClientArea;
private bool _showNonClientArea = true; private bool _showNonClientArea = true;
private double _tempNonClientAreaHeight; private double _tempNonClientAreaHeight;
private Thickness _tempThickness;
private WindowState _tempWindowState; private WindowState _tempWindowState;
private WindowStyle _tempWindowStyle; private WindowStyle _tempWindowStyle;
@@ -106,31 +104,7 @@ namespace HandyControl.Controls
new Binding(NonClientAreaHeightProperty.Name) {Source = this}); new Binding(NonClientAreaHeightProperty.Name) {Source = this});
WindowChrome.SetWindowChrome(this, chrome); WindowChrome.SetWindowChrome(this, chrome);
Loaded += delegate Loaded += (s, e) => OnLoaded(e);
{
_tempThickness = BorderThickness;
if (WindowState == WindowState.Maximized)
{
BorderThickness = new Thickness();
}
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand,
(s, e) => WindowState = WindowState.Minimized));
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand,
(s, e) => WindowState = WindowState.Maximized));
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand,
(s, e) => WindowState = WindowState.Normal));
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (s, e) => Close()));
CommandBindings.Add(new CommandBinding(SystemCommands.ShowSystemMenuCommand, ShowSystemMenu));
_tempNonClientAreaHeight = NonClientAreaHeight;
_tempWindowState = WindowState;
_tempWindowStyle = WindowStyle;
_tempResizeMode = ResizeMode;
SwitchIsFullScreen(_isFullScreen);
SwitchShowNonClientArea(_showNonClientArea);
};
} }
public Brush CloseButtonBackground public Brush CloseButtonBackground
@@ -317,15 +291,34 @@ namespace HandyControl.Controls
} }
else if (WindowState == WindowState.Normal) else if (WindowState == WindowState.Normal)
{ {
BorderThickness = _tempThickness; BorderThickness = _actualBorderThickness;
} }
} }
public override void OnApplyTemplate() protected void OnLoaded(RoutedEventArgs args)
{ {
base.OnApplyTemplate(); _actualBorderThickness = BorderThickness;
if (WindowState == WindowState.Maximized)
{
BorderThickness = new Thickness();
}
_nonClientArea = GetTemplateChild(ElementNonClientArea) as UIElement; CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand,
(s, e) => WindowState = WindowState.Minimized));
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand,
(s, e) => WindowState = WindowState.Maximized));
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand,
(s, e) => WindowState = WindowState.Normal));
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (s, e) => Close()));
CommandBindings.Add(new CommandBinding(SystemCommands.ShowSystemMenuCommand, ShowSystemMenu));
_tempNonClientAreaHeight = NonClientAreaHeight;
_tempWindowState = WindowState;
_tempWindowStyle = WindowStyle;
_tempResizeMode = ResizeMode;
SwitchIsFullScreen(_isFullScreen);
SwitchShowNonClientArea(_showNonClientArea);
if (SizeToContent != SizeToContent.WidthAndHeight) if (SizeToContent != SizeToContent.WidthAndHeight)
return; return;
@@ -334,11 +327,18 @@ namespace HandyControl.Controls
Dispatcher.BeginInvoke(new Action(() => { SizeToContent = SizeToContent.WidthAndHeight; })); Dispatcher.BeginInvoke(new Action(() => { SizeToContent = SizeToContent.WidthAndHeight; }));
} }
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_nonClientArea = GetTemplateChild(ElementNonClientArea) as UIElement;
}
private void ShowSystemMenu(object sender, ExecutedRoutedEventArgs e) private void ShowSystemMenu(object sender, ExecutedRoutedEventArgs e)
{ {
var point = WindowState == WindowState.Maximized var point = WindowState == WindowState.Maximized
? new Point(0, 28) ? new Point(0, NonClientAreaHeight)
: new Point(Left, Top + 28); : new Point(Left, Top + NonClientAreaHeight);
SystemCommands.ShowSystemMenu(this, point); SystemCommands.ShowSystemMenu(this, point);
} }
@@ -348,28 +348,5 @@ namespace HandyControl.Controls
if (SizeToContent == SizeToContent.WidthAndHeight) if (SizeToContent == SizeToContent.WidthAndHeight)
InvalidateMeasure(); InvalidateMeasure();
} }
/// <summary>
/// 获取自定义窗口
/// </summary>
/// <returns></returns>
public static Window GetCustomWindow(FrameworkElement content)
{
var window = new Window
{
Style = ResourceHelper.GetResource<Style>(ResourceToken.WindowWin10),
Content = content
};
window.Loaded += (s, e) =>
{
window.Width = window.BorderThickness.Left + window.BorderThickness.Right + content.Width;
if (!(window.Template.FindName("GridMenu", window) is Grid nemuArea))
throw new NullReferenceException("can not find GridMenu in template");
window.Height = window.BorderThickness.Top + window.BorderThickness.Bottom + content.Height +
nemuArea.ActualHeight;
};
return window;
}
} }
} }
+1
View File
@@ -64,5 +64,6 @@
internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast); internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
internal const string BehaviorXY400 = nameof(BehaviorXY400);
} }
} }
@@ -22,14 +22,14 @@ namespace HandyControl.Interactivity
internal override void ItemAdded(Behavior item) internal override void ItemAdded(Behavior item)
{ {
if (AssociatedObject == null) if (item == null || AssociatedObject == null)
return; return;
item.Attach(AssociatedObject); item.Attach(AssociatedObject);
} }
internal override void ItemRemoved(Behavior item) internal override void ItemRemoved(Behavior item)
{ {
if (((IAttachedObject) item).AssociatedObject == null) if (((IAttachedObject) item)?.AssociatedObject == null)
return; return;
item.Detach(); item.Detach();
} }
+98 -22
View File
@@ -17,30 +17,106 @@
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="1"/>
<Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/> <Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Content"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<Grid> <ControlTemplate TargetType="controls:MessageBox">
<Grid.ColumnDefinitions> <Border SnapsToDevicePixels="True" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
<ColumnDefinition Width="Auto"/> <Grid Margin="{TemplateBinding Padding}">
<ColumnDefinition/> <Grid.RowDefinitions>
</Grid.ColumnDefinitions> <RowDefinition Height="Auto"/>
<Grid.RowDefinitions> <RowDefinition/>
<RowDefinition/> </Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <Grid Background="{TemplateBinding NonClientAreaBackground}" Name="PART_NonClientArea" TextElement.Foreground="{TemplateBinding NonClientAreaForeground}">
</Grid.RowDefinitions> <Grid.ColumnDefinitions>
<Path x:Name="PART_Image" HorizontalAlignment="Center" Visibility="Collapsed" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/> <ColumnDefinition/>
<ScrollViewer Grid.Column="1" Grid.Row="0"> <ColumnDefinition Width="Auto"/>
<TextBlock Margin="10,39,10,10" x:Name="PART_Message" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"/> </Grid.ColumnDefinitions>
</ScrollViewer> <StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center"> <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/> <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.Confirm}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/> <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{x:Static langs:Lang.No}" Margin="5,0"/> <Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" controls:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" controls:IconElement.Width="10" controls:IconElement.Height="10"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/> </StackPanel>
</StackPanel> <Grid Grid.Column="0">
</Grid> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Name="Icon" Margin="10,0,0,0" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Path Data="{TemplateBinding Image}" Fill="{TemplateBinding ImageBrush}" HorizontalAlignment="Center" Visibility="{TemplateBinding ShowImage,Converter={StaticResource Boolean2VisibilityConverter}}" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/>
<ScrollViewer Grid.Column="1" Grid.Row="0">
<TextBlock Margin="10,39,10,10" Text="{TemplateBinding Message}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</ScrollViewer>
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.Confirm}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{x:Static langs:Lang.No}" Margin="5,0"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Style="{StaticResource ButtonPrimary}"/>
</StackPanel>
</Grid>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsActive" Value="False">
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" TargetName="Icon"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="NoResize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="CanMinimize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>
+8 -7
View File
@@ -46,25 +46,26 @@
</Setter> </Setter>
</Style> </Style>
<Style x:Key="WindowDefault" BasedOn="{x:Null}" TargetType="Window"> <Style x:Key="WindowDefault" TargetType="Window">
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/> <Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/> <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
</Style> </Style>
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window"> <Style x:Key="WindowWin10" TargetType="controls:Window">
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/> <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/> <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ReverseTextBrush}"/>
<Setter Property="UseLayoutRounding" Value="True"/> <Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="NonClientAreaBackground" Value="White"/> <Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
<Setter Property="NonClientAreaForeground" Value="{DynamicResource ReverseTextBrush}"/> <Setter Property="NonClientAreaForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="CloseButtonBackground" Value="Transparent"/> <Setter Property="CloseButtonBackground" Value="Transparent"/>
<Setter Property="CloseButtonForeground" Value="{DynamicResource ReverseTextBrush}"/> <Setter Property="CloseButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="CloseButtonHoverBackground" Value="#e81123"/> <Setter Property="CloseButtonHoverBackground" Value="#e81123"/>
<Setter Property="CloseButtonHoverForeground" Value="White"/> <Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonBackground" Value="Transparent"/> <Setter Property="OtherButtonBackground" Value="Transparent"/>
<Setter Property="OtherButtonForeground" Value="{DynamicResource ReverseTextBrush}"/> <Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/> <Setter Property="OtherButtonHoverBackground" Value="#e5e5e5"/>
<Setter Property="OtherButtonHoverForeground" Value="{DynamicResource ReverseTextBrush}"/> <Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:Window"> <ControlTemplate TargetType="controls:Window">
+8
View File
@@ -359,6 +359,7 @@
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" /> <Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\CoverViewModel.cs" /> <Compile Include="ViewModel\Controls\CoverViewModel.cs" />
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" /> <Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
<Compile Include="ViewModel\Controls\SearchBarDemoViewModel.cs" />
<Compile Include="ViewModel\DemoViewModelBase!1.cs" /> <Compile Include="ViewModel\DemoViewModelBase!1.cs" />
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" /> <Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
<Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" /> <Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" />
@@ -380,6 +381,9 @@
<Compile Include="Window\CustomNonClientAreaWindow.xaml.cs"> <Compile Include="Window\CustomNonClientAreaWindow.xaml.cs">
<DependentUpon>CustomNonClientAreaWindow.xaml</DependentUpon> <DependentUpon>CustomNonClientAreaWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Window\GrowlDemoWindow.xaml.cs">
<DependentUpon>GrowlDemoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Window\NoNonClientAreaDragableWindow.xaml.cs"> <Compile Include="Window\NoNonClientAreaDragableWindow.xaml.cs">
<DependentUpon>NoNonClientAreaDragableWindow.xaml</DependentUpon> <DependentUpon>NoNonClientAreaDragableWindow.xaml</DependentUpon>
</Compile> </Compile>
@@ -763,6 +767,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Window\GrowlDemoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Window\NoNonClientAreaDragableWindow.xaml"> <Page Include="Window\NoNonClientAreaDragableWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
+1 -1
View File
@@ -33,7 +33,7 @@
<userControl:MainContent Grid.Column="1"/> <userControl:MainContent Grid.Column="1"/>
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" Width="4" Background="Transparent" BorderThickness="1,0,0,0" BorderBrush="{DynamicResource BorderBrush}"/> <GridSplitter Grid.Column="1" HorizontalAlignment="Left" Width="4" Background="Transparent" BorderThickness="1,0,0,0" BorderBrush="{DynamicResource BorderBrush}"/>
<controls:ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Right" IsEnableInertia="True" IsPenetrating="True"> <controls:ScrollViewer Grid.Column="1" VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Right" IsEnableInertia="True" IsPenetrating="True">
<StackPanel controls:Growl.GrowlParent="True" VerticalAlignment="Top" Margin="0,10,10,10"/> <StackPanel Name="GrowlPanel" VerticalAlignment="Top" Margin="0,10,10,10"/>
</controls:ScrollViewer> </controls:ScrollViewer>
</Grid> </Grid>
</controls:BlurWindow> </controls:BlurWindow>
+18 -1
View File
@@ -1,4 +1,7 @@
namespace HandyControlDemo using System;
using HandyControl.Controls;
namespace HandyControlDemo
{ {
public partial class MainWindow public partial class MainWindow
{ {
@@ -6,5 +9,19 @@
{ {
InitializeComponent(); InitializeComponent();
} }
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
Growl.SetGrowlParent(GrowlPanel, true);
}
protected override void OnDeactivated(EventArgs e)
{
base.OnDeactivated(e);
Growl.SetGrowlParent(GrowlPanel, false);
}
} }
} }
+18
View File
@@ -519,6 +519,15 @@ namespace HandyControlDemo.Properties.Langs {
} }
} }
/// <summary>
/// 查找类似 消息通知示例 的本地化字符串。
/// </summary>
public static string GrowlDemo {
get {
return ResourceManager.GetString("GrowlDemo", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 连接失败,请检查网络! 的本地化字符串。 /// 查找类似 连接失败,请检查网络! 的本地化字符串。
/// </summary> /// </summary>
@@ -672,6 +681,15 @@ namespace HandyControlDemo.Properties.Langs {
} }
} }
/// <summary>
/// 查找类似 新建窗口 的本地化字符串。
/// </summary>
public static string NewWindow {
get {
return ResourceManager.GetString("NewWindow", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 下一步 的本地化字符串。 /// 查找类似 下一步 的本地化字符串。
/// </summary> /// </summary>
@@ -522,4 +522,10 @@
<data name="PleaseWait" xml:space="preserve"> <data name="PleaseWait" xml:space="preserve">
<value>Please wait...</value> <value>Please wait...</value>
</data> </data>
<data name="GrowlDemo" xml:space="preserve">
<value>Growl demo</value>
</data>
<data name="NewWindow" xml:space="preserve">
<value>New window</value>
</data>
</root> </root>
@@ -522,4 +522,10 @@
<data name="PleaseWait" xml:space="preserve"> <data name="PleaseWait" xml:space="preserve">
<value>请稍后...</value> <value>请稍后...</value>
</data> </data>
<data name="GrowlDemo" xml:space="preserve">
<value>消息通知示例</value>
</data>
<data name="NewWindow" xml:space="preserve">
<value>新建窗口</value>
</data>
</root> </root>
@@ -1,8 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl" xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl" xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl">
xmlns:langs="clr-namespace:HandyControl.Properties.Langs;assembly=HandyControl">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Basic/Geometries.xaml"/> <ResourceDictionary Source="../Basic/Geometries.xaml"/>
@@ -98,30 +97,6 @@
<Setter Property="OtherButtonHoverForeground" Value="White"/> <Setter Property="OtherButtonHoverForeground" Value="White"/>
<Setter Property="NonClientAreaForeground" Value="White"/> <Setter Property="NonClientAreaForeground" Value="White"/>
<Setter Property="CloseButtonForeground" Value="White"/> <Setter Property="CloseButtonForeground" Value="White"/>
<Setter Property="Content">
<Setter.Value>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Path x:Name="PART_Image" HorizontalAlignment="Center" Visibility="Collapsed" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="20,32,0,0" Width="30" Height="30" Stretch="Uniform"/>
<ScrollViewer Grid.Column="1" Grid.Row="0">
<TextBlock Margin="10,39,10,10" x:Name="PART_Message" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</ScrollViewer>
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Margin="0,10,0,16" Orientation="Horizontal" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Margin="5,0"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.Confirm}" Margin="5,0" Background="#262e2f" Style="{StaticResource ButtonPrimary}"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsCancel="True" MinWidth="88" Command="interactivity:ControlCommands.No" Content="{x:Static langs:Lang.No}" Margin="5,0"/>
<Button Visibility="{Binding IsEnabled,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2VisibilityConverter}}" IsDefault="True" MinWidth="88" Command="interactivity:ControlCommands.Yes" Content="{x:Static langs:Lang.Yes}" Margin="5,0" Background="#262e2f" Style="{StaticResource ButtonPrimary}"/>
</StackPanel>
</Grid>
</Setter.Value>
</Setter>
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>
@@ -6,14 +6,17 @@
DataContext="{Binding GrowlDemo,Source={StaticResource Locator}}" DataContext="{Binding GrowlDemo,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}"> Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl> <controls:TransitioningContentControl>
<WrapPanel Margin="32" VerticalAlignment="Center"> <StackPanel Margin="32">
<Button Command="{Binding InfoCmd}" Content="{x:Static langs:Lang.Info}" Margin="0,5,5,5" Style="{StaticResource ButtonInfo}"/> <WrapPanel VerticalAlignment="Center">
<Button Command="{Binding SuccessCmd}" Content="{x:Static langs:Lang.Success}" Margin="5" Style="{StaticResource ButtonSuccess}"/> <Button Command="{Binding InfoCmd}" Content="{x:Static langs:Lang.Info}" Margin="0,5,5,5" Style="{StaticResource ButtonInfo}"/>
<Button Command="{Binding WarningCmd}" Content="{x:Static langs:Lang.Warning}" Margin="5" Style="{StaticResource ButtonWarning}"/> <Button Command="{Binding SuccessCmd}" Content="{x:Static langs:Lang.Success}" Margin="5" Style="{StaticResource ButtonSuccess}"/>
<Button Command="{Binding ErrorCmd}" Content="{x:Static langs:Lang.Error}" Margin="5" Style="{StaticResource ButtonDanger}"/> <Button Command="{Binding WarningCmd}" Content="{x:Static langs:Lang.Warning}" Margin="5" Style="{StaticResource ButtonWarning}"/>
<Button Command="{Binding AskCmd}" Content="{x:Static langs:Lang.Ask}" Margin="5" Background="BlueViolet" Foreground="White"/> <Button Command="{Binding ErrorCmd}" Content="{x:Static langs:Lang.Error}" Margin="5" Style="{StaticResource ButtonDanger}"/>
<Button Command="{Binding FatalCmd}" Content="{x:Static langs:Lang.Fatal}" Margin="5,0"/> <Button Command="{Binding AskCmd}" Content="{x:Static langs:Lang.Ask}" Margin="5" Background="BlueViolet" Foreground="White"/>
<Button Command="{Binding ClearCmd}" Content="{x:Static langs:Lang.Clear}" Margin="5,0,0,0" Style="{StaticResource ButtonPrimary}"/> <Button Command="{Binding FatalCmd}" Content="{x:Static langs:Lang.Fatal}" Margin="5,0"/>
</WrapPanel> <Button Command="{Binding ClearCmd}" Content="{x:Static langs:Lang.Clear}" Margin="5,0,0,0" Style="{StaticResource ButtonPrimary}"/>
</WrapPanel>
<Button Command="{Binding NewWindowCmd}" Content="{x:Static langs:Lang.NewWindow}" Margin="0,5,0,0" HorizontalAlignment="Left"/>
</StackPanel>
</controls:TransitioningContentControl> </controls:TransitioningContentControl>
</UserControl> </UserControl>
@@ -3,11 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl" xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
DataContext="{Binding SearchBarDemo,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}"> Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl> <controls:TransitioningContentControl>
<StackPanel Margin="32" Orientation="Horizontal"> <StackPanel Margin="32" Orientation="Horizontal">
<StackPanel> <StackPanel>
<controls:SearchBar/> <controls:SearchBar Command="{Binding SearchCmd}" CommandParameter="{Binding Text,RelativeSource={RelativeSource Self}}"/>
<controls:SearchBar Margin="0,32,0,0" IsEnabled="False"/> <controls:SearchBar Margin="0,32,0,0" IsEnabled="False"/>
<controls:SearchBar controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr1}" Margin="0,32,0,0" Style="{StaticResource SearchBarExtend}"/> <controls:SearchBar controls:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr1}" Margin="0,32,0,0" Style="{StaticResource SearchBarExtend}"/>
@@ -2,6 +2,7 @@
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using HandyControl.Controls; using HandyControl.Controls;
using HandyControl.Data; using HandyControl.Data;
using HandyControlDemo.Window;
namespace HandyControlDemo.ViewModel namespace HandyControlDemo.ViewModel
{ {
@@ -44,5 +45,8 @@ namespace HandyControlDemo.ViewModel
public RelayCommand ClearCmd => new Lazy<RelayCommand>(() => public RelayCommand ClearCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(Growl.Clear)).Value; new RelayCommand(Growl.Clear)).Value;
public RelayCommand NewWindowCmd => new Lazy<RelayCommand>(() =>
new RelayCommand(() => new GrowlDemoWindow().Show())).Value;
} }
} }
@@ -0,0 +1,18 @@
using System;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HandyControl.Controls;
namespace HandyControlDemo.ViewModel
{
public class SearchBarDemoViewModel : ViewModelBase
{
public RelayCommand<string> SearchCmd => new Lazy<RelayCommand<string>>(() =>
new RelayCommand<string>(Search)).Value;
private void Search(string key)
{
Growl.Info(key);
}
}
}
@@ -25,6 +25,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register<ChatBoxViewModel>(); SimpleIoc.Default.Register<ChatBoxViewModel>();
SimpleIoc.Default.Register<CoverViewModel>(); SimpleIoc.Default.Register<CoverViewModel>();
SimpleIoc.Default.Register<DialogDemoViewModel>(); SimpleIoc.Default.Register<DialogDemoViewModel>();
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
} }
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() => public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
@@ -54,6 +55,8 @@ namespace HandyControlDemo.ViewModel
public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance<DialogDemoViewModel>(); public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance<DialogDemoViewModel>();
public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance<SearchBarDemoViewModel>();
#endregion #endregion
} }
} }
@@ -0,0 +1,29 @@
<Window x:Class="HandyControlDemo.Window.GrowlDemoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
DataContext="{Binding GrowlDemo,Source={StaticResource Locator}}"
Title="{x:Static langs:Lang.GrowlDemo}"
Width="800"
Height="500">
<controls:TransitioningContentControl>
<controls:SimplePanel>
<StackPanel Margin="32">
<WrapPanel HorizontalAlignment="Left" VerticalAlignment="Top">
<Button Command="{Binding InfoCmd}" Content="{x:Static langs:Lang.Info}" Margin="0,5,5,5" Style="{StaticResource ButtonInfo}"/>
<Button Command="{Binding SuccessCmd}" Content="{x:Static langs:Lang.Success}" Margin="5" Style="{StaticResource ButtonSuccess}"/>
<Button Command="{Binding WarningCmd}" Content="{x:Static langs:Lang.Warning}" Margin="5" Style="{StaticResource ButtonWarning}"/>
<Button Command="{Binding ErrorCmd}" Content="{x:Static langs:Lang.Error}" Margin="5" Style="{StaticResource ButtonDanger}"/>
<Button Command="{Binding AskCmd}" Content="{x:Static langs:Lang.Ask}" Margin="5" Background="BlueViolet" Foreground="White"/>
<Button Command="{Binding FatalCmd}" Content="{x:Static langs:Lang.Fatal}" Margin="5,0"/>
<Button Command="{Binding ClearCmd}" Content="{x:Static langs:Lang.Clear}" Margin="5,0,0,0" Style="{StaticResource ButtonPrimary}"/>
</WrapPanel>
<Button Command="{Binding NewWindowCmd}" Content="{x:Static langs:Lang.NewWindow}" HorizontalAlignment="Left" Margin="0,5,0,0"/>
</StackPanel>
<controls:ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Right" IsEnableInertia="True" IsPenetrating="True">
<StackPanel Name="GrowlPanel" VerticalAlignment="Top" Margin="0,10,10,10"/>
</controls:ScrollViewer>
</controls:SimplePanel>
</controls:TransitioningContentControl>
</Window>
@@ -0,0 +1,27 @@
using System;
using HandyControl.Controls;
namespace HandyControlDemo.Window
{
public partial class GrowlDemoWindow
{
public GrowlDemoWindow()
{
InitializeComponent();
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
Growl.SetGrowlParent(GrowlPanel, true);
}
protected override void OnDeactivated(EventArgs e)
{
base.OnDeactivated(e);
Growl.SetGrowlParent(GrowlPanel, false);
}
}
}