Archived
forked from RDTKEditor/RDTKEditor
底部时间栏组件更换
This commit is contained in:
+105
-155
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user