123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- using PDF_Master.EventAggregators;
- using PDF_Master.Model.Dialog.HomePageToolsDialogs.HomePagePrinter;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Management.Instrumentation;
- using System.Windows.Controls;
- namespace PDF_Master.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
- {
- public class HomePagePrinterModSizeContentViewModel : BindableBase, INavigationAware
- {
- private IEventAggregator eventAggregator;
- private string Unicode = null;
- public string CurrentSelectedRdoName = "StatusAdaptiveRdo";
- private string _displayRatio = "100";
- public string DisplayRatio
- {
- get { return _displayRatio; }
- set { SetProperty(ref _displayRatio, value); }
- }
- private SizeInfo _sizeInfo;
- public SizeInfo SizeInfo
- {
- get { return _sizeInfo; }
- set { _sizeInfo = value; }
- }
- private bool _isDuplexModLongEdge = true;
- public bool IsDuplexModLongEdge
- {
- get { return _isDuplexModLongEdge;}
- set { _isDuplexModLongEdge = value; }
- }
- private bool _isDuplexModShortEdge = false;
- public bool IsDuplexModShortEdge
- {
- get { return _isDuplexModShortEdge;}
- set { _isDuplexModShortEdge = value;}
- }
- public DelegateCommand<object> SetModSizeStatusCommand { get; set; }
- public DelegateCommand SetDisplayRatioCommand { get; set; }
- public DelegateCommand<object> UnlockDuplexCommand { get; set; }
- public DelegateCommand<object> ChangeDuplexModCommand { get; set; }
-
- public DelegateCommand SendSizeInfoCommand { get; set; }
- public HomePagePrinterModSizeContentViewModel(IEventAggregator eventAggregator)
- {
- this.eventAggregator = eventAggregator;
- SizeInfo = new SizeInfo();
- SizeInfo.EnumPrintMod = EnumPrintMod.StatusSize;
- SetModSizeStatusCommand = new DelegateCommand<object>(SetModSizeStatus);
- SetDisplayRatioCommand = new DelegateCommand(SetDisplayRatio);
- UnlockDuplexCommand = new DelegateCommand<object>(UnlockDuplex);
- ChangeDuplexModCommand = new DelegateCommand<object>(ChangeDuplexMod);
- }
- public void UnlockDuplex(object e)
- {
- var chk = e as CheckBox;
- if (chk != null)
- {
- if (chk.IsChecked == false)
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusNone, Unicode = this.Unicode });
- }
- else
- {
- if (IsDuplexModLongEdge)
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
- }
- else
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
- }
- }
- }
- }
- public void ChangeDuplexMod(object e)
- {
- var rdo = e as RadioButton;
- if (rdo != null)
- {
- if (rdo.Name == "DuplexModLongEdgeRdo")
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipLongEdge, Unicode = this.Unicode });
- }
- else
- {
- this.eventAggregator.GetEvent<SendDuplexPrintModEvent>().Publish(new EnumDuplexPrintModWithUnicode { enumDuplexPrintMod = EnumDuplexPrintMod.StatusFlipShortEdge, Unicode = this.Unicode });
- }
- }
- }
- public void SendSizeInfo()
- {
- if (SizeInfo != null)
- {
- this.eventAggregator.GetEvent<SendPrintSettingsModInfoEvent>().Publish(new PrintModInfoWithUnicode { printModInfo = SizeInfo, Unicode = this.Unicode});
- }
- }
- public void SetModSizeStatus(object e)
- {
- var rdo = e as RadioButton;
- if (rdo.Name == CurrentSelectedRdoName)
- {
- return;
- }
- else
- {
- CurrentSelectedRdoName = rdo.Name;
- if (rdo.Name == "StatusAdaptiveRdo")
- {
- SizeInfo.EnumSizeType = EnumSizeType.StatusAdaptive;
- }
- else if (rdo.Name == "StatusActuralRdo")
- {
- SizeInfo.EnumSizeType = EnumSizeType.StatusActural;
- }
- else
- {
- SizeInfo.EnumSizeType = EnumSizeType.StatusCustomized;
- }
- if (SizeInfo.EnumSizeType == EnumSizeType.StatusAdaptive || SizeInfo.EnumSizeType == EnumSizeType.StatusActural || (SizeInfo.EnumSizeType == EnumSizeType.StatusCustomized)&& DisplayRatio != null)
- {
- SendSizeInfo();
- }
- }
- }
- public void SetDisplayRatio()
- {
- int previousDisplayRatio = SizeInfo.DisplayRatio;
- SizeInfo.DisplayRatio = int.Parse(DisplayRatio);
- if (previousDisplayRatio != SizeInfo.DisplayRatio)
- {
- SendSizeInfo();
- }
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
- SendSizeInfo();
- }
- }
- }
|