Merge pull request 'master' (#3) from Koquem/RDTKEditor:master into master

Reviewed-on: obugs/RDTKEditor#3
This commit is contained in:
2025-03-26 10:51:43 +08:00
2 changed files with 50 additions and 3 deletions
+49 -3
View File
@@ -3,6 +3,7 @@ using RDTKEditor.Models;
using RhythmBase.Events; using RhythmBase.Events;
using SkiaSharp; using SkiaSharp;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@@ -239,7 +240,7 @@ namespace RDTKEditor
}; };
timelineCanvas.Children.Add(rectangle); 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 sfc = e.Surface;
var cvs = sfc.Canvas; var cvs = sfc.Canvas;
@@ -248,8 +249,53 @@ namespace RDTKEditor
{ {
Color = SKColors.Red, 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 class MainViewModel : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
+1
View File
@@ -145,3 +145,4 @@ namespace RDTKEditor.Models
} }
} }
} }