diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index b6d58a8..b855a77 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -3,6 +3,7 @@ using RDTKEditor.Models; using RhythmBase.Events; using SkiaSharp; using System.ComponentModel; +using System.Diagnostics; using System.Reflection; using System.Windows; using System.Windows.Controls; @@ -239,7 +240,7 @@ namespace RDTKEditor }; timelineCanvas.Children.Add(rectangle); } - private void mainUI_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) + /*private void mainUI_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) { var sfc = e.Surface; var cvs = sfc.Canvas; @@ -248,8 +249,53 @@ namespace RDTKEditor { Color = SKColors.Red, }); - } - } + }*/ + + private void mainUI_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintSurfaceEventArgs e) + { + var sfc = e.Surface; + var cvs = sfc.Canvas; + var info = e.Info; + + // 清除画布 + cvs.Clear(SKColors.Black); + + // 获取绘图表面的宽度和高度 + float width = info.Width; + float height = info.Height; + + // 设置缩放比例 + float scaleX = width / 1600f; + float scaleY = height / 900f; + + // 保存画布状态 + cvs.Save(); + + // 应用缩放 + cvs.Scale(scaleX, scaleY); + + // 绘制内容 + cvs.DrawLine(0, 0, 1600, 900, new SKPaint + { + Color = SKColors.Red, + StrokeWidth = 3, + IsStroke = true, + }); + cvs.DrawLine(0, 900, 1600, 0, new SKPaint + { + Color = SKColors.White, + StrokeWidth = 3, + IsStroke = true, + }); + + // 恢复画布状态 + cvs.Restore(); + + // 打印绘图表面的尺寸 + Debug.Print(info.Size.ToString()); + } + + } public class MainViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; diff --git a/Models/RDTKView.cs b/Models/RDTKView.cs index 5db3917..e4bdd38 100644 --- a/Models/RDTKView.cs +++ b/Models/RDTKView.cs @@ -145,3 +145,4 @@ namespace RDTKEditor.Models } } } +