-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.bak
More file actions
375 lines (354 loc) · 22.1 KB
/
MainWindow.xaml.bak
File metadata and controls
375 lines (354 loc) · 22.1 KB
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
<Window x:Class="StickyNote.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StickyNote"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="便签" Height="300" Width="400"
MinHeight="150" MinWidth="100"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
ResizeMode="CanResize"
Icon="{StaticResource AppIconImage}">
<Window.InputBindings>
<KeyBinding Command="{x:Static local:MainWindow.NewCmd}" Key="N" Modifiers="Control"/>
<KeyBinding Command="{x:Static local:MainWindow.DeleteCmd}" Key="D" Modifiers="Control"/>
<KeyBinding Command="{x:Static local:MainWindow.ToggleTopmostCmd}" Key="T" Modifiers="Control"/>
<KeyBinding Command="{x:Static local:MainWindow.CloseCmd}" Key="W" Modifiers="Control"/>
<KeyBinding Command="{x:Static local:MainWindow.ExportCmd}" Key="E" Modifiers="Control"/>
<KeyBinding Command="{x:Static local:MainWindow.InsertSeparatorCmd}" Key="Enter" Modifiers="Control"/>
</Window.InputBindings>
<!-- 使用 WindowChrome 实现现代化的无边框缩放 (替代 ResizeGrip) -->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="5" GlassFrameThickness="0" CornerRadius="0"/>
</WindowChrome.WindowChrome>
<Window.Resources>
<!-- 牛皮纸底色与横线合成画刷 -->
<DrawingBrush x:Key="LinedPaperBrush" Viewport="0,0,1,30" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="#E8D096">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,100,30" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Pen>
<Pen Brush="#BFA870" Thickness="1" />
</GeometryDrawing.Pen>
<GeometryDrawing.Geometry>
<LineGeometry StartPoint="0,29" EndPoint="100,29" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<!-- 2. 按钮样式 -->
<Style TargetType="Button" x:Key="IconBtnStyle">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 3. 图钉(置顶)样式 -->
<Style TargetType="ToggleButton" x:Key="PinToggleStyle">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid Background="Transparent">
<!-- 图钉图标 -->
<Path x:Name="PinPath"
Data="M12,2 L12,10 L18,16 L18,18 L11,18 L11,23 L9,23 L9,18 L2,18 L2,16 L8,10 L8,2 Z"
Fill="#5D4037" Stretch="Uniform" Width="14" Height="14" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<RotateTransform Angle="45"/>
<!-- 默认倾斜 -->
</Path.RenderTransform>
</Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="PinPath" Property="Fill" Value="#3E2723"/>
<Setter TargetName="PinPath" Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="0"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="PinPath" Property="Width" Value="16"/>
<Setter TargetName="PinPath" Property="Height" Value="16"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="PinPath" Property="Width" Value="13"/>
<Setter TargetName="PinPath" Property="Height" Value="13"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<!-- 主背景层:颜色由此 Border 控制 -->
<Border x:Name="MainBorder"
CornerRadius="2"
BorderThickness="1"
BorderBrush="#805D4037"
Background="Transparent">
<!-- 默认牛皮纸色 -->
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="10" ShadowDepth="3" Opacity="0.3"/>
</Border.Effect>
<Border.CacheMode>
<BitmapCache/>
</Border.CacheMode>
<!-- 右键菜单 -->
<Border.ContextMenu>
<ContextMenu>
<MenuItem Header="新建便签 (Ctrl+N)" Click="NewNote_Click"/>
<Separator/>
<MenuItem Header="纸张颜色">
<MenuItem Header="经典牛皮纸" Click="ChangeColor_Click" Tag="#E3C887"/>
<MenuItem Header="樱花粉" Click="ChangeColor_Click" Tag="#FFCDD2"/>
<MenuItem Header="天空蓝" Click="ChangeColor_Click" Tag="#B3E5FC"/>
<MenuItem Header="护眼绿" Click="ChangeColor_Click" Tag="#DCEDC8"/>
<MenuItem Header="极简白" Click="ChangeColor_Click" Tag="#FFF9C4"/>
<Separator/>
<MenuItem Header="深灰" Click="ChangeColor_Click" Tag="#424242"/>
<MenuItem Header="木炭黑" Click="ChangeColor_Click" Tag="#263238"/>
<MenuItem Header="橄榄绿" Click="ChangeColor_Click" Tag="#3D5B3D"/>
</MenuItem>
<MenuItem Header="透明度">
<MenuItem Header="100%" Click="ChangeOpacity_Click" Tag="1.0"/>
<MenuItem Header="80%" Click="ChangeOpacity_Click" Tag="0.8"/>
<MenuItem Header="50%" Click="ChangeOpacity_Click" Tag="0.5"/>
</MenuItem>
<MenuItem Header="搜索便签" Click="Search_Click"/>
<Separator/>
<MenuItem Header="复制 (Ctrl+C)" Click="Copy_Click"/>
<MenuItem Header="粘贴 (Ctrl+V)" Click="Paste_Click"/>
<MenuItem Header="全选 (Ctrl+A)" Click="SelectAll_Click"/>
<MenuItem Header="导出为文本 (Ctrl+E)" Click="Export_Click"/>
<MenuItem Header="锁定内容" Click="ToggleLock_Click" IsCheckable="True"/>
<Separator/>
<MenuItem Header="清空内容" Click="Clear_Click"/>
<MenuItem Header="删除此便签 (Ctrl+D)" Click="DeleteNote_Click" Foreground="Red"/>
<Separator/>
<MenuItem Header="关于 StickyNote v1.4.0" Click="About_Click"/>
</ContextMenu>
</Border.ContextMenu>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" MinWidth="50" MaxWidth="300"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 左侧标签栏 -->
<Grid Grid.Column="0" Background="#10000000">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListBox x:Name="TabList" Grid.Row="0"
Background="Transparent" BorderThickness="0"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionChanged="TabList_SelectionChanged"
PreviewMouseLeftButtonUp="TabList_PreviewMouseLeftButtonUp"
MouseDoubleClick="TabList_MouseDoubleClick">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,1">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="重命名" Click="RenameTab_Click" />
<MenuItem Header="删除" Click="DeleteTab_Click" Foreground="Red" />
</ContextMenu>
</Grid.ContextMenu>
<StackPanel>
<TextBlock Text="{Binding Title}" FontWeight="Bold" Foreground="#3E2723" TextTrimming="CharacterEllipsis"/>
<TextBlock Text="{Binding Preview}" FontSize="10" Foreground="#5D4037" Opacity="0.7" TextTrimming="CharacterEllipsis" MaxHeight="30"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" CornerRadius="2">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Bd" Property="Background" Value="#405D4037"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Bd" Property="Background" Value="#205D4037"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Button Grid.Row="1" Content="+ 新建便签" Click="AddTab_Click" Height="30" Margin="5" Style="{StaticResource IconBtnStyle}" Foreground="#5D4037" FontWeight="Bold"/>
</Grid>
<!-- 分割线 -->
<GridSplitter Grid.Column="1" Width="2" HorizontalAlignment="Center" VerticalAlignment="Stretch" Background="#405D4037"/>
<!-- 横线层:使用合成画刷包含底色与横线 -->
<Grid x:Name="LinesGrid" Grid.Column="2" Background="{StaticResource LinedPaperBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 1. 标题栏 -->
<DockPanel Grid.Row="0" Background="Transparent">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
<Button Style="{StaticResource IconBtnStyle}" Width="30" Click="NewNote_Click" ToolTip="新建">
<TextBlock Text="+" FontSize="20" FontWeight="Bold" Foreground="#5D4037" Margin="0,-2,0,0"/>
</Button>
<Button x:Name="PaletteBtn" Style="{StaticResource IconBtnStyle}" Width="30" Click="PaletteButton_Click" ToolTip="更改颜色">
<TextBlock Text="🎨" FontSize="16" Foreground="#5D4037"/>
</Button>
</StackPanel>
<!-- 右侧功能区 -->
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
<ToggleButton x:Name="btnTopmost" Style="{StaticResource PinToggleStyle}" Width="30" Click="PinButton_Click" ToolTip="置顶"/>
<Button Style="{StaticResource IconBtnStyle}" Width="30" Click="Minimize_Click" ToolTip="最小化">
<Path Data="M2,8 L12,8" Stroke="#5D4037" StrokeThickness="1.5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button>
<Button x:Name="btnMaximize" Style="{StaticResource IconBtnStyle}" Width="30" Click="Maximize_Click" ToolTip="最大化">
<Path x:Name="pathMaximize" Data="M2,2 L12,2 L12,12 L2,12 Z" Stroke="#5D4037" StrokeThickness="1.5" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="Transparent"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="30" Click="CloseButton_Click" ToolTip="关闭">
<Path Data="M0,0 L10,10 M0,10 L10,0" Stroke="#5D4037" StrokeThickness="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Button>
</StackPanel>
<!-- 拖动区域 (WindowChrome 会自动处理,只需透明背景) -->
<Border Background="Transparent"/>
<TextBlock x:Name="StatusText" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#5D4037" Opacity="0" FontSize="12"/>
</DockPanel>
<!-- 2. 内容输入区 -->
<TextBlock x:Name="EmptyStateText" Grid.Row="1"
Text="点击左下角 + 新建便签"
HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="#5D4037" Opacity="0.5" FontSize="16"
Visibility="Collapsed" IsHitTestVisible="False"/>
<RichTextBox x:Name="rtbContent"
Grid.Row="1"
UndoLimit="50"
Background="Transparent"
BorderThickness="0"
FontFamily="Microsoft YaHei"
Foreground="#3E2723"
Padding="10,2,10,10"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Auto"
TextChanged="RtbContent_TextChanged"
PreviewMouseLeftButtonUp="RtbContent_PreviewMouseLeftButtonUp">
<RichTextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="设为待办" Click="BatchSetTodo_Click"/>
<MenuItem Header="取消待办" Click="BatchUnsetTodo_Click"/>
<Separator/>
<MenuItem Header="标记完成" Click="BatchCheckTodo_Click"/>
<MenuItem Header="取消完成" Click="BatchUncheckTodo_Click"/>
<Separator/>
<MenuItem Header="添加编号">
<MenuItem Header="1. 内容" Click="BatchNumbering_Click" Tag="1."/>
<MenuItem Header="1) 内容" Click="BatchNumbering_Click" Tag="1)"/>
<MenuItem Header="① 内容" Click="BatchNumbering_Click" Tag="①"/>
<MenuItem Header="A. 内容" Click="BatchNumbering_Click" Tag="A."/>
<Separator/>
<MenuItem Header="取消编号" Click="BatchRemoveNumbering_Click"/>
</MenuItem>
<Separator/>
<MenuItem Header="剪切" Command="Cut"/>
<MenuItem Header="复制" Command="Copy"/>
<MenuItem Header="粘贴" Command="Paste"/>
</ContextMenu>
</RichTextBox.ContextMenu>
<RichTextBox.Resources>
<Style TargetType="Paragraph">
<Setter Property="Margin" Value="0"/>
<Setter Property="LineHeight" Value="30"/>
<Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>
</Style>
</RichTextBox.Resources>
<RichTextBox.Template>
<ControlTemplate TargetType="RichTextBox">
<Border Background="{TemplateBinding Background}" BorderThickness="0">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</RichTextBox.Template>
</RichTextBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="6,0,0,6" Background="#20FFFFFF">
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="FontInc_Click" ToolTip="增大字号">
<TextBlock Text="A" FontSize="16" FontWeight="Bold" Foreground="#5D4037"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="FontDec_Click" ToolTip="减小字号">
<TextBlock Text="A" FontSize="12" Foreground="#5D4037"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="ToggleBold_Click" ToolTip="加粗">
<TextBlock Text="B" FontSize="14" FontWeight="Bold" Foreground="#5D4037"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="ToggleItalic_Click" ToolTip="斜体">
<TextBlock Text="/" FontSize="14" FontStyle="Italic" Foreground="#5D4037"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="ToggleUnderline_Click" ToolTip="下划线">
<TextBlock Text="U" FontSize="14" TextDecorations="Underline" Foreground="#5D4037"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="ToggleStrikethrough_Click" ToolTip="删除线">
<TextBlock Text="abc" FontSize="14" Foreground="#5D4037" TextDecorations="Strikethrough"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="AlignLeft_Click" ToolTip="左对齐">
<Path Data="M0,3 L14,3 M0,7 L10,7 M0,11 L14,11" Stroke="#5D4037" StrokeThickness="2"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="AlignCenter_Click" ToolTip="居中">
<Path Data="M2,3 L12,3 M0,7 L14,7 M2,11 L12,11" Stroke="#5D4037" StrokeThickness="2"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="26" Click="AlignRight_Click" ToolTip="右对齐">
<Path Data="M0,3 L14,3 M4,7 L14,7 M0,11 L14,11" Stroke="#5D4037" StrokeThickness="2"/>
</Button>
<Button Style="{StaticResource IconBtnStyle}" Width="28" Click="AddTodo_Click" ToolTip="添加代办事项">
<Path Data="M0,0 L14,0 L14,14 L0,14 Z" Stroke="#5D4037" StrokeThickness="2" Fill="Transparent"/>
</Button>
</StackPanel>
<!-- 3. 自定义右下角 Resize Grip (装饰用,实际缩放由WindowChrome处理) -->
<Path Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Data="M 0,12 L 12,12 L 12,0 Z" Fill="#405D4037" Margin="0,0,2,2" IsHitTestVisible="False"/>
</Grid>
</Grid>
</Border>
</Window>