Skip to content

Commit b48395a

Browse files
committed
Completed Input sub-elements and moved the event aggregator to globals; - NWZ
1 parent 100cd9c commit b48395a

File tree

13 files changed

+145
-38
lines changed

13 files changed

+145
-38
lines changed

UI++Editor/Globals.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Caliburn.Micro;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
@@ -18,5 +19,6 @@ public static class Globals
1819
public static string PREFLIGHTFAILED;
1920
public static string PREFLIGHTPASSED;
2021
public static string PREFLIGHTPASSEDWITHWARNING;
22+
public static IEventAggregator EventAggregator;
2123
}
2224
}

UI++Editor/Models/ActionClasses/Input.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class Input : PropertyChangedBase, IElement, IAction, IParentElement
2020
public string[] ValidChildren { get; set; } = { "InputCheckbox","InputChoice","InputInfo","InputText" };
2121
public bool? ShowBack { get; set; } = false;
2222
public bool? ShowCancel { get; set; } = false;
23-
public bool? ADValidate { get; set; } = false;
2423
public string Name { get; set; }
2524
public string Size { get; set; } // default is Regular | Regular, Tall
2625
public bool CenterTitle = false;
@@ -54,7 +53,6 @@ public XmlNode GenerateXML()
5453
XmlAttribute type = d.CreateAttribute("Type");
5554
XmlAttribute showBack = d.CreateAttribute("ShowBack");
5655
XmlAttribute showCancel = d.CreateAttribute("ShowCancel");
57-
XmlAttribute adValidate = d.CreateAttribute("ADValidate");
5856
XmlAttribute name = d.CreateAttribute("Name");
5957
XmlAttribute size = d.CreateAttribute("Size");
6058
XmlAttribute title = d.CreateAttribute("Title");
@@ -65,7 +63,6 @@ public XmlNode GenerateXML()
6563
type.Value = ActionType;
6664
showBack.Value = ShowBack.ToString();
6765
showCancel.Value = ShowCancel.ToString();
68-
adValidate.Value = ADValidate.ToString();
6966
name.Value = Name;
7067
size.Value = Size;
7168
title.Value = Title;
@@ -82,10 +79,6 @@ public XmlNode GenerateXML()
8279
{
8380
output.Attributes.Append(showCancel);
8481
}
85-
if (null != ADValidate)
86-
{
87-
output.Attributes.Append(adValidate);
88-
}
8982
if (!string.IsNullOrEmpty(Name))
9083
{
9184
output.Attributes.Append(name);

UI++Editor/ViewModels/Actions/Children/ChoiceListViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public string HiddenAttributes
2626
public ChoiceListViewModel(ChoiceList c)
2727
{
2828
ModelClass = c;
29+
EventAggregator = Globals.EventAggregator;
2930
}
3031

3132
public string OptionList
@@ -34,6 +35,7 @@ public string OptionList
3435
set
3536
{
3637
(ModelClass as ChoiceList).OptionList = value;
38+
EventAggregator.BeginPublishOnUIThread(new EventAggregators.ChangeUI("PreviewChange", null));
3739
}
3840
}
3941

UI++Editor/ViewModels/Actions/Children/ChoiceViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public string HiddenAttributes
2525
public ChoiceViewModel(Choice c)
2626
{
2727
ModelClass = c;
28+
EventAggregator = Globals.EventAggregator;
2829
}
2930

3031
public string Option
@@ -33,6 +34,7 @@ public string Option
3334
set
3435
{
3536
(ModelClass as Choice).Option = value;
37+
EventAggregator.BeginPublishOnUIThread(new EventAggregators.ChangeUI("PreviewChange", null));
3638
}
3739
}
3840

UI++Editor/ViewModels/Actions/Children/InputChoiceViewModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using UI__Editor.Models;
88
using UI__Editor.ViewModels.Elements;
99
using UI__Editor.ViewModels.Preview;
10+
using UI__Editor.ViewModels.Preview.Children;
11+
using UI__Editor.Views.Preview.Children;
1012

1113
namespace UI__Editor.ViewModels.Actions.Children
1214
{
@@ -23,7 +25,8 @@ public string HiddenAttributes
2325
public InputChoiceViewModel(InputChoice i)
2426
{
2527
ModelClass = i;
26-
PreviewViewModel = new ViewModels.Preview.Children.InputChoiceViewModel();
28+
PreviewViewModel = new Preview.Children.InputChoiceViewModel();
29+
(PreviewViewModel as Preview.Children.InputChoiceViewModel).SubChildren = i.SubChildren;
2730
}
2831

2932
public string AlternateVariable
@@ -59,6 +62,7 @@ public int DropDownSize
5962
set
6063
{
6164
(ModelClass as InputChoice).DropDownSize = value;
65+
(PreviewViewModel as Preview.Children.InputChoiceViewModel).DropDownSize = value;
6266
}
6367
}
6468

