Skip to content

Commit c016245

Browse files
committed
白板
1 parent f6d8706 commit c016245

5 files changed

Lines changed: 243 additions & 385 deletions

File tree

Ink Canvas/Controls/Toolbar/BoardToolbar/BoardToolbarRegistry.cs

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Ink_Canvas.Controls;
22
using Ink_Canvas.Helpers;
3+
using Ink_Canvas.Properties;
34
using Newtonsoft.Json;
45
using System;
56
using System.Collections.Generic;
@@ -70,7 +71,7 @@ public static FrameworkElement BuildView(string id, IBoardToolbarHost host)
7071
}
7172
}
7273

73-
public static List<FrameworkElement> BuildGroup(IBoardToolbarHost host, List<BoardToolbarComponentEntry> components)
74+
public static List<FrameworkElement> BuildGroup(IBoardToolbarHost host, List<BoardToolbarComponentEntry> components, string areaId = null)
7475
{
7576
var views = new List<FrameworkElement>();
7677
var items = Discover();
@@ -82,7 +83,7 @@ public static List<FrameworkElement> BuildGroup(IBoardToolbarHost host, List<Boa
8283

8384
if (entry.Id == "board.pageInfo")
8485
{
85-
var pageInfoView = BuildPageInfoView(host);
86+
var pageInfoView = BuildPageInfoView(host, areaId);
8687
if (pageInfoView != null)
8788
{
8889
views.Add(pageInfoView);
@@ -105,6 +106,8 @@ public static List<FrameworkElement> BuildGroup(IBoardToolbarHost host, List<Boa
105106
item.ApplyPosition(view, position);
106107
ApplyComponentSettings(view, entry);
107108
host.RegisterView(entry.Id, view);
109+
if (areaId != null)
110+
host.RegisterView($"{entry.Id}.{areaId}", view);
108111
views.Add(view);
109112
}
110113
}
@@ -117,29 +120,44 @@ public static List<FrameworkElement> BuildGroup(IBoardToolbarHost host, List<Boa
117120
return views;
118121
}
119122

120-
private static FrameworkElement BuildPageInfoView(IBoardToolbarHost host)
123+
private static FrameworkElement BuildPageInfoView(IBoardToolbarHost host, string areaId)
121124
{
122125
var pageInfoTextBlock = new TextBlock
123126
{
124127
Text = "1/1",
128+
HorizontalAlignment = HorizontalAlignment.Center,
129+
Margin = new Thickness(0, -1, 0, 0),
130+
FontSize = 17,
131+
FontWeight = FontWeights.Bold,
132+
TextAlignment = TextAlignment.Center
133+
};
134+
host.RegisterView($"board.pageInfo.{areaId}", pageInfoTextBlock);
135+
136+
var pageLabel = new TextBlock
137+
{
138+
Text = FloatingBarStrings.Board_Page,
125139
Foreground = (Brush)Application.Current.TryFindResource("FloatBarForeground"),
126-
VerticalAlignment = VerticalAlignment.Center,
140+
VerticalAlignment = VerticalAlignment.Bottom,
127141
HorizontalAlignment = HorizontalAlignment.Center,
128-
FontSize = 14
142+
FontSize = 12
129143
};
130-
host.RegisterView("board.pageInfo", pageInfoTextBlock);
144+
145+
var grid = new Grid { Margin = new Thickness(6, 6, 6, 4) };
146+
grid.Children.Add(pageInfoTextBlock);
147+
grid.Children.Add(pageLabel);
131148

132149
var pageInfoBorder = new Border
133150
{
134-
CornerRadius = new CornerRadius(2),
135-
Margin = new Thickness(2, 0, 2, 0),
136-
Padding = new Thickness(6, 0, 6, 0),
137-
Child = pageInfoTextBlock,
138-
Cursor = System.Windows.Input.Cursors.Hand,
139-
Background = Brushes.Transparent,
140-
VerticalAlignment = VerticalAlignment.Stretch
151+
Width = 75,
152+
Height = 50,
153+
BorderThickness = new Thickness(1),
154+
BorderBrush = (Brush)Application.Current.TryFindResource("BoardFloatBarBorderBrush"),
155+
Background = (Brush)Application.Current.TryFindResource("BoardFloatBarBackground"),
156+
Opacity = 1,
157+
Child = grid,
158+
Cursor = System.Windows.Input.Cursors.Hand
141159
};
142-
host.RegisterView("board.pageList.rightBtn", pageInfoBorder);
160+
host.RegisterView($"board.pageList.{areaId}Btn", pageInfoBorder);
143161
return pageInfoBorder;
144162
}
145163

@@ -202,7 +220,7 @@ public static Border CreateGroupBorder(List<FrameworkElement> views, Orientation
202220
{
203221
CornerRadius = new CornerRadius(5, 5, 5, 5),
204222
Background = (Brush)Application.Current.TryFindResource("BoardFloatBarBackground"),
205-
Margin = new Thickness(0, 0, 5, 0),
223+
Margin = new Thickness(0),
206224
Child = panel
207225
};
208226

@@ -375,7 +393,7 @@ private static void RebuildArea(IBoardToolbarHost host, Panel container, BoardTo
375393

376394
foreach (var group in area.Groups)
377395
{
378-
var views = BuildGroup(host, group.Components);
396+
var views = BuildGroup(host, group.Components, area.Id);
379397
if (views.Count > 0)
380398
{
381399
container.Children.Add(CreateGroupBorder(views));

Ink Canvas/Controls/Toolbar/BoardToolbar/WhiteboardPageManager.cs

Lines changed: 0 additions & 161 deletions
This file was deleted.

Ink Canvas/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
Stretch="None">
634634
<Grid Name="BlackboardLeftSide" Visibility="Collapsed" d:Visibility="Visible" Margin="0,0,0,3" Height="50"
635635
HorizontalAlignment="Center" VerticalAlignment="Bottom">
636-
<ikw:SimpleStackPanel x:Name="BlackboardLeftSidePanel" Orientation="Horizontal" Spacing="5">
636+
<ikw:SimpleStackPanel x:Name="BlackboardLeftSidePanel" Orientation="Horizontal">
637637
<!-- 白板左下角导航将由 BoardToolbarRegistry 动态构建 -->
638638
</ikw:SimpleStackPanel>
639639
</Grid>
@@ -689,7 +689,7 @@
689689
Stretch="None">
690690
<Grid Name="BlackboardRightSide" Visibility="Collapsed" d:Visibility="Visible" Margin="0,0,0,3" Height="50"
691691
HorizontalAlignment="Center" VerticalAlignment="Bottom">
692-
<ikw:SimpleStackPanel x:Name="BlackboardRightSidePanel" Orientation="Horizontal" Spacing="5">
692+
<ikw:SimpleStackPanel x:Name="BlackboardRightSidePanel" Orientation="Horizontal">
693693
<!-- 白板右下角导航将由 BoardToolbarRegistry 动态构建 -->
694694
</ikw:SimpleStackPanel>
695695
</Grid>

Ink Canvas/MainWindow_cs/MW_BoardControls.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,26 +714,29 @@ private void UpdateIndexInfoDisplay()
714714
TextBlockWhiteBoardIndexInfo.Text =
715715
$"{CurrentWhiteboardIndex}/{WhiteboardTotalCount}";
716716

717+
UpdatePageInfo();
718+
717719
bool isLastPage = CurrentWhiteboardIndex == WhiteboardTotalCount;
718720
bool isMaxPage = WhiteboardTotalCount >= 99;
719721

720-
// 设置按钮文本
721-
if (BtnLeftWhiteBoardSwitchNext != null) BtnLeftWhiteBoardSwitchNext.LabelTextBlockControl.Text = isLastPage ? "新页面" : FloatingBarStrings.Board_NextPage;
722+
if (BtnLeftWhiteBoardSwitchNext != null) BtnLeftWhiteBoardSwitchNext.LabelTextBlockControl.Text = isLastPage ? FloatingBarStrings.Board_NewPage : FloatingBarStrings.Board_NextPage;
722723
if (BtnRightWhiteBoardSwitchNext != null) BtnRightWhiteBoardSwitchNext.LabelTextBlockControl.Text = isLastPage ? FloatingBarStrings.Board_NewPage : FloatingBarStrings.Board_NextPage;
723724

724725
if (isLastPage)
725726
{
726727
BtnWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
728+
if (BtnLeftWhiteBoardSwitchNext != null) BtnLeftWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
729+
if (BtnRightWhiteBoardSwitchNext != null) BtnRightWhiteBoardSwitchNext.IsEnabled = !isMaxPage;
727730
}
728731
else
729732
{
730733
BtnWhiteBoardSwitchNext.IsEnabled = true;
734+
if (BtnLeftWhiteBoardSwitchNext != null) BtnLeftWhiteBoardSwitchNext.IsEnabled = true;
735+
if (BtnRightWhiteBoardSwitchNext != null) BtnRightWhiteBoardSwitchNext.IsEnabled = true;
731736
}
732737

733-
// 获取主题颜色资源
734738
var iconForegroundBrush = Application.Current.FindResource("IconForeground") as SolidColorBrush;
735739

736-
// 设置下一页按钮颜色
737740
if (iconForegroundBrush != null)
738741
{
739742
if (BtnLeftWhiteBoardSwitchNext != null) BtnLeftWhiteBoardSwitchNext.IconGeometryDrawing.Brush = iconForegroundBrush;
@@ -743,10 +746,14 @@ private void UpdateIndexInfoDisplay()
743746
if (BtnRightWhiteBoardSwitchNext != null) BtnRightWhiteBoardSwitchNext.LabelTextBlockControl.Opacity = 1;
744747

745748
BtnWhiteBoardSwitchPrevious.IsEnabled = true;
749+
if (BtnLeftWhiteBoardSwitchPrevious != null) BtnLeftWhiteBoardSwitchPrevious.IsEnabled = true;
750+
if (BtnRightWhiteBoardSwitchPrevious != null) BtnRightWhiteBoardSwitchPrevious.IsEnabled = true;
746751

747752
if (CurrentWhiteboardIndex == 1)
748753
{
749754
BtnWhiteBoardSwitchPrevious.IsEnabled = false;
755+
if (BtnLeftWhiteBoardSwitchPrevious != null) BtnLeftWhiteBoardSwitchPrevious.IsEnabled = false;
756+
if (BtnRightWhiteBoardSwitchPrevious != null) BtnRightWhiteBoardSwitchPrevious.IsEnabled = false;
750757
if (iconForegroundBrush != null)
751758
{
752759
var disabledBrush = new SolidColorBrush(Color.FromArgb(127, iconForegroundBrush.Color.R, iconForegroundBrush.Color.G, iconForegroundBrush.Color.B));

0 commit comments

Comments
 (0)