mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
File Explore Binding (Part 2)
This commit is contained in:
parent
6bfebe9fbd
commit
a69f4a7ea6
5 changed files with 63 additions and 13 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Flow.Launcher.Plugin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -6,12 +7,24 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
public class CustomExplorerViewModel
|
||||
public class CustomExplorerViewModel : BaseModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string FileArgument { get; set; } = "\"%d\"";
|
||||
public string DirectoryArgument { get; set; } = "\"%d\"";
|
||||
public bool Editable { get; init; } = true;
|
||||
|
||||
public CustomExplorerViewModel Copy()
|
||||
{
|
||||
return new CustomExplorerViewModel
|
||||
{
|
||||
Name = Name,
|
||||
Path = Path,
|
||||
FileArgument = FileArgument,
|
||||
DirectoryArgument = DirectoryArgument,
|
||||
Editable = Editable
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,13 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public string ResultFontStretch { get; set; }
|
||||
public bool UseGlyphIcons { get; set; } = true;
|
||||
|
||||
public CustomExplorerViewModel CustomExplorer { get; set; }
|
||||
public int CustomExplorerIndex { get; set; } = 0;
|
||||
public CustomExplorerViewModel CustomExplorer
|
||||
{
|
||||
get => CustomExplorerList[CustomExplorerIndex];
|
||||
set => CustomExplorerList[CustomExplorerIndex] = value;
|
||||
}
|
||||
|
||||
public List<CustomExplorerViewModel> CustomExplorerList { get; set; } = new()
|
||||
{
|
||||
new()
|
||||
|
|
|
|||
|
|
@ -53,9 +53,8 @@
|
|||
Margin="14,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{Binding Settings.CustomExplorerList}"
|
||||
SelectedIndex="0"
|
||||
SelectedItem="{Binding Settings.CustomExplorer}">
|
||||
ItemsSource="{Binding CustomExplorers}"
|
||||
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
|
|
@ -66,7 +65,7 @@
|
|||
<Rectangle Height="1" Margin="0,20,0,12" Fill="#cecece" />
|
||||
<StackPanel Margin="0,0,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
DataContext="{Binding Settings.CustomExplorer}"
|
||||
DataContext="{Binding CustomExplorer}"
|
||||
Orientation="Horizontal">
|
||||
<Grid Width="430">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
|
@ -163,13 +162,15 @@
|
|||
Width="100"
|
||||
Height="30"
|
||||
Margin="0,0,5,0"
|
||||
Content="{DynamicResource cancel}" />
|
||||
Content="{DynamicResource cancel}"
|
||||
Click="btnCancel_Click"/>
|
||||
<Button x:Name="btnDone"
|
||||
Width="100"
|
||||
Height="30"
|
||||
Margin="5,0,0,0">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
|
||||
</Button>
|
||||
Margin="5,0,0,0"
|
||||
Content="{DynamicResource done}"
|
||||
Click="btnDone_Click"
|
||||
/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Flow.Launcher.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -19,14 +20,43 @@ namespace Flow.Launcher
|
|||
/// <summary>
|
||||
/// SelectFileManagerWindow.xaml에 대한 상호 작용 논리
|
||||
/// </summary>
|
||||
public partial class SelectFileManagerWindow : Window
|
||||
public partial class SelectFileManagerWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private int selectedCustomExplorerIndex;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public Settings Settings { get; }
|
||||
|
||||
public int SelectedCustomExplorerIndex
|
||||
{
|
||||
get => selectedCustomExplorerIndex; set
|
||||
{
|
||||
selectedCustomExplorerIndex = value;
|
||||
PropertyChanged?.Invoke(this, new(nameof(CustomExplorer)));
|
||||
}
|
||||
}
|
||||
public List<CustomExplorerViewModel> CustomExplorers { get; set; }
|
||||
|
||||
public CustomExplorerViewModel CustomExplorer => CustomExplorers[SelectedCustomExplorerIndex];
|
||||
public SelectFileManagerWindow(Settings settings)
|
||||
{
|
||||
Settings = settings;
|
||||
CustomExplorers = Settings.CustomExplorerList.Select(x => x.Copy()).ToList();
|
||||
SelectedCustomExplorerIndex = Settings.CustomExplorerIndex;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnDone_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings.CustomExplorerIndex = SelectedCustomExplorerIndex;
|
||||
Settings.CustomExplorerList = CustomExplorers;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@
|
|||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||
<Button Margin="10 0 18 0" MaxWidth="250" Width="160"
|
||||
Content="Explorer" Click="OnSelectFileManagerClick">
|
||||
Content="{Binding Settings.CustomExplorer.Name}" Click="OnSelectFileManagerClick">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue