-
Notifications
You must be signed in to change notification settings - Fork 24
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
4 changed files
with
112 additions
and
117 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,75 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using FzLib; | ||
using Mapster; | ||
using Microsoft.Win32; | ||
using SimpleFFmpegGUI.Manager; | ||
using SimpleFFmpegGUI.WPF.Messages; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Windows; | ||
|
||
namespace SimpleFFmpegGUI.WPF.ViewModels | ||
{ | ||
public partial class SettingPageViewModel : ViewModelBase | ||
{ | ||
private readonly ConfigManager configManager; | ||
|
||
[ObservableProperty] | ||
private Config configs; | ||
|
||
public SettingPageViewModel(ConfigManager configManager) | ||
{ | ||
configs = Config.Instance.DeepCopy(); | ||
this.configManager = configManager; | ||
ObservableRemoteHosts = new ObservableCollection<RemoteHost>(Configs.RemoteHosts); | ||
this.Notify(nameof(ObservableRemoteHosts)); | ||
} | ||
|
||
public event EventHandler RequestToClose; | ||
|
||
public IEnumerable DefaultOutputDirTypes => Enum.GetValues<DefaultOutputDirType>(); | ||
|
||
public int DefaultProcessPriority | ||
{ | ||
get => configManager.DefaultProcessPriority; | ||
set => configManager.DefaultProcessPriority = value; | ||
} | ||
|
||
public ObservableCollection<RemoteHost> ObservableRemoteHosts { get; set; } | ||
[RelayCommand] | ||
private void AddRemoteHost() | ||
{ | ||
ObservableRemoteHosts.Add(new RemoteHost()); | ||
} | ||
|
||
[RelayCommand] | ||
private void BrowseSpecialDirPath() | ||
{ | ||
var dialog = new OpenFolderDialog(); | ||
SendMessage(new FileDialogMessage(dialog)); | ||
var path = dialog.FolderName; | ||
if (!string.IsNullOrEmpty(path)) | ||
{ | ||
Configs.DefaultOutputDirSpecialDirPath = path; | ||
} | ||
} | ||
|
||
[RelayCommand] | ||
private void Cancel() | ||
{ | ||
RequestToClose?.Invoke(this, EventArgs.Empty); | ||
} | ||
|
||
[RelayCommand] | ||
private void Save() | ||
{ | ||
Configs.RemoteHosts = ObservableRemoteHosts.ToList(); | ||
Configs.Adapt(Config.Instance); | ||
Config.Instance.Save(); | ||
RequestToClose?.Invoke(this, EventArgs.Empty); | ||
} | ||
} | ||
} |