Skip to content

Commit 460cbc6

Browse files
committed
add references to Forms and Drawing (required to use NotifyIcon), add minimize to taskbar button, add ico image, set app icon, disable multirow selection in grid, move testdata-class as Project
1 parent 083f8db commit 460cbc6

File tree

5 files changed

+101
-21
lines changed

5 files changed

+101
-21
lines changed

UnityLauncherPro/Images/icon.ico

22.7 KB
Binary file not shown.

UnityLauncherPro/MainWindow.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
<Rectangle Fill="#FF0C0C0C" MouseDown="OnRectangleMouseDown" />
8585
<Image Source="Images/icon.png" RenderOptions.BitmapScalingMode="NearestNeighbor" HorizontalAlignment="Left" Width="16" Height="16" Margin="4,0,0,0" SnapsToDevicePixels="True" UseLayoutRounding="True" />
8686
<Label Content="UnityLauncherPro" IsHitTestVisible="False" Margin="19,0,0,-5" Foreground="#FFB8B8B8" FontSize="12" HorizontalAlignment="Left" />
87+
<Button Name="btnMinimize" BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="{x:Null}" Click="BtnMinimize_Click" Margin="0,0,27,0">
88+
<TextBlock Text="-" Margin="0,-5,0,0" FontSize="18" Foreground="#FFC3C3C3"/>
89+
</Button>
8790
<Button Name="btnClose" BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="{x:Null}" Click="BtnClose_Click">
8891
<TextBlock Text="x" Margin="0,-5,0,0" FontSize="18" Foreground="#FFC3C3C3"/>
8992
</Button>
@@ -110,9 +113,9 @@
110113
<Button Style="{StaticResource CustomButton}" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Background="#FF3F3F46" Foreground="#FFC1C1C1" Margin="0,4,34,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" />
111114
<Button Style="{StaticResource CustomButton}" x:Name="btnRefreshProjectList" Content="" Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Background="#FF3F3F46" Foreground="#FFC1C1C1" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}"/>
112115

