| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using Prism.Commands;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Web.UI;
- using System.Windows.Shapes;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Models;
- namespace TeamAAS_VP.ViewModels.Product
- {
- public class CreateProductPageViewModel : BindableBase
- {
- private string _ProductName;
- public string ProductName
- {
- get { return _ProductName; }
- set { SetProperty(ref _ProductName,value); }
- }
- private ObservableCollection<string> _Templates;
- public ObservableCollection<string> Templates
- {
- get { return _Templates; }
- set { SetProperty(ref _Templates, value); }
- }
- private string _SelectTemplate;
- public string SelectTemplate
- {
- get { return _SelectTemplate; }
- set { SetProperty(ref _SelectTemplate, value); }
- }
- private DelegateCommand _LoadedCommand;
- public DelegateCommand LoadedCommand =>
- _LoadedCommand ?? (_LoadedCommand = new DelegateCommand(ExecuteLoadedCommand));
- public CreateProductPageViewModel()
- {
- }
- void ExecuteLoadedCommand()
- {
-
- try
- {
- Templates = new ObservableCollection<string>();
- Templates.Add("空白");
- SelectTemplate = Templates[0];
- if (!Directory.Exists(FilePath.ProductTemplatePath))
- {
- Directory.CreateDirectory(FilePath.ProductTemplatePath);
- }
- DirectoryInfo dir = new DirectoryInfo(FilePath.ProductTemplatePath);
- DirectoryInfo[] subdirectories = dir.GetDirectories();
- foreach (DirectoryInfo subdir in subdirectories)
- {
- try
- {
- var product = FileHelper.ReadJsonFile<ProductModel>(FilePath.ProductTemplatePath + "//" + subdir.Name + "//" + subdir.Name + ".cfg");
- if (product!=null)
- {
- Templates.Add(subdir.Name);
- }
- }
- catch (Exception)
- {
- }
- }
- }
- catch (Exception)
- {
-
- }
- }
- }
- }
|