Skip to content
Open

Dusk #697

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Ink Canvas/InkCanvasForClass.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
</ItemGroup>
<ItemGroup Condition="Exists('..\..\Dusk\sdk\Dusk.Wpf.Shell\Dusk.Wpf.Shell.csproj')">
<ProjectReference Include="..\..\Dusk\sdk\Dusk.Wpf.Shell\Dusk.Wpf.Shell.csproj">
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup Condition="!Exists('..\..\Dusk\sdk\Dusk.Wpf.Shell\Dusk.Wpf.Shell.csproj')">
<Reference Include="Dusk.Wpf.Shell">
<HintPath>libs\Dusk.Wpf.Shell.dll</HintPath>
<Private>True</Private>
</Reference>
<None Include="libs\Dusk.Wpf.Shell.dll">
<Link>Dusk.Wpf.Shell.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="libs\Dusk.Native.dll">
<Link>Dusk.Native.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Resources\TimerDownNotice.wav" />
<None Include="Resources\ProgressiveAudio.wav" />
Expand Down
20 changes: 14 additions & 6 deletions Ink Canvas/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
xmlns:helpers="clr-namespace:Ink_Canvas.Helpers"
xmlns:wmk="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
xmlns:icons="clr-namespace:Ink_Canvas"
xmlns:dusk="clr-namespace:Dusk.Wpf.Shell;assembly=Dusk.Wpf.Shell"
mc:Ignorable="d"
WindowStyle="None"
ResizeMode="NoResize"
Expand Down Expand Up @@ -226,7 +227,8 @@
<Grid Name="GridTransparencyFakeBackground" Opacity="0" />
<Label Name="Label" Visibility="Collapsed" Foreground="Gray" Content="0" />
<Grid Name="InkCanvasGridForInkReplay" d:Visibility="Collapsed">
<InkCanvas x:Name="inkCanvas" ForceCursor="True" UseCustomCursor="True"
<InkCanvas x:Name="inkCanvas" Visibility="Hidden" IsHitTestVisible="False"
ForceCursor="True" UseCustomCursor="True"
TouchDown="Main_Grid_TouchDown"
TouchMove="inkCanvas_TouchMove"
ManipulationDelta="Main_Grid_ManipulationDelta"
Expand All @@ -246,6 +248,12 @@
ClipToBounds="False"
Background="Transparent" />

<!-- Dusk 原生内核墨迹画布:全屏置顶接管书写与渲染 -->
<dusk:WpfNativeInkCanvas x:Name="duskCanvas"

@augmentcode augmentcode Bot Oct 10, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At Ink Canvas/MainWindow.xaml:252, Dusk strokes stay in the new canvas, while SaveInkCanvasStrokes still serializes only inkCanvas.Strokes (Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs:829) and no stroke bridge is installed. Could you check saving and reopening a page drawn with the now-default Dusk engine, which currently reports success while saving none of that ink?

Severity: high

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Focusable="False" />

<Canvas x:Name="EraserOverlayCanvas" d:Visibility="Collapsed"
Background="Transparent"
IsHitTestVisible="False"
Expand Down Expand Up @@ -776,7 +784,7 @@
Panel.ZIndex="1000" />

