55using System . Text ;
66using System . Threading . Tasks ;
77using Caliburn . Micro ;
8+ using UI__Editor . EventAggregators ;
9+ using UI__Editor . Interfaces ;
10+ using UI__Editor . Models ;
811
912namespace UI__Editor . ViewModels . Preview . Children
1013{
11- class InputChoiceViewModel : PropertyChangedBase , IChild , IPreview
14+ class InputChoiceViewModel : PropertyChangedBase , IChild , IPreview , IHandle < ChangeUI >
1215 {
13- public IEventAggregator EventAggregator { get ; set ; }
16+ private IEventAggregator _EventAggregator ;
17+ public IEventAggregator EventAggregator
18+ {
19+ get { return _EventAggregator ; }
20+ set
21+ {
22+ _EventAggregator = value ;
23+ EventAggregator . Subscribe ( this ) ;
24+ }
25+ }
26+
1427 public bool PreviewRefreshButtonVisible { get { return false ; } }
1528 public bool PreviewBackButtonVisible { get { return false ; } }
1629 public bool PreviewCancelButtonVisible { get { return false ; } }
1730 public bool PreviewAcceptButtonVisible { get { return false ; } }
1831 public bool HasCustomPreview { get { return false ; } }
1932 public string WindowHeight { get ; set ; }
2033
21- private string _Font ;
34+ public InputChoiceViewModel ( )
35+ {
36+ EventAggregator = new EventAggregator ( ) ;
37+ }
38+
2239 public string Font
2340 {
24- get { return _Font ; }
25- set
41+ get
2642 {
27- _Font = value ;
28- NotifyOfPropertyChange ( ( ) => Font ) ;
43+ return Globals . DisplayFont ;
2944 }
3045 }
3146
@@ -40,14 +55,83 @@ public string Question
4055 }
4156 }
4257
43- private ObservableCollection < string > _Content ;
44- public ObservableCollection < string > Content
58+ private int _DropDownSize ;
59+ public int DropDownSize
60+ {
61+ get { return _DropDownSize ; }
62+ set
63+ {
64+ _DropDownSize = value ;
65+ NotifyOfPropertyChange ( ( ) => DropDownSize ) ;
66+ NotifyOfPropertyChange ( ( ) => DropDownHeight ) ;
67+ }
68+ }
69+
70+ private bool _Sort ;
71+ public bool Sort
4572 {
46- get { return _Content ; }
73+ get { return _Sort ; }
4774 set
4875 {
49- _Content = value ;
50- NotifyOfPropertyChange ( ( ) => Content ) ;
76+ _Sort = value ;
77+ NotifyOfPropertyChange ( ( ) => Sort ) ;
78+ NotifyOfPropertyChange ( ( ) => Choices ) ;
79+ }
80+ }
81+
82+ public string DropDownHeight
83+ {
84+ get
85+ {
86+ if ( DropDownSize > 0 )
87+ {
88+ return ( DropDownSize * 26 ) . ToString ( ) ;
89+ }
90+ else
91+ {
92+ return "130" ;
93+ }
94+ }
95+ }
96+
97+ public ObservableCollection < IChildElement > SubChildren { get ; set ; }
98+
99+ public List < string > Choices
100+ {
101+ get
102+ {
103+ List < string > returnList = new List < string > ( ) ;
104+ foreach ( IChildElement subchild in SubChildren )
105+ {
106+ if ( subchild is Choice )
107+ {
108+ returnList . Add ( ( subchild as Choice ) . Option ) ;
109+ }
110+ if ( subchild is ChoiceList )
111+ {
112+ if ( null != ( subchild as ChoiceList ) . OptionList )
113+ {
114+ returnList . AddRange ( ( subchild as ChoiceList ) . OptionList . Split ( ',' ) ) ;
115+ }
116+ }
117+ }
118+ if ( Sort )
119+ {
120+ returnList . Sort ( ) ;
121+ return returnList ;
122+ }
123+ else
124+ {
125+ return returnList ;
126+ }
127+ }
128+ }
129+
130+ public void Handle ( ChangeUI message )
131+ {
132+ if ( message . Type == "PreviewChange" )
133+ {
134+ NotifyOfPropertyChange ( ( ) => Choices ) ;
51135 }
52136 }
53137 }
0 commit comments