123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.Model;
- 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;
- using System.Windows;
- namespace PDF_Office.ViewModels.Form
- {
- public class FormsToolContentViewModel : BindableBase, INavigationAware
- {
- private CPDFViewer PDFViewer;
- public ViewContentViewModel viewContentViewModel;
- private IRegionManager regions;
- /// <summary>
- /// 按钮和属性面板键值对
- /// </summary>
- private Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
- private Visibility showPreView;
- /// <summary>
- /// 显示PreView按钮
- /// </summary>
- public Visibility ShowPreView
- {
- get { return showPreView; }
- set
- {
- SetProperty(ref showPreView, value);
- }
- }
- public DelegateCommand<string> CheckedCommand { get; set; }
- public FormsToolContentViewModel(IRegionManager regionManager)
- {
- regions = regionManager;
- CheckedCommand = new DelegateCommand<string>(CheckedEvent);
- InitBtnToProperty();
- }
- private void InitBtnToProperty()
- {
- btnToProperty.Add("Text", "TextFieldProperty");
- btnToProperty.Add("CheckBox", "CheckBoxProperty");
- btnToProperty.Add("RadioButton", "RadioButtonProperty");
- btnToProperty.Add("ListBox", "ListBoxProperty");
- btnToProperty.Add("Combox", "ComboxProperty");
- btnToProperty.Add("Button", "ButtonProperty");
- btnToProperty.Add("Sign", "SignProperty");
- }
- /// <summary>
- /// Form
- /// </summary>
- /// <param name="type"></param>
- private void CheckedEvent(string type)
- {
- AddToPropertyPanel(type);
- }
- private void AddToPropertyPanel(string type, WidgetArgs widget = null)
- {
- if (btnToProperty.ContainsKey(type))
- {
- NavigationParameters parameters = new NavigationParameters();
- parameters.Add(ParameterNames.PDFViewer, PDFViewer);
- parameters.Add("WidgetArgs", widget);
- regions.RequestNavigate(RegionNames.PropertyRegionName, btnToProperty[type], parameters);
- ShowPropertyPanel(true);
- }
- }
- #region 获取Form
- private void GetTextField()
- {
-
- }
- private void GetButton()
- {
- }
- private void GeCheckBox()
- {
- }
- private void GetCombox()
- {
- }
- private void GetListBox()
- {
- }
- private void GetRadioButton()
- {
- }
- private void GetSign()
- {
- }
- #endregion
- private void ShowPropertyPanel(bool show = true)
- {
- viewContentViewModel.IsPropertyOpen = show;
- }
- #region 表单内部触发的事件(比如选中表单行为等)
- private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
- {
- }
- #endregion
- #region Navegation
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
-
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel,out viewContentViewModel);
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- BindingFormHandler();
- }
- private void BindingFormHandler()
- {
- if(PDFViewer != null)
- {
- PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
- PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
- }
- }
- #endregion
- }
- }
|