Files
PDFPatcher/App/Functions/Editor/InsertPageLabelForm.cs
T
2021-12-24 20:35:03 +08:00

52 lines
1.4 KiB
C#

using System;
using System.Windows.Forms;
using PDFPatcher.Common;
namespace PDFPatcher.Functions
{
public partial class InsertPageLabelForm : DraggableForm
{
public int PageNumber {
get => _PageNumberBox.Text.ToInt32();
set => _PageNumberBox.Text = value.ToText();
}
internal MuPdfSharp.PageLabel PageLabel => new MuPdfSharp.PageLabel(PageNumber - 1, (int)_StartAtBox.Value, _PrefixBox.Text, (MuPdfSharp.PageLabelStyle)Constants.PageLabelStyles.PdfValues[_NumericStyleBox.SelectedIndex]);
public InsertPageLabelForm () {
InitializeComponent ();
_NumericStyleBox.AddRange (Constants.PageLabelStyles.Names).Select (0);
_RemoveLabelButton.Enabled = false;
}
private void InsertPageLabelForm_Load (object sender, EventArgs e) {
_CancelButton.Click += (s, args) => {
DialogResult = DialogResult.Cancel;
Close ();
};
_OkButton.Click += (s, args) => {
DialogResult = DialogResult.OK;
Close ();
};
_RemoveLabelButton.Click += (s, args) => {
DialogResult = DialogResult.Abort;
Close ();
};
}
internal void SetValues (MuPdfSharp.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 ();
}
}
}