private void Refresh() { try { _listView.ItemsSource = new[] { UiDataProviderNode.Create(InteractionService.Configuration), UiDataProviderNode.Create(InteractionService.GameLocation), UiDataProviderNode.Create(InteractionService.WorkingLocation), UiDataProviderNode.Create(InteractionService.TextEncoding) }; } catch (Exception ex) { UiHelper.ShowError(this, ex); } }
public static UiDataProviderNode Create <T>(InfoProviderGroup <T> providers) where T : class { UiContextMenu menu = UiContextMenuFactory.Create(); for (int index = 0; index < providers.Count; index++) { IInfoProvider <T> provider = providers[index]; UiMenuItem menuItem = UiMenuItemFactory.Create(provider.Title, new UiDataProviderNodeRefreshCommand(() => providers.Refresh(provider))); menuItem.ToolTip = provider.Description; menu.AddChild(menuItem); } UiDataProviderNode node = new UiDataProviderNode(providers.Title, providers.Description, menu); providers.InfoLost += node.OnInfoLost; providers.InfoProvided += node.OnInfoProvided; return(node); }