using PDF_Master.Properties;
using PDFSettings;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PDF_Master.Model.SettingsDialog
{
public class DescriptionModel:BindableBase
{
private bool openUnClosedFileWhenOpen;
public bool OpenUnClosedFileWhenOpen
{
get { return openUnClosedFileWhenOpen; }
set
{
SetProperty(ref openUnClosedFileWhenOpen, value);
}
}
private bool recoveryViewWhenOpen;
public bool RecoveryViewWhenOpen
{
get { return recoveryViewWhenOpen; }
set
{
SetProperty(ref recoveryViewWhenOpen, value);
}
}
private int fileCountInRecentFiles;
public int FileCountInRecentFiles
{
get { return fileCountInRecentFiles; }
set
{
SetProperty(ref fileCountInRecentFiles, value);
}
}
private bool autoSave;
public bool AutoSave
{
get { return autoSave; }
set
{
SetProperty(ref autoSave, value);
}
}
private int autoSaveInterval;
public int AutoSaveInterval
{
get { return autoSaveInterval; }
set
{
SetProperty(ref autoSaveInterval, value);
}
}
private bool showSaveWhenClose;
public bool ShowSaveWhenClose
{
get { return showSaveWhenClose; }
set
{
SetProperty(ref showSaveWhenClose, value);
}
}
private bool notShowSaveWhenClose;
public bool NotShowSaveWhenClose
{
get { return notShowSaveWhenClose; }
set
{
SetProperty(ref notShowSaveWhenClose, value);
}
}
private bool autoScanImageFile;
public bool AutoScanImageFile
{
get { return autoScanImageFile; }
set
{
SetProperty(ref autoScanImageFile, value);
}
}
private bool tipScanImageFile;
public bool TipScanImageFile
{
get { return tipScanImageFile; }
set
{
SetProperty(ref tipScanImageFile, value);
}
}
private string author;
public string Author
{
get { return author; }
set
{
SetProperty(ref author, value);
}
}
public DescriptionModel()
{
InitFromSettings();
}
///
/// 重置
///
public void Reset()
{
var description = new DescriptionPropertyClass();
this.OpenUnClosedFileWhenOpen = description.OpenUnClosedFileWhenOpen;
this.RecoveryViewWhenOpen = description.RecoveryViewWhenOpen;
this.FileCountInRecentFiles = description.FileCountInRecentFiles;
this.AutoSave = description.AutoSave;
this.AutoSaveInterval = description.AutoSaveInterval;
this.ShowSaveWhenClose = description.ShowSaveWhenClose;
this.NotShowSaveWhenClose = description.NotShowSaveWhenClose;
this.AutoScanImageFile = description.AutoScanImageFile;
this.TipScanImageFile = description.TipScanImageFile;
this.Author = description.Author;
}
///
/// 保存配置到缓存 外面需要统一调用一次settngs.save
///
public void Save()
{
DescriptionPropertyClass description = new DescriptionPropertyClass();
description.OpenUnClosedFileWhenOpen = this.OpenUnClosedFileWhenOpen;
description.RecoveryViewWhenOpen = this.RecoveryViewWhenOpen;
description.FileCountInRecentFiles = this.FileCountInRecentFiles;
description.AutoSave = this.AutoSave;
description.AutoSaveInterval = this.AutoSaveInterval;
description.ShowSaveWhenClose = this.ShowSaveWhenClose;
description.NotShowSaveWhenClose = this.NotShowSaveWhenClose;
description.AutoScanImageFile = this.AutoScanImageFile;
description.TipScanImageFile = this.TipScanImageFile;
description.Author = this.Author;
Settings.Default.AppProperties.Description = description;
}
///
/// 从缓存读取配置
///
private void InitFromSettings()
{
var description = Settings.Default.AppProperties.Description;
this.OpenUnClosedFileWhenOpen = description.OpenUnClosedFileWhenOpen;
this.RecoveryViewWhenOpen = description.RecoveryViewWhenOpen;
this.FileCountInRecentFiles = description.FileCountInRecentFiles;
this.AutoSave = description.AutoSave;
this.AutoSaveInterval = description.AutoSaveInterval;
this.ShowSaveWhenClose = description.ShowSaveWhenClose;
this.NotShowSaveWhenClose = description.NotShowSaveWhenClose;
this.AutoScanImageFile = description.AutoScanImageFile;
this.TipScanImageFile = description.TipScanImageFile;
this.Author = description.Author;
}
}
}