mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-18 13:42:28 +08:00
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using BrightIdeasSoftware;
|
|
using PDFPatcher.Common;
|
|
using BO = PDFPatcher.ToolbarOptions.ButtonOption;
|
|
|
|
namespace PDFPatcher.Functions
|
|
{
|
|
public partial class CustomizeToolbarForm : Form
|
|
{
|
|
public CustomizeToolbarForm() {
|
|
InitializeComponent();
|
|
}
|
|
|
|
void _ResetButton_Click(object sender, EventArgs e) {
|
|
AppContext.Toolbar.Reset();
|
|
_ItemListBox.Objects = AppContext.Toolbar.Buttons;
|
|
}
|
|
|
|
void CustomizeToolbarForm_Load(object sender, EventArgs e) {
|
|
foreach (var item in Toolkit.Toolkits) {
|
|
_ItemListBox.SmallImageList.Images.Add(item.Icon, Properties.Resources.ResourceManager.GetObject(item.Icon) as Image);
|
|
}
|
|
new TypedColumn<BO>(_NameColumn) {
|
|
AspectGetter = (o) => o.GetToolkit().Name,
|
|
ImageGetter = (o) => o.GetToolkit().Icon
|
|
};
|
|
new TypedColumn<BO>(_ShowTextColumn) {
|
|
AspectGetter = (o) => o.ShowText,
|
|
AspectPutter = (o, v) => o.ShowText = (bool)v
|
|
};
|
|
new TypedColumn<BO>(_VisibleColumn) {
|
|
AspectGetter = (o) => o.Visible,
|
|
AspectPutter = (o, v) => o.Visible = (bool)v
|
|
};
|
|
new TypedColumn<BO>(_DisplayTextColumn) {
|
|
AspectGetter = (o) => o.DisplayName,
|
|
AspectPutter = (o, v) => o.DisplayName = v as string ?? o.GetToolkit().Name,
|
|
};
|
|
AppContext.Toolbar.AddMissedButtons();
|
|
_ItemListBox.IsSimpleDragSource = true;
|
|
_ItemListBox.IsSimpleDropSink = true;
|
|
_ItemListBox.DragSource = new SimpleDragSource(true);
|
|
_ItemListBox.DropSink = new RearrangingDropSink(false) {
|
|
CanDropBetween = true,
|
|
CanDropOnItem = false
|
|
};
|
|
_ItemListBox.Objects = AppContext.Toolbar.Buttons;
|
|
_ItemListBox.FixEditControlWidth();
|
|
_ItemListBox.ScaleColumnWidths();
|
|
}
|
|
|
|
void _OkButton_Click(object sender, EventArgs e) {
|
|
var l = new List<BO>();
|
|
foreach (BO item in _ItemListBox.Objects) {
|
|
l.Add(item);
|
|
}
|
|
AppContext.Toolbar.Buttons.Clear();
|
|
AppContext.Toolbar.Buttons.AddRange(l);
|
|
Close();
|
|
}
|
|
}
|
|
}
|