1- using OnnxStack . UI . Commands ;
1+ using Models ;
2+ using OnnxStack . StableDiffusion . Enums ;
3+ using OnnxStack . UI . Commands ;
24using OnnxStack . UI . Models ;
5+ using System . Collections . ObjectModel ;
6+ using System ;
37using System . ComponentModel ;
48using System . Runtime . CompilerServices ;
59using System . Windows ;
610using System . Windows . Controls ;
711using System . Windows . Input ;
12+ using System . Linq ;
813
914namespace OnnxStack . UI . UserControls
1015{
@@ -13,6 +18,7 @@ namespace OnnxStack.UI.UserControls
1318 /// </summary>
1419 public partial class PromptControl : UserControl , INotifyPropertyChanged
1520 {
21+ private ObservableCollection < SchedulerType > _schedulerTypes = new ( ) ;
1622
1723 /// <summary>Initializes a new instance of the <see cref="PromptControl" /> class.</summary>
1824 public PromptControl ( )
@@ -43,6 +49,46 @@ public PromptOptionsModel PromptOptions
4349 DependencyProperty . Register ( "PromptOptions" , typeof ( PromptOptionsModel ) , typeof ( PromptControl ) ) ;
4450
4551
52+ public ModelOptionsModel SelectedModel
53+ {
54+ get { return ( ModelOptionsModel ) GetValue ( SelectedModelProperty ) ; }
55+ set { SetValue ( SelectedModelProperty , value ) ; }
56+ }
57+
58+ public static readonly DependencyProperty SelectedModelProperty =
59+ DependencyProperty . Register ( "SelectedModel" , typeof ( ModelOptionsModel ) , typeof ( PromptControl ) , new PropertyMetadata ( ( d , e ) =>
60+ {
61+ if ( d is PromptControl schedulerControl )
62+ schedulerControl . OnModelChanged ( e . NewValue as ModelOptionsModel ) ;
63+ } ) ) ;
64+
65+ public ObservableCollection < SchedulerType > SchedulerTypes
66+ {
67+ get { return _schedulerTypes ; }
68+ set { _schedulerTypes = value ; NotifyPropertyChanged ( ) ; }
69+ }
70+
71+
72+ /// <summary>
73+ /// Called when the selected model has changed.
74+ /// </summary>
75+ /// <param name="modelOptionsModel">The model options model.</param>
76+ private void OnModelChanged ( ModelOptionsModel model )
77+ {
78+ SchedulerTypes . Clear ( ) ;
79+ if ( model . ModelOptions . PipelineType == DiffuserPipelineType . StableDiffusion )
80+ {
81+ foreach ( SchedulerType type in Enum . GetValues < SchedulerType > ( ) . Where ( x => x != SchedulerType . LCM ) )
82+ SchedulerTypes . Add ( type ) ;
83+ }
84+ else if ( model . ModelOptions . PipelineType == DiffuserPipelineType . LatentConsistency )
85+ {
86+ SchedulerTypes . Add ( SchedulerType . LCM ) ;
87+ }
88+
89+ PromptOptions . SchedulerType = SchedulerTypes . FirstOrDefault ( ) ;
90+ }
91+
4692 /// <summary>
4793 /// Resets the parameters.
4894 /// </summary>
0 commit comments