v1.2
This commit is contained in:
20
FSI.BT.Tools/Global/Helpers/GetFolderByName.cs
Normal file
20
FSI.BT.Tools/Global/Helpers/GetFolderByName.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FSI.BT.Tools.Global.Helpers
|
||||
{
|
||||
internal class GetFolderByName
|
||||
{
|
||||
internal static (string path, string description) Get(IEnumerable<Settings.Folder.IFolder> folders, string name)
|
||||
{
|
||||
foreach (var folder in folders)
|
||||
{
|
||||
if (folder.Name.Equals(name))
|
||||
{
|
||||
return (folder.Path, folder.Description);
|
||||
}
|
||||
}
|
||||
|
||||
return (null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
FSI.BT.Tools/Global/Helpers/RelayCommand.cs
Normal file
46
FSI.BT.Tools/Global/Helpers/RelayCommand.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FSI.BT.Tools.Global.Helpers
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action action;
|
||||
|
||||
private Func<bool> condition;
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public RelayCommand(Action action)
|
||||
{
|
||||
this.action = action;
|
||||
condition = () => true;
|
||||
}
|
||||
|
||||
public RelayCommand(Action action, bool condition)
|
||||
{
|
||||
this.action = action;
|
||||
this.condition = () => condition;
|
||||
}
|
||||
|
||||
public RelayCommand(Action action, Func<bool> condition)
|
||||
{
|
||||
this.action = action;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return condition.Invoke();
|
||||
}
|
||||
|
||||
void ICommand.Execute(object parameter)
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user