using ComPDFKit.PDFDocument; using PDF_Office.Helper; using PDF_Office.Model.EditTools.Background; using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PDF_Office.ViewModels.EditTools.Background { public class BackgroundCreateFileContentViewModel : BindableBase, INavigationAware { public BackgroundInfo BackgroundInfo { get; set; } = new BackgroundInfo(); private List _rotationList = new List(); public List RotationList { get { return _rotationList; } set { SetProperty(ref _rotationList, value); } } private List _opacityList = new List(); public List OpacityList { get { return _opacityList; } set { SetProperty(ref _opacityList, value); } } private List _relativeRatioList = new List(); public List RelativeRatioList { get { return _relativeRatioList; } set { SetProperty(ref _relativeRatioList, value); } } private int _rotationNumber = 0; public int RotationNumber { get { return _rotationNumber; } set { SetProperty(ref _rotationNumber, value); } } private int _opacityNumber = 100; public int OpacityNumber { get { return _opacityNumber; } set { SetProperty(ref _opacityNumber, value); } } private int _relativeRatioNumber = 0; public int RelativeRatioNumber { get { return _relativeRatioNumber; } set { SetProperty(ref _rotationNumber, value); } } private ObservableDictionary _getLocationFromNumber = new ObservableDictionary(); public ObservableDictionary GetLocationFromNumber { get { return _getLocationFromNumber; } } public BackgroundCreateFileContentViewModel() { ChangeLocationCommand = new DelegateCommand(ChangeLocation); InitComponent(); BackgroundInfo.BackgroundHorizalign = C_Background_Horizalign.BG_HORIZALIGN_CENTER; BackgroundInfo.BackgroundVertalign = C_Background_Vertalign.BG_VERTALIGN_CENTER; InitLocationButtonMatrix(); } public void InitComponent() { InitOpacityList(); InitRotationList(); InitRelativeRatioList(); } private void InitRotationList() { OpacityList.Clear(); for (int defaultRotation = -45; defaultRotation <= 45; defaultRotation += 15) { RotationList.Add(defaultRotation.ToString()); } } private void InitOpacityList() { OpacityList.Clear(); for (int defaultOpacity = 10; defaultOpacity <= 100; defaultOpacity += 10) { OpacityList.Add(defaultOpacity.ToString() + " %"); } } private void InitRelativeRatioList() { RelativeRatioList.Clear(); for (int defaultRelativeRatioList = 10; defaultRelativeRatioList <= 100; defaultRelativeRatioList += 10) { RelativeRatioList.Add(defaultRelativeRatioList.ToString() + " %"); } } private void InitLocationButtonMatrix() { GetLocationFromNumber.Clear(); for (var temp = 0; temp <= 22; temp++) { GetLocationFromNumber.Add(temp.ToString(), true); if (temp % 10 == 2) { temp += 7; } } int Num = (int)BackgroundInfo.BackgroundVertalign * 10 + (int)BackgroundInfo.BackgroundHorizalign; GetLocationFromNumber[Num.ToString()] = false; } public DelegateCommand ChangeLocationCommand { get; set; } public void ChangeLocation(object e) { string args = e as string; if (args != null) { BackgroundInfo.BackgroundVertalign = (C_Background_Vertalign)(int.Parse(args) / 10); BackgroundInfo.BackgroundHorizalign = (C_Background_Horizalign)(int.Parse(args) % 10); InitLocationButtonMatrix(); } } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { } } }