public FilterSetting(PokemonId pokemonId, IPokemonFilter filter, string filterName, Action <PokemonId, IPokemonFilter> onSave) { this.data = filter; translator = TinyIoCContainer.Current.Resolve <UITranslation>(); this.Title = string.Format(translator.TransferFilterFormTitle, pokemonId.ToString()); this.PokemonId = pokemonId; this.FilterName = filterName; this.onSaveFilter = onSave; this.DataContext = data; InitializeComponent(); pnlFilters.Children.Add(BuildObjectForm(filter)); DisplayListPokemons(filter.AffectToPokemons); }
public UIElement BuildObjectForm(IPokemonFilter source) { StackPanel panelWrap = new StackPanel(); Border border = new Border() { BorderBrush = Brushes.CadetBlue, BorderThickness = new Thickness(2, 2, 3, 3) }; StackPanel panel = new StackPanel() { Margin = new Thickness(20, 20, 20, 20), HorizontalAlignment = HorizontalAlignment.Left }; border.Child = panel; panelWrap.Children.Add(border); var type = source.GetType(); var fieldName = type.Name; foreach (var item in type.GetProperties()) { if (item.Name == "AffectToPokemons") { continue; } var att = item.GetCustomAttributes <NecrobotConfigAttribute>(true).FirstOrDefault(); if (att != null && !att.HiddenOnGui) { string resKey = $"Setting.{FilterName}.{item.Name}"; string DescKey = $"Setting.{FilterName}.{item.Name}Desc"; panel.Children.Add(new Label() { Content = translator.GetTranslation(resKey), FontSize = 15, ToolTip = translator.GetTranslation(DescKey) }); panel.Children.Add(GetInputControl(item, source)); } } return(panelWrap); }