Skip to content

Commit 074d4c6

Browse files
committed
recent projects: tab key to jump into results, cleanup, add editor logs button code, add player logs button code, add logcat button code
1 parent 65d569e commit 074d4c6

File tree

2 files changed

+79
-58
lines changed

2 files changed

+79
-58
lines changed

UnityLauncherPro/MainWindow.xaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
<!-- search box -->
263263
<Grid Background="{DynamicResource TextBoxBackground}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="222" Margin="6,5,0,0" Height="20" >
264264
<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="#7F919191" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />
265-
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBox" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" TextChanged="OnSearchTextChanged" PreviewKeyDown="TxtSearchBox_PreviewKeyDown" />
266-
<Button x:Name="btnClearSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearProjectSearchClick">
265+
<TextBox MinWidth="100" CaretBrush="#FFE2E2E2" x:Name="txtSearchBox" Background="Transparent" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" TextChanged="OnSearchTextChanged" PreviewKeyDown="TxtSearchBox_PreviewKeyDown" TabIndex="1" />
266+
<Button x:Name="btnClearSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" Click="OnClearProjectSearchClick" IsTabStop="False">
267267
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ButtonForeground}" Padding="5,3,4,4" HorizontalAlignment="Center">
268268
<TextBlock.Style>
269269
<Style TargetType="{x:Type TextBlock}">
@@ -295,10 +295,10 @@
295295
</TextBlock.Style>
296296
</TextBlock>-->
297297

298-
<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}" />
299-
<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"/>
298+
<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}" TabIndex="10" />
299+
<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" TabIndex="11"/>
300300

301-
<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" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded">
301+
<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" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2">
302302
<DataGrid.Columns>
303303
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Title}" ClipboardContentBinding="{x:Null}" Header="Project" IsReadOnly="True" Width="150"/>
304304
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True" Width="72">
@@ -546,16 +546,16 @@
546546
<Grid Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Left">
547547
<Border>
548548
<StackPanel Orientation="Horizontal" Margin="10">
549-
<Button Style="{StaticResource CustomButton}" x:Name="btnTemp1" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top">
549+
<Button Style="{StaticResource CustomButton}" x:Name="btnOpenEditorLogsFolder" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="BtnOpenEditorLogsFolder_Click">
550550
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Editor Logs"/>
551551
</Button>
552-
<Button Style="{StaticResource CustomButton}" x:Name="btnTemp2" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top">
552+
<Button Style="{StaticResource CustomButton}" x:Name="btnOpenPlayerLogs" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="10,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="BtnOpenPlayerLogs_Click">
553553
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Player Logs"/>
554554
</Button>
555-
<Button Style="{StaticResource CustomButton}" x:Name="btnTemp3" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top">
555+
<Button Style="{StaticResource CustomButton}" x:Name="btnOpenADBLogCat" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="10,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="BtnOpenADBLogCat_Click">
556556
<Label Foreground="{DynamicResource ButtonForeground}" Content="_ADB logcat"/>
557557
</Button>
558-
<Button Style="{StaticResource CustomButton}" x:Name="btnTemp4" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top">
558+
<Button Style="{StaticResource CustomButton}" x:Name="btnAdbBindWifi" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="10,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="BtnAdbBindWifi_Click">
559559
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Bind Wifi"/>
560560
</Button>
561561
</StackPanel>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ void AddUnityInstallationRootFolder()
199199
}
200200
}
201201

202+
void SetFocusToGrid(DataGrid targetGrid)
203+
{
204+
//e.Handled = true; // if enabled, we enter to first row initially
205+
targetGrid.Focus();
206+
targetGrid.SelectedIndex = 0;
207+
DataGridRow row = (DataGridRow)targetGrid.ItemContainerGenerator.ContainerFromIndex(0);
208+
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
209+
}
210+
211+
202212
//
203213
//
204214
// EVENTS
@@ -333,11 +343,7 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
333343
// activate searchbar if not active and we are in tab#1
334344
if (tabControl.SelectedIndex == 0 && txtSearchBox.IsFocused == false)
335345
{
336-
// dont write tab key on search field
337-
if (e.Key == Key.Tab) break;
338-
339346
txtSearchBox.Focus();
340-
//txtSearchBox.Text += e.Key;
341347
txtSearchBox.Select(txtSearchBox.Text.Length, 0);
342348
}
343349
break;
@@ -396,31 +402,6 @@ private void BtnLaunchProject_Click(object sender, RoutedEventArgs e)
396402
{
397403
Tools.LaunchProject(GetSelectedProject());
398404
}
399-
/*
400-
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
401-
{
402-
// override Enter for datagrid
403-
switch (tabControl.SelectedIndex)
404-
{
405-
case 0: // projects
406-
407-
//Tools.LaunchProject(GetSelectedProject());
408-
break;
409-
case 1: // unitys
410-
break;
411-
case 2: // updates
412-
break;
413-
case 3: // tools
414-
break;
415-
case 4: // settings
416-
break;
417-
default:
418-
break;
419-
}
420-
421-
422-
base.OnKeyDown(e);
423-
}*/
424405

