This commit is contained in:
Maddo 2016-11-07 16:20:31 +01:00
commit 7117b2e4a8
13 changed files with 834 additions and 675 deletions

View file

@ -1,22 +1,103 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CatalogLib;
using GalaSoft.MvvmLight.Command;
using MaddoLibrary.Helpers;
namespace WPFCatalog
{
public class MainWindowViewModel : ViewModelBase
{
public PicSettings PicSettings { get; set; }
public PicSettings PicSettings
{
get { return PicSettings.Instance; }
}
public MainWindowViewModel()
{
PicSettings = new PicSettings();
//PicSettings = new PicSettings();
RegisterCommands();
}
// todo: comandi e serializzazione
#region commands
public RelayCommand ExportSettingsCommand { get; private set; }
public RelayCommand SelectSourceFolderCommand { get; private set; }
public RelayCommand SelectDestinationFolderCommand { get; private set; }
public RelayCommand OpenSourceFolderCommand { get; private set; }
public RelayCommand OpenDestinationFolderCommand { get; private set; }
private void RegisterCommands()
{
ExportSettingsCommand = new RelayCommand(ExportSettings);
SelectSourceFolderCommand = new RelayCommand(SelectSourceFolder);
OpenSourceFolderCommand = new RelayCommand(OpenSourceFolder);
SelectDestinationFolderCommand = new RelayCommand(SelectDestinationFolder);
OpenDestinationFolderCommand = new RelayCommand(OpenDestinationFolder);
}
private void OpenSourceFolder()
{
if (Directory.Exists(DirSorgente))
{
Process.Start("explorer.exe", DirSorgente);
}
}
private void OpenDestinationFolder()
{
if (Directory.Exists(DirDestinazione))
{
Process.Start("explorer.exe", DirDestinazione);
}
}
private void SelectSourceFolder()
{
var a = FileHelper.GetOpenFolderPath();
if (!string.IsNullOrWhiteSpace(a))
{
this.DirSorgente = a;
}
}
private void SelectDestinationFolder()
{
var a = FileHelper.GetOpenFolderPath();
if (!string.IsNullOrWhiteSpace(a))
{
this.DirDestinazione = a;
}
}
private void ExportSettings()
{
string s = PicSettings.SerializeSettings();
DialogHelper.PopUpAlert(s, "data");
}
#endregion
#region Proprietà
public PicSettings SettingsString
@ -26,42 +107,46 @@ namespace WPFCatalog
public string DirSorgente
{
get { return PicSettings.GetString("dirSorgente"); }
set { PicSettings.Set("dirSorgente", value); }
get { return PicSettings.GetString("DirSorgente"); }
set { PicSettings.Set("DirSorgente", value); RaisePropertyChanged("DirSorgente"); }
}
public string DirDestinazione
{
get { return PicSettings.GetString("dirDestinazione"); }
get { return PicSettings.DirectoryDestinazione; }
set
{
PicSettings.Set("dirDestinazione", value);
PicSettings.Set("DirDestinazione", value);
RaisePropertyChanged("DirDestinazione");
}
}
public bool DirSottoDirectory
public bool DirAggiornaSottoDirectory
{
get { return PicSettings.GetBool("dirSottoDirectory"); }
get { return PicSettings.DirAggiornaSottoDirectory; }
set
{
PicSettings.Set("dirSottoDirectory", value);
RaisePropertyChanged("DirSottoDirectory");
PicSettings.DirAggiornaSottoDirectory = value;
RaisePropertyChanged("DirAggiornaSottoDirectory");
}
}
public bool SubdirCreaSottoCartelle
{
get { return true; }
set { }// temp
//get { return PicSettings.GetBool("")}
}
public string DirDividiNumFile { get { return PicSettings.GetString("dirDividiNumFile"); } set { PicSettings.Set("dirDividiNumFile", value); } }
public string DirDividiSuffisso { get { return PicSettings.GetString("dirDividiSuffisso"); } set { PicSettings.Set("dirDividiSuffisso", value); } }
public string DirDividiNumCifre { get { return PicSettings.GetString("dirDividiNumCifre"); } set { PicSettings.Set("dirDividiNumCifre", value); RaisePropertyChanged("DirDividiNumCifre");} }
public string DirDividiNumCifre { get { return PicSettings.GetString("dirDividiNumCifre"); } set { PicSettings.Set("dirDividiNumCifre", value); RaisePropertyChanged("DirDividiNumCifre"); } }
public bool DirDividiDestinazione { get { return PicSettings.GetBool("dirDividiDestinazione"); } set { PicSettings.Set("dirDividiDestinazione", value); } }
public bool DirDividiTipoNumerazioneProg { get { return PicSettings.GetString("DirDividiTipoNumerazione").ToUpper() == "PROGRESSIVA"; } set { if (value == true) PicSettings.Set("DirDividiTipoNumerazione", "PROGRESSIVA"); } }
public bool DirDividiTipoNumerazioneFile { get { return PicSettings.GetString("DirDividiTipoNumerazione").ToUpper() == "FILES"; } set { if (value == false) PicSettings.Set("DirDividiTipoNumerazione", "FILES"); } }
public bool MiniatureCrea { get { return PicSettings.GetBool("miniatureCrea"); } set { PicSettings.Set("miniatureCrea",value); RaisePropertyChanged("MiniatureCrea");} }
public bool MiniatureCrea { get { return PicSettings.GetBool("miniatureCrea"); } set { PicSettings.Set("miniatureCrea", value); RaisePropertyChanged("MiniatureCrea"); } }
public string MiniatureSuffisso
{
@ -333,32 +418,32 @@ namespace WPFCatalog
}
}
public bool GeneraleForzaJpg
public bool GeneraleForzaJPG
{
get { return PicSettings.GetBool("generaleForzaJpg"); }
get { return PicSettings.GeneraleForzaJPG; }
set
{
PicSettings.Set("generaleForzaJpg", value);
RaisePropertyChanged("GeneraleForzaJpg");
PicSettings.GeneraleForzaJPG = value;
RaisePropertyChanged("GeneraleForzaJPG");
}
}
public bool GeneraleRotazioneAutomatica
{
get { return PicSettings.GetBool("generaleRotazioneAutomatica"); }
get { return PicSettings.GeneraleRotazioneAutomatica; }
set
{
PicSettings.Set("generaleRotazioneAutomatica", value);
PicSettings.GeneraleRotazioneAutomatica = value;
RaisePropertyChanged("GeneraleRotazioneAutomatica");
}
}
public bool GeneraleSovrascriviFile
{
get { return PicSettings.GetBool("generaleSovrascriviFile"); }
get { return PicSettings.GeneraleSovrascriviFile; }
set
{
PicSettings.Set("generaleSovrascriviFile", value);
PicSettings.GeneraleSovrascriviFile = value;
RaisePropertyChanged("GeneraleSovrascriviFile");
}
}