-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
252 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Flow.Launcher.Plugin.FendCalculator | ||
{ | ||
public class Settings | ||
{ | ||
public string FendCommand { get; set; } = "fend"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Windows.Input; | ||
|
||
namespace Flow.Launcher.Plugin.FendCalculator.ViewModels | ||
{ | ||
internal class RelayCommand : ICommand | ||
{ | ||
private Action<object> _action; | ||
|
||
public RelayCommand(Action<object> action) | ||
{ | ||
_action = action; | ||
} | ||
|
||
public virtual bool CanExecute(object parameter) | ||
{ | ||
return true; | ||
} | ||
|
||
public event EventHandler CanExecuteChanged; | ||
|
||
public virtual void Execute(object parameter) | ||
{ | ||
_action?.Invoke(parameter); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Forms; | ||
using System.Windows.Input; | ||
|
||
namespace Flow.Launcher.Plugin.FendCalculator.ViewModels | ||
{ | ||
public class SettingsViewModel : BaseModel | ||
{ | ||
public SettingsViewModel(Settings settings) | ||
{ | ||
Settings = settings; | ||
} | ||
|
||
public Settings Settings { get; init; } | ||
|
||
public string FendCommand | ||
{ | ||
get => Settings.FendCommand; | ||
set | ||
{ | ||
Settings.FendCommand = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
private string? PromptUserSelectPath(string? initialDirectory = null) | ||
{ | ||
string? path = null; | ||
|
||
var openFileDialog = new OpenFileDialog(); | ||
if (initialDirectory is not null) | ||
openFileDialog.InitialDirectory = initialDirectory; | ||
|
||
if (openFileDialog.ShowDialog() != DialogResult.OK) | ||
return path; | ||
|
||
path = openFileDialog.FileName; | ||
|
||
return path; | ||
} | ||
|
||
private ICommand? _openFendPathCommand; | ||
|
||
public ICommand OpenFendPath => _openFendPathCommand ??= new RelayCommand(_ => | ||
{ | ||
var path = PromptUserSelectPath(Settings.FendCommand != null ? Path.GetDirectoryName(Settings.FendCommand) : null); | ||
if (path is null) | ||
return; | ||
FendCommand = path; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<UserControl | ||
x:Class="Flow.Launcher.Plugin.FendCalculator.Views.FendCalculatorSettings" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="http://schemas.modernwpf.com/2019" | ||
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.FendCalculator.ViewModels" | ||
xmlns:views="clr-namespace:Flow.Launcher.Plugin.FendCalculator.Views" | ||
d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}" | ||
d:DesignHeight="450" | ||
d:DesignWidth="800" | ||
mc:Ignorable="d"> | ||
|
||
<!-- <UserControl.Resources> | ||
<core:LocalizationConverter x:Key="LocalizationConverter" /> | ||
</UserControl.Resources> --> | ||
|
||
<Grid Margin="70,14,0,14"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="3*" /> | ||
</Grid.ColumnDefinitions> | ||
|
||
<TextBlock | ||
Grid.Row="0" | ||
Grid.Column="0" | ||
Margin="0,0,10,0" | ||
VerticalAlignment="Center" | ||
FontSize="14" | ||
Text="Fend Command" /> | ||
<StackPanel | ||
Grid.Row="0" | ||
Grid.Column="1" | ||
Margin="0,6,6,6" | ||
Orientation="Horizontal"> | ||
<TextBox | ||
Width="250" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Text="{Binding FendCommand}" | ||
TextWrapping="NoWrap" /> | ||
<Button | ||
MinWidth="50" | ||
Margin="5,0,0,0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Command="{Binding OpenFendPath}" | ||
Content="..." /> | ||
</StackPanel> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
using Flow.Launcher.Plugin.FendCalculator.ViewModels; | ||
|
||
namespace Flow.Launcher.Plugin.FendCalculator.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for FendCalculatorSettings.xaml | ||
/// </summary> | ||
public partial class FendCalculatorSettings : UserControl | ||
{ | ||
private readonly SettingsViewModel _viewModel; | ||
private readonly Settings _settings; | ||
|
||
public FendCalculatorSettings(SettingsViewModel viewModel) | ||
{ | ||
_viewModel = viewModel; | ||
_settings = viewModel.Settings; | ||
DataContext = viewModel; | ||
InitializeComponent(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters