using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CatalogLib;
using GalaSoft.MvvmLight.Command;
using MaddoLibrary.Base.Log;
using MaddoLibrary.Helpers;
using WPFCatalog.Messages;

namespace WPFCatalog
{
    public class MainWindowViewModel : ViewModelBase
    {


        public PicSettings PicSettings
        {
            get { return PicSettings.Instance; }
        }

        public MainWindowViewModel()
        {
            //PicSettings = new PicSettings();
            RegisterCommands();
        }

        // todo: comandi e serializzazione

        #region commands

        public RelayCommand ExportSettingsCommand { get; private set; }
        public RelayCommand ImportSettingsCommand { 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; }

        public RelayCommand StartCommand { get; private set; }
        public RelayCommand StopCommand { get; private set; }

        public RelayCommand PickFontCommand { get; private set; }

        private void RegisterCommands()
        {
            ExportSettingsCommand = new RelayCommand(ExportSettings);
            ImportSettingsCommand = new RelayCommand(ImportSettings);

            SelectSourceFolderCommand = new RelayCommand(SelectSourceFolder);
            OpenSourceFolderCommand = new RelayCommand(OpenSourceFolder);

            SelectDestinationFolderCommand = new RelayCommand(SelectDestinationFolder);
            OpenDestinationFolderCommand = new RelayCommand(OpenDestinationFolder);

            StartCommand = new RelayCommand(Start);
            StopCommand = new RelayCommand(Stop);


            PickFontCommand = new RelayCommand(PickFont);
        }

        private void PickFont()
        {
            //FontData d = null;
            MessengerInstance.Send<OpenFontWindowMessage>(new OpenFontWindowMessage((ayy) =>
            {
                this.FontName = ayy.Name;
                this.FontSize = ayy.Size;
                //d = ayy;
            }));
            //if (d != null)
            //{
            //    FontName = d.Name;
            //}

            //string s = d.Name;
        }

        private struct ImageTask
        {
            public Task TaskImage;
            public string ImageName;
            public bool Completed;
        }

        private Task _workTask;
        //private List<ImageTask> _tasks;
        private async void Start()
        {
            
            //Task outerTask = new Task(() =>
            //{
            //    Stopwatch s = new Stopwatch();

            //    var tasks = new List<Task>();
            //    // todo folder mode
            //    MaddoLogger.Log("Starting elaboration");
            //    foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
            //    {
            //        //Task t = new Task(() =>
            //        //{

            //        //    //CompleteFile(file);
            //        //});
            //        var t = FileTask(file);
            //        if (t != null)
            //        {
            //            tasks.Add(t);
            //        }
            //        else
            //        {
            //            MaddoLogger.LogError("Task was null for file: {0}", file);
            //        }
            //        //_tasks.Add(new ImageTask() { ImageName = file, TaskImage = t, Completed = false });
            //        //t.Start();



            //    }
            //    s.Start();

            //    await Task.WhenAll(tasks);

            //    Task.WhenAll(tasks).Start();
            //    s.Stop();
            //    //tt.RunSynchronously();
            //    MaddoLogger.Log("Finished: {0}, {1}", s.Elapsed, s.ElapsedMilliseconds);
            //    DialogHelper.PopUpAlert($"Finished: {s.Elapsed}, {s.ElapsedMilliseconds}", "message");
            //});
            if (/*_workTask == null || _workTask.IsCanceled || _workTask.IsCompleted || _workTask.IsFaulted*/!_isRunning)
            {
                _workTask = OuterTask();
                try
                {
                    await _workTask;
                }
                catch (TaskCanceledException e)
                {
                    MaddoLogger.LogError(e);
                    MaddoLogger.LogError("Master Task cancelled");
                    //throw;
                }
                
            }



        }

        

        private void Stop()
        {
            if (_isRunning)
            {
                _tokenSource.Cancel();
            }
        }

