Files
bluflame/intromat/Intromat/Views/Editors/SamplerEditorView.cs
2026-04-18 22:31:51 +02:00

44 lines
1.6 KiB
C#

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<SamplerEditorViewModel>
{
private ComboBox _comboBoxFilter = null!;
private ComboBox _comboBoxAddress = null!;
public SamplerEditorView()
{
DefaultStyleKey = typeof(SamplerEditorView);
this.WhenActivated(d =>
{
var addressNames = Enum.GetValues(typeof(TextureAddressMode)).Cast<TextureAddressMode>().ToArray();
_comboBoxAddress.ItemsSource = addressNames;
var filterNames = Enum.GetValues(typeof(Filter)).Cast<Filter>();
_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))!;
}
}
}