* Added Move Function

* Fixed #364

* Quick fix as the issue still sort of persisted.

* Update ModToIdConverter.cs

* Fixed the logic inverse.
This commit is contained in:
Neko Boi Nick
2020-02-15 12:56:51 -08:00
committed by GitHub
parent 5035fa39b7
commit bc54b79098
3 changed files with 22 additions and 7 deletions

View File

@@ -32,9 +32,14 @@ namespace Torch.Server.Views.Converters
{
//if (targetType != typeof(int))
// throw new NotSupportedException("ModToIdConverter can only convert mods into int values or vise versa!");
var mod = (ModItemInfo) values[0];
var theModList = (MtObservableList<ModItemInfo>) values[1];
return theModList.IndexOf(mod);
if (values[0] is ModItemInfo mod && values[1] is MtObservableList<ModItemInfo> modList)
{
return modList.IndexOf(mod);
}
else
{
return null;
}
}
/// <summary>

View File

@@ -205,9 +205,9 @@ namespace Torch.Server.Views
{
_hasOrderChanged = true;
var modList = (MtObservableList<ModItemInfo>)DataContext;
//modList.Move(modList.IndexOf(_draggedMod), modList.IndexOf(targetMod));
modList.RemoveAt(modList.IndexOf(_draggedMod));
modList.Insert(modList.IndexOf(targetMod), _draggedMod);
modList.Move(modList.IndexOf(targetMod), _draggedMod);
//modList.RemoveAt(modList.IndexOf(_draggedMod));
//modList.Insert(modList.IndexOf(targetMod), _draggedMod);
ModList.Items.Refresh();
ModList.SelectedItem = _draggedMod;
}