Merge pull request '底部时间栏组件更换' (#11) from obsmain into master

Reviewed-on: RDTKEditor/RDTKEditor#11
This commit is contained in:
2025-05-13 21:10:18 +08:00
5 changed files with 224 additions and 264 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CSharpToJsonSchema; using CSharpToJsonSchema;
using Ollama; using Ollama;
using RhythmBase.Components; using RhythmBase.RhythmDoctor.Components;
using System.ComponentModel; using System.ComponentModel;
namespace RDTKEditor.AIAssistant namespace RDTKEditor.AIAssistant
+106 -105
View File
@@ -5,113 +5,114 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:skia="clr-namespace:SkiaSharp.Views.WPF;assembly=SkiaSharp.Views.WPF" xmlns:skia="clr-namespace:SkiaSharp.Views.WPF;assembly=SkiaSharp.Views.WPF"
xmlns:local="clr-namespace:RDTKEditor" xmlns:local="clr-namespace:RDTKEditor"
xmlns:rdtkwpf="clr-namespace:RhythmBase.Control.WPF;assembly=RhythmBase.Control.WPF"
mc:Ignorable="d" mc:Ignorable="d"
Title="RDTK Editor" Height="450" Width="800"> Title="RDTK Editor" Height="450" Width="800">
<Window.DataContext> <Window.DataContext>
<local:MainViewModel/> <local:MainViewModel/>
</Window.DataContext> </Window.DataContext>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Menu Grid.Row="0" VerticalAlignment="Top"> <Menu Grid.Row="0" VerticalAlignment="Top">
<MenuItem Header="文件(_F)"> <MenuItem Header="文件(_F)">
<MenuItem Header="打开文件(_O)" Click="OpenFile" InputGestureText="Ctrl+O"/> <MenuItem Header="打开文件(_O)" Click="OpenFile" InputGestureText="Ctrl+O"/>
<MenuItem Header="保存文件(_S)" Click="SaveFile" InputGestureText="Ctrl+S"/> <MenuItem Header="保存文件(_S)" Click="SaveFile" InputGestureText="Ctrl+S"/>
<Separator/> <Separator/>
<MenuItem Header="退出(_E)" Click="Exit"/> <MenuItem Header="退出(_E)" Click="Exit"/>
</MenuItem> </MenuItem>
<MenuItem Header="帮助(_H)"> <MenuItem Header="帮助(_H)">
<MenuItem Header="关于(_A)" Click="About"/> <MenuItem Header="关于(_A)" Click="About"/>
</MenuItem> </MenuItem>
</Menu> </Menu>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="100" MaxWidth="300" /> <ColumnDefinition Width="200" MinWidth="100" MaxWidth="300" />
<ColumnDefinition Width="5" /> <ColumnDefinition Width="5" />
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="5" /> <ColumnDefinition Width="5" />
<ColumnDefinition Width="200" MinWidth="100" MaxWidth="300" /> <ColumnDefinition Width="200" MinWidth="100" MaxWidth="300" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="5" /> <RowDefinition Height="5" />
<RowDefinition Height="100" MinHeight="90" MaxHeight="270"/> <RowDefinition Height="100" MinHeight="90" MaxHeight="270"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Border Grid.Column="0" Background="LightBlue"> <Border Grid.Column="0" Background="LightBlue">
<ScrollViewer VerticalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="ItemProperties" Background="LightGray"> <ItemsControl x:Name="ItemProperties" Background="LightGray">
<ComboBox Grid.Row="0" BorderBrush="#FFDF4444" Foreground="#FFC65E5E" RenderTransformOrigin="0.5,0.5"> <ComboBox Grid.Row="0" BorderBrush="#FFDF4444" Foreground="#FFC65E5E" RenderTransformOrigin="0.5,0.5">
<ComboBox.RenderTransform> <ComboBox.RenderTransform>
<TransformGroup> <TransformGroup>
<ScaleTransform/> <ScaleTransform/>
<SkewTransform/> <SkewTransform/>
<RotateTransform Angle="-0.383"/> <RotateTransform Angle="-0.383"/>
<TranslateTransform/> <TranslateTransform/>
</TransformGroup> </TransformGroup>
</ComboBox.RenderTransform> </ComboBox.RenderTransform>
<ComboBox.Background> <ComboBox.Background>
<LinearGradientBrush EndPoint="0,1"> <LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#FFF0F0F0"/> <GradientStop Color="#FFF0F0F0"/>
<GradientStop Color="#FF963333" Offset="1"/> <GradientStop Color="#FF963333" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
</ComboBox.Background> </ComboBox.Background>
<ComboBoxItem Content="选项 1" /> <ComboBoxItem Content="选项 1" />
<ComboBoxItem Content="选项 2" /> <ComboBoxItem Content="选项 2" />
</ComboBox> </ComboBox>
<Label Grid.Row="1" Content="Label" RenderTransformOrigin="0.5,0.5"> <Label Grid.Row="1" Content="Label" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform> <Label.RenderTransform>
<TransformGroup> <TransformGroup>
<ScaleTransform/> <ScaleTransform/>
<SkewTransform/> <SkewTransform/>
<RotateTransform Angle="0.017"/> <RotateTransform Angle="0.017"/>
<TranslateTransform/> <TranslateTransform/>
</TransformGroup> </TransformGroup>
</Label.RenderTransform> </Label.RenderTransform>
</Label> </Label>
<ListView Grid.Row="3" d:ItemsSource="{d:SampleData ItemCount=3}"> <ListView Grid.Row="3" d:ItemsSource="{d:SampleData ItemCount=3}">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn/> <GridViewColumn/>
</GridView> </GridView>
</ListView.View> </ListView.View>
</ListView> </ListView>
</ItemsControl> </ItemsControl>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
<GridSplitter Grid.Column="1" Width="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> <GridSplitter Grid.Column="1" Width="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Viewbox Grid.Row="0" Grid.Column="2" Stretch="Uniform"> <Viewbox Grid.Row="0" Grid.Column="2" Stretch="Uniform">
<Border Background="LightGray" Width="1600" Height="900"> <Border Background="LightGray" Width="1600" Height="900">
<skia:SKElement x:Name="mainUI" PaintSurface="mainUI_PaintSurface" /> <skia:SKElement x:Name="mainUI" PaintSurface="mainUI_PaintSurface" />
</Border> </Border>
</Viewbox> </Viewbox>
<GridSplitter Grid.Column="3" Width="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> <GridSplitter Grid.Column="3" Width="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Border Grid.Column="4" Background="LightBlue" > <Border Grid.Column="4" Background="LightBlue" >
<ScrollViewer VerticalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto">
<Grid x:Name="timelineCanvas3" Background="LightGray" > <Grid x:Name="timelineCanvas3" Background="LightGray" >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="20" /> <RowDefinition Height="20" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Grid.Row="0" x:Name="AIAssistantText" TextWrapping="Wrap" > <TextBox Grid.Row="0" x:Name="AIAssistantText" TextWrapping="Wrap" >
AI问答 AI问答
</TextBox> </TextBox>
<Button Grid.Row="1" x:Name="AIButton" VerticalAlignment="Bottom" Click="AIAssistantButton_Click" IsEnabled="{Binding IsButtonEnabled}" > <Button Grid.Row="1" x:Name="AIButton" VerticalAlignment="Bottom" Click="AIAssistantButton_Click" IsEnabled="{Binding IsButtonEnabled}" >
点击按钮开发 点击按钮开发
</Button> </Button>
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
<GridSplitter Grid.Row="1" Grid.ColumnSpan="5" Height="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> <GridSplitter Grid.Row="1" Grid.ColumnSpan="5" Height="5" Background="Gray" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Border Grid.ColumnSpan="5" Grid.Row="2" Background="LightSalmon"> <Border Grid.ColumnSpan="5" Grid.Row="2" Background="LightSalmon">
<ScrollViewer x:Name="timelineScrollviewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" > <ScrollViewer x:Name="timelineScrollviewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Canvas x:Name="timelineCanvas" Background="LightGray" > <rdtkwpf:RDTimeLinePanel x:Name="timeLine">
</Canvas> </rdtkwpf:RDTimeLinePanel>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
</Grid> </Grid>
</Grid> </Grid>
</Window> </Window>
+103 -153
View File
@@ -2,8 +2,8 @@
using Ollama; using Ollama;
using RDTKEditor.AIAssistant; using RDTKEditor.AIAssistant;
using RDTKEditor.Models; using RDTKEditor.Models;
using RhythmBase.Components; using RhythmBase.RhythmDoctor.Components;
using RhythmBase.Events; using RhythmBase.RhythmDoctor.Events;
using SkiaSharp; using SkiaSharp;
using SkiaSharp.Views.Desktop; using SkiaSharp.Views.Desktop;
using System.ComponentModel; using System.ComponentModel;
@@ -12,6 +12,7 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
using RhythmBase.Control.WPF;
namespace RDTKEditor namespace RDTKEditor
{ {
@@ -28,30 +29,8 @@ namespace RDTKEditor
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
viewModel.Level = RDLevel.Default; timeLine.Level = RDLevel.Default;
}
viewModel.Level.Add(new Comment() { Beat = new RDBeat(1,2.33f) });
viewModel.Level.Add(new Comment() { Beat = new RDBeat(1,4f),Y=1 });
foreach (var item in viewModel.Level)
{
var time = item.Beat.BeatOnly;
Label label = new();
label.Content = time;
label.Background = new SolidColorBrush(Colors.Red);
if (time ==1)
{
label.Margin = new Thickness(0, 0, 0, 0);
}else
{
label.Margin = new Thickness(time*10, item.Y*30, 0, 0);
}
timelineCanvas.Children.Add(label);
}
}
private void OpenFile(object sender, RoutedEventArgs e) private void OpenFile(object sender, RoutedEventArgs e)
{ {
OpenFileDialog openFileDialog = new() OpenFileDialog openFileDialog = new()
@@ -93,7 +72,7 @@ namespace RDTKEditor
} }
else else
{ {
}
} }
private RDTKProperty[] GetProperties(BaseEvent e) private RDTKProperty[] GetProperties(BaseEvent e)
{ {
@@ -170,7 +149,7 @@ namespace RDTKEditor
}; };
} }
private readonly List<BaseEvent> selectedEvents = new(); private readonly List<BaseEvent> selectedEvents = new();
internal void OnUpdateEventProperties(RDTKProperty[] properties) internal void OnUpdateEventProperties(BaseEvent baseEvent, RDTKProperty[] properties)
{ {
ItemProperties.Items.Clear(); ItemProperties.Items.Clear();
StackPanel[] panel = new StackPanel[properties.Length]; StackPanel[] panel = new StackPanel[properties.Length];
@@ -180,26 +159,26 @@ namespace RDTKEditor
} }
else else
{ {
foreach (var property in properties) foreach (var property in properties)
{
StackPanel stackPanel = property.Type switch
{ {
RDPropertyType.Bool => new() StackPanel stackPanel = property.Type switch
{ {
Orientation = Orientation.Horizontal, RDPropertyType.Bool => new()
FlowDirection = FlowDirection.LeftToRight, {
Children = Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight,
Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new CheckBox() { IsChecked = bool.Parse( property.Value), } new CheckBox() { IsChecked = bool.Parse( property.Value), }
}, },
}, },
RDPropertyType.Enum => new() RDPropertyType.Enum => new()
{ {
AllowDrop = true, AllowDrop = true,
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight, FlowDirection = FlowDirection.LeftToRight,
Children = Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new ComboBox() new ComboBox()
@@ -208,114 +187,94 @@ namespace RDTKEditor
SelectedValue = property.Value, SelectedValue = property.Value,
} }
}, },
}, },
RDPropertyType.String => new() RDPropertyType.String => new()
{ {
AllowDrop = true, AllowDrop = true,
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight, FlowDirection = FlowDirection.LeftToRight,
Children = Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new TextBox() { Text = property.Value, } new TextBox() { Text = property.Value, }
}, },
}, },
RDPropertyType.Integer => new() RDPropertyType.Integer => new()
{ {
AllowDrop = true, AllowDrop = true,
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight, FlowDirection = FlowDirection.LeftToRight,
Children = Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new TextBox() { Text = property.Value, } new TextBox() { Text = property.Value, }
}, },
}, },
RDPropertyType.Float => new() RDPropertyType.Float => new()
{ {
AllowDrop = true, AllowDrop = true,
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight, FlowDirection = FlowDirection.LeftToRight,
Children = Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new TextBox() { Text = property.Value, } new TextBox() { Text = property.Value, }
}, },
}, },
RDPropertyType.Color => new() RDPropertyType.Color => new()
{ {
AllowDrop = true, AllowDrop = true,
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight, FlowDirection = FlowDirection.LeftToRight,
Children = Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new TextBox() { Text = property.Value, } new TextBox() { Text = property.Value, }
}, },
}, },
_ => new() _ => new()
{ {
Orientation = Orientation.Horizontal, Orientation = Orientation.Horizontal,
Children = Children =
{
new Label(){Content = property.Name},
new TextBox() { Text = property.Value, }
},
},
RDPropertyType.Color => new()
{
AllowDrop = true,
Orientation = Orientation.Horizontal,
FlowDirection = FlowDirection.LeftToRight,
Children =
{
new Label(){Content = property.Name},
new TextBox() { Text = property.Value, }
},
},
_ => new()
{
Orientation = Orientation.Horizontal,
Children =
{ {
new Label(){Content = property.Name}, new Label(){Content = property.Name},
new Label(){Content = property.Value} new Label(){Content = property.Value}
} }
}, },
}; };
foreach (var child in stackPanel.Children) foreach (var child in stackPanel.Children)
{
switch (child)
{ {
case CheckBox checkBox: switch (child)
checkBox.Checked += (sender, e) => {
{ case CheckBox checkBox:
property.OnChanged("true"); checkBox.Checked += (sender, e) =>
}; {
checkBox.Unchecked += (sender, e) => property.OnChanged("true");
{ };
property.OnChanged("false"); checkBox.Unchecked += (sender, e) =>
}; {
break; property.OnChanged("false");
case TextBox textBox: };
textBox.TextChanged += (sender, e) => break;
{ case TextBox textBox:
property.OnChanged(textBox.Text); textBox.TextChanged += (sender, e) =>
}; {
break; property.OnChanged(textBox.Text);
case ComboBox comboBox: };
comboBox.SelectionChanged += (sender, e) => break;
{ case ComboBox comboBox:
property.OnChanged(comboBox.SelectedValue); comboBox.SelectionChanged += (sender, e) =>
}; {
break; property.OnChanged(comboBox.SelectedValue);
default: };
break; break;
default:
break;
}
} }
ItemProperties.Items.Add(stackPanel);
property.PropertyChanged += (e, s) => UpdateEvent();
} }
ItemProperties.Items.Add(stackPanel);
property.PropertyChanged += (e, s) => UpdateEvent();
}
} }
} }
@@ -323,7 +282,8 @@ namespace RDTKEditor
{ {
if (_selectedEvents.Count == 0) if (_selectedEvents.Count == 0)
return; return;
else if (_selectedEvents.Count == 1){ else if (_selectedEvents.Count == 1)
{
var e = _selectedEvents[0]; var e = _selectedEvents[0];
foreach (var property in ItemProperties.Items) foreach (var property in ItemProperties.Items)
{ {
@@ -356,12 +316,6 @@ namespace RDTKEditor
} }
private void UpdateTimeLine() private void UpdateTimeLine()
{ {
Rectangle rectangle = new()
{
Width = 100,
Height = 100,
};
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)
{ {
@@ -373,11 +327,7 @@ namespace RDTKEditor
Color = SKColors.Red, Color = SKColors.Red,
}); });
}*/ }*/
private void mainUI_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
private void mainUI_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
{ {
var sfc = e.Surface; var sfc = e.Surface;
var cvs = sfc.Canvas; var cvs = sfc.Canvas;
@@ -406,10 +356,10 @@ namespace RDTKEditor
IsStroke = true, IsStroke = true,
}); });
} }
private void CheckBox_Checked(object sender, RoutedEventArgs e) private void CheckBox_Checked(object sender, RoutedEventArgs e)
{ {
MessageBox.Show("已确认"); MessageBox.Show("已确认");
} }
private async void AIAssistantButton_Click(object sender, RoutedEventArgs e) private async void AIAssistantButton_Click(object sender, RoutedEventArgs e)
{ {
@@ -422,21 +372,21 @@ namespace RDTKEditor
} }
public class MainViewModel : INotifyPropertyChanged public class MainViewModel : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
private bool _isButtonEnabled = true; private bool _isButtonEnabled = true;
public bool IsButtonEnabled public bool IsButtonEnabled
{ {
get => _isButtonEnabled; get => _isButtonEnabled;
set set
{ {
_isButtonEnabled = value; _isButtonEnabled = value;
} }
} }
} }
+1 -1
View File
@@ -1,4 +1,4 @@
using RhythmBase.Components; using RhythmBase.RhythmDoctor.Components;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace RDTKEditor.Models namespace RDTKEditor.Models
+11 -2
View File
@@ -10,12 +10,21 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Ollama" Version="1.15.1-dev.12" /> <PackageReference Include="Ollama" Version="1.15.1-dev.13" />
<PackageReference Include="RhythmBase" Version="1.1.0-beta2" /> <PackageReference Include="RhythmBase" Version="1.2.0-beta1" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="3.119.0-preview.1.2" /> <PackageReference Include="SkiaSharp.Views.WPF" Version="3.119.0-preview.1.2" />
<PackageReference Include="sly" Version="3.7.3" /> <PackageReference Include="sly" Version="3.7.3" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="RhythmBase.Control.Core">
<HintPath>..\RhythmBase.Control.WPF\bin\Debug\net8.0-windows\RhythmBase.Control.Core.dll</HintPath>
</Reference>
<Reference Include="RhythmBase.Control.WPF">
<HintPath>..\RhythmBase.Control.WPF\bin\Debug\net8.0-windows\RhythmBase.Control.WPF.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Using Include="System.IO" /> <Using Include="System.IO" />
</ItemGroup> </ItemGroup>