        private CancellationTokenSource _tokenSource;
        private bool _isRunning = false;
        private async Task OuterTask()
        {
            _isRunning = true;
            _tokenSource = new CancellationTokenSource();
            var token = _tokenSource.Token;
            
            var tasks = new ConcurrentBag<Task>();

            IsUiActive = false;
            Stopwatch s = new Stopwatch();

            //var tasks = new List<Task>();
            // todo folder mode
            MaddoLogger.Log("Starting elaboration");
            var files = Directory.EnumerateFiles(PicSettings.DirectorySorgente).ToArray();

            TotalPictures = files.Count();

            IImageProcessor i = new ImgSharpCreator();

            foreach (var file in files)
            {
                //Task t = new Task(() =>
                //{

                //    //CompleteFile(file);
                //});
                var t = FileTask(file, i, token);
                
                tasks.Add(t);

                //_tasks.Add(new ImageTask() { ImageName = file, TaskImage = t, Completed = false });
                //t.Start();



            }
            s.Start();



            try
            {
                await Task.WhenAll(tasks);
            }
            catch (AggregateException e)
            {
                MaddoLogger.LogError(e);
                MaddoLogger.LogError("Task cancelled");
                //Console.WriteLine(e);
                //Console.WriteLine("Task cancelled");
                //throw;
            }
            finally
            {
                _tokenSource.Dispose();

                //Task.WhenAll(tasks).Start();
                s.Stop();
                //tt.RunSynchronously();
                MaddoLogger.Log("Finished: {0}, {1}", s.Elapsed, s.ElapsedMilliseconds);
                DialogHelper.PopUpAlert($"Finished: {s.Elapsed}, {s.ElapsedMilliseconds}", "message");

                IsUiActive = true;
                _isRunning = false;
            }
            



            
        }


        private async Task FileTask(string file, IImageProcessor i, CancellationToken token)
        {
            if (token.IsCancellationRequested == true)
            {
                token.ThrowIfCancellationRequested();
            }
            MaddoLogger.Log("Starting task for image {0}", file);
            //IImageProcessor i = new ImgSharpCreator();
            await Task.Run(() => i.Start(new FileInfo(file)), token);
            CurrentImage = file;
            TotalPictures--;
        }

        private void CompleteFile(string file)
        {

        }

        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");

            var savePath = FileHelper.GetSavePath("", "settings.json", string.Empty);
            if (string.IsNullOrWhiteSpace(savePath)) return;
            if (Directory.Exists(Path.GetDirectoryName(savePath)))
            {
                Debug.WriteLine(savePath);
                FileHelper.WriteToFile(savePath, s, false);
                Debug.WriteLine(s);
            }

        }

        private void ImportSettings()
        {
            var loadPath = FileHelper.GetOpenPath();
            if (string.IsNullOrWhiteSpace(loadPath)) return;
            if (File.Exists(loadPath))
            {
                var f = FileHelper.ReadTextFile(loadPath);
                PicSettings.DeserializeSettings(f);
                RaisePropertyChanged(string.Empty);
            }
        }

        #endregion

        #region Proprietà

        private bool _isUiActive = true;
        public bool IsUiActive
        {
            get => _isUiActive;
            set { _isUiActive = value; RaisePropertyChanged("IsUiActive"); }
        }

        private string _currentImage;

        public string CurrentImage
        {
            get => _currentImage;
            set { _currentImage = value; RaisePropertyChanged("CurrentImage"); }
        }

        private int _totalPictures;

        public int TotalPictures
        {
            get => _totalPictures;
            set { _totalPictures = value; RaisePropertyChanged("TotalPictures"); }
        }


        public PicSettings SettingsString
        {
            get { return PicSettings; }
        }

        public string DirSorgente
        {
            get { return PicSettings.GetString("DirSorgente"); }
            set { PicSettings.Set("DirSorgente", value); RaisePropertyChanged("DirSorgente"); }
        }

