|
@@ -1,14 +1,137 @@
|
|
-using Prism.Regions;
|
|
|
|
|
|
+using PDF_Office.Properties;
|
|
|
|
+using PDFSettings;
|
|
|
|
+using Prism.Commands;
|
|
|
|
+using Prism.Mvvm;
|
|
|
|
+using Prism.Regions;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Security.Permissions;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using System.Windows;
|
|
|
|
+using System.Windows.Forms;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.EditTools.Background
|
|
namespace PDF_Office.ViewModels.EditTools.Background
|
|
{
|
|
{
|
|
- internal class BackgroundTemplateListColorContentViewModel : INavigationAware
|
|
|
|
|
|
+
|
|
|
|
+ public class BackgroundTemplateListColorContentViewModel : BindableBase, INavigationAware
|
|
{
|
|
{
|
|
|
|
+ public ObservableCollection<BackgroundItem> backgroundModcolorCollection = new ObservableCollection<BackgroundItem>();
|
|
|
|
+ public ObservableCollection<BackgroundItem> BackgroundModColorCollection
|
|
|
|
+ {
|
|
|
|
+ get { return backgroundModcolorCollection; }
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ backgroundModcolorCollection = value;
|
|
|
|
+ RaisePropertyChanged();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Visibility _createTemplateVisible;
|
|
|
|
+ public Visibility CreateTemplateVisible
|
|
|
|
+ {
|
|
|
|
+ get { return _createTemplateVisible; }
|
|
|
|
+ set { SetProperty(ref _createTemplateVisible, value); }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public DelegateCommand AddTemplateCommand { get; set; }
|
|
|
|
+ public DelegateCommand<object> DeleteTemplateItemCommand { get; set; }
|
|
|
|
+
|
|
|
|
+ BackgroundTemplateListColorContentViewModel()
|
|
|
|
+ {
|
|
|
|
+ AddTemplateCommand = new DelegateCommand(AddTemplate);
|
|
|
|
+ DeleteTemplateItemCommand = new DelegateCommand<object>(DeleteTemplateItem);
|
|
|
|
+
|
|
|
|
+ InitBackgroundTemplateList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void CheckTemplateListIsEmpty(List<BackgroundItem> backgroundTemplateList)
|
|
|
|
+ {
|
|
|
|
+ if (backgroundTemplateList.Count() == 0)
|
|
|
|
+ {
|
|
|
|
+ CreateTemplateVisible = Visibility.Visible;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ CreateTemplateVisible = Visibility.Collapsed;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void GetBackgroundSource()
|
|
|
|
+ {
|
|
|
|
+ List<BackgroundItem> backgroundModColorTemplateList = new List<BackgroundItem>();
|
|
|
|
+ for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
|
|
|
|
+ {
|
|
|
|
+ if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
|
|
|
|
+ {
|
|
|
|
+ backgroundModColorTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BackgroundModColorCollection = new ObservableCollection<BackgroundItem>(backgroundModColorTemplateList);
|
|
|
|
+ CheckTemplateListIsEmpty(backgroundModColorTemplateList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void InitBackgroundTemplateList()
|
|
|
|
+ {
|
|
|
|
+ if (Settings.Default.BackgroundTemplateList == null)
|
|
|
|
+ {
|
|
|
|
+ Settings.Default.BackgroundTemplateList = new BackgroundTemplateList();
|
|
|
|
+ }
|
|
|
|
+ GetBackgroundSource();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void UpdateBackgroundSources()
|
|
|
|
+ {
|
|
|
|
+ List<BackgroundItem> backgroundModColorTemplateList = new List<BackgroundItem>();
|
|
|
|
+ for (int temp = 0; temp < Settings.Default.BackgroundTemplateList.Count; temp++)
|
|
|
|
+ {
|
|
|
|
+ if (Settings.Default.BackgroundTemplateList[temp].type == ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR)
|
|
|
|
+ {
|
|
|
|
+ backgroundModColorTemplateList.Add(Settings.Default.BackgroundTemplateList[temp]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BackgroundModColorCollection = new ObservableCollection<BackgroundItem>(backgroundModColorTemplateList);
|
|
|
|
+ CheckTemplateListIsEmpty(backgroundModColorTemplateList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void AddTemplate()
|
|
|
|
+ {
|
|
|
|
+ var backgroundItem = new BackgroundItem();
|
|
|
|
+ backgroundItem.pageRange = "0";
|
|
|
|
+ backgroundItem.type = ComPDFKit.PDFDocument.C_Background_Type.BG_TYPE_COLOR;
|
|
|
|
+ backgroundItem.templateName += Settings.Default.BackgroundIndex.ToString();
|
|
|
|
+ Settings.Default.BackgroundTemplateList.Add(backgroundItem);
|
|
|
|
+ Settings.Default.Save();
|
|
|
|
+ UpdateBackgroundSources();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void DeleteTemplateItem(object e)
|
|
|
|
+ {
|
|
|
|
+ var btn = e as System.Windows.Controls.Button;
|
|
|
|
+ if(btn == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var template = btn.DataContext as BackgroundItem;
|
|
|
|
+ if(template == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Settings.Default.AppProperties.NeedToDeletePath.Add(template.previeImagePath);
|
|
|
|
+ Settings.Default.AppProperties.NeedToDeletePath.Add(template.imagepath);
|
|
|
|
+
|
|
|
|
+ Settings.Default.BackgroundTemplateList.Remove(template);
|
|
|
|
+ Settings.Default.Save();
|
|
|
|
+
|
|
|
|
+ BackgroundModColorCollection.Remove(template);
|
|
|
|
+ UpdateBackgroundSources();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
{
|
|
{
|
|
return true;
|
|
return true;
|