Skip to content

Commit

Permalink
Add album ComboBox refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
VPKSoft committed Aug 21, 2022
1 parent c6ff588 commit b661ad5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions amp.EtoForms/FormMain.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using EtoForms.Controls.Custom.UserIdle;
using EtoForms.Controls.Custom.Utilities;
using Microsoft.EntityFrameworkCore;
using Album = amp.EtoForms.DtoClasses.Album;
using AlbumTrack = amp.EtoForms.DtoClasses.AlbumTrack;
using AudioTrack = amp.EtoForms.DtoClasses.AudioTrack;

Expand Down Expand Up @@ -534,14 +535,35 @@ await Globals.LoggerSafeInvokeAsync(async () =>

private async void ManageAlbumsCommand_Executed(object? sender, EventArgs e)
{
using var form = new FormAlbums(context);

bool changed;

if (UtilityOS.IsMacOS)
{
// ReSharper disable once MethodHasAsyncOverload, Shown-event won't fire on macOS.
new FormAlbums(context).ShowModal(this);
changed = form.ShowModal(this);
}
else
{
await new FormAlbums(context).ShowModalAsync(this);
changed = await form.ShowModalAsync(this);
}

if (changed)
{
suspendAlbumChange = true;
albums = context.Albums.Select(f => Globals.AutoMapper.Map<Album>(f)).ToList();
cmbAlbumSelect.DataStore = albums;
var index = albums.FindIndex(f => f.Id == CurrentAlbumId);
if (index == -1)
{
CurrentAlbumId = 1;
}
else
{
cmbAlbumSelect.SelectedIndex = index;
}
suspendAlbumChange = false;
}
}

Expand Down

0 comments on commit b661ad5

Please sign in to comment.