        public string DirDestinazione
        {
            get { return PicSettings.DirectoryDestinazione; }
            set
            {
                PicSettings.Set("DirDestinazione", value);
                RaisePropertyChanged("DirDestinazione");
            }
        }

        public bool DirAggiornaSottoDirectory
        {
            get { return PicSettings.DirAggiornaSottoDirectory; }
            set
            {
                PicSettings.DirAggiornaSottoDirectory = value;
                RaisePropertyChanged("DirAggiornaSottoDirectory");
            }
        }

        public bool SubdirCreaSottoCartelle
        {
            get { return PicSettings.SubdirCreaSottoCartelle; }
            set { PicSettings.SubdirCreaSottoCartelle = value; RaisePropertyChanged("SubdirCreaSottoCartelle"); }
        }

        public int SubdirIntervalloFile
        {
            get { return PicSettings.SubdirIntervalloFile; }
            set { PicSettings.SubdirIntervalloFile = value; RaisePropertyChanged("SubdirIntervalloFile"); }
        }

        public string SubdirSuffisso
        {
            get { return PicSettings.SubdirSuffisso; }
            set { PicSettings.SubdirSuffisso = value; RaisePropertyChanged("SubdirSuffisso"); }
        }

        public int SubdirCifreContatore
        {
            get { return PicSettings.SubdirCifreContatore; }
            set { PicSettings.SubdirCifreContatore = value; RaisePropertyChanged("SubdirCifreContatore"); }
        }

        public bool SubdirNumerazioneProgressiva
        {
            get { return PicSettings.SubdirNumerazioneProgressiva; }
            set { PicSettings.SubdirNumerazioneProgressiva = value; RaisePropertyChanged("SubdirNumerazioneProgressiva"); }
        }

        public bool SubdirNumerazioneFiles
        {
            get { return PicSettings.SubdirNumerazioneFiles; }
            set { PicSettings.SubdirNumerazioneFiles = value; RaisePropertyChanged("SubdirNumerazioneFiles"); }
        }

        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 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 string MiniatureSuffisso
        {
            get { return PicSettings.GetString("miniatureSuffisso"); }
            set
            {
                PicSettings.Set("miniatureSuffisso", value);
                RaisePropertyChanged("MiniatureSuffisso");
            }
        }

        public string MiniatureAltezza
        {
            get { return PicSettings.GetString("miniatureAltezza"); }
            set
            {
                PicSettings.Set("miniatureAltezza", value);
                RaisePropertyChanged("MiniatureAltezza");
            }
        }

        public string MiniatureLarghezza
        {
            get { return PicSettings.GetString("miniatureLarghezza"); }
            set
            {
                PicSettings.Set("miniatureLarghezza", value);
                RaisePropertyChanged("MiniatureLarghezza");
            }
        }

        public bool MiniatureAddScritta
        {
            get { return PicSettings.GetBool("miniatureAddScritta"); }
            set
            {
                PicSettings.Set("miniatureAddScritta", value);
                RaisePropertyChanged("MiniatureAddScritta");
            }
        }

        public bool MiniatureAddOrario
        {
            get { return PicSettings.GetBool("miniatureAddOrario"); }
            set
            {
                PicSettings.Set("miniatureAddOrario", value);
                RaisePropertyChanged("MiniatureAddOrario");
            }
        }

        public bool FotoRidimensiona
        {
            get { return PicSettings.FotoRidimensiona; }
            set
            {
                PicSettings.FotoRidimensiona = value;
                RaisePropertyChanged("FotoRidimensiona");
            }
        }

        public int FotoAltezza
        {
            get
            {
                return PicSettings.FotoAltezza;
            }
            set
            {
                PicSettings.FotoAltezza = value;
                RaisePropertyChanged("FotoAltezza");
            }
        }

        public int FotoLarghezza
        {
            get { return PicSettings.FotoLarghezza; }
            set
            {
                PicSettings.FotoLarghezza = value;
                RaisePropertyChanged("FotoLarghezza");
            }
        }