@@ -68,6 +72,7 @@ public string Question
6872
set
6973
{
7074
(ModelClass as InputChoice).Question = value;
75+
(PreviewViewModel as Preview.Children.InputChoiceViewModel).Question = value;
7176
}
7277
}
7378

@@ -86,6 +91,7 @@ public bool Sort
8691
set
8792
{
8893
(ModelClass as InputChoice).Sort = value;
94+
(PreviewViewModel as Preview.Children.InputChoiceViewModel).Sort = value;
8995
}
9096
}
9197

UI++Editor/ViewModels/Actions/Children/InputTextViewModel.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ public InputTextViewModel(InputText i)
2626
PreviewViewModel = new Preview.Children.InputTextViewModel();
2727
}
2828

29+
private List<string> _ADValidations = new List<string>()
30+
{
31+
"",
32+
"Computer",
33+
"ComputerWarning",
34+
"User",
35+
"UserWarning"
36+
};
37+
public List<string> ADValidations
38+
{
39+
get { return _ADValidations; }
40+
set
41+
{
42+
_ADValidations = value;
43+
NotifyOfPropertyChange(() => ADValidations);
44+
}
45+
}
46+
47+
private string _SelectedADValidation;
48+
public string SelectedADValidation
49+
{
50+
get { return _SelectedADValidation; }
51+
set
52+
{
53+
_SelectedADValidation = value;
54+
ADValidate = value;
55+
}
56+
}
57+
2958
public string ADValidate
3059
{
3160
get { return (ModelClass as InputText).ADValidate; }

UI++Editor/ViewModels/Actions/InputViewModel.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public string HiddenAttributes
2323
{
2424
string ha;
2525
ha = "Name: " + Name;
26-
ha += "\r\nAD Validation: " + ADValidate;
2726
return ha;
2827
}
2928
}
@@ -61,17 +60,6 @@ public string Name
6160
}
6261
}
6362

64-
public bool? ADValidate
65-
{
66-
get { return (ModelClass as Input).ADValidate; }
67-
set
68-
{
69-
(ModelClass as Input).ADValidate = value;
70-
NotifyOfPropertyChange(() => HiddenAttributes);
71-
EventAggregator.BeginPublishOnUIThread(new EventAggregators.SendMessage("AttributeChange", null));
72-
}
73-
}
74-
7563
private BindableCollection<string> _Size = new BindableCollection<string>()
7664
{
7765
"Regular",

UI++Editor/ViewModels/Menus/ActionsViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ public ActionsViewModel(IEventAggregator ea, UIpp uipp)
425425
{
426426
_eventAggregator = ea;
427427
_eventAggregator.Subscribe(this);
428+
Globals.EventAggregator = ea;
428429
UIpp = uipp;
429430

430431
FontFamilies = new List<string>();

UI++Editor/ViewModels/Preview/Children/InputChoiceViewModel.cs

Lines changed: 96 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,42 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using Caliburn.Micro;
8+
using UI__Editor.EventAggregators;
9+
using UI__Editor.Interfaces;
10+
using UI__Editor.Models;
811

912
namespace 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
}

UI++Editor/Views/Actions/Children/InputTextView.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<ColumnDefinition Width="Auto" />
2828
<ColumnDefinition Width="*" />
2929
</Grid.ColumnDefinitions>
30-
<CheckBox x:Name="ADValidate" Margin="10,5" Grid.Row="0" IsChecked="False" Grid.ColumnSpan="3">AD Validate</CheckBox>
30+
<Label Margin="10,5,5,5">AD Validate:</Label>
31+
<ComboBox x:Name="ADValidations" Margin="0,5" HorizontalAlignment="Left" Width="150" Grid.Column="1" />
3132
<Label Margin="10,5,5,5" Grid.Row="1">Default Value:</Label>
3233
<TextBox x:Name="Default" Margin="0,5" Grid.Row="1" HorizontalAlignment="Left" Width="150" Grid.Column="1" />
3334
<Label Margin="10,5,5,5" Grid.Row="2">Force Case:</Label>

0 commit comments

Comments
 (0)