mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-18 13:42:28 +08:00
5632c1b5d1
!重构代码,提取插入页码标签指令
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using PDFPatcher.Common;
|
|
|
|
namespace PDFPatcher.Functions.Editor
|
|
{
|
|
sealed partial class InsertPageLabelForm : DraggableForm
|
|
{
|
|
public int PageNumber {
|
|
get => _PageNumberBox.Text.ToInt32();
|
|
set => _PageNumberBox.Text = value.ToText();
|
|
}
|
|
|
|
internal MuPDF.PageLabel PageLabel => new MuPDF.PageLabel(PageNumber - 1, (int)_StartAtBox.Value, _PrefixBox.Text, (MuPDF.PageLabelStyle)Constants.PageLabelStyles.PdfValues[_NumericStyleBox.SelectedIndex]);
|
|
|
|
internal EditModel Model { get; set; }
|
|
internal ViewerControl Viewer { get; set; }
|
|
|
|
public InsertPageLabelForm() {
|
|
InitializeComponent();
|
|
this.OnFirstLoad(OnLoad);
|
|
}
|
|
|
|
void OnLoad() {
|
|
_NumericStyleBox.AddRange(Constants.PageLabelStyles.Names).Select(0);
|
|
_RemoveLabelButton.Enabled = false;
|
|
_CancelButton.Click += HandleCommandButtonClick;
|
|
_OkButton.Click += HandleCommandButtonClick;
|
|
_RemoveLabelButton.Click += HandleCommandButtonClick;
|
|
}
|
|
|
|
protected override void OnFormClosed(FormClosedEventArgs e) {
|
|
base.OnFormClosed(e);
|
|
Model = null;
|
|
Viewer = null;
|
|
}
|
|
|
|
void HandleCommandButtonClick(object sender, EventArgs e) {
|
|
DialogResult = sender == _CancelButton ? DialogResult.Cancel
|
|
: sender == _OkButton ? DialogResult.OK
|
|
: sender == _RemoveLabelButton ? DialogResult.Abort
|
|
: DialogResult.None;
|
|
Close();
|
|
}
|
|
|
|
internal void SetValues(MuPDF.PageLabel label) {
|
|
var s = Array.IndexOf(Constants.PageLabelStyles.PdfValues, (char)label.NumericStyle);
|
|
_NumericStyleBox.Select(s);
|
|
_PrefixBox.Text = label.Prefix;
|
|
_StartAtBox.SetValue(label.StartAt);
|
|
_RemoveLabelButton.Enabled = true;
|
|
}
|
|
|
|
protected override void OnDeactivate(EventArgs e) {
|
|
base.OnDeactivate(e);
|
|
Close();
|
|
}
|
|
|
|
}
|
|
}
|