        public string FontDimensione
        {
            get { return PicSettings.GetString("fontDimensione"); }
            set
            {
                PicSettings.Set("fontDimensione", value);
                RaisePropertyChanged("FontDimensione");
            }
        }

        public string FontDimensioneMiniatura
        {
            get { return PicSettings.GetString("fontDimensioneMiniatura"); }
            set
            {
                PicSettings.Set("fontDimensioneMiniatura", value);
                RaisePropertyChanged("FontDimensioneMiniatura");
            }
        }

        public bool FontBold
        {
            get { return PicSettings.GetBool("fontBold"); }
            set
            {
                PicSettings.Set("fontBold", value);
                RaisePropertyChanged("FontBold");
            }
        }

        public bool FontNome
        {
            get { return PicSettings.GetBool("fontNome"); }
            set
            {
                PicSettings.Set("$parName", value);
                RaisePropertyChanged("FontNome");
            }
        }

        public string TestoTesto
        {
            get { return PicSettings.GetString("testoTesto"); }
            set
            {
                PicSettings.Set("testoTesto", value);
                RaisePropertyChanged("TestoTesto");
            }
        }

        public string TestoTrasparente
        {
            get { return PicSettings.GetString("testoTrasparente"); }
            set
            {
                PicSettings.Set("testoTrasparente", value);
                RaisePropertyChanged("TestoTrasparente");
            }
        }

        public string TestoMargine
        {
            get { return PicSettings.GetString("testoMargine"); }
            set
            {
                PicSettings.Set("testoMargine", value);
                RaisePropertyChanged("TestoMargine");
            }
        }

        public string TestoPosizione
        {
            get { return PicSettings.GetString("testoPosizione"); }
            set
            {
                PicSettings.Set("testoPosizione", value);
                RaisePropertyChanged("TestoPosizione");
            }
        }

        public string TestoAllineamento
        {
            get { return PicSettings.GetString("testoAllineamento"); }
            set
            {
                PicSettings.Set("testoAllineamento", value);
                RaisePropertyChanged("TestoAllineamento");
            }
        }

        public string MarchioFile
        {
            get { return PicSettings.GetString("marchioFile"); }
            set
            {
                PicSettings.Set("marchioFile", value);
                RaisePropertyChanged("MarchioFile");
            }
        }

        public string MarchioAltezza
        {
            get { return PicSettings.GetString("marchioAltezza"); }
            set
            {
                PicSettings.Set("marchioAltezza", value);
                RaisePropertyChanged("MarchioAltezza");
            }
        }

        public string MarchioLarghezza
        {
            get { return PicSettings.GetString("marchioLarghezza"); }
            set
            {
                PicSettings.Set("marchioLarghezza", value);
                RaisePropertyChanged("MarchioLarghezza");
            }
        }

        public string MarchioMargine
        {
            get { return PicSettings.GetString("marchioMargine"); }
            set
            {
                PicSettings.Set("marchioMargine", value);
                RaisePropertyChanged("MarchioMargine");
            }
        }

        public string MarchioAllOrizzontale
        {
            get { return PicSettings.GetString("marchioAllOrizzontale"); }
            set
            {
                PicSettings.Set("marchioAllOrizzontale", value);
                RaisePropertyChanged("MarchioAllOrizzontale");
            }
        }

        public string MarchioAllVerticale
        {
            get { return PicSettings.GetString("marchioAllVerticale"); }
            set
            {
                PicSettings.Set("marchioAllVerticale", value);
                RaisePropertyChanged("MarchioAllVerticale");
            }
        }

        public string MarchioTrasparenza
        {
            get { return PicSettings.GetString("marchioTrasparenza"); }
            set
            {
                PicSettings.Set("marchioTrasparenza", value);
                RaisePropertyChanged("MarchioTrasparenza");
            }
        }

