dev 19-3-29
This commit is contained in:
1 parent
67dc02ae83
commit
5ee2bdd3f7
17 files changed
+321
-97
No files matched your search
@@ -32,5 +32,7 @@ namespace HandyControlDemo.Data
|
||||
}
|
||||
|
||||
public static AppConfig Config { get; set; }
|
||||
|
||||
public static bool NotifyIconIsShow { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -362,6 +362,7 @@
|
||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\NotifyIconDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\SearchBarDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\DemoViewModelBase!1.cs" />
|
||||
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using HandyControl.Controls;
|
||||
using HandyControlDemo.Data;
|
||||
|
||||
namespace HandyControlDemo
|
||||
{
|
||||
@@ -23,5 +25,19 @@ namespace HandyControlDemo
|
||||
|
||||
Growl.SetGrowlParent(GrowlPanel, false);
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (GlobalData.NotifyIconIsShow)
|
||||
{
|
||||
MessageBox.Info(Properties.Langs.Lang.AppClosingTip, Properties.Langs.Lang.Tip);
|
||||
Hide();
|
||||
e.Cancel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
@@ -78,6 +78,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 托盘图标已打开,将隐藏窗口而不是关闭程序 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string AppClosingTip {
|
||||
get {
|
||||
return ResourceManager.GetString("AppClosingTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 询问 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -105,6 +114,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 闪烁 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Blink {
|
||||
get {
|
||||
return ResourceManager.GetString("Blink", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 博客 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -429,6 +447,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 退出 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Exit {
|
||||
get {
|
||||
return ResourceManager.GetString("Exit", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 展开框 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -798,6 +825,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 打开面板 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string OpenPanel {
|
||||
get {
|
||||
return ResourceManager.GetString("OpenPanel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 轮廓文本 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -1176,6 +1212,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 提示 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Tip {
|
||||
get {
|
||||
return ResourceManager.GetString("Tip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 标题 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -1248,6 +1293,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 试试关闭程序吧? 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Try2CloseApp {
|
||||
get {
|
||||
return ResourceManager.GetString("Try2CloseApp", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 类型 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -1275,6 +1329,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 可见性 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Visibility {
|
||||
get {
|
||||
return ResourceManager.GetString("Visibility", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 警告 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -531,4 +531,25 @@
|
||||
<data name="NewWindow" xml:space="preserve">
|
||||
<value>New window</value>
|
||||
</data>
|
||||
<data name="Visibility" xml:space="preserve">
|
||||
<value>Visibility</value>
|
||||
</data>
|
||||
<data name="Blink" xml:space="preserve">
|
||||
<value>Blink</value>
|
||||
</data>
|
||||
<data name="Exit" xml:space="preserve">
|
||||
<value>Exit</value>
|
||||
</data>
|
||||
<data name="OpenPanel" xml:space="preserve">
|
||||
<value>Open Panel</value>
|
||||
</data>
|
||||
<data name="AppClosingTip" xml:space="preserve">
|
||||
<value>The tray icon is open and will hide the window instead of closing the program</value>
|
||||
</data>
|
||||
<data name="Tip" xml:space="preserve">
|
||||
<value>Prompt</value>
|
||||
</data>
|
||||
<data name="Try2CloseApp" xml:space="preserve">
|
||||
<value>Try to close app?</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -531,4 +531,25 @@
|
||||
<data name="NewWindow" xml:space="preserve">
|
||||
<value>新建窗口</value>
|
||||
</data>
|
||||
<data name="Visibility" xml:space="preserve">
|
||||
<value>可见性</value>
|
||||
</data>
|
||||
<data name="Blink" xml:space="preserve">
|
||||
<value>闪烁</value>
|
||||
</data>
|
||||
<data name="Exit" xml:space="preserve">
|
||||
<value>退出</value>
|
||||
</data>
|
||||
<data name="OpenPanel" xml:space="preserve">
|
||||
<value>打开面板</value>
|
||||
</data>
|
||||
<data name="AppClosingTip" xml:space="preserve">
|
||||
<value>托盘图标已打开,将隐藏窗口而不是关闭程序</value>
|
||||
</data>
|
||||
<data name="Tip" xml:space="preserve">
|
||||
<value>提示</value>
|
||||
</data>
|
||||
<data name="Try2CloseApp" xml:space="preserve">
|
||||
<value>试试关闭程序吧?</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,15 +1,29 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.NotifyIconDemoCtl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
|
||||
DataContext="{Binding NotifyIconDemo,Source={StaticResource Locator}}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<Grid>
|
||||
<controls:NotifyIcon Text="123">
|
||||
<StackPanel Margin="32">
|
||||
<GroupBox controls:TitleElement.TitleAlignment="Left" Style="{StaticResource GroupBoxOriginal}" Header="{x:Static langs:Lang.Visibility}">
|
||||
<ToggleButton IsChecked="{Binding IsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
||||
</GroupBox>
|
||||
<TextBlock Foreground="{DynamicResource InfoBrush}" Visibility="{Binding IsShow,Converter={StaticResource Boolean2VisibilityConverter}}" Text="{x:Static langs:Lang.Try2CloseApp}" Margin="0,6,0,0"/>
|
||||
<GroupBox Margin="0,16,0,0" controls:TitleElement.TitleAlignment="Left" Style="{StaticResource GroupBoxOriginal}" Header="{x:Static langs:Lang.Blink}">
|
||||
<ToggleButton IsEnabled="{Binding IsShow}" Style="{StaticResource ToggleButtonSwitch}"/>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
<controls:NotifyIcon Text="123" Visibility="{Binding IsShow,Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<!--<controls:NotifyIcon.ContextContent>
|
||||
<Border Width="100" Height="300" Background="Black"/>
|
||||
</controls:NotifyIcon.ContextContent>-->
|
||||
<controls:NotifyIcon.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="123"/>
|
||||
<MenuItem Header="123"/>
|
||||
<MenuItem Header="123"/>
|
||||
<MenuItem Command="interactivity:ControlCommands.PushMainWindow2Top" Header="{x:Static langs:Lang.OpenPanel}"/>
|
||||
<MenuItem Command="interactivity:ControlCommands.ShutdownApp" Header="{x:Static langs:Lang.Exit}"/>
|
||||
</ContextMenu>
|
||||
</controls:NotifyIcon.ContextMenu>
|
||||
</controls:NotifyIcon>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -32,7 +31,7 @@ namespace HandyControlDemo.UserControl
|
||||
GlobalData.Config.Lang = tag;
|
||||
GlobalData.Save();
|
||||
Process.Start(Assembly.GetExecutingAssembly().Location);
|
||||
Environment.Exit(0);
|
||||
Application.Current.Shutdown();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using GalaSoft.MvvmLight;
|
||||
using HandyControlDemo.Data;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class NotifyIconDemoViewModel : ViewModelBase
|
||||
{
|
||||
private bool _isShow;
|
||||
|
||||
public bool IsShow
|
||||
{
|
||||
get => _isShow;
|
||||
set
|
||||
{
|
||||
Set(ref _isShow, value);
|
||||
GlobalData.NotifyIconIsShow = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace HandyControlDemo.ViewModel
|
||||
SimpleIoc.Default.Register<CoverViewModel>();
|
||||
SimpleIoc.Default.Register<DialogDemoViewModel>();
|
||||
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
||||
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@@ -57,6 +58,8 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance<SearchBarDemoViewModel>();
|
||||
|
||||
public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance<NotifyIconDemoViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user