using System; using System.Linq; using System.Reactive.Disposables; using System.Windows; using System.Windows.Controls; using Intromat.Interfaces; using Intromat.ViewModels.Editors; using ReactiveUI; using SharpDX.Direct3D11; namespace Intromat.Views.Editors { [TemplatePart(Name = nameof(_comboBoxFilter), Type = typeof(ComboBox))] [TemplatePart(Name = nameof(_comboBoxAddress), Type = typeof(ComboBox))] public class SamplerEditorView : EditorViewBase { private ComboBox _comboBoxFilter = null!; private ComboBox _comboBoxAddress = null!; public SamplerEditorView() { DefaultStyleKey = typeof(SamplerEditorView); this.WhenActivated(d => { var addressNames = Enum.GetValues(typeof(TextureAddressMode)).Cast().ToArray(); _comboBoxAddress.ItemsSource = addressNames; var filterNames = Enum.GetValues(typeof(Filter)).Cast(); _comboBoxFilter.ItemsSource = filterNames; this.Bind(ViewModel, vm => vm.Address, v => v._comboBoxAddress.SelectedItem).DisposeWith(d); this.Bind(ViewModel, vm => vm.Filter, v => v._comboBoxFilter.SelectedItem).DisposeWith(d); }); } public override void OnApplyTemplate() { base.OnApplyTemplate(); _comboBoxFilter = (ComboBox)GetTemplateChild(nameof(_comboBoxFilter))!; _comboBoxAddress = (ComboBox)GetTemplateChild(nameof(_comboBoxAddress))!; } } }