8
8
using Avalonia . Platform . Storage ;
9
9
using FluentAvalonia . UI . Controls ;
10
10
using MsBox . Avalonia ;
11
+ using SkiaSharp ;
11
12
12
13
namespace UnityHubNative . Net ;
13
14
@@ -27,7 +28,9 @@ class MainWindow : Window
27
28
28
29
static DockPanel s_transparentPanel ;
29
30
static Slider s_backgroundBlurIntensitySlider ;
30
- static private Key s_lastKey ;
31
+ static TextBox s_openInTerminalFormatText ;
32
+ static Key s_lastKey ;
33
+ private static TabControl s_tabControl ;
31
34
32
35
public MainWindow ( object data )
33
36
{
@@ -55,29 +58,32 @@ protected override void OnKeyDown(KeyEventArgs e)
55
58
56
59
s_lastKey = e . Key ;
57
60
58
- // focus on searchbar if typed a character
59
- if ( e . KeyModifiers is KeyModifiers . None or KeyModifiers . Shift && ( int ) e . Key >= ( int ) Key . A && ( int ) e . Key <= ( int ) Key . Z )
61
+ if ( s_tabControl . SelectedIndex == 0 )
60
62
{
61
- if ( ! s_projectSearchBoxAutoComplete . IsKeyboardFocusWithin )
63
+ // focus on searchbar if typed a character
64
+ if ( e . KeyModifiers is KeyModifiers . None or KeyModifiers . Shift && ( int ) e . Key >= ( int ) Key . A && ( int ) e . Key <= ( int ) Key . Z )
62
65
{
63
- s_projectSearchBoxAutoComplete . Focus ( ) ;
64
- s_projectSearchBoxAutoComplete . Text += e . KeyModifiers == KeyModifiers . Shift ? e . Key . ToString ( ) : e . Key . ToString ( ) . ToLower ( ) ;
65
- s_projectSearchBoxAutoComplete . CaretIndex = s_projectSearchBoxAutoComplete . Text . Length ;
66
- e . Handled = true ;
66
+ if ( ! s_projectSearchBoxAutoComplete . IsKeyboardFocusWithin )
67
+ {
68
+ s_projectSearchBoxAutoComplete . Focus ( ) ;
69
+ s_projectSearchBoxAutoComplete . Text += e . KeyModifiers == KeyModifiers . Shift ? e . Key . ToString ( ) : e . Key . ToString ( ) . ToLower ( ) ;
70
+ s_projectSearchBoxAutoComplete . CaretIndex = s_projectSearchBoxAutoComplete . Text . Length ;
71
+ e . Handled = true ;
72
+ }
73
+ return ;
67
74
}
68
- return ;
69
- }
70
75
71
- // focus on the list of escaped
72
- if ( e . Key == Key . Escape )
73
- {
74
- if ( s_unityProjectsParent . SelectedItem != null )
76
+ // focus on the list of escaped
77
+ if ( e . Key == Key . Escape )
75
78
{
76
- s_unityProjectsParent . ContainerFromIndex ( GetUnityProjectSelectedIndex ( ) ) ! . Focus ( ) ;
77
- s_projectSearchBoxAutoComplete . Text = string . Empty ;
78
- }
79
+ if ( s_unityProjectsParent . SelectedItem != null )
80
+ {
81
+ s_unityProjectsParent . ContainerFromIndex ( GetUnityProjectSelectedIndex ( ) ) ! . Focus ( ) ;
82
+ s_projectSearchBoxAutoComplete . Text = string . Empty ;
83
+ }
79
84
80
- return ;
85
+ return ;
86
+ }
81
87
}
82
88
}
83
89
@@ -247,7 +253,7 @@ public static void MoveSelectedProjectDown()
247
253
{
248
254
} . AddChildren
249
255
( [
250
- new TabControl
256
+ s_tabControl = new TabControl
251
257
{
252
258
TabStripPlacement = Dock . Top ,
253
259
} . AddItems
@@ -526,14 +532,39 @@ public static void MoveSelectedProjectDown()
526
532
VerticalAlignment = VerticalAlignment . Center ,
527
533
} . OnCheckChanged ( OnCloseAfterOpenProjectCheckboxChanged ) . SetDock ( Dock . Right )
528
534
] )
529
- } . SetTooltip ( "If checked, the app will close after opening a project" )
535
+ } . SetTooltip ( "If checked, the app will close after opening a project" ) ,
536
+ new SettingsExpanderItem
537
+ {
538
+ Content = new DockPanel
539
+ {
540
+ } . AddChildren
541
+ ( [
542
+ new TextBlock
543
+ {
544
+ Text = "Format to open project in Terminal" ,
545
+ VerticalAlignment = VerticalAlignment . Center ,
546
+ Margin = new ( 0 , 0 , 10 , 0 ) ,
547
+ } . SetDock ( Dock . Left ) ,
548
+ s_openInTerminalFormatText = new TextBox
549
+ {
550
+ Text = UnityHubNativeNetApp . Config . openInTerminalFormat ,
551
+ VerticalAlignment = VerticalAlignment . Center ,
552
+ } . OnTextChanged ( OnOpenInTerminalFormatChanged ) . SetDock ( Dock . Right )
553
+ ] )
554
+ } . SetTooltip ( "Defines the process format of when opening a project in terminal. {path} will be replaced by the project path" ) ,
530
555
] )
531
556
] )
532
557
}
533
558
] )
534
559
] )
535
560
] ) ;
536
561
562
+ static void OnOpenInTerminalFormatChanged ( )
563
+ {
564
+ UnityHubNativeNetApp . Config . openInTerminalFormat = s_openInTerminalFormatText . Text ;
565
+ UnityHubNativeNetApp . SaveConfig ( UnityHubNativeNetApp . Config ) ;
566
+ }
567
+
537
568
static void OnExtendToTitlebarCheckChanged ( )
538
569
{
539
570
UnityHubNativeNetApp . Config . extendToTitlebar = ! UnityHubNativeNetApp . Config . extendToTitlebar ;
0 commit comments