113-
<DataGrid x:Name="dataGrid" Margin="0,30" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="#FFD8D8D8" HorizontalGridLinesBrush="#4C000000" VerticalGridLinesBrush="#19000000">
116+
<DataGrid x:Name="dataGrid" SelectionMode="Single" Margin="0,30" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="#FFD8D8D8" HorizontalGridLinesBrush="#4C000000" VerticalGridLinesBrush="#19000000">
114117
<DataGrid.Columns>
115-
<DataGridTextColumn Binding="{Binding Project}" ClipboardContentBinding="{x:Null}" Header="Project" IsReadOnly="True" MinWidth="123"/>
118+
<DataGridTextColumn Binding="{Binding Title}" ClipboardContentBinding="{x:Null}" Header="Project" IsReadOnly="True" MinWidth="123"/>
116119
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True"/>
117120
<DataGridTextColumn Binding="{Binding Path}" ClipboardContentBinding="{x:Null}" Header="Path" IsReadOnly="True"/>
118121
<DataGridTextColumn Binding="{Binding Modified}" ClipboardContentBinding="{x:Null}" Header="Modified" IsReadOnly="True"/>
@@ -132,7 +135,7 @@
132135
</Style.Triggers>
133136
</Style>
134137
</DataGrid.RowStyle>
135-
<local:TestData GITBranch="" Modified="" Project="MMO" Path="A:/temp" Version="2099.1.2.3"/>
138+
<local:Project GITBranch="" Modified="" Title="MMO" Path="A:/temp" Version="2099.1.2.3"/>
136139
</DataGrid>
137140
</Grid>
138141
</TabItem>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Drawing; // for notifyicon
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
@@ -20,6 +21,9 @@ namespace UnityLauncherPro
2021
/// </summary>
2122
public partial class MainWindow : Window
2223
{
24+
25+
private System.Windows.Forms.NotifyIcon notifyIcon;
26+
2327
public MainWindow()
2428
{
2529
InitializeComponent();
@@ -29,10 +33,39 @@ public MainWindow()
2933
void Start()
3034
{
3135
// test data
32-
dataGrid.Items.Add(new TestData { Project = "asdf", Version = "5000", Path = "A:/", Modified = DateTime.Now, Arguments ="", GITBranch = "-" });
33-
dataGrid.Items.Add(new TestData { Project = "asdf asd", Version = "2", Path = "C:/", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
34-
dataGrid.Items.Add(new TestData { Project = "kuykkyu", Version = "23.23.23", Path = "8,1", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
35-
dataGrid.Items.Add(new TestData { Project = "RT435y", Version = "3333", Path = "X:/", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
36+
dataGrid.Items.Add(new Project { Title = "asdf", Version = "5000", Path = "A:/", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
37+
dataGrid.Items.Add(new Project { Title = "asdf asd", Version = "2", Path = "C:/", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
38+
dataGrid.Items.Add(new Project { Title = "kuykkyu", Version = "23.23.23", Path = "8,1", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
39+
dataGrid.Items.Add(new Project { Title = "RT435y", Version = "3333", Path = "X:/", Modified = DateTime.Now, Arguments = "", GITBranch = "-" });
40+
41+
// build notifyicon
42+
notifyIcon = new System.Windows.Forms.NotifyIcon();
43+
notifyIcon.Icon = new Icon(System.Windows.Application.GetResourceStream(new Uri("pack://application:,,,/Images/icon.ico")).Stream);
44+
notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(NotifyIcon_MouseClick);
45+
}
46+
47+
void NotifyIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
48+
{
49+
this.Show();
50+
this.WindowState = WindowState.Normal;
51+
notifyIcon.Visible = false;
52+
}
53+
54+
private void Window_StateChanged(object sender, EventArgs e)
55+
{
56+
if (this.WindowState == WindowState.Minimized)
57+
{
58+
this.ShowInTaskbar = false;
59+
notifyIcon.BalloonTipTitle = "Minimize Sucessful";
60+
notifyIcon.BalloonTipText = "Minimized the app ";
61+
notifyIcon.ShowBalloonTip(400);
62+
notifyIcon.Visible = true;
63+
}
64+
else if (this.WindowState == WindowState.Normal)
65+
{
66+
notifyIcon.Visible = false;
67+
this.ShowInTaskbar = true;
68+
}
3669
}
3770

3871

@@ -65,7 +98,7 @@ private void BtnAddProjectFolder_Click(object sender, RoutedEventArgs e)
6598
// https://stackoverflow.com/a/50261723/5452781
6699
// Create a "Save As" dialog for selecting a directory (HACK)
67100
var dialog = new Microsoft.Win32.SaveFileDialog();
68-
dialog.InitialDirectory = "c:";//textbox.Text; // Use current value for initial dir
101+
dialog.InitialDirectory = "c:"; // Use current value for initial dir
69102
dialog.Title = "Select a Directory"; // instead of default "Save As"
70103
dialog.Filter = "Project Folder|*.Folder"; // Prevents displaying files
71104
dialog.FileName = "Project"; // Filename will then be "select.this.directory"
@@ -81,7 +114,6 @@ private void BtnAddProjectFolder_Click(object sender, RoutedEventArgs e)
81114
System.IO.Directory.CreateDirectory(path);
82115
}
83116
// Our final value is in path
84-
//textbox.Text = path;
85117
Console.WriteLine(path);
86118
}
87119
}
@@ -90,18 +122,13 @@ private void BtnClose_Click(object sender, RoutedEventArgs e)
90122
{
91123
this.Close();
92124
}
93-
}
94125

95-
public struct TestData
96-
{
97-
public string Project { set; get; }
98-
public string Version { set; get; }
99-
public string Path { set; get; }
100-
public DateTime Modified { set; get; }
101-
public string Arguments { set; get; }
102-
public string GITBranch { set; get; }
126+
private void BtnMinimize_Click(object sender, RoutedEventArgs e)
127+
{
128+
// remove focus from minimize button
129+
dataGrid.Focus();
130+
notifyIcon.Visible = true;
131+
this.Hide();
132+
}
103133
}
104-
105-
106-
107134
}

UnityLauncherPro/Project.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
3+
namespace UnityLauncherPro
4+
{
5+
public class Project
6+
{
7+
public string Title { set; get; }
8+
public string Version { set; get; }
9+
public string Path { set; get; }
10+
public DateTime Modified { set; get; }
11+
public string Arguments { set; get; }
12+
public string GITBranch { set; get; }
13+
}
14+
}

UnityLauncherPro/UnityLauncherPro.csproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
<WarningLevel>4</WarningLevel>
1515
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1616
<Deterministic>true</Deterministic>
17+
<PublishUrl>publish\</PublishUrl>
18+
<Install>true</Install>
19+
<InstallFrom>Disk</InstallFrom>
20+
<UpdateEnabled>false</UpdateEnabled>
21+
<UpdateMode>Foreground</UpdateMode>
22+
<UpdateInterval>7</UpdateInterval>
23+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
24+
<UpdatePeriodically>false</UpdatePeriodically>
25+
<UpdateRequired>false</UpdateRequired>
26+
<MapFileExtensions>true</MapFileExtensions>
27+
<ApplicationRevision>0</ApplicationRevision>
28+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
29+
<IsWebBootstrapper>false</IsWebBootstrapper>
30+
<UseApplicationTrust>false</UseApplicationTrust>
31+
<BootstrapperEnabled>true</BootstrapperEnabled>
1732
</PropertyGroup>
1833
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1934
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -34,9 +49,14 @@
3449
<ErrorReport>prompt</ErrorReport>
3550
<WarningLevel>4</WarningLevel>
3651
</PropertyGroup>
52+
<PropertyGroup>
53+
<ApplicationIcon>Images/icon.ico</ApplicationIcon>
54+
</PropertyGroup>
3755
<ItemGroup>
3856
<Reference Include="System" />
3957
<Reference Include="System.Data" />
58+
<Reference Include="System.Drawing" />
59+
<Reference Include="System.Windows.Forms" />
4060
<Reference Include="System.Xml" />
4161
<Reference Include="Microsoft.CSharp" />
4262
<Reference Include="System.Core" />
@@ -69,6 +89,7 @@
6989
</Compile>
7090
</ItemGroup>
7191
<ItemGroup>
92+
<Compile Include="Project.cs" />
7293
<Compile Include="Properties\AssemblyInfo.cs">
7394
<SubType>Code</SubType>
7495
</Compile>
@@ -97,5 +118,20 @@
97118
<ItemGroup>
98119
<Resource Include="Images\icon.png" />
99120
</ItemGroup>
121+
<ItemGroup>
122+
<Resource Include="Images\icon.ico" />
123+
</ItemGroup>
124+
<ItemGroup>
125+
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
126+
<Visible>False</Visible>
127+
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
128+
<Install>true</Install>
129+
</BootstrapperPackage>
130+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
131+
<Visible>False</Visible>
132+
<ProductName>.NET Framework 3.5 SP1</ProductName>
133+
<Install>false</Install>
134+
</BootstrapperPackage>
135+
</ItemGroup>
100136
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
101137
</Project>

0 commit comments

Comments
 (0)