mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Implement editing
This commit is contained in:
parent
672616ef62
commit
e5e8c48d51
5 changed files with 54 additions and 17 deletions
|
|
@ -2,7 +2,25 @@
|
|||
{
|
||||
public class CustomBrowser : BaseModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string DataDirectoryPath { get; set; }
|
||||
private string _name;
|
||||
private string _dataDirectoryPath;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
public string DataDirectoryPath
|
||||
{
|
||||
get => _dataDirectoryPath;
|
||||
set
|
||||
{
|
||||
_dataDirectoryPath = value;
|
||||
OnPropertyChanged(nameof(DataDirectoryPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:local="clr-namespace:Flow.Launcher.Plugin.BrowserBookmark.Models"
|
||||
mc:Ignorable="d"
|
||||
Title="CustomBrowserSetting" Height="450" Width="600"
|
||||
KeyDown="WindowKeyDown"
|
||||
>
|
||||
<Window.DataContext>
|
||||
<local:CustomBrowser/>
|
||||
|
|
@ -21,13 +22,13 @@
|
|||
<ColumnDefinition Width="6*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Browser Name" FontSize="15"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Browser Data Directory Path" FontSize="15"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Name}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="30"/>
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center" Width="100" Height="30"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding DataDirectoryPath}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="30"/>
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center" Width="200" Height="30"/>
|
||||
<StackPanel HorizontalAlignment="Right" Grid.Row="2" Orientation="Horizontal" Grid.Column="1" Height="60">
|
||||
<Button Content="Confirm" Margin="15" Click="ConfirmEditCustomBrowser"/>
|
||||
<Button Content="Cancel" Margin="15"/>
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
currentCustomBrowser = browser;
|
||||
DataContext = new CustomBrowser
|
||||
{
|
||||
Name = browser.Name,
|
||||
DataDirectoryPath = browser.DataDirectoryPath
|
||||
Name = browser.Name, DataDirectoryPath = browser.DataDirectoryPath
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -41,5 +40,12 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
}
|
||||
Close();
|
||||
}
|
||||
private void WindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
ConfirmEditCustomBrowser(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
mc:Ignorable="d"
|
||||
Background="White"
|
||||
d:DesignHeight="300" d:DesignWidth="500"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}, Path=Settings}">
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
|
|
@ -33,30 +33,32 @@
|
|||
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1" Height="60" Margin="25,13,0,0">
|
||||
<Label Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_setBrowserFromPath}"
|
||||
Height="28" Margin="10"/>
|
||||
<TextBox x:Name="browserPathBox"
|
||||
<TextBox x:Name="BrowserPathBox"
|
||||
HorizontalAlignment="Left"
|
||||
Height="30"
|
||||
TextWrapping="NoWrap"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding BrowserPath}"
|
||||
Text="{Binding Settings.BrowserPath}"
|
||||
Width="240"
|
||||
Margin="10"/>
|
||||
<Button x:Name="viewButton" Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_choose}"
|
||||
<Button x:Name="ViewButton" Content="{DynamicResource flowlauncher_plugin_browserbookmark_settings_choose}"
|
||||
HorizontalAlignment="Left" Margin="10" Width="100" Height="30" Click="OnChooseClick" FontSize="14" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Vertical">
|
||||
<TextBlock Text="CustomBrowsers" Margin="10"/>
|
||||
<ListView Grid.Row="2" ItemsSource="{Binding CustomChromiumBrowsers}"
|
||||
<ListView Grid.Row="2" ItemsSource="{Binding Settings.CustomChromiumBrowsers}"
|
||||
SelectedItem="{Binding SelectedCustomBrowser}"
|
||||
Margin="10"
|
||||
BorderBrush="DarkGray"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"
|
||||
Height="auto"
|
||||
Name="CustomBrowsers">
|
||||
Name="CustomBrowsers"
|
||||
MouseDoubleClick="MouseDoubleClickOnSelectedCustomBrowser">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Browser Name"/>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath}" Header="DataDirectoryPath"/>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name, Mode=OneWay}" Header="Browser Name"/>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding DataDirectoryPath, Mode=OneWay}" Header="DataDirectoryPath"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Microsoft.Win32;
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Flow.Launcher.Plugin.BrowserBookmark.Models;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
||||
{
|
||||
|
|
@ -11,6 +12,7 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
public partial class SettingsControl
|
||||
{
|
||||
public Settings Settings { get; }
|
||||
public CustomBrowser SelectedCustomBrowser { get; set; }
|
||||
|
||||
public SettingsControl(Settings settings)
|
||||
{
|
||||
|
|
@ -64,5 +66,13 @@ namespace Flow.Launcher.Plugin.BrowserBookmark.Views
|
|||
Settings.CustomChromiumBrowsers.Remove(selectedCustomBrowser);
|
||||
}
|
||||
}
|
||||
private void MouseDoubleClickOnSelectedCustomBrowser(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (SelectedCustomBrowser is null)
|
||||
return;
|
||||
|
||||
var window = new CustomBrowserSettingWindow(SelectedCustomBrowser);
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue