private async Task PopulateEntities() { if (WorkingState) { return; } // Reinit other controls Entities.Clear(); WorkingState = true; OnWorkingStateChanged?.Invoke(this, EventArgs.Empty); var infoPanelEventArgs = new GetInformationPanelEventArgs { Message = "Loading Entities...", Width = 340, Height = 150 }; OnGetInformationPanel?.Invoke(this, infoPanelEventArgs); var informationPanel = infoPanelEventArgs.Panel; var sourceEntitiesList = new List <EntityItem>(); try { await Task.Factory.StartNew(() => { var sourceList = _metadataHelper.RetrieveEntities(Service); foreach (EntityMetadata entity in sourceList) { sourceEntitiesList.Add(new EntityItem(entity)); } }); informationPanel.Dispose(); if (sourceEntitiesList.Count == 0) { OnShowMessageBox?.Invoke(this, new MessageBoxEventArgs("The system does not contain any entities", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)); } else { Entities.AddRange(sourceEntitiesList); Entities.Sort(); OnEntitiesListChanged?.Invoke(this, EventArgs.Empty); } } catch (Exception ex) { OnShowMessageBox?.Invoke(this, new MessageBoxEventArgs("An error occured: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)); } WorkingState = false; OnWorkingStateChanged?.Invoke(this, EventArgs.Empty); }
public void Show(string title, string message, MessageBoxButtonTypeEnum buttonType, Action <MessageBoxResultEnum> actionToInvoke) { OnShowMessageBox.Invoke(title, message, buttonType, actionToInvoke); }