        public bool MarchioAggiungi
        {
            get { return PicSettings.GetBool("marchioAggiungi"); }
            set
            {
                PicSettings.Set("marchioAggiungi", value);
                RaisePropertyChanged("MarchioAggiungi");
            }
        }

        public bool TempoGara
        {
            get { return PicSettings.GetBool("tempoGara"); }
            set
            {
                PicSettings.Set("tempoGara", value);
                RaisePropertyChanged("TempoGara");
            }
        }

        public bool Orario
        {
            get { return PicSettings.GetBool("orario"); }
            set
            {
                PicSettings.Set("orario", value);
                RaisePropertyChanged("Orario");
            }
        }

        public string EtichettaOrario
        {
            get { return PicSettings.GetString("etichettaOrario"); }
            set
            {
                PicSettings.Set("etichettaOrario", value);
                RaisePropertyChanged("EtichettaOrario");
            }
        }

        public bool GeneraleForzaJPG
        {
            get { return PicSettings.GeneraleForzaJPG; }
            set
            {
                PicSettings.GeneraleForzaJPG = value;
                RaisePropertyChanged("GeneraleForzaJPG");
            }
        }

        public bool GeneraleRotazioneAutomatica
        {
            get { return PicSettings.GeneraleRotazioneAutomatica; }
            set
            {
                PicSettings.GeneraleRotazioneAutomatica = value;
                RaisePropertyChanged("GeneraleRotazioneAutomatica");
            }
        }

        public bool GeneraleSovrascriviFile
        {
            get { return PicSettings.GeneraleSovrascriviFile; }
            set
            {
                PicSettings.GeneraleSovrascriviFile = value;
                RaisePropertyChanged("GeneraleSovrascriviFile");
            }
        }


        public string GrandezzaVerticale
        {
            get { return PicSettings.GetString("grandezzaVerticale"); }
            set
            {
                PicSettings.Set("grandezzaVerticale", value);
                RaisePropertyChanged("GrandezzaVerticale");
            }
        }

        public string MargineVerticale
        {
            get { return PicSettings.GetString("margineVerticale"); }
            set
            {
                PicSettings.Set("margineVerticale", value);
                RaisePropertyChanged("MargineVerticale");
            }
        }

        public bool DimensioniOriginali
        {
            get { return PicSettings.GetBool("dimensioniOriginali"); }
            set
            {
                PicSettings.Set("dimensioniOriginali", value);
                RaisePropertyChanged("DimensioniOriginali");
            }
        }

        public string TestoVerticale
        {
            get { return PicSettings.GetString("testoVerticale"); }
            set
            {
                PicSettings.Set("testoVerticale", value);
                RaisePropertyChanged("TestoVerticale");
            }
        }

        public bool NomeMiniatura
        {
            get { return PicSettings.GetBool("nomeMiniatura"); }
            set
            {
                PicSettings.Set("nomeMiniatura", value);
                RaisePropertyChanged("NomeMiniatura");
            }
        }

        public bool DataFoto
        {
            get { return PicSettings.GetBool("dataFoto"); }
            set
            {
                PicSettings.Set("dataFoto", value);
                RaisePropertyChanged("DataFoto");
            }
        }

        public bool NumeroFoto
        {
            get { return PicSettings.GetBool("numeroFoto"); }
            set
            {
                PicSettings.Set("numeroFoto", value);
                RaisePropertyChanged("NumeroFoto");
            }
        }

        public bool TempoSmall
        {
            get { return PicSettings.GetBool("tempoSmall"); }
            set
            {
                PicSettings.Set("tempoSmall", value);
                RaisePropertyChanged("TempoSmall");
            }
        }

        public bool NumTempoSmall
        {
            get { return PicSettings.GetBool("numTempoSmall"); }
            set
            {
                PicSettings.Set("numTempoSmall", value);
                RaisePropertyChanged("NumTempoSmall");
            }
        }

        public int CompressioneJpeg
        {
            get { return PicSettings.CompressioneJpeg; }
            set
            {
                PicSettings.CompressioneJpeg = value;
                RaisePropertyChanged("CompressioneJpeg");
            }
        }

