Minor fix
* Fix selection error when use delete after to delete the last tas unit * Fix sel_rect display error * Add some documents * Fix layout becoming confusing when secondly open file.
This commit is contained in:
@ -28,8 +28,6 @@ namespace BallanceTASEditor.UI {
|
||||
|
||||
public event Action Click;
|
||||
|
||||
private const double SELECTION_HEADER_HEIGHT = 10.0f; // header selection height, originally copied from TASFlowItem class
|
||||
|
||||
private readonly TextBlock[] mHeaders;
|
||||
private bool mIsHorizontalLayout;
|
||||
private Grid uiCoreWindow;
|
||||
@ -57,7 +55,7 @@ namespace BallanceTASEditor.UI {
|
||||
// column is tas unit
|
||||
|
||||
// header
|
||||
layout_row_adder(new GridLength(SELECTION_HEADER_HEIGHT, GridUnitType.Pixel));
|
||||
layout_row_adder(GridLength.Auto);
|
||||
for (int r = 0; r < lenHeader; r++) {
|
||||
layout_row_adder(GridLength.Auto);
|
||||
}
|
||||
@ -74,7 +72,7 @@ namespace BallanceTASEditor.UI {
|
||||
// column is header count (use start to split, not auto)
|
||||
|
||||
// header
|
||||
layout_column_adder(new GridLength(SELECTION_HEADER_HEIGHT, GridUnitType.Pixel));
|
||||
layout_column_adder(GridLength.Auto);
|
||||
for (int r = 0; r < lenHeader; r++) {
|
||||
if (r == 0 || r == 1)
|
||||
layout_column_adder(GridLength.Auto);
|
||||
@ -249,6 +247,7 @@ namespace BallanceTASEditor.UI {
|
||||
private static readonly Color COLOR_UNSET = Color.FromArgb(0, 255, 255, 255);
|
||||
private static readonly Color COLOR_SELECTED = Colors.OrangeRed;
|
||||
private static readonly Color COLOR_UNSELECTED = Colors.LightGray;
|
||||
private const double SELECTION_HEADER_HEIGHT = 10.0f;
|
||||
private const int KEY_COUNT = 9;
|
||||
|
||||
public TASFlowUIItem(int column, bool useHorizontalLayout) {
|
||||
@ -279,7 +278,10 @@ namespace BallanceTASEditor.UI {
|
||||
|
||||
sel_rect.StrokeThickness = 2;
|
||||
sel_rect.Stroke = SEL_RECT_STROKE;
|
||||
//sel_rect.Height = SELECTION_HEADER_HEIGHT; // now sel_rect's size decided by layout
|
||||
if (useHorizontalLayout)
|
||||
sel_rect.Height = SELECTION_HEADER_HEIGHT;
|
||||
else
|
||||
sel_rect.Width = SELECTION_HEADER_HEIGHT;
|
||||
|
||||
// keystates item
|
||||
keystates = new Rectangle[KEY_COUNT];
|
||||
@ -314,6 +316,11 @@ namespace BallanceTASEditor.UI {
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
UI.Util.SwapGridItemRC(keystates[i]);
|
||||
}
|
||||
|
||||
// swap sel_rect height and width
|
||||
var swap = sel_rect.Height;
|
||||
sel_rect.Height = sel_rect.Width;
|
||||
sel_rect.Width = swap;
|
||||
}
|
||||
|
||||
public void Add(Grid target, Dictionary<Rectangle, CellPosition> map, MouseButtonEventHandler func) {
|
||||
|
||||
@ -34,8 +34,16 @@ namespace BallanceTASEditor.UI {
|
||||
}
|
||||
|
||||
public void UpdateRange(TASFile mFile) {
|
||||
components.mSlider.Maximum = mFile.mFrameCount - 1;
|
||||
components.mSlider.Value = mFile.GetPointerIndex();
|
||||
components.mSlider.Maximum = mFile.mFrameCount == 0 ? 0 : mFile.mFrameCount - 1;
|
||||
var index = mFile.GetPointerIndex();
|
||||
if (index >= 0) {
|
||||
components.mSlider.Value = mFile.GetPointerIndex();
|
||||
components.mSlider.IsEnabled = true;
|
||||
} else {
|
||||
// invalid index, mean slider is useless, disable it
|
||||
components.mSlider.Value = components.mSlider.Maximum;
|
||||
components.mSlider.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_SliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
|
||||
@ -202,12 +202,12 @@ namespace BallanceTASEditor.UI {
|
||||
if (oper == OperationEnum.DeleteBefore) pos -= 1; // delete after mean delete current selected item
|
||||
if (pos < 0 || pos >= mFile.mFrameCount) return;
|
||||
|
||||
// only delete before need shift selection
|
||||
// delete before need shift selection
|
||||
// delete before couldn't cause empty list, so we just need to directly shift
|
||||
if (oper == OperationEnum.DeleteBefore)
|
||||
mSelectionHelp.ShiftTo(false);
|
||||
// also, if we use delete after and delete the tail of item list, we also need to shift pos(use `else if` to prevent double shift)
|
||||
else if (oper == OperationEnum.DeleteAfter && pos == mFile.mFrameCount) {
|
||||
else if (oper == OperationEnum.DeleteAfter && pos == mFile.mFrameCount - 1) {
|
||||
// but delete after may cause empty list error(delete the item within only 1 item list)
|
||||
// so we need prevent this situation
|
||||
if (mFile.mFrameCount == 1) mSelectionHelp.Reset(); //yes, reset selection to prevent error
|
||||
|
||||
Reference in New Issue
Block a user