Skip to content

Commit 992735f

Browse files
committed
Add add & delete feature
1 parent 8a312d4 commit 992735f

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>
138138
<system:String x:Key="fileManager_tips">Please specify the file location of the file manager you using and add arguments (optional) if necessary.</system:String>
139139
<system:String x:Key="fileManager_name">File Manager</system:String>
140+
<system:String x:Key="fileManager_profile_name">Profile Name</system:String>
140141
<system:String x:Key="fileManager_path">Path</system:String>
141142
<system:String x:Key="fileManager_directory_arg">Argument For Directory</system:String>
142143
<system:String x:Key="fileManager_file_arg">Argument For File Parent Directory</system:String>

Flow.Launcher/SelectFileManagerWindow.xaml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</DataTemplate>
6262
</ComboBox.ItemTemplate>
6363
</ComboBox>
64+
<Button Click="btnAdd_Click" Content="{DynamicResource add}" />
65+
<Button Click="btnDelete_Click" Content="{DynamicResource delete}" IsEnabled="{Binding CustomExplorer.Editable}" />
66+
6467
</StackPanel>
6568
<Rectangle Height="1" Margin="0,20,0,12" Fill="#cecece" />
6669
<StackPanel Margin="0,0,0,0"
@@ -73,7 +76,8 @@
7376
<ColumnDefinition />
7477
</Grid.ColumnDefinitions>
7578
<Grid.RowDefinitions>
76-
<RowDefinition Height="50" />
79+
<RowDefinition />
80+
<RowDefinition />
7781
<RowDefinition />
7882
<RowDefinition />
7983
</Grid.RowDefinitions>
@@ -83,15 +87,15 @@
8387
HorizontalAlignment="Left"
8488
VerticalAlignment="Center"
8589
FontSize="14"
86-
Text="{DynamicResource fileManager_path}" />
90+
Text="{DynamicResource fileManager_profile_name}" />
8791
<TextBox Grid.Row="0"
8892
Grid.Column="1"
8993
Width="Auto"
9094
Margin="10,0,15,0"
9195
HorizontalAlignment="Stretch"
9296
VerticalAlignment="Center"
9397
IsEnabled="{Binding Editable}"
94-
Text="{Binding Path}">
98+
Text="{Binding Name}">
9599
<TextBox.Style>
96100
<Style TargetType="TextBox">
97101
<Setter Property="Background" Value="#ffffff" />
@@ -104,13 +108,39 @@
104108
</TextBox.Style>
105109
</TextBox>
106110
<TextBlock Grid.Row="1"
111+
Grid.Column="0"
112+
Margin="14,0,0,0"
113+
HorizontalAlignment="Left"
114+
VerticalAlignment="Center"
115+
FontSize="14"
116+
Text="{DynamicResource fileManager_path}" />
117+
<TextBox Grid.Row="1"
118+
Grid.Column="1"
119+
Width="Auto"
120+
Margin="10,0,15,0"
121+
HorizontalAlignment="Stretch"
122+
VerticalAlignment="Center"
123+
IsEnabled="{Binding Editable}"
124+
Text="{Binding Path}">
125+
<TextBox.Style>
126+
<Style TargetType="TextBox">
127+
<Setter Property="Background" Value="#ffffff" />
128+
<Setter Property="Height" Value="34" />
129+
<Setter Property="FontSize" Value="14" />
130+
<Setter Property="Padding" Value="6,6,0,0" />
131+
<Setter Property="VerticalAlignment" Value="Center" />
132+
<Setter Property="BorderBrush" Value="#000000" />
133+
</Style>
134+
</TextBox.Style>
135+
</TextBox>
136+
<TextBlock Grid.Row="2"
107137
Grid.Column="0"
108138
Margin="14,15,0,0"
109139
HorizontalAlignment="Left"
110140
VerticalAlignment="Center"
111141
FontSize="14"
112142
Text="{DynamicResource fileManager_directory_arg}" />
113-
<TextBox Grid.Row="1"
143+
<TextBox Grid.Row="2"
114144
Grid.Column="1"
115145
Width="Auto"
116146
Margin="10,15,15,0"
@@ -129,14 +159,14 @@
129159
</Style>
130160
</TextBox.Style>
131161
</TextBox>
132-
<TextBlock Grid.Row="2"
162+
<TextBlock Grid.Row="3"
133163
Grid.Column="0"
134164
Margin="14,15,0,0"
135165
HorizontalAlignment="Left"
136166
VerticalAlignment="Center"
137167
FontSize="14"
138168
Text="{DynamicResource fileManager_file_arg}" />
139-
<TextBox Grid.Row="2"
169+
<TextBox Grid.Row="3"
140170
Grid.Column="1"
141171
Width="Auto"
142172
Margin="10,15,15,0"

Flow.Launcher/SelectFileManagerWindow.xaml.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Flow.Launcher.ViewModel;
33
using System;
44
using System.Collections.Generic;
5+
using System.Collections.ObjectModel;
56
using System.ComponentModel;
67
using System.Linq;
78
using System.Text;
@@ -36,13 +37,13 @@ public int SelectedCustomExplorerIndex
3637
PropertyChanged?.Invoke(this, new(nameof(CustomExplorer)));
3738
}
3839
}
39-
public List<CustomExplorerViewModel> CustomExplorers { get; set; }
40+
public ObservableCollection<CustomExplorerViewModel> CustomExplorers { get; set; }
4041

4142
public CustomExplorerViewModel CustomExplorer => CustomExplorers[SelectedCustomExplorerIndex];
4243
public SelectFileManagerWindow(Settings settings)
4344
{
4445
Settings = settings;
45-
CustomExplorers = Settings.CustomExplorerList.Select(x => x.Copy()).ToList();
46+
CustomExplorers = new ObservableCollection<CustomExplorerViewModel>(Settings.CustomExplorerList.Select(x => x.Copy()));
4647
SelectedCustomExplorerIndex = Settings.CustomExplorerIndex;
4748
InitializeComponent();
4849
}
@@ -55,8 +56,22 @@ private void btnCancel_Click(object sender, RoutedEventArgs e)
5556
private void btnDone_Click(object sender, RoutedEventArgs e)
5657
{
5758
Settings.CustomExplorerIndex = SelectedCustomExplorerIndex;
58-
Settings.CustomExplorerList = CustomExplorers;
59+
Settings.CustomExplorerList = CustomExplorers.ToList();
5960
Close();
6061
}
62+
63+
private void btnAdd_Click(object sender, RoutedEventArgs e)
64+
{
65+
CustomExplorers.Add(new()
66+
{
67+
Name = "New Profile"
68+
});
69+
SelectedCustomExplorerIndex = CustomExplorers.Count - 1;
70+
}
71+
72+
private void btnDelete_Click(object sender, RoutedEventArgs e)
73+
{
74+
CustomExplorers.RemoveAt(SelectedCustomExplorerIndex--);
75+
}
6176
}
6277
}

0 commit comments

Comments
 (0)