Skip to content

Commit

Permalink
Merge pull request #102 from VPKSoft/fix_albumComboUpdate
Browse files Browse the repository at this point in the history
Add album Combo box refresh.
  • Loading branch information
Petteri Kautonen authored Aug 21, 2022
2 parents c6ff588 + b661ad5 commit 3d9c8af
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 3d9c8af

Please sign in to comment.