425406
private void BtnExplore_Click(object sender, RoutedEventArgs e)
426407
{
@@ -459,11 +440,7 @@ private void BtnUpgradeProject_Click(object sender, RoutedEventArgs e)
459440

460441
private void GridRecent_Loaded(object sender, RoutedEventArgs e)
461442
{
462-
gridRecent.Focus();
463-
gridRecent.SelectedIndex = 0;
464-
// properly set focus to row
465-
DataGridRow row = (DataGridRow)gridRecent.ItemContainerGenerator.ContainerFromIndex(0);
466-
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
443+
SetFocusToGrid(gridRecent);
467444
}
468445

469446
private void BtnExploreUnity_Click(object sender, RoutedEventArgs e)
@@ -499,13 +476,10 @@ private void TxtSearchBox_PreviewKeyDown(object sender, KeyEventArgs e)
499476
{
500477
switch (e.Key)
501478
{
479+
case Key.Tab:
502480
case Key.Up:
503481
case Key.Down:
504-
//e.Handled = true; // if enabled, we enter to first row initially
505-
gridRecent.Focus();
506-
gridRecent.SelectedIndex = 0;
507-
DataGridRow row = (DataGridRow)gridRecent.ItemContainerGenerator.ContainerFromIndex(0);
508-
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
482+
SetFocusToGrid(gridRecent);
509483
break;
510484
default:
511485
break;
@@ -518,11 +492,7 @@ private void TxtSearchBoxUnity_PreviewKeyDown(object sender, KeyEventArgs e)
518492
{
519493
case Key.Up:
520494
case Key.Down:
521-
//e.Handled = true; // if enabled, we enter to first row initially
522-
dataGridUnitys.Focus();
523-
dataGridUnitys.SelectedIndex = 0;
524-
DataGridRow row = (DataGridRow)dataGridUnitys.ItemContainerGenerator.ContainerFromIndex(0);
525-
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
495+
SetFocusToGrid(dataGridUnitys);
526496
break;
527497
default:
528498
break;
@@ -579,16 +549,67 @@ private void TxtSearchBoxUpdates_PreviewKeyDown(object sender, KeyEventArgs e)
579549
{
580550
case Key.Up:
581551
case Key.Down:
582-
//e.Handled = true; // if enabled, we enter to first row initially
583-
dataGridUpdates.Focus();
584-
dataGridUpdates.SelectedIndex = 0;
585-
DataGridRow row = (DataGridRow)dataGridUpdates.ItemContainerGenerator.ContainerFromIndex(0);
586-
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
552+
SetFocusToGrid(dataGridUpdates);
587553
break;
588554
default:
589555
break;
590556
}
591557
}
558+
559+
private void BtnOpenEditorLogsFolder_Click(object sender, RoutedEventArgs e)
560+
{
561+
var logfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Unity", "Editor");
562+
if (Directory.Exists(logfolder) == true)
563+
{
564+
if (Tools.LaunchExplorer(logfolder) == false)
565+
{
566+
Console.WriteLine("Cannot open folder.." + logfolder);
567+
}
568+
}
569+
}
570+
571+
private void BtnOpenPlayerLogs_Click(object sender, RoutedEventArgs e)
572+
{
573+
var logfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/../LocalLow");
574+
if (Directory.Exists(logfolder) == true)
575+
{
576+
if (Tools.LaunchExplorer(logfolder) == false)
577+
{
578+
Console.WriteLine("Error> Directory not found: " + logfolder);
579+
}
580+
}
581+
}
582+
583+
private void BtnOpenADBLogCat_Click(object sender, RoutedEventArgs e)
584+
{
585+
try
586+
{
587+
Process myProcess = new Process();
588+
var cmd = "cmd.exe";
589+
myProcess.StartInfo.FileName = cmd;
590+
// NOTE windows 10 cmd line supports ansi colors, otherwise remove -v color
591+
var pars = " /c adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG -v color";
592+
myProcess.StartInfo.Arguments = pars;
593+
myProcess.Start();
594+
}
595+
catch (Exception ex)
596+
{
597+
Console.WriteLine(ex);
598+
}
599+
}
600+
601+
private void BtnAdbBindWifi_Click(object sender, RoutedEventArgs e)
602+
{
603+
// TODO async
604+
//// check if your device is present
605+
//adb devices
606+
//// get device ip address (see inet row)
607+
//adb shell ip addr show wlan0
608+
//// enable tcpip and port
609+
//adb tcpip 5555
610+
//// connect device (use your device ip address)
611+
//adb connect IP_HERE:5555
612+
}
592613
} // class
593614
} //namespace
594615

0 commit comments

Comments
 (0)