Minimize to tray andd icon

This commit is contained in:
Anton Volkov
2019-03-27 16:33:05 +03:00
parent dfc8017766
commit c8465c504d
6 changed files with 36 additions and 53 deletions
+7 -8
View File
@@ -61,6 +61,8 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@@ -124,19 +126,12 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\Settings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Views\Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
@@ -181,6 +176,10 @@
<ItemGroup>
<SplashScreen Include="Splash.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="app.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+3 -1
View File
@@ -9,7 +9,9 @@
SizeToContent="WidthAndHeight"
d:DataContext="{d:DesignInstance viewModels:ApplicationViewModel}"
Title="ApplicationWindow"
ShowInTaskbar="True" d:DesignWidth="517.579" d:DesignHeight="260.977"
Icon="../app.ico"
ShowInTaskbar="True"
d:DesignWidth="517.579" d:DesignHeight="260.977"
>
<Window.Resources>
<DataTemplate DataType="{x:Type viewModels:MainPageViewModel}">
+26 -3
View File
@@ -1,15 +1,38 @@
namespace JiraTimeBot.Ui
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Forms;
namespace JiraTimeBot.Ui
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
NotifyIcon trayIcon = new System.Windows.Forms.NotifyIcon();
trayIcon.Icon = new Icon("app.ico");
trayIcon.Visible = true;
trayIcon.DoubleClick += (sender, args) =>
{
Show();
ShowInTaskbar = true;
WindowState = WindowState.Normal;
};
}
protected override void OnStateChanged(EventArgs e)
{
if (WindowState == WindowState.Minimized)
{
ShowInTaskbar = false;
Hide();
}
base.OnStateChanged(e);
}
}
}
-13
View File
@@ -1,13 +0,0 @@
<UserControl x:Class="JiraTimeBot.Ui.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:JiraTimeBot.Ui"
mc:Ignorable="d"
Width="100"
Height="200">
<Grid>
</Grid>
</UserControl>
-28
View File
@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace JiraTimeBot.Ui
{
/// <summary>
/// Interaction logic for Settings.xaml
/// </summary>
public partial class Settings : UserControl
{
public Settings()
{
InitializeComponent();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB