49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
|
|
using System;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
namespace ImageCatalog_2.ViewModels;
|
||
|
|
|
||
|
|
public class PathSettingsViewModel : ViewModelBase
|
||
|
|
{
|
||
|
|
private string _sourcePath = string.Empty;
|
||
|
|
public string SourcePath
|
||
|
|
{
|
||
|
|
get => _sourcePath;
|
||
|
|
set
|
||
|
|
{
|
||
|
|
_sourcePath = value;
|
||
|
|
NotifyPropertyChanged();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private string _destinationPath = string.Empty;
|
||
|
|
public string DestinationPath
|
||
|
|
{
|
||
|
|
get => _destinationPath;
|
||
|
|
set
|
||
|
|
{
|
||
|
|
_destinationPath = value;
|
||
|
|
NotifyPropertyChanged();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void NormalizePaths()
|
||
|
|
{
|
||
|
|
SourcePath = NormalizePath(SourcePath);
|
||
|
|
DestinationPath = NormalizePath(DestinationPath);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static string NormalizePath(string path)
|
||
|
|
{
|
||
|
|
if (string.IsNullOrWhiteSpace(path))
|
||
|
|
{
|
||
|
|
return string.Empty;
|
||
|
|
}
|
||
|
|
|
||
|
|
path = path.Trim().Trim('"');
|
||
|
|
path = path.Replace('/', Path.DirectorySeparatorChar)
|
||
|
|
.Replace('\\', Path.DirectorySeparatorChar);
|
||
|
|
|
||
|
|
return path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
|
||
|
|
}
|
||
|
|
}
|