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