</Grid>
<Grid Visibility="Collapsed" d:Visibility="Visible">
<Grid Visibility="Collapsed" d:Visibility="Visible" Panel.ZIndex="1000">
<Grid Visibility="{Binding ElementName=GridBackgroundCoverHolder, Path=Visibility}" d:Visibility="Visible">
<Viewbox Margin="10" Height="50" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="5">
Expand Down Expand Up @@ -811,7 +819,7 @@
</Grid>
</Grid>
<!--白板-->
<Grid Name="BlackboardUIGridForInkReplay">
<Grid Name="BlackboardUIGridForInkReplay" Panel.ZIndex="1000">
<Grid Visibility="{Binding ElementName=GridBackgroundCoverHolder, Path=Visibility}">
<!-- 左下角 -->
<Viewbox x:Name="ViewboxBlackboardLeftSide" Margin="3,0,0,0" Height="55" HorizontalAlignment="Left"
Expand Down Expand Up @@ -1028,7 +1036,7 @@
Margin="0,0,6,0"
HorizontalAlignment="Right" VerticalAlignment="Center"/>
<!--浮动工具栏-->
<Grid Name="FloatingbarUIForInkReplay" d:Visibility="Collapsed">
<Grid Name="FloatingbarUIForInkReplay" Panel.ZIndex="1000" d:Visibility="Collapsed">
<Viewbox Name="ViewboxFloatingBar" Margin="-500,0,0,0" Cursor="Arrow"
Visibility="Collapsed" d:Visibility="Visible"
HorizontalAlignment="Left" VerticalAlignment="Top"
Expand Down Expand Up @@ -1330,7 +1338,7 @@
Visibility="Visible" Margin="-60,0,0,-150"
HorizontalAlignment="Left" VerticalAlignment="Center" />
<!--收纳下的快捷面板//左-->
<Viewbox Width="50" Visibility="Collapsed" d:Visibility="Visible" Name="LeftUnFoldButtonQuickPanel" Margin="-60,0,0,-150" d:Margin="-60,0,0,500"
<Viewbox Width="50" Panel.ZIndex="1000" Visibility="Collapsed" d:Visibility="Visible" Name="LeftUnFoldButtonQuickPanel" Margin="-60,0,0,-150" d:Margin="-60,0,0,500"
HorizontalAlignment="Left" VerticalAlignment="Center">
<Border x:Name="LeftQuickPanelBorder" ClipToBounds="False" Visibility="Visible" CornerRadius="6" Background="{DynamicResource FloatingBarBackgroundBrush}" Opacity="1"
BorderThickness="1" BorderBrush="{DynamicResource FloatingBarBorderBrush}" d:BorderBrush="Red" d:Background="Green" Width="32">
Expand All @@ -1354,7 +1362,7 @@
Margin="0,0,-60,-150" IsRightSide="True"
HorizontalAlignment="Right" VerticalAlignment="Center" />
<!--收纳下的快捷面板//右-->
<Viewbox Width="50" Visibility="Collapsed" d:Visibility="Visible" Name="RightUnFoldButtonQuickPanel" Margin="0,0,-60,-150" d:Margin="0,0,-60,500"
<Viewbox Width="50" Panel.ZIndex="1000" Visibility="Collapsed" d:Visibility="Visible" Name="RightUnFoldButtonQuickPanel" Margin="0,0,-60,-150" d:Margin="0,0,-60,500"
HorizontalAlignment="Right" VerticalAlignment="Center">
<Border x:Name="RightQuickPanelBorder" ClipToBounds="False" Visibility="Visible" CornerRadius="6" Background="{DynamicResource FloatingBarBackgroundBrush}" Opacity="1"
BorderThickness="1" BorderBrush="{DynamicResource FloatingBarBorderBrush}" d:BorderBrush="Red" d:Background="Green" Width="32">
Expand Down
34 changes: 33 additions & 1 deletion Ink Canvas/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
{
LogHelper.WriteLogToFile($"[Startup] 主窗口加载开始,启动模式={App.CurrentStartupMode}", LogHelper.LogType.Info);
loadPenCanvas();
ApplyInkEngine(Settings?.Canvas?.InkEngine ?? InkEngineType.Dusk);

@augmentcode augmentcode Bot Oct 10, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At Ink Canvas/MainWindow.xaml.cs:1535, this runs before LoadSettings(true) at line 1545, so SettingsManager's initial Dusk default is applied instead of the persisted InkEngine. Could you check restarting after selecting WPF or WinRT, since loading the saved settings never calls ApplyInkEngine again and leaves the window configured for Dusk?

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

// 工具栏插件化按钮先注入到容器,确保 LoadSettings 内部对 Cursor_Icon / Pen_Icon 等的访问非空。
// Settings.Toolbar 此时尚为默认值(全部可见),与旧 XAML 行为一致。
InitializeToolbarPlugins();
Expand Down Expand Up @@ -1991,6 +1992,7 @@ private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e)
private void Window_Closed(object sender, EventArgs e)
{
LogHelper.WriteLogToFile("[Exit] 主窗口 Closed,开始释放资源", LogHelper.LogType.Info);
DisposeDuskEngine();
RealtimeInkFrameScheduler.Clear();
try
{
Expand Down Expand Up @@ -3543,7 +3545,37 @@ internal bool SetCurrentToolMode(InkCanvasEditingMode newMode, Action additional

// 执行模式切换
inkCanvas.EditingMode = newMode;
SyncWinRTInkPipelineWithLogicalTool();

if (Settings?.Canvas?.InkEngine == InkEngineType.Dusk)
{
// 同步切换 Dusk 原生内核墨迹引擎状态
switch (newMode)
{
case InkCanvasEditingMode.Ink:
SetDuskCanvasActive(true);
SetDuskEditingMode(Dusk.Wpf.Shell.ShellEditingMode.Ink);
SyncDuskPenAttributes(drawingAttributes?.Color ?? Ink_DefaultColor, drawingAttributes != null && drawingAttributes.Width > 0 ? drawingAttributes.Width : 2.5);
break;
case InkCanvasEditingMode.EraseByPoint:
SetDuskCanvasActive(true);
SetDuskEditingMode(Dusk.Wpf.Shell.ShellEditingMode.EraseByPoint);
SetDuskEraserRadius(eraserWidth > 0 ? eraserWidth / 2 : 24.0);
break;
case InkCanvasEditingMode.EraseByStroke:
SetDuskCanvasActive(true);
SetDuskEditingMode(Dusk.Wpf.Shell.ShellEditingMode.EraseByStroke);
SetDuskEraserRadius(eraserWidth > 0 ? eraserWidth / 2 : 24.0);
break;
default:
SetDuskCanvasActive(false);
SetDuskEditingMode(Dusk.Wpf.Shell.ShellEditingMode.None);
break;
}
}
else
{
SyncWinRTInkPipelineWithLogicalTool();
}

// 根据模式确定是否为鼠标模式(无工具模式)
bool isMouseMode = newMode == InkCanvasEditingMode.None;
Expand Down
3 changes: 3 additions & 0 deletions Ink Canvas/MainWindow_cs/MW_BoardControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private void ClearStrokes(bool isErasedByCode)
// here as well so page switches, loads and code/UI clears cannot leave them behind.
ClearSecAgentSceneElements();
inkCanvas.Strokes.Clear();
DuskClear(isErasedByCode);
// 只隐藏 hint,不暂停(ClearStrokes 在切换页面、保存加载时都会被调用,
// 设置 _edgeExpandHintSuspended 会导致后续书写永远无法触发提示)。
HideEdgeExpandHint();
Expand Down Expand Up @@ -258,6 +259,7 @@ private void RestoreStrokes(bool isBackupMain = false)
}

var targetIndex = isBackupMain ? 0 : CurrentWhiteboardIndex;
DuskSwitchSlot(targetIndex);

@augmentcode augmentcode Bot Oct 10, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check inserting a whiteboard page before an existing page at Ink Canvas/MainWindow_cs/MW_BoardControls.cs:262? BtnWhiteBoardAdd_Click shifts only the WPF histories, so DuskSwitchSlot(targetIndex) selects the old next page's native strokes for the supposedly blank new page, while the displaced page subsequently selects a different slot.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.


// 先清空当前画布的墨迹
inkCanvas.Strokes.Clear();
Expand Down Expand Up @@ -811,6 +813,7 @@ private void DeleteWhiteBoardPageByIndex(int pageIndex)
var deletingCurrentPluginPage = pageIndex == CurrentWhiteboardIndex;
if (deletingCurrentPluginPage) CaptureCurrentPluginPageStates();
var removedPluginPage = RemovePluginWhiteboardPageId(pageIndex, oldPluginPageCount);
DuskDeleteSlot(pageIndex);

if (pageIndex == CurrentWhiteboardIndex)
{
Expand Down
6 changes: 6 additions & 0 deletions Ink Canvas/MainWindow_cs/MW_Colors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,12 @@ private void CheckColorTheme(bool changeColorTheme = false)
UpdatePenIconColor();
// 更新白板工具栏画笔图标颜色
UpdateBoardPenIconColor();

// 同步笔触属性给 Dusk 原生内核
if (duskCanvas != null && inkCanvas != null)
{
SyncDuskPenAttributes(inkCanvas.DefaultDrawingAttributes.Color, inkCanvas.DefaultDrawingAttributes.Width);
}
}

/// <summary>
Expand Down
Loading
Loading