-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
774 lines (638 loc) · 25.9 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Linq;
namespace PenTabletNotebook {
public partial class MainWindow : Window, IHitObjectMoved {
private void LocalizeUI() {
mMenuItemFile.Header = Properties.Resources.File;
mMenuItemFileNew.Header = Properties.Resources.FileNew;
mMenuItemFileOpen.Header = Properties.Resources.FileOpen;
mMenuItemFileAddImg.Header = Properties.Resources.FileAddImg;
mMenuItemFileSave.Header = Properties.Resources.FileSave;
mMenuItemFileSaveAs.Header = Properties.Resources.FileSaveAs;
mMenuItemFileExit.Header = Properties.Resources.FileExit;
mMenuItemEdit.Header = Properties.Resources.Edit;
mMenuItemEditUndo.Header = Properties.Resources.EditUndo;
mMenuItemEditRedo.Header = Properties.Resources.EditRedo;
mGroupBoxSettings.Header = Properties.Resources.Settings;
mGroupBoxPenMode.Header = Properties.Resources.PenMode;
mRBPenEraser.Content = Properties.Resources.PenEraser;
mRBEraser.Content = Properties.Resources.Eraser;
mGroupBoxPenThickness.Header = Properties.Resources.PenThickness;
mGroupBoxColor.Header = Properties.Resources.Color;
mRBCWhite.Content = Properties.Resources.White;
mRBCCyan.Content = Properties.Resources.Cyan;
mRBCMagenta.Content = Properties.Resources.Magenta;
mRBCYellow.Content = Properties.Resources.Yellow;
mRBCRed.Content = Properties.Resources.Red;
mRBCGreen.Content = Properties.Resources.Green;
mRBCBlue.Content = Properties.Resources.Blue;
mRBCBlack.Content = Properties.Resources.Black;
mGroupBoxDisplay.Header = Properties.Resources.Display;
mCBDispDrawings.Content = Properties.Resources.DispDrawings;
mLabelScale.Content = Properties.Resources.Scale + ":";
mButtonScaleToImageW.Content = Properties.Resources.ScaleToImageWidth;
mButtonScaleToFit.Content = Properties.Resources.ScaleToFit;
mGroupBoxPageControl.Header = Properties.Resources.PageControl;
mButtonSetImage.Content = Properties.Resources.SetImage;
mButtonDeletePage.Content = Properties.Resources.DeletePage;
mButtonAddNewPage.Content = Properties.Resources.AddNewPage;
mButtonClearDrawings.Content = Properties.Resources.ClearDrawings;
mGroupBoxPageTags.Header = Properties.Resources.PageTags;
mButtonTagBack.Content = Properties.Resources.BackBeforeJump;
mLabelName.Content = Properties.Resources.Name + ":";
mButtonAddTag.Content = Properties.Resources.NewOrUpdateTag;
mGroupBoxPageNumber.Header = Properties.Resources.PageNumber;
mLabelPage.Content = Properties.Resources.Page + ":";
mButtonPrev.Content = Properties.Resources.Prev;
mButtonNext.Content = Properties.Resources.Next;
mGroupBoxCanvas.Header = Properties.Resources.Canvas;
}
private bool mInitialized = false;
private string DefaultExt = ".ptnb";
private string mSavePath = "";
private PageListMgr mPLMgr;
private int mPageNrBeforeJump = -1;
private static string AssemblyVersion {
get { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
}
private void UpdateWindowTitle() {
var s = string.Format("PenTabletNotebook {0} {1}", AssemblyVersion, mSavePath);
Title = s;
}
private void Undo() {
UpdateUI();
}
private void Redo() {
UpdateUI();
}
private void UpdateUI() {
Console.WriteLine("UpdateUI()");
// ページ番号関連。
mTBPageNr.Text = string.Format("{0}", mPLMgr.CurPageNr + 1);
mLabelTotalPages.Content = string.Format("/ {0}", mPLMgr.PageCount);
System.Diagnostics.Debug.Assert(mPLMgr.CurPageNr < mPLMgr.PageCount);
mButtonNext.IsEnabled = 0 < mPLMgr.PageCount;
mButtonPrev.IsEnabled = 0 < mPLMgr.PageCount;
mSliderPageNr.Maximum = mPLMgr.PageCount - 1;
mSliderPageNr.Value = mPLMgr.CurPageNr;
mButtonTagBack.IsEnabled = 0 <= mPageNrBeforeJump && mPageNrBeforeJump < mPLMgr.PageCount;
// タグに該当ページがあるときタグを選択状態にします。
for (int i=0; i<mLBPageTags.Items.Count; ++i) {
var pt = mLBPageTags.Items[i] as PageTag;
if (pt.PageNr == mPLMgr.CurPageNr) {
mLBPageTags.SelectedIndex = i;
mLBPageTags.ScrollIntoView(pt);
break;
}
}
UpdateWindowTitle();
}
private bool ChangePage(int pageNr) {
if (mPLMgr.CurPageNr == pageNr) {
Console.WriteLine("ChangePage() already shows the page specified : {0}", pageNr);
return false;
}
System.Diagnostics.Debug.Assert(mPLMgr.CurPageNr != pageNr);
Console.WriteLine("ChangePage() from {0} to {1}", mPLMgr.CurPageNr, pageNr);
var dop = mPLMgr.ChangePage(pageNr);
UpdateUI();
return true;
}
private bool OpenFileDialogAndLoad() {
// OpenFileDialogを開いて開くファイル名を取得。
var ofd = new OpenFileDialog();
ofd.DefaultExt = DefaultExt;
ofd.CheckFileExists = true;
var r = ofd.ShowDialog();
if (r != true) {
return false;
}
string path = ofd.FileName;
return LoadSpecifiedFile(path);
}
private bool LoadSpecifiedFile(string path) {
var ptList = new List<PageTag>();
bool result = mPLMgr.Load(path, ref ptList);
if (result) {
// 読み出し成功。
mSavePath = path;
// PageTagリストを更新します。
mLBPageTags.Items.Clear();
foreach (var pt in ptList) {
mLBPageTags.Items.Add(pt);
}
ScaleToFit();
// 現在表示ページ番号の同期等。
UpdateUI();
} else {
// 読み出し失敗。
MessageBox.Show("Error Opening File", "Error opening file", MessageBoxButton.OK, MessageBoxImage.Error);
}
return result;
}
/// <summary>
/// mSavePathのファイルにセーブします。
/// </summary>
private void Save() {
System.Diagnostics.Debug.Assert(0 < mSavePath.Length);
var ptList = new List<PageTag>();
for (int i = 0; i < mLBPageTags.Items.Count; ++i) {
var pt = mLBPageTags.Items[i] as PageTag;
ptList.Add(pt);
}
ptList.Sort(PageTag.Compare);
bool result = mPLMgr.Save(mSavePath, ptList);
if (!result) {
MessageBox.Show("Error Saving File", "Error saving file {0}", MessageBoxButton.OK, MessageBoxImage.Error);
}
UpdateUI();
}
private void SaveAs() {
var sfd = new SaveFileDialog();
sfd.DefaultExt = DefaultExt;
var r = sfd.ShowDialog();
if (r != true) {
return;
}
mSavePath = sfd.FileName;
Save();
}
private void New() {
mPLMgr.ClearAndNewPage();
mImage.Source = null;
mLBPageTags.Items.Clear();
mPageNrBeforeJump = -1;
UpdateUI();
}
private void DeleteCurPage() {
mPLMgr.DeleteCurPage();
// Backボタンで戻るページ番号の更新。
if (0 <= mPageNrBeforeJump && mPLMgr.CurPageNr <= mPageNrBeforeJump) {
--mPageNrBeforeJump;
}
UpdateUI();
}
private void NextPage() {
System.Diagnostics.Debug.Assert(0 < mPLMgr.PageCount);
if (mPLMgr.PageCount == 1) {
return;
}
int newPgNr = mPLMgr.CurPageNr + 1;
if (mPLMgr.PageCount <= newPgNr) {
newPgNr = 0;
}
ChangePage(newPgNr);
}
private void PrevPage() {
System.Diagnostics.Debug.Assert(0 < mPLMgr.PageCount);
if (mPLMgr.PageCount == 1) {
return;
}
int newPgNr = mPLMgr.CurPageNr - 1;
if (newPgNr < 0) {
newPgNr = mPLMgr.PageCount - 1;
}
ChangePage(newPgNr);
}
private void DrawHLines() {
mPLMgr.DrawHLines((int)mSliderHLine.Value, new SolidColorBrush(Colors.Gray), 1.0);
}
private void UndrawHLines() {
mPLMgr.UndrawHLines();
}
private void DrawVLines() {
mPLMgr.DrawVLines((int)mSliderVLine.Value, new SolidColorBrush(Colors.Gray), 1.0);
}
private void UndrawVLines() {
mPLMgr.UndrawVLines();
}
private void ScaleToFit() {
double imageW = mImage.ActualWidth;
if (imageW <= 0) {
imageW = mImage.Width;
}
double imageH = mImage.ActualHeight;
if (imageH <= 0) {
imageH = mImage.Height;
}
double scaleX = mSVCanvas.ViewportWidth / imageW;
double scaleY = mSVCanvas.ViewportHeight / imageH;
if (scaleX < scaleY) {
mSliderScaling.Value = scaleX;
} else {
mSliderScaling.Value = scaleY;
}
}
private void ScaleToImage() {
double imageW = mImage.ActualWidth;
if (imageW <= 0) {
imageW = mImage.Width;
}
double scaleX = mSVCanvas.ViewportWidth / imageW;
mSliderScaling.Value = scaleX;
}
// アプリ起動 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
public MainWindow() {
InitializeComponent();
LocalizeUI();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
// デフォルトのペンの色は赤。ペンの太さ==3。
mPLMgr = new PageListMgr(mInkCanvas, mCanvas, mImage, Colors.Red, 4.0);
mRBCRed.IsChecked = true;
mRBT4.IsChecked = true;
mInitialized = true;
var args = System.Environment.GetCommandLineArgs();
if (1 < args.Length) {
var path = args[1];
if (0 == ".ptnb".CompareTo(System.IO.Path.GetExtension(path))) {
// 第1引数のファイルを開きます。
LoadSpecifiedFile(path);
}
}
UpdateUI();
}
// File menu ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
private void MenuItemFileNew_Click(object sender, RoutedEventArgs e) {
New();
}
private void MenuItemFileOpen_Click(object sender, RoutedEventArgs e) {
// ファイルからロードします。
OpenFileDialogAndLoad();
}
private void MenuItemFileSave_Click(object sender, RoutedEventArgs e) {
if (mSavePath.Length == 0) {
SaveAs();
} else {
Save();
}
}
private void MenuItemFileSaveAs_Click(object sender, RoutedEventArgs e) {
SaveAs();
}
private void MenuItemFileExit_Click(object sender, RoutedEventArgs e) {
Close();
}
// Edit menu ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
private void MenuItemEditUndo_Click(object sender, RoutedEventArgs e) {
Undo();
}
private void MenuItemEditRedo_Click(object sender, RoutedEventArgs e) {
Redo();
}
// Command handlings ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
private void FileNewCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}
private void FileOpenCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}
private void FileSaveCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}
private void FileSaveAsCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}
private void FileExitCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = true;
}
private void EditUndoCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mPLMgr.CanUndo();
}
private void EditRedoCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mPLMgr.CanRedo();
}
// Mouse Events ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
public void HitObjectMoved(Object tag, HitObjectShape hos, Rect xywh) {
Console.WriteLine("HitObjectMoved {0} {1} {2} {3} {4}", tag, xywh.Left, xywh.Top, xywh.Width, xywh.Height);
}
private void RBCWhite_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.White);
}
private void RBCCyan_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Cyan);
}
private void RBCMagenta_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Magenta);
}
private void RBCYellow_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Yellow);
}
private void RBCRed_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Red);
}
private void RBCGreen_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Green);
}
private void RBCBlue_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Blue);
}
private void RBCBlack_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenColor(Colors.Black);
}
private void ButtonUndo_Click(object sender, RoutedEventArgs e) {
Undo();
}
private void ButtonRedo_Click(object sender, RoutedEventArgs e) {
Redo();
}
private void RBSelect_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetPenMode(PenModeEnum.PM_Select);
}
private void RBPen_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetPenMode(PenModeEnum.PM_Pen);
}
private void RBEraser_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetPenMode(PenModeEnum.PM_Eraser);
}
private void MenuItemFileAddImg_Click(object sender, RoutedEventArgs e) {
var ofd = new OpenFileDialog();
ofd.Filter = "Image files (*.BMP;*.JPG;*.PNG;*.TIF)|*.BMP;*.JPG;*.PNG;*.TIF|All files (*.*)|*.*";
ofd.CheckFileExists = true;
ofd.Multiselect = true;
var b = ofd.ShowDialog();
if (b != true) {
return;
}
var fnList = new List<string>();
foreach (var fn in ofd.FileNames) {
fnList.Add(fn);
}
fnList.Sort();
foreach (var fn in fnList) {
// 今の位置の次のページに追加。
var dop = mPLMgr.AddNewPage(mPLMgr.CurPageNr + 1);
dop.ImgFilename = fn;
}
UpdateUI();
}
private void ButtonPrevPage_Click(object sender, RoutedEventArgs e) {
PrevPage();
}
private void ButtonNextPage_Click(object sender, RoutedEventArgs e) {
NextPage();
}
private void TBPageNr_TextChanged(object sender, TextChangedEventArgs e) {
if (!mInitialized) {
return;
}
Console.WriteLine("mTBPageNr_TextChanged()");
if (!int.TryParse(mTBPageNr.Text, out int newPgNr)) {
return;
}
// 画面表示ページ番号は1多いので。
--newPgNr;
if (newPgNr < 0 || mPLMgr.PageCount <= newPgNr) {
// 範囲外の値。入力中かもしれないので無視。
return;
}
ChangePage(newPgNr);
}
private void ButtonSetImage_Click(object sender, RoutedEventArgs e) {
var ofd = new OpenFileDialog();
ofd.Filter = "Image files (*.BMP;*.JPG;*.PNG;*.TIF)|*.BMP;*.JPG;*.PNG;*.TIF|All files (*.*)|*.*";
ofd.CheckFileExists = true;
var b = ofd.ShowDialog();
if (b != true) {
return;
}
mPLMgr.SetImage(ofd.FileName);
}
private void ButtonDeletePage_Click(object sender, RoutedEventArgs e) {
DeleteCurPage();
}
private void CBDispDrawings_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mInkCanvas.Visibility = Visibility.Visible;
}
private void CBDispDrawings_Unchecked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mInkCanvas.Visibility = Visibility.Hidden;
}
private void CBDispHLine_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
DrawHLines();
}
private void CBDispHLine_Unchecked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
UndrawHLines();
}
private void CBDispVLine_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
DrawVLines();
}
private void CBDispVLine_Unchecked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
UndrawVLines();
}
private void ButtonAddNewPage_Click(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.AddNewPage(mPLMgr.CurPageNr + 1);
mPLMgr.ChangePage(mPLMgr.CurPageNr + 1);
UpdateUI();
}
private void ButtonClearDrawings_Click(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mInkCanvas.Strokes.Clear();
UpdateUI();
}
private void SliderPageNr_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
if (!mInitialized) {
return;
}
int newPgNr = (int)mSliderPageNr.Value;
ChangePage(newPgNr);
}
private void ButtonAddTag_Click(object sender, RoutedEventArgs e) {
// タグ名tagNameを決定。
string tagName = "Untitled tag";
if (0 < mTBTagName.Text.Length) {
tagName = mTBTagName.Text;
}
for (int i = mLBPageTags.Items.Count - 1; 0 <= i; --i) {
var pt = mLBPageTags.Items[i] as PageTag;
if (pt.PageNr == mPLMgr.CurPageNr) {
// 同じページのタグが既にあるので削除。
mLBPageTags.Items.RemoveAt(i);
// 処理続行。
}
}
var newPageTag = new PageTag(tagName, mPLMgr.CurPageNr);
bool bAdded = false;
for (int i = mLBPageTags.Items.Count - 1; 0 <= i; --i) {
var pt = mLBPageTags.Items[i] as PageTag;
if (pt.PageNr < mPLMgr.CurPageNr) {
mLBPageTags.Items.Insert(i + 1, newPageTag);
bAdded = true;
mLBPageTags.SelectedIndex = i + 1;
mLBPageTags.ScrollIntoView(mLBPageTags.Items[i + 1]);
break;
}
}
if (!bAdded) {
// リストの先頭に追加します。
mLBPageTags.Items.Insert(0, newPageTag);
mLBPageTags.SelectedIndex = 0;
}
}
private void ButtonTagBack_Click(object sender, RoutedEventArgs e) {
if (mPageNrBeforeJump < 0 || mPLMgr.PageCount <= mPageNrBeforeJump) {
Console.WriteLine("TagBack Invalid pageNr {0}", mPageNrBeforeJump);
return;
}
ChangePage(mPageNrBeforeJump);
mPageNrBeforeJump = -1;
UpdateUI();
}
private void LBPageTags_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (mLBPageTags.SelectedIndex < 0) {
// 何も選択されてない。
return;
}
mPageNrBeforeJump = mPLMgr.CurPageNr;
var tnp = mLBPageTags.SelectedItem as PageTag;
ChangePage(tnp.PageNr);
}
private void LBPageTags_MouseRightButtonUp(object sender, MouseButtonEventArgs e) {
if (0 <= mLBPageTags.SelectedIndex) {
// 選択されたPageTagを削除。
mLBPageTags.Items.RemoveAt(mLBPageTags.SelectedIndex);
}
}
private void Window_KeyUp(object sender, KeyEventArgs e) {
switch (e.Key) {
case Key.PageDown:
NextPage();
e.Handled = true;
break;
case Key.PageUp:
PrevPage();
e.Handled = true;
break;
default:
break;
}
}
private void Window_MouseWheel(object sender, MouseWheelEventArgs e) {
if (0 < e.Delta) {
// 上に回す。
PrevPage();
e.Handled = true;
} else if (e.Delta < 0) {
// 下に回す。
NextPage();
e.Handled = true;
}
}
private void ButtonScaleToFit_Click(object sender, RoutedEventArgs e) {
ScaleToFit();
}
private void ButtonScaleToImageW_Click(object sender, RoutedEventArgs e) {
ScaleToImage();
}
private void RBT1_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(1.0);
}
private void RBT2_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(2.0);
}
private void RBT4_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(4.0);
}
private void RBT6_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(6.0);
}
private void RBT8_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(8.0);
}
private void RBT12_Checked(object sender, RoutedEventArgs e) {
if (!mInitialized) {
return;
}
mPLMgr.SetCurPenThickness(12.0);
}
private void SliderHLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
if (!mInitialized) {
return;
}
DrawHLines();
}
private void SliderVLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
if (!mInitialized) {
return;
}
DrawVLines();
}
}
}