        public bool FotoMantieniDimensioni
        {
            get { return PicSettings.FotoMantieniDimensioni; }
            set
            {
                PicSettings.FotoMantieniDimensioni = value;
                RaisePropertyChanged("FotoMantieniDimensioni");
            }
        }

        public string FotoSuffisso
        {
            get { return PicSettings.FotoSuffisso; }
            set { PicSettings.FotoSuffisso = value; RaisePropertyChanged("FotoSuffisso"); }
        }

        public string CompressioneJpegMiniatura
        {
            get { return PicSettings.GetString("compressioneJpegMiniatura"); }
            set
            {
                PicSettings.Set("compressioneJpegMiniatura", value);
                RaisePropertyChanged("CompressioneJpegMiniatura");
            }
        }

        public bool Threading
        {
            get => PicSettings.Threading;
            set { PicSettings.Threading = value; RaisePropertyChanged("Threading"); }
        }

        public int Margine
        {
            get => PicSettings.Margine;
            set { PicSettings.Margine = value; RaisePropertyChanged("Margine"); }
        }

        public Positions TextPosition
        {
            get => PicSettings.TextPosition;
            set { PicSettings.TextPosition = value; RaisePropertyChanged("TextPosition"); }
        }

        public Alignments TextAlignment
        {
            get => PicSettings.TextAlignment;
            set { PicSettings.TextAlignment = value; RaisePropertyChanged("TextAlignment"); }
        }

        public ResizeModes ResizeMode
        {
            get => PicSettings.ResizeMode;
            set { PicSettings.ResizeMode = value; RaisePropertyChanged("ResizeMode"); }
        }

        public ResizeDimensions ResizeDimension
        {
            get => PicSettings.ResizeDimension;
            set { PicSettings.ResizeDimension = value; RaisePropertyChanged("ResizeDimension"); }
        }

        public bool Grassetto
        {
            get => PicSettings.Grassetto;
            set { PicSettings.Grassetto = value; RaisePropertyChanged("Grassetto"); }
        }

        //public PicSettings.Positions Positions
        //{
        //    get => PicSettings.Positions;
        //}

        #endregion

        #region Testo

        public bool EnableText
        {
            get { return PicSettings.EnableText; }
            set { PicSettings.EnableText = value; RaisePropertyChanged("EnableText"); }

        }



        public string ColoreTestoRGB
        {
            get { return PicSettings.ColoreTestoRGB; }
            set
            {
                PicSettings.ColoreTestoRGB = value;
                RaisePropertyChanged("ColoreTestoRGB");
            }
        }

        public string FontName
        {
            get { return PicSettings.NomeFont; }
            set
            {
                PicSettings.NomeFont = value;
                RaisePropertyChanged("FontName");
            }
        }

        public double FontSize
        {
            get
            {
                {
                    return PicSettings.DimensioneFont;
                }
            }
            set
            {
                PicSettings.DimensioneFont = value;
                RaisePropertyChanged("FontSize");
            }
        }

        public string TestoApplicareOrizzontale
        {
            get
            {
                return PicSettings.TestoApplicareOrizzontale;

            }
            set
            {
                PicSettings.TestoApplicareOrizzontale = value;
                RaisePropertyChanged("TestoApplicareOrizzontale");
            }

        }

        //todo: bold

        //todo: italic
        #endregion

        #region Logo


        public bool EnableLogo
        {
            get { return PicSettings.EnableLogo; }
            set { PicSettings.EnableLogo = value; RaisePropertyChanged("EnableLogo"); }

        }

        #endregion

        #region Thumbnail

        public bool EnableThumbnails
        {
            get { return PicSettings.EnableThumbnails; }
            set { PicSettings.EnableThumbnails = value; RaisePropertyChanged("EnableThumbnails"); }

        }

        #endregion




    }
}
