Skip to content

Commit 6173442

Browse files
committed
add custom button style, add "add project" button, add custom select folder dialog, add mouseover color to tabs, add close window button, fix blurry titlebar icon
1 parent 4d19b51 commit 6173442

File tree

4 files changed

+69
-7
lines changed

4 files changed

+69
-7
lines changed

UnityLauncherPro/Images/icon.png

-195 Bytes
Loading

UnityLauncherPro/MainWindow.xaml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Title="UnityLauncherPro" Height="600" Width="500" WindowStartupLocation="CenterScreen" Background="#FF121212" MinWidth="500" MinHeight="300" WindowStyle="None" ResizeMode="CanResizeWithGrip" AllowsTransparency="True">
99

1010
<Window.Resources>
11+
<!-- tabs -->
1112
<Style x:Key="TabItemStyle1" TargetType="{x:Type TabItem}">
1213
<Setter Property="Template">
1314
<Setter.Value>
@@ -23,7 +24,9 @@
2324
</Trigger>
2425
<Trigger Property="IsSelected" Value="True">
2526
<Setter Property="TextElement.Foreground" TargetName="ContentSite" Value="White"/>
26-
<Setter Property="TextElement.FontWeight" TargetName="ContentSite" Value="SemiBold"/>
27+
<Setter TargetName="Border" Property="Background" Value="#FF262626"/>
28+
</Trigger>
29+
<Trigger Property="IsMouseOver" Value="True">
2730
<Setter TargetName="Border" Property="Background" Value="#FF262626"/>
2831
</Trigger>
2932
</ControlTemplate.Triggers>
@@ -32,6 +35,7 @@
3235
</Setter>
3336
</Style>
3437

38+
<!-- datagrid -->
3539
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
3640
<Setter Property="Background" Value="#4C3F3F46" />
3741
<Setter Property="Foreground" Value="#FFB6B6B6" />
@@ -43,6 +47,31 @@
4347
<Setter Property="Padding" Value="6,2,2,2" />
4448
</Style>
4549

50+
<!-- custom buttons -->
51+
<Style x:Key="CustomButton" TargetType="Button">
52+
<Setter Property="SnapsToDevicePixels" Value="true"/>
53+
<Setter Property="OverridesDefaultStyle" Value="true"/>
54+
<Setter Property="Template">
55+
<Setter.Value>
56+
<ControlTemplate TargetType="Button">
57+
<Border Name="shortcutbutton" BorderThickness="0" BorderBrush="Black" Background="{TemplateBinding Background}">
58+
<ContentPresenter Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/>
59+
</Border>
60+
<ControlTemplate.Triggers>
61+
<Trigger Property="IsMouseOver" Value="true">
62+
<Setter TargetName="shortcutbutton" Property="Background" Value="#FF494949" />
63+
<!--<Setter Property="TextElement.Foreground" TargetName="shortcutbutton" Value="Blue"/>-->
64+
</Trigger>
65+
<Trigger Property="IsPressed" Value="true">
66+
<Setter TargetName="shortcutbutton" Property="Background" Value="#FF0F0F0F" />
67+
<!--<Setter Property="TextElement.Foreground" TargetName="shortcutbutton" Value="Red"/>-->
68+
</Trigger>
69+
</ControlTemplate.Triggers>
70+
</ControlTemplate>
71+
</Setter.Value>
72+
</Setter>
73+
</Style>
74+
4675
</Window.Resources>
4776

4877
<Grid Margin="0">
@@ -51,10 +80,13 @@
5180
<RowDefinition />
5281
</Grid.RowDefinitions>
5382

54-
<Grid>
55-
<Rectangle Grid.Row="0" Fill="#FF0C0C0C" MouseDown="OnRectangleMouseDown" />
56-
<Image Source="Images/icon.png" HorizontalAlignment="Left" Width="16" Height="16" Margin="4,0,0,0" />
57-
<Label Content="UnityLauncherPro 1.0" IsHitTestVisible="False" Margin="19,0,0,-5" Foreground="#FFB8B8B8" FontSize="12" HorizontalAlignment="Left" />
83+
<Grid Grid.Row="0" UseLayoutRounding="False">
84+
<Rectangle Fill="#FF0C0C0C" MouseDown="OnRectangleMouseDown" />
85+
<Image Source="Images/icon.png" RenderOptions.BitmapScalingMode="NearestNeighbor" HorizontalAlignment="Left" Width="16" Height="16" Margin="4,0,0,0" SnapsToDevicePixels="True" UseLayoutRounding="True" />
86+
<Label Content="UnityLauncherPro" IsHitTestVisible="False" Margin="19,0,0,-5" Foreground="#FFB8B8B8" FontSize="12" HorizontalAlignment="Left" />
87+
<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">
88+
<TextBlock Text="x" Margin="0,-5,0,0" FontSize="18" Foreground="#FFC3C3C3"/>
89+
</Button>
5890
</Grid>
5991

6092
<TabControl Grid.Row="1" x:Name="tabControl" Background="#FF262626" BorderBrush="{x:Null}" Padding="0">
@@ -75,7 +107,8 @@
75107
</TextBlock.Style>
76108
</TextBlock>
77109

78-
<Button x:Name="button" 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"/>
110+
<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}" />
111+
<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}"/>
79112

80113
<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">
81114
<DataGrid.Columns>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,36 @@ private void OnSearchPreviewKeyDown(object sender, KeyEventArgs e)
6060
}
6161
}
6262

63+
private void BtnAddProjectFolder_Click(object sender, RoutedEventArgs e)
64+
{
65+
// https://stackoverflow.com/a/50261723/5452781
66+
// Create a "Save As" dialog for selecting a directory (HACK)
67+
var dialog = new Microsoft.Win32.SaveFileDialog();
68+
dialog.InitialDirectory = "c:";//textbox.Text; // Use current value for initial dir
69+
dialog.Title = "Select a Directory"; // instead of default "Save As"
70+
dialog.Filter = "Project Folder|*.Folder"; // Prevents displaying files
71+
dialog.FileName = "Project"; // Filename will then be "select.this.directory"
72+
if (dialog.ShowDialog() == true)
73+
{
74+
string path = dialog.FileName;
75+
// Remove fake filename from resulting path
76+
path = path.Replace("\\Project.Folder", "");
77+
path = path.Replace("Project.Folder", "");
78+
// If user has changed the filename, create the new directory
79+
if (!System.IO.Directory.Exists(path))
80+
{
81+
System.IO.Directory.CreateDirectory(path);
82+
}
83+
// Our final value is in path
84+
//textbox.Text = path;
85+
Console.WriteLine(path);
86+
}
87+
}
88+
89+
private void BtnClose_Click(object sender, RoutedEventArgs e)
90+
{
91+
this.Close();
92+
}
6393
}
6494

6595
public struct TestData

UnityLauncherPro/UnityLauncherPro.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
<ItemGroup>
9595
<None Include="App.config" />
9696
</ItemGroup>
97-
<ItemGroup />
9897
<ItemGroup>
9998
<Resource Include="Images\icon.png" />
10099
</ItemGroup>

0 commit comments

Comments
 (0)