can remove from music order viewer
This commit is contained in:
parent
b6dc9131b7
commit
5cdbdfc032
16
Controls/MusicOrderViewer.Designer.cs
generated
16
Controls/MusicOrderViewer.Designer.cs
generated
@ -35,6 +35,7 @@
|
||||
this.CutButton = new System.Windows.Forms.Button();
|
||||
this.PageLabel = new System.Windows.Forms.Label();
|
||||
this.LeftButton = new System.Windows.Forms.Button();
|
||||
this.RemoveButton = new System.Windows.Forms.Button();
|
||||
this.ControlsPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -64,6 +65,7 @@
|
||||
//
|
||||
// ControlsPanel
|
||||
//
|
||||
this.ControlsPanel.Controls.Add(this.RemoveButton);
|
||||
this.ControlsPanel.Controls.Add(this.PasteButton);
|
||||
this.ControlsPanel.Controls.Add(this.CutButton);
|
||||
this.ControlsPanel.Controls.Add(this.PageLabel);
|
||||
@ -120,6 +122,19 @@
|
||||
this.LeftButton.UseVisualStyleBackColor = true;
|
||||
this.LeftButton.Click += new System.EventHandler(this.LeftButton_Click);
|
||||
//
|
||||
// RemoveButton
|
||||
//
|
||||
this.RemoveButton.BackgroundImage = global::TaikoSoundEditor.Properties.Resources.ic_remove_gs;
|
||||
this.RemoveButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.RemoveButton.FlatAppearance.BorderSize = 0;
|
||||
this.RemoveButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.RemoveButton.Location = new System.Drawing.Point(63, 3);
|
||||
this.RemoveButton.Name = "RemoveButton";
|
||||
this.RemoveButton.Size = new System.Drawing.Size(24, 24);
|
||||
this.RemoveButton.TabIndex = 3;
|
||||
this.RemoveButton.UseVisualStyleBackColor = true;
|
||||
this.RemoveButton.Click += new System.EventHandler(this.RemoveButton_Click);
|
||||
//
|
||||
// MusicOrderViewer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
@ -145,5 +160,6 @@
|
||||
private Label PageLabel;
|
||||
private Button CutButton;
|
||||
private Button PasteButton;
|
||||
private Button RemoveButton;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Drawing2D;
|
||||
using TaikoSoundEditor.Data;
|
||||
using TaikoSoundEditor.Extensions;
|
||||
using TaikoSoundEditor.Properties;
|
||||
|
||||
namespace TaikoSoundEditor.Controls
|
||||
@ -33,8 +34,9 @@ namespace TaikoSoundEditor.Controls
|
||||
CutSelection.RemoveWhere(c => c.MusicOrder == mo);
|
||||
|
||||
PasteActive = CutSelection.Count > 0;
|
||||
CutActive = Selection.Count > 0;
|
||||
CutActive = RemoveActive = Selection.Count > 0;
|
||||
if (!PasteActive) PasteMode = false;
|
||||
CurrentPage = CurrentPage;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ namespace TaikoSoundEditor.Controls
|
||||
get => _CurrentPage;
|
||||
set
|
||||
{
|
||||
_CurrentPage = value;
|
||||
_CurrentPage = value.Clamp(0, PagesCount - 1);
|
||||
PageLabel.Text = $"Page {_CurrentPage + 1} of {PagesCount}";
|
||||
MusicOrdersPanel.Invalidate();
|
||||
|
||||
@ -247,7 +249,7 @@ namespace TaikoSoundEditor.Controls
|
||||
CutSelection.Clear();
|
||||
PasteMode = false;
|
||||
PasteActive = false;
|
||||
CutActive = false;
|
||||
CutActive = RemoveActive = false;
|
||||
MusicOrdersPanel.Invalidate();
|
||||
|
||||
return;
|
||||
@ -284,7 +286,7 @@ namespace TaikoSoundEditor.Controls
|
||||
MusicOrdersPanel.Invalidate();
|
||||
}
|
||||
|
||||
CutActive = Selection.Count > 0;
|
||||
CutActive = RemoveActive = Selection.Count > 0;
|
||||
}
|
||||
|
||||
private bool _CutActive = false;
|
||||
@ -311,6 +313,19 @@ namespace TaikoSoundEditor.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private bool _RemoveActive=false;
|
||||
|
||||
public bool RemoveActive
|
||||
{
|
||||
get => _RemoveActive;
|
||||
set
|
||||
{
|
||||
_RemoveActive = value;
|
||||
RemoveButton.BackgroundImage = RemoveActive ? Resources.ic_remove : Resources.ic_remove_gs;
|
||||
RemoveButton.Enabled = RemoveActive;
|
||||
}
|
||||
}
|
||||
|
||||
private void CutButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PasteMode = false;
|
||||
@ -329,7 +344,7 @@ namespace TaikoSoundEditor.Controls
|
||||
Selection.Clear();
|
||||
|
||||
PasteActive = CutSelection.Count > 0;
|
||||
CutActive= Selection.Count > 0;
|
||||
CutActive = RemoveActive = Selection.Count > 0;
|
||||
|
||||
MusicOrdersPanel.Invalidate();
|
||||
}
|
||||
@ -346,6 +361,7 @@ namespace TaikoSoundEditor.Controls
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void PasteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PasteMode = !PasteMode;
|
||||
@ -353,7 +369,37 @@ namespace TaikoSoundEditor.Controls
|
||||
foreach (var card in Selection)
|
||||
card.IsSelected = false;
|
||||
Selection.Clear();
|
||||
CutActive = RemoveActive = false;
|
||||
MusicOrdersPanel.Invalidate();
|
||||
}
|
||||
|
||||
private void RemoveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var toRemove = Selection.ToList();
|
||||
if (Selection.Count == 0)
|
||||
return;
|
||||
|
||||
var message = $"Are you sure you want to remove {toRemove.Count} song{(toRemove.Count>0?"s":"")}?";
|
||||
|
||||
if (MessageBox.Show(message, "Remove?", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
foreach(var card in Selection)
|
||||
{
|
||||
SongCards.Remove(card);
|
||||
CutSelection.Remove(card);
|
||||
SongRemoved?.Invoke(this, card.MusicOrder);
|
||||
}
|
||||
Selection.Clear();
|
||||
|
||||
CutActive = RemoveActive = false;
|
||||
PasteActive = CutSelection.Count > 0;
|
||||
if (!PasteActive) PasteMode = false;
|
||||
CurrentPage = CurrentPage;
|
||||
MusicOrdersPanel.Invalidate();
|
||||
}
|
||||
|
||||
public delegate void OnSongRemoved(MusicOrderViewer sender, MusicOrder mo);
|
||||
public event OnSongRemoved SongRemoved;
|
||||
}
|
||||
}
|
||||
|
5
MainForm.Designer.cs
generated
5
MainForm.Designer.cs
generated
@ -803,13 +803,18 @@
|
||||
// MusicOrderViewer
|
||||
//
|
||||
this.MusicOrderViewer.CurrentPage = 0;
|
||||
this.MusicOrderViewer.CutActive = false;
|
||||
this.MusicOrderViewer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.MusicOrderViewer.ItemsPerCol = 5;
|
||||
this.MusicOrderViewer.ItemsPerRow = 4;
|
||||
this.MusicOrderViewer.Location = new System.Drawing.Point(3, 3);
|
||||
this.MusicOrderViewer.Name = "MusicOrderViewer";
|
||||
this.MusicOrderViewer.PasteActive = false;
|
||||
this.MusicOrderViewer.PasteMode = false;
|
||||
this.MusicOrderViewer.RemoveActive = false;
|
||||
this.MusicOrderViewer.Size = new System.Drawing.Size(515, 290);
|
||||
this.MusicOrderViewer.TabIndex = 0;
|
||||
this.MusicOrderViewer.SongRemoved += new TaikoSoundEditor.Controls.MusicOrderViewer.OnSongRemoved(this.MusicOrderViewer_SongRemoved);
|
||||
//
|
||||
// RemoveSongButton
|
||||
//
|
||||
|
50
MainForm.cs
50
MainForm.cs
@ -123,13 +123,8 @@ namespace TaikoSoundEditor
|
||||
|
||||
#endregion
|
||||
|
||||
private void RemoveSongButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||
private void RemoveNewSong(NewSongData ns)
|
||||
{
|
||||
Logger.Info("Clicked remove song");
|
||||
if (NewSoundsBox.SelectedItem != null)
|
||||
{
|
||||
Logger.Info("Removing newly added song");
|
||||
var ns = NewSoundsBox.SelectedItem as NewSongData;
|
||||
AddedMusic.Remove(ns);
|
||||
Logger.Info("Refreshing list");
|
||||
AddedMusicBinding.ResetBindings(false);
|
||||
@ -140,14 +135,10 @@ namespace TaikoSoundEditor
|
||||
WordList.Items.Remove(ns.WordDetail);
|
||||
WordList.Items.Remove(ns.WordSub);
|
||||
MusicAttributes.Items.Remove(ns.MusicAttribute);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (LoadedMusicBox.SelectedItem != null)
|
||||
private void RemoveExistingSong(MusicInfo mi)
|
||||
{
|
||||
Logger.Info("Removing existing song");
|
||||
var mi = LoadedMusicBox.SelectedItem as MusicInfo;
|
||||
var ma = MusicAttributes.GetByUniqueId(mi.UniqueId);
|
||||
var mo = MusicOrders.GetByUniqueId(mi.UniqueId);
|
||||
var w = WordList.GetBySong(mi.Id);
|
||||
@ -181,7 +172,24 @@ namespace TaikoSoundEditor
|
||||
|
||||
Logger.Info("Removing from music orders");
|
||||
MusicOrderViewer.RemoveSong(mo);
|
||||
}
|
||||
|
||||
private void RemoveSongButton_Click(object sender, EventArgs e) => ExceptionGuard.Run(() =>
|
||||
{
|
||||
Logger.Info("Clicked remove song");
|
||||
if (NewSoundsBox.SelectedItem != null)
|
||||
{
|
||||
Logger.Info("Removing newly added song");
|
||||
var ns = NewSoundsBox.SelectedItem as NewSongData;
|
||||
RemoveNewSong(ns);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LoadedMusicBox.SelectedItem != null)
|
||||
{
|
||||
Logger.Info("Removing existing song");
|
||||
var mi = LoadedMusicBox.SelectedItem as MusicInfo;
|
||||
RemoveExistingSong(mi);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -255,5 +263,25 @@ namespace TaikoSoundEditor
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
private void MusicOrderViewer_SongRemoved(Controls.MusicOrderViewer sender, MusicOrder mo) => ExceptionGuard.Run(() =>
|
||||
{
|
||||
var uniqId = mo.UniqueId;
|
||||
var mi = MusicInfos.Items.Where(x => x.UniqueId == uniqId).FirstOrDefault();
|
||||
|
||||
if (mi != null)
|
||||
{
|
||||
RemoveExistingSong(mi);
|
||||
return;
|
||||
}
|
||||
|
||||
var ns = AddedMusic.Where(x => x.UniqueId == uniqId).FirstOrDefault();
|
||||
if (ns != null)
|
||||
{
|
||||
RemoveNewSong(ns);
|
||||
return;
|
||||
}
|
||||
throw new InvalidOperationException("Nothing to remove.");
|
||||
});
|
||||
}
|
||||
}
|
20
Properties/Resources.Designer.cs
generated
20
Properties/Resources.Designer.cs
generated
@ -100,6 +100,26 @@ namespace TaikoSoundEditor.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ic_remove {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ic_remove", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap ic_remove_gs {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ic_remove_gs", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
|
@ -130,6 +130,12 @@
|
||||
<data name="ic_paste_gs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ic_paste_gs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ic_remove" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ic_remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ic_remove_gs" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ic_remove_gs.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="song_ABCDEF_nus3bank" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\song_ABCDEF_nus3bank.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
|
BIN
Resources/ic_remove.png
Normal file
BIN
Resources/ic_remove.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 562 B |
BIN
Resources/ic_remove_gs.png
Normal file
BIN
Resources/ic_remove_gs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 554 B |
Loading…
Reference in New Issue
Block a user