added more exception guards
This commit is contained in:
parent
dfe174b4e7
commit
68fa74593f
@ -3,6 +3,7 @@ using System.Drawing.Drawing2D;
|
|||||||
using TaikoSoundEditor.Data;
|
using TaikoSoundEditor.Data;
|
||||||
using TaikoSoundEditor.Extensions;
|
using TaikoSoundEditor.Extensions;
|
||||||
using TaikoSoundEditor.Properties;
|
using TaikoSoundEditor.Properties;
|
||||||
|
using TaikoSoundEditor.Utils;
|
||||||
|
|
||||||
namespace TaikoSoundEditor.Controls
|
namespace TaikoSoundEditor.Controls
|
||||||
{
|
{
|
||||||
@ -150,15 +151,15 @@ namespace TaikoSoundEditor.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MusicOrdersPanel_Resize(object sender, EventArgs e)
|
private void MusicOrdersPanel_Resize(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
MusicOrdersPanel.Invalidate();
|
MusicOrdersPanel.Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
private void MusicOrdersPanel_Paint(object sender, PaintEventArgs e)
|
private void MusicOrdersPanel_Paint(object sender, PaintEventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
RefreshMusicOrdersPanel(e.Graphics);
|
RefreshMusicOrdersPanel(e.Graphics);
|
||||||
}
|
});
|
||||||
|
|
||||||
private void LeftButton_Click(object sender, EventArgs e)
|
private void LeftButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -170,21 +171,21 @@ namespace TaikoSoundEditor.Controls
|
|||||||
if (CurrentPage < PagesCount - 1) CurrentPage++;
|
if (CurrentPage < PagesCount - 1) CurrentPage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MusicOrdersPanel_MouseMove(object sender, MouseEventArgs e)
|
private void MusicOrdersPanel_MouseMove(object sender, MouseEventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
private void MusicOrdersPanel_MouseLeave(object sender, EventArgs e)
|
private void MusicOrdersPanel_MouseLeave(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
public HashSet<SongCard> Selection = new();
|
public HashSet<SongCard> Selection = new();
|
||||||
public HashSet<SongCard> CutSelection = new();
|
public HashSet<SongCard> CutSelection = new();
|
||||||
|
|
||||||
|
|
||||||
private void MusicOrdersPanel_MouseDown(object sender, MouseEventArgs e)
|
private void MusicOrdersPanel_MouseDown(object sender, MouseEventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
if (e.Button != MouseButtons.Left) return;
|
if (e.Button != MouseButtons.Left) return;
|
||||||
Select();
|
Select();
|
||||||
@ -234,7 +235,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
message = $"Do you want to move the selected songs before {before.Id}?";
|
message = $"Do you want to move the selected songs before {before.Id}?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(after != null)
|
else if (after != null)
|
||||||
{
|
{
|
||||||
message = $"Do you want to move the selected songs after {after.Id}?";
|
message = $"Do you want to move the selected songs after {after.Id}?";
|
||||||
}
|
}
|
||||||
@ -243,7 +244,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SongCards.RemoveAll(CutSelection.Contains);
|
SongCards.RemoveAll(CutSelection.Contains);
|
||||||
var ix = after != null ? SongCards.IndexOf(after)+1 : before != null ? SongCards.IndexOf(before) : 0;
|
var ix = after != null ? SongCards.IndexOf(after) + 1 : before != null ? SongCards.IndexOf(before) : 0;
|
||||||
SongCards.InsertRange(ix, CutSelection);
|
SongCards.InsertRange(ix, CutSelection);
|
||||||
|
|
||||||
foreach (var c in CutSelection) c.IsCut = false;
|
foreach (var c in CutSelection) c.IsCut = false;
|
||||||
@ -262,7 +263,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
|
|
||||||
if (Form.ModifierKeys == Keys.Control)
|
if (Form.ModifierKeys == Keys.Control)
|
||||||
{
|
{
|
||||||
if(card.IsSelected)
|
if (card.IsSelected)
|
||||||
{
|
{
|
||||||
card.IsSelected = false;
|
card.IsSelected = false;
|
||||||
Selection.Remove(card);
|
Selection.Remove(card);
|
||||||
@ -276,7 +277,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach(var sel in Selection)
|
foreach (var sel in Selection)
|
||||||
{
|
{
|
||||||
sel.IsSelected = false;
|
sel.IsSelected = false;
|
||||||
}
|
}
|
||||||
@ -288,7 +289,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
CutActive = RemoveActive = Selection.Count > 0;
|
CutActive = RemoveActive = Selection.Count > 0;
|
||||||
}
|
});
|
||||||
|
|
||||||
private bool _CutActive = false;
|
private bool _CutActive = false;
|
||||||
public bool CutActive
|
public bool CutActive
|
||||||
@ -327,16 +328,16 @@ namespace TaikoSoundEditor.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CutButton_Click(object sender, EventArgs e)
|
private void CutButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
PasteMode = false;
|
PasteMode = false;
|
||||||
foreach(var card in CutSelection)
|
foreach (var card in CutSelection)
|
||||||
{
|
{
|
||||||
card.IsCut = false;
|
card.IsCut = false;
|
||||||
}
|
}
|
||||||
CutSelection.Clear();
|
CutSelection.Clear();
|
||||||
|
|
||||||
foreach(var card in Selection)
|
foreach (var card in Selection)
|
||||||
{
|
{
|
||||||
card.IsCut = true;
|
card.IsCut = true;
|
||||||
card.IsSelected = false;
|
card.IsSelected = false;
|
||||||
@ -348,7 +349,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
CutActive = RemoveActive = Selection.Count > 0;
|
CutActive = RemoveActive = Selection.Count > 0;
|
||||||
|
|
||||||
MusicOrdersPanel.Invalidate();
|
MusicOrdersPanel.Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
private bool _PasteMode = false;
|
private bool _PasteMode = false;
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void PasteButton_Click(object sender, EventArgs e)
|
private void PasteButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
PasteMode = !PasteMode;
|
PasteMode = !PasteMode;
|
||||||
|
|
||||||
@ -372,20 +373,20 @@ namespace TaikoSoundEditor.Controls
|
|||||||
Selection.Clear();
|
Selection.Clear();
|
||||||
CutActive = RemoveActive = false;
|
CutActive = RemoveActive = false;
|
||||||
MusicOrdersPanel.Invalidate();
|
MusicOrdersPanel.Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
private void RemoveButton_Click(object sender, EventArgs e)
|
private void RemoveButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
var toRemove = Selection.ToList();
|
var toRemove = Selection.ToList();
|
||||||
if (Selection.Count == 0)
|
if (Selection.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var message = $"Are you sure you want to remove {toRemove.Count} song{(toRemove.Count!=1?"s":"")}?";
|
var message = $"Are you sure you want to remove {toRemove.Count} song{(toRemove.Count != 1 ? "s" : "")}?";
|
||||||
|
|
||||||
if (MessageBox.Show(message, "Remove?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
if (MessageBox.Show(message, "Remove?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach(var card in Selection)
|
foreach (var card in Selection)
|
||||||
{
|
{
|
||||||
SongCards.Remove(card);
|
SongCards.Remove(card);
|
||||||
CutSelection.Remove(card);
|
CutSelection.Remove(card);
|
||||||
@ -398,7 +399,7 @@ namespace TaikoSoundEditor.Controls
|
|||||||
if (!PasteActive) PasteMode = false;
|
if (!PasteActive) PasteMode = false;
|
||||||
CurrentPage = CurrentPage;
|
CurrentPage = CurrentPage;
|
||||||
MusicOrdersPanel.Invalidate();
|
MusicOrdersPanel.Invalidate();
|
||||||
}
|
});
|
||||||
|
|
||||||
public delegate void OnSongRemoved(MusicOrderViewer sender, MusicOrder mo);
|
public delegate void OnSongRemoved(MusicOrderViewer sender, MusicOrder mo);
|
||||||
public event OnSongRemoved SongRemoved;
|
public event OnSongRemoved SongRemoved;
|
||||||
|
26
MainForm.cs
26
MainForm.cs
@ -23,7 +23,7 @@ namespace TaikoSoundEditor
|
|||||||
|
|
||||||
private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
|
private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Logger.Info($"Commuted to tab {TabControl.SelectedIndex}");
|
Logger.Info($"Commuted to tab {TabControl.SelectedIndex}.{TabControl.Name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Editor
|
#region Editor
|
||||||
@ -96,7 +96,7 @@ namespace TaikoSoundEditor
|
|||||||
|
|
||||||
private bool indexChanging = false;
|
private bool indexChanging = false;
|
||||||
|
|
||||||
private void LoadedMusicBox_SelectedIndexChanged(object sender, EventArgs e)
|
private void LoadedMusicBox_SelectedIndexChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
if (indexChanging) return;
|
if (indexChanging) return;
|
||||||
indexChanging = true;
|
indexChanging = true;
|
||||||
@ -105,21 +105,21 @@ namespace TaikoSoundEditor
|
|||||||
Logger.Info($"Selection Changed MusicItem: {item}");
|
Logger.Info($"Selection Changed MusicItem: {item}");
|
||||||
LoadMusicInfo(item);
|
LoadMusicInfo(item);
|
||||||
indexChanging = false;
|
indexChanging = false;
|
||||||
}
|
});
|
||||||
|
|
||||||
private void EditorTable_Resize(object sender, EventArgs e)
|
private void EditorTable_Resize(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
WordsGB.Height = WordSubGB.Height = WordDetailGB.Height = EditorTable.Height / 3;
|
WordsGB.Height = WordSubGB.Height = WordDetailGB.Height = EditorTable.Height / 3;
|
||||||
}
|
});
|
||||||
|
|
||||||
private void NewSoundsBox_SelectedIndexChanged(object sender, EventArgs e)
|
private void NewSoundsBox_SelectedIndexChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
if (indexChanging) return;
|
if (indexChanging) return;
|
||||||
indexChanging = true;
|
indexChanging = true;
|
||||||
LoadedMusicBox.SelectedItem = null;
|
LoadedMusicBox.SelectedItem = null;
|
||||||
var item = NewSoundsBox.SelectedItem as NewSongData;
|
var item = NewSoundsBox.SelectedItem as NewSongData;
|
||||||
LoadNewSongData(item);
|
LoadNewSongData(item);
|
||||||
}
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -194,9 +194,9 @@ namespace TaikoSoundEditor
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
private void SoundViewTab_SelectedIndexChanged(object sender, EventArgs e)
|
private void SoundViewTab_SelectedIndexChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
if(SoundViewTab.SelectedTab==MusicOrderTab)
|
if (SoundViewTab.SelectedTab == MusicOrderTab)
|
||||||
{
|
{
|
||||||
MusicOrderViewer.Invalidate();
|
MusicOrderViewer.Invalidate();
|
||||||
return;
|
return;
|
||||||
@ -213,14 +213,14 @@ namespace TaikoSoundEditor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NewSoundsBox.SelectedItem!=null)
|
if (NewSoundsBox.SelectedItem != null)
|
||||||
{
|
{
|
||||||
var item = NewSoundsBox.SelectedItem as NewSongData;
|
var item = NewSoundsBox.SelectedItem as NewSongData;
|
||||||
Logger.Info($"Tab switched, reloading NewSongData: {item}");
|
Logger.Info($"Tab switched, reloading NewSongData: {item}");
|
||||||
LoadNewSongData(item);
|
LoadNewSongData(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
private bool simpleBoxLoading = false;
|
private bool simpleBoxLoading = false;
|
||||||
private void SimpleBoxChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
private void SimpleBoxChanged(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
@ -284,7 +284,7 @@ namespace TaikoSoundEditor
|
|||||||
throw new InvalidOperationException("Nothing to remove.");
|
throw new InvalidOperationException("Nothing to remove.");
|
||||||
});
|
});
|
||||||
|
|
||||||
private void LocateInMusicOrderButton_Click(object sender, EventArgs e)
|
private void LocateInMusicOrderButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||||
{
|
{
|
||||||
if (LoadedMusicBox.SelectedItem != null)
|
if (LoadedMusicBox.SelectedItem != null)
|
||||||
{
|
{
|
||||||
@ -305,6 +305,6 @@ namespace TaikoSoundEditor
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2023-07-29T08:28:56.2445862Z;True|2023-07-29T11:05:03.3876668+03:00;True|2023-07-29T10:54:04.8963992+03:00;True|2023-07-29T10:22:03.4096107+03:00;True|2023-07-29T10:05:26.6712083+03:00;True|2023-07-28T19:30:15.3174413+03:00;True|2023-07-22T19:07:39.3718711+03:00;True|2023-07-22T19:06:41.2393088+03:00;True|2023-07-22T12:07:26.2620601+03:00;True|2023-07-22T12:06:39.9230498+03:00;True|2023-07-22T11:29:18.0153916+03:00;True|2023-07-22T08:23:07.5000923+03:00;True|2023-07-21T20:03:15.6598520+03:00;True|2023-07-21T19:41:13.2800435+03:00;True|2023-07-19T13:08:33.4726289+03:00;True|2023-07-19T12:08:17.2430335+03:00;True|2023-07-18T09:38:50.7615921+03:00;True|2023-07-18T09:25:23.0403589+03:00;True|2023-07-17T17:57:08.1469738+03:00;True|2023-07-17T11:28:41.9554245+03:00;True|2023-07-17T11:15:26.2194507+03:00;</History>
|
<History>True|2023-07-30T05:20:21.5020489Z;True|2023-07-29T11:28:56.2445862+03:00;True|2023-07-29T11:05:03.3876668+03:00;True|2023-07-29T10:54:04.8963992+03:00;True|2023-07-29T10:22:03.4096107+03:00;True|2023-07-29T10:05:26.6712083+03:00;True|2023-07-28T19:30:15.3174413+03:00;True|2023-07-22T19:07:39.3718711+03:00;True|2023-07-22T19:06:41.2393088+03:00;True|2023-07-22T12:07:26.2620601+03:00;True|2023-07-22T12:06:39.9230498+03:00;True|2023-07-22T11:29:18.0153916+03:00;True|2023-07-22T08:23:07.5000923+03:00;True|2023-07-21T20:03:15.6598520+03:00;True|2023-07-21T19:41:13.2800435+03:00;True|2023-07-19T13:08:33.4726289+03:00;True|2023-07-19T12:08:17.2430335+03:00;True|2023-07-18T09:38:50.7615921+03:00;True|2023-07-18T09:25:23.0403589+03:00;True|2023-07-17T17:57:08.1469738+03:00;True|2023-07-17T11:28:41.9554245+03:00;True|2023-07-17T11:15:26.2194507+03:00;</History>
|
||||||
<LastFailureDetails />
|
<LastFailureDetails />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue
Block a user