Skip to content

Commit 94ae764

Browse files
committed
add Explore project folder, add copy selected project unity version string to clipboard, add refresh project list
1 parent e1fc9b5 commit 94ae764

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

UnityLauncherPro/MainWindow.xaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
</TextBlock>-->
288288

289289
<Button Style="{StaticResource CustomButton}" ToolTip="Add existing project" 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}" />
290-
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" 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}"/>
290+
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" 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}" Click="BtnRefreshProjectList_Click"/>
291291

292292
<DataGrid x:Name="gridRecent" SelectionMode="Single" Margin="4,30,2,42" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="#FFD8D8D8" HorizontalGridLinesBrush="#4C000000" VerticalGridLinesBrush="#19000000" AutoGenerateColumns="False">
293293

@@ -303,7 +303,7 @@
303303
<!-- right click context menu -->
304304
<DataGrid.ContextMenu>
305305
<ContextMenu>
306-
<MenuItem Header="Copy Unity Version" />
306+
<MenuItem x:Name="menuItemCopyVersion" Header="Copy Unity Version" Click="MenuItemCopyVersion_Click" />
307307
<Separator />
308308
<MenuItem Header="Menu item asdf" />
309309
</ContextMenu>
@@ -366,7 +366,7 @@
366366
<Label Foreground="{DynamicResource ButtonForeground}">_Open Project</Label>
367367
</Button>
368368

369-
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnExplore" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="8,0,0,0" BorderBrush="{x:Null}" >
369+
<Button Grid.Column="3" Style="{StaticResource CustomButton}" x:Name="btnExplore" Background="{DynamicResource ButtonBackground}" Foreground="#FFC1C1C1" Margin="8,0,0,0" BorderBrush="{x:Null}" Click="BtnExplore_Click" >
370370
<Label Foreground="{DynamicResource ButtonForeground}">_Explore</Label>
371371
</Button>
372372

@@ -388,7 +388,6 @@
388388
<Style.Triggers>
389389
<DataTrigger Binding="{Binding ElementName=txtSearchBoxUnity, Path=Text}" Value="">
390390
<Setter Property="Visibility" Value="Hidden"/>
391-
392391
</DataTrigger>
393392
<DataTrigger Binding="{Binding ElementName=txtSearchBoxUnity, Path=Text}" Value="{x:Null}">
394393
<Setter Property="Visibility" Value="Hidden"/>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,5 +454,24 @@ private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
454454

455455
base.OnKeyDown(e);
456456
}
457+
458+
private void BtnExplore_Click(object sender, RoutedEventArgs e)
459+
{
460+
var proj = GetSelectedProject();
461+
Tools.ExploreProjectFolder(proj);
462+
}
463+
464+
// copy selected row unity version to clipboard
465+
private void MenuItemCopyVersion_Click(object sender, RoutedEventArgs e)
466+
{
467+
var proj = GetSelectedProject();
468+
Clipboard.SetText(proj?.Version);
469+
}
470+
471+
private void BtnRefreshProjectList_Click(object sender, RoutedEventArgs e)
472+
{
473+
projectsSource = GetProjects.Scan();
474+
gridRecent.ItemsSource = projectsSource;
475+
}
457476
} // class
458477
} //namespace

UnityLauncherPro/Tools.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,35 @@ public static string GetFileVersionData(string path)
110110
return fvi.ProductName.Replace("(64-bit)", "").Replace("Unity", "").Trim();
111111
}
112112

113+
public static void ExploreProjectFolder(Project proj)
114+
{
115+
if (proj != null)
116+
{
117+
if (proj.Path != null)
118+
{
119+
if (LaunchExplorer(proj.Path) == false)
120+
{
121+
//SetStatus("Error> Directory not found: " + folder);
122+
}
123+
}
124+
}
125+
}
126+
127+
// opens Explorer to target folder
128+
public static bool LaunchExplorer(string folder)
129+
{
130+
bool result = false;
131+
if (Directory.Exists(folder) == true)
132+
{
133+
Process.Start(folder);
134+
result = true;
135+
}
136+
else
137+
{
138+
result = false;
139+
}
140+
return result;
141+
}
142+
113143
} // class
114144
} // namespace

0 commit comments

Comments
 (0)