Skip to content

Commit 6fa466b

Browse files
committed
add open github button code, add custom arguments code
1 parent 7a88f4b commit 6fa466b

File tree

2 files changed

+123
-18
lines changed

2 files changed

+123
-18
lines changed

UnityLauncherPro/MainWindow.xaml

+18-15
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
<Window.Resources>
1212

13-
<!-- datagrid scrollbar customization -->
14-
1513
<!-- colors for unity missing installatios -->
1614
<local:UnityInstallation x:Key="MyConverter"/>
1715

@@ -72,6 +70,9 @@
7270
<Setter Property="Background" Value="{StaticResource DataGridRowSelectedBackground}" />
7371
</Trigger>
7472
</Style.Triggers>
73+
<Style.Resources>
74+
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}"/>
75+
</Style.Resources>
7576
</Style>
7677

7778
<!-- datagrid hide selected cell borders -->
@@ -296,7 +297,7 @@
296297
<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" />
297298
<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"/>
298299

299-
<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">
300+
<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" CellEditEnding="GridRecent_CellEditEnding">
300301
<DataGrid.Columns>
301302
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Title}" ClipboardContentBinding="{x:Null}" Header="Project" IsReadOnly="True" Width="150"/>
302303
<DataGridTextColumn Binding="{Binding Version}" ClipboardContentBinding="{x:Null}" Header="Version" IsReadOnly="True" Width="72">
@@ -313,7 +314,7 @@
313314
</DataGridTextColumn>
314315
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Path}" ClipboardContentBinding="{x:Null}" Header="Path" IsReadOnly="True" Width="185"/>
315316
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Modified, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Modified" IsReadOnly="True" Width="120"/>
316-
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Arguments}" ClipboardContentBinding="{x:Null}" Header="Arguments" IsReadOnly="True" Width="100"/>
317+
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Arguments}" ClipboardContentBinding="{x:Null}" Header="Arguments" IsReadOnly="False" Width="100"/>
317318
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="GITBranch" IsReadOnly="True" Width="100"/>
318319
</DataGrid.Columns>
319320

@@ -493,7 +494,7 @@
493494
</Button>
494495
</Grid>
495496

496-
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh installations (F5)" x:Name="btnRefreshUpdatesList" 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="OnGetUnityUpdatesClick"/>
497+
<Button Style="{StaticResource CustomButton}" ToolTip="Fetch released versions" x:Name="btnRefreshUpdatesList" 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="OnGetUnityUpdatesClick"/>
497498

498499
<DataGrid x:Name="dataGridUpdates" 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="DataGridUpdates_PreviewKeyDown">
499500

@@ -587,17 +588,19 @@
587588
<!-- settings -->
588589
<RowDefinition Height="70*" />
589590
<!-- links -->
590-
<RowDefinition Height="33" />
591+
<RowDefinition Height="40" />
591592
</Grid.RowDefinitions>
592593

593594
<!-- top labels -->
594-
<Label Grid.Row="0" Content="Unity Installation Parent Folders" Foreground="{DynamicResource ButtonForeground}" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
595+
<Label Grid.Row="0" Content="Unity Installation Parent Folders" Foreground="{DynamicResource ButtonForeground}" HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="Search will try to find Unity installations under these folders"/>
595596
<Label x:Name="lblFoundXInstallations" Grid.Row="0" Content="Found .. Installations" Foreground="{DynamicResource ButtonForeground}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
596597
<!-- locations list -->
597-
<ListBox x:Name="lstRootFolders" Grid.Row="1" Background="#FF3C3C3C" Margin="4,0,2,0" />
598+
<ListBox x:Name="lstRootFolders" Grid.Row="1" Background="#FF3C3C3C" Margin="4,0,2,0" Foreground="{DynamicResource ButtonForeground}" >
599+
<System:String>c:\Program Files</System:String>
600+
</ListBox>
598601
<!-- locations add/remove -->
599602
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0" >
600-
<Button Style="{StaticResource CustomButton}" x:Name="btnAddInstallationFolder" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="BtnAddInstallationFolder_Click">
603+
<Button Style="{StaticResource CustomButton}" x:Name="btnAddInstallationFolder" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,4,0,3" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="BtnAddInstallationFolder_Click" Width="116">
601604
<Label Foreground="{DynamicResource ButtonForeground}" Content="_Add Folder"/>
602605
</Button>
603606
<Button Style="{StaticResource CustomButton}" x:Name="btnRemoveInstallationFolder" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="BtnRemoveInstallationFolder_Click">
@@ -606,16 +609,16 @@
606609
</StackPanel>
607610
<!-- settings-->
608611
<StackPanel Grid.Row="3" Orientation="Vertical" Margin="5,10,3,3" >
609-
<CheckBox x:Name="chkMinimizeToTaskbar" Content="Minimize to taskbar" Foreground="{DynamicResource ButtonForeground}" Checked="ChkMinimizeToTaskbar_CheckedChanged" Unchecked="ChkMinimizeToTaskbar_CheckedChanged" Margin="0,0,0,3"/>
610-
<CheckBox x:Name="chkRegisterExplorerMenu" Content="Register Explorer context menu" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkRegisterExplorerMenu_CheckedChanged" Checked="ChkRegisterExplorerMenu_CheckedChanged" Margin="0,0,0,3"/>
611-
<CheckBox x:Name="chkQuitAfterOpen" Content="Close after opening project" Foreground="{DynamicResource ButtonForeground}" Checked="ChkQuitAfterOpen_CheckedChanged" Unchecked="ChkQuitAfterOpen_CheckedChanged" Margin="0,0,0,3"/>
612-
<CheckBox x:Name="chkQuitAfterCommandline" Content="Close after launching from Explorer" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkQuitAfterCommandline_CheckedChanged" Checked="ChkQuitAfterCommandline_CheckedChanged" Margin="0,0,0,3"/>
613-
<CheckBox x:Name="chkShowLauncherArgumentsColumn" Content="Show Arguments Column" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkShowLauncherArgumentsColumn_CheckedChanged" Checked="ChkShowLauncherArgumentsColumn_CheckedChanged" Margin="0,0,0,3"/>
612+
<CheckBox x:Name="chkMinimizeToTaskbar" Content="Minimize to tray" Foreground="{DynamicResource ButtonForeground}" Checked="ChkMinimizeToTaskbar_CheckedChanged" Unchecked="ChkMinimizeToTaskbar_CheckedChanged" Margin="0,0,0,3" ToolTip="Minimizers as notification icon and hides from taskbar"/>
613+
<CheckBox x:Name="chkRegisterExplorerMenu" Content="Register Explorer context menu" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkRegisterExplorerMenu_CheckedChanged" Checked="ChkRegisterExplorerMenu_CheckedChanged" Margin="0,0,0,3" ToolTip="Install registry entries for Explorer context menu"/>
614+
<CheckBox x:Name="chkQuitAfterOpen" Content="Close after opening project" Foreground="{DynamicResource ButtonForeground}" Checked="ChkQuitAfterOpen_CheckedChanged" Unchecked="ChkQuitAfterOpen_CheckedChanged" Margin="0,0,0,3" ToolTip="Exists launcher after running project (not really useful)"/>
615+
<CheckBox x:Name="chkQuitAfterCommandline" Content="Close after launching from Explorer" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkQuitAfterCommandline_CheckedChanged" Checked="ChkQuitAfterCommandline_CheckedChanged" Margin="0,0,0,3" ToolTip="Close launcher after running form commandline or Explorer (recommended to be enabed)"/>
616+
<CheckBox x:Name="chkShowLauncherArgumentsColumn" Content="Show commandline arguments Column" Foreground="{DynamicResource ButtonForeground}" Unchecked="ChkShowLauncherArgumentsColumn_CheckedChanged" Checked="ChkShowLauncherArgumentsColumn_CheckedChanged" Margin="0,0,0,3"/>
614617
<CheckBox x:Name="chkShowGitBranchColumn" Content="Show Git Branch Column" Foreground="{DynamicResource ButtonForeground}" Checked="ChkShowGitBranchColumn_CheckedChanged" Unchecked="ChkShowGitBranchColumn_CheckedChanged" Margin="0,0,0,3"/>
615618
</StackPanel>
616619

617620
<!-- links-->
618-
<Button Grid.Row="4" Style="{StaticResource CustomButton}" x:Name="btnASASDFasdf22" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="5,0,0,0" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center">
621+
<Button Grid.Row="4" Style="{StaticResource CustomButton}" x:Name="btnOpenGithub" Background="{DynamicResource ButtonBackground}" Foreground="{DynamicResource ButtonForeground}" Margin="10,0,0,10" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Center" Click="BtnOpenGithub_Click">
619622
<Label Foreground="{DynamicResource ButtonForeground}" Content="_View in Github"/>
620623
</Button>
621624

UnityLauncherPro/MainWindow.xaml.cs

+105-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public partial class MainWindow : Window
2323
const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
2424
public static readonly string launcherArgumentsFile = "LauncherArguments.txt";
2525
string _filterString = null;
26+
const string githubURL = "https://github.com/unitycoder/UnityLauncherPro";
2627

2728
public MainWindow()
2829
{
@@ -410,7 +411,13 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
410411
case Key.Escape: // clear project search
411412
txtSearchBox.Text = "";
412413
break;
414+
case Key.F2: // edit arguments
415+
break;
413416
default: // any key
417+
// cancel if editing cell
418+
IEditableCollectionView itemsView = gridRecent.Items;
419+
if (itemsView.IsAddingNew || itemsView.IsEditingItem) return;
420+
414421
// activate searchbar if not active and we are in tab#1
415422
if (txtSearchBox.IsFocused == false)
416423
{
@@ -646,8 +653,13 @@ private void GridRecent_PreviewKeyDown(object sender, KeyEventArgs e)
646653
}
647654
break;
648655
case Key.Return:
656+
// cancel if editing cell
657+
IEditableCollectionView itemsView = gridRecent.Items;
658+
if (itemsView.IsAddingNew || itemsView.IsEditingItem) return;
659+
649660
e.Handled = true;
650-
Tools.LaunchProject(GetSelectedProject());
661+
var proj = GetSelectedProject();
662+
Tools.LaunchProject(proj);
651663
break;
652664
default:
653665
break;
@@ -729,7 +741,7 @@ private void BtnOpenADBLogCat_Click(object sender, RoutedEventArgs e)
729741

730742
private void BtnAdbBindWifi_Click(object sender, RoutedEventArgs e)
731743
{
732-
// TODO async
744+
// TODO
733745
//// check if your device is present
734746
//adb devices
735747
//// get device ip address (see inet row)
@@ -738,7 +750,52 @@ private void BtnAdbBindWifi_Click(object sender, RoutedEventArgs e)
738750
//adb tcpip 5555
739751
//// connect device (use your device ip address)
740752
//adb connect IP_HERE:5555
741-
}
753+
754+
// get device ip address
755+
//Process process = new Process();
756+
//process.StartInfo.FileName = "adb";
757+
//process.StartInfo.Arguments = "shell ip route";
758+
//process.StartInfo.UseShellExecute = false;
759+
//process.StartInfo.RedirectStandardOutput = true;
760+
//process.StartInfo.RedirectStandardError = true;
761+
//process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler1);
762+
//process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler1);
763+
//process.Start();
764+
//process.BeginOutputReadLine();
765+
//process.BeginErrorReadLine();
766+
//process.WaitForExit();
767+
}
768+
769+
//static void OutputHandler1(object sendingProcess, DataReceivedEventArgs outLine)
770+
//{
771+
// string outputData = outLine.Data;
772+
// //Console.WriteLine("adboutput=" + outputData);
773+
// if (string.IsNullOrEmpty(outputData)) return;
774+
775+
// // check if its wlan row
776+
// if (outputData.IndexOf("wlan0") > -1)
777+
// {
778+
// // parse ip address
779+
// var getip = outputData.Trim().Split(' ');
780+
// if (getip == null || getip.Length < 1) return;
781+
782+
// Console.WriteLine("device ip=" + getip[getip.Length - 1]);
783+
784+
// // next, call adb connect to that ip address
785+
// Process process = new Process();
786+
// process.StartInfo.FileName = "adb";
787+
// process.StartInfo.Arguments = "connet " + getip[getip.Length - 1] + ":5555";
788+
// process.StartInfo.UseShellExecute = false;
789+
// process.StartInfo.RedirectStandardOutput = true;
790+
// process.StartInfo.RedirectStandardError = true;
791+
// process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler1);
792+
// process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler1);
793+
// process.Start();
794+
// process.BeginOutputReadLine();
795+
// process.BeginErrorReadLine();
796+
// process.WaitForExit();
797+
// }
798+
//}
742799

743800
private void BtnRefreshUnityList_Click(object sender, RoutedEventArgs e)
744801
{
@@ -828,5 +885,50 @@ private void MenuItemShowProjectInExplorer_Click(object sender, RoutedEventArgs
828885
}
829886
Tools.LaunchExplorer(folder);
830887
}
888+
889+
private void BtnOpenGithub_Click(object sender, RoutedEventArgs e)
890+
{
891+
Process.Start(githubURL);
892+
}
893+
894+
private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
895+
{
896+
// get current row data
897+
var proj = GetSelectedProject();
898+
899+
// check that folder exists
900+
string path = proj.Path;
901+
if (string.IsNullOrEmpty(path)) return;
902+
903+
// get current arguments, after editing
904+
TextBox t = e.EditingElement as TextBox;
905+
string arguments = t.Text.ToString();
906+
907+
string projSettingsFolder = "ProjectSettings";
908+
909+
// check if projectsettings folder exists, if not then add
910+
string outputFolder = Path.Combine(path, projSettingsFolder);
911+
if (Directory.Exists(outputFolder) == false)
912+
{
913+
Directory.CreateDirectory(outputFolder);
914+
}
915+
916+
// save arguments to projectsettings folder
917+
string outputFile = Path.Combine(path, projSettingsFolder, launcherArgumentsFile);
918+
919+
try
920+
{
921+
StreamWriter sw = new StreamWriter(outputFile);
922+
sw.WriteLine(arguments);
923+
sw.Close();
924+
}
925+
catch (Exception ex)
926+
{
927+
//SetStatus("File error: " + exception.Message);
928+
Console.WriteLine(ex);
929+
}
930+
931+
// TODO select the same row again
932+
}
831933
} // class
832934
} //namespace

0 commit comments

Comments
 (0)