Skip to content

Commit 8d72b54

Browse files
committed
Added Vertical Line checkbox
1 parent b20ba23 commit 8d72b54

File tree

5 files changed

+96
-30
lines changed

5 files changed

+96
-30
lines changed

MainWindow.xaml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<RowDefinition Height="60" />
6060
<RowDefinition Height="80" />
6161
<RowDefinition Height="100"/>
62-
<RowDefinition Height="145" />
62+
<RowDefinition Height="195" />
6363
<RowDefinition Height="118" />
6464
<RowDefinition Height="1*" />
6565
</Grid.RowDefinitions>
@@ -117,23 +117,26 @@
117117
<GroupBox x:Name="mGroupBoxDisplay" Grid.Row="3" Header="Display" >
118118
<Grid>
119119
<Grid.ColumnDefinitions>
120-
<ColumnDefinition Width="4*" />
121-
<ColumnDefinition Width="9*" />
120+
<ColumnDefinition Width="2*" />
121+
<ColumnDefinition Width="3*" />
122122
</Grid.ColumnDefinitions>
123123
<Grid.RowDefinitions>
124124
<RowDefinition Height="1*" />
125125
<RowDefinition Height="1*" />
126126
<RowDefinition Height="1*" />
127127
<RowDefinition Height="1*" />
128128
<RowDefinition Height="1*" />
129+
<RowDefinition Height="1*" />
129130
</Grid.RowDefinitions>
130-
<CheckBox x:Name="mCBDispLine" Grid.Row="0" Margin="4,0,0,0" VerticalAlignment="Center" Content="Line" IsChecked="False" Checked="CBDispLine_Checked" Unchecked="CBDispLine_Unchecked" />
131-
<Slider Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Name="mSliderLine" Margin="0,0,4,0" Maximum="25" Value="14" Minimum="12" SmallChange="1" LargeChange="2" TickPlacement="Both" ValueChanged="mSliderLine_ValueChanged" />
132-
<CheckBox x:Name="mCBDispDrawings" Grid.Row="1" Grid.ColumnSpan="2" Margin="4,0,0,0" VerticalAlignment="Center" Content="Display Drawings" IsChecked="True" Checked="CBDispDrawings_Checked" Unchecked="CBDispDrawings_Unchecked" />
133-
<Label x:Name="mLabelScale" Content="Scale:" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" />
134-
<Slider Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Name="mSliderScaling" Margin="0,0,4,0" Maximum="2.0" Value="0.5" Minimum="0.25" Ticks="0.25 0.375 0.5 0.625 0.75 0.875 1.0 1.25 1.5 1.75 2.0" SmallChange="0.125" LargeChange="0.125" TickFrequency="0.125" TickPlacement="Both" IsMoveToPointEnabled="True" />
135-
<Button Grid.Row="3" Grid.ColumnSpan="2" x:Name="mButtonScaleToImageW" Margin="4,0,4,0" Content="Scale to Image Width" VerticalAlignment="Center" Click="ButtonScaleToImageW_Click" />
136-
<Button Grid.Row="4" Grid.ColumnSpan="2" x:Name="mButtonScaleToFit" Margin="4,0,4,0" Content="Scale to Fit" VerticalAlignment="Center" Click="ButtonScaleToFit_Click" />
131+
<CheckBox x:Name="mCBDispHLine" Grid.Row="0" Margin="4,0,0,0" VerticalAlignment="Center" Content="H.Line" IsChecked="False" Checked="CBDispHLine_Checked" Unchecked="CBDispHLine_Unchecked" />
132+
<Slider Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Name="mSliderHLine" Margin="0,0,4,0" Maximum="25" Value="14" Minimum="12" SmallChange="1" LargeChange="2" TickPlacement="Both" ValueChanged="SliderHLine_ValueChanged" />
133+
<CheckBox x:Name="mCBDispVLine" Grid.Row="1" Margin="4,0,0,0" VerticalAlignment="Center" Content="V.Line" IsChecked="False" Checked="CBDispVLine_Checked" Unchecked="CBDispVLine_Unchecked" />
134+
<Slider Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Name="mSliderVLine" Margin="0,0,4,0" Maximum="10" Value="5" Minimum="2" SmallChange="1" LargeChange="2" TickPlacement="Both" ValueChanged="SliderVLine_ValueChanged" />
135+
<CheckBox x:Name="mCBDispDrawings" Grid.Row="2" Grid.ColumnSpan="2" Margin="4,0,0,0" VerticalAlignment="Center" Content="Display Drawings" IsChecked="True" Checked="CBDispDrawings_Checked" Unchecked="CBDispDrawings_Unchecked" />
136+
<Label x:Name="mLabelScale" Content="Scale:" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" />
137+
<Slider Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" Name="mSliderScaling" Margin="0,0,4,0" Maximum="2.0" Value="0.5" Minimum="0.25" Ticks="0.25 0.375 0.5 0.625 0.75 0.875 1.0 1.25 1.5 1.75 2.0" SmallChange="0.125" LargeChange="0.125" TickFrequency="0.125" TickPlacement="Both" IsMoveToPointEnabled="True" />
138+
<Button Grid.Row="4" Grid.ColumnSpan="2" x:Name="mButtonScaleToImageW" Margin="4,0,4,0" Content="Scale to Image Width" VerticalAlignment="Center" Click="ButtonScaleToImageW_Click" />
139+
<Button Grid.Row="5" Grid.ColumnSpan="2" x:Name="mButtonScaleToFit" Margin="4,0,4,0" Content="Scale to Fit" VerticalAlignment="Center" Click="ButtonScaleToFit_Click" />
137140
</Grid>
138141
</GroupBox>
139142
<GroupBox x:Name="mGroupBoxPageControl" Grid.Row="4" Header="Page Control" >

MainWindow.xaml.cs

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,20 @@ private void PrevPage() {
247247
ChangePage(newPgNr);
248248
}
249249

250-
private void DrawLines() {
251-
mPLMgr.DrawLines((int)mSliderLine.Value, new SolidColorBrush(Colors.Gray), 1.0);
250+
private void DrawHLines() {
251+
mPLMgr.DrawHLines((int)mSliderHLine.Value, new SolidColorBrush(Colors.Gray), 1.0);
252252
}
253253

254-
private void UndrawLines() {
255-
mPLMgr.UndrawLines();
254+
private void UndrawHLines() {
255+
mPLMgr.UndrawHLines();
256+
}
257+
258+
private void DrawVLines() {
259+
mPLMgr.DrawVLines((int)mSliderVLine.Value, new SolidColorBrush(Colors.Gray), 1.0);
260+
}
261+
262+
private void UndrawVLines() {
263+
mPLMgr.UndrawVLines();
256264
}
257265

258266
private void ScaleToFit() {
@@ -553,18 +561,32 @@ private void CBDispDrawings_Unchecked(object sender, RoutedEventArgs e) {
553561
}
554562

555563

556-
private void CBDispLine_Checked(object sender, RoutedEventArgs e) {
564+
private void CBDispHLine_Checked(object sender, RoutedEventArgs e) {
565+
if (!mInitialized) {
566+
return;
567+
}
568+
DrawHLines();
569+
}
570+
571+
private void CBDispHLine_Unchecked(object sender, RoutedEventArgs e) {
572+
if (!mInitialized) {
573+
return;
574+
}
575+
UndrawHLines();
576+
}
577+
578+
private void CBDispVLine_Checked(object sender, RoutedEventArgs e) {
557579
if (!mInitialized) {
558580
return;
559581
}
560-
DrawLines();
582+
DrawVLines();
561583
}
562584

563-
private void CBDispLine_Unchecked(object sender, RoutedEventArgs e) {
585+
private void CBDispVLine_Unchecked(object sender, RoutedEventArgs e) {
564586
if (!mInitialized) {
565587
return;
566588
}
567-
UndrawLines();
589+
UndrawVLines();
568590
}
569591

570592
private void ButtonAddNewPage_Click(object sender, RoutedEventArgs e) {
@@ -620,12 +642,15 @@ private void ButtonAddTag_Click(object sender, RoutedEventArgs e) {
620642
if (pt.PageNr < mPLMgr.CurPageNr) {
621643
mLBPageTags.Items.Insert(i + 1, newPageTag);
622644
bAdded = true;
645+
mLBPageTags.SelectedIndex = i + 1;
646+
mLBPageTags.ScrollIntoView(mLBPageTags.Items[i + 1]);
623647
break;
624648
}
625649
}
626650
if (!bAdded) {
627651
// リストの先頭に追加します。
628652
mLBPageTags.Items.Insert(0, newPageTag);
653+
mLBPageTags.SelectedIndex = 0;
629654
}
630655
}
631656

@@ -733,11 +758,17 @@ private void RBT12_Checked(object sender, RoutedEventArgs e) {
733758
mPLMgr.SetCurPenThickness(12.0);
734759
}
735760

736-
private void mSliderLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
761+
private void SliderHLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
762+
if (!mInitialized) {
763+
return;
764+
}
765+
DrawHLines();
766+
}
767+
private void SliderVLine_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
737768
if (!mInitialized) {
738769
return;
739770
}
740-
DrawLines();
771+
DrawVLines();
741772
}
742773
}
743774
}

PageListMgr.cs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class PageListMgr {
1616
private Canvas mCanvas;
1717
private Image mImage;
1818

19-
private List<System.Windows.Shapes.Line> mLineList = new List<System.Windows.Shapes.Line>();
19+
private List<System.Windows.Shapes.Line> mHLineList = new List<System.Windows.Shapes.Line>();
20+
private List<System.Windows.Shapes.Line> mVLineList = new List<System.Windows.Shapes.Line>();
2021

2122
/// <summary>
2223
/// 0で始まる番号のページ番号。
@@ -261,8 +262,8 @@ public void SetPenMode(PenModeEnum pm) {
261262
}
262263
}
263264

264-
public void DrawLines(int nLines, Brush brush, double thickness) {
265-
UndrawLines();
265+
public void DrawHLines(int nLines, Brush brush, double thickness) {
266+
UndrawHLines();
266267

267268
double W = 2048.0;
268269
double H = 2048.0;
@@ -279,16 +280,46 @@ public void DrawLines(int nLines, Brush brush, double thickness) {
279280
Canvas.SetLeft(l, 0);
280281
Canvas.SetTop(l, 0);
281282

282-
mLineList.Add(l);
283+
mHLineList.Add(l);
283284
}
284285
}
285286

286-
public void UndrawLines() {
287-
for (int i=mLineList.Count-1; 0<=i;--i) {
288-
var l = mLineList[i];
287+
public void UndrawHLines() {
288+
for (int i=mHLineList.Count-1; 0<=i;--i) {
289+
var l = mHLineList[i];
289290
mCanvas.Children.Remove(l);
290291
}
291-
mLineList.Clear();
292+
mHLineList.Clear();
293+
}
294+
295+
public void DrawVLines(int nLines, Brush brush, double thickness) {
296+
UndrawVLines();
297+
298+
double W = 2048.0;
299+
double H = 2048.0;
300+
for (int i = 1; i <= nLines * 3; ++i) {
301+
double x = W * i / nLines;
302+
var l = new System.Windows.Shapes.Line();
303+
l.X1 = x;
304+
l.X2 = x;
305+
l.Y1 = 0;
306+
l.Y2 = H * 2;
307+
l.Stroke = brush;
308+
l.StrokeThickness = thickness;
309+
mCanvas.Children.Add(l);
310+
Canvas.SetLeft(l, 0);
311+
Canvas.SetTop(l, 0);
312+
313+
mVLineList.Add(l);
314+
}
315+
}
316+
317+
public void UndrawVLines() {
318+
for (int i = mVLineList.Count - 1; 0 <= i; --i) {
319+
var l = mVLineList[i];
320+
mCanvas.Children.Remove(l);
321+
}
322+
mHLineList.Clear();
292323
}
293324
}
294325
}

PenTabletNotebook.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<Generator>SettingsSingleFileGenerator</Generator>
125125
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
126126
</None>
127+
<None Include="README.md" />
127128
</ItemGroup>
128129
<ItemGroup>
129130
<None Include="App.config" />

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.3.0.0")]
55-
[assembly: AssemblyFileVersion("1.3.0.0")]
54+
[assembly: AssemblyVersion("1.4.0.0")]
55+
[assembly: AssemblyFileVersion("1.4.0.0")]

0 commit comments

Comments
 (0)