增加导入后自动选中最后一项
This commit is contained in:
@@ -11,6 +11,7 @@ using SpineViewer.ViewModels.Exporters;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -45,6 +46,11 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
_customFFmpegExporterViewModel = new(_vmMain);
|
_customFFmpegExporterViewModel = new(_vmMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求选中项发生变化
|
||||||
|
/// </summary>
|
||||||
|
public event NotifyCollectionChangedEventHandler? RequestSelectionChanging;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单帧导出 ViewModel
|
/// 单帧导出 ViewModel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -489,6 +495,19 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
{
|
{
|
||||||
var sp = new SpineObjectModel(skelPath, atlasPath);
|
var sp = new SpineObjectModel(skelPath, atlasPath);
|
||||||
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
|
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
|
||||||
|
if (Application.Current.Dispatcher.CheckAccess())
|
||||||
|
{
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Reset));
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Add, sp));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Reset));
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Add, sp));
|
||||||
|
});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -505,6 +524,19 @@ namespace SpineViewer.ViewModels.MainWindow
|
|||||||
{
|
{
|
||||||
var sp = new SpineObjectModel(cfg);
|
var sp = new SpineObjectModel(cfg);
|
||||||
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
|
lock (_spineObjectModels.Lock) _spineObjectModels.Add(sp);
|
||||||
|
if (Application.Current.Dispatcher.CheckAccess())
|
||||||
|
{
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Reset));
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Add, sp));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Reset));
|
||||||
|
RequestSelectionChanging?.Invoke(this, new(NotifyCollectionChangedAction.Add, sp));
|
||||||
|
});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace SpineViewer.Views;
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 布局文件保存路径
|
/// 上一次状态文件保存路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string LastStateFilePath = Path.Combine(Path.GetDirectoryName(Environment.ProcessPath), "laststate.json");
|
public static readonly string LastStateFilePath = Path.Combine(Path.GetDirectoryName(Environment.ProcessPath), "laststate.json");
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ public partial class MainWindow : Window
|
|||||||
InitializeLogConfiguration();
|
InitializeLogConfiguration();
|
||||||
_vm = new (_renderPanel);
|
_vm = new (_renderPanel);
|
||||||
DataContext = _vm;
|
DataContext = _vm;
|
||||||
|
_vm.SpineObjectListViewModel.RequestSelectionChanging += SpinesListView_RequestSelectionChanging;
|
||||||
_vm.SFMLRendererViewModel.RequestSelectionChanging += SpinesListView_RequestSelectionChanging;
|
_vm.SFMLRendererViewModel.RequestSelectionChanging += SpinesListView_RequestSelectionChanging;
|
||||||
|
|
||||||
Loaded += MainWindow_Loaded;
|
Loaded += MainWindow_Loaded;
|
||||||
Closed += MainWindow_Closed;
|
Closed += MainWindow_Closed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user