Skip to content

Commit a048a71

Browse files
committed
#254 Screens - Timer Control is now editable.
1 parent eb0c1ab commit a048a71

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

UI/OSAE.UI.Controls/AddControlPropertyLabel.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Button Name="btnAdd" Content="Add" HorizontalAlignment="Left" Margin="9,239,0,0" VerticalAlignment="Top" Width="75" Click="btnAdd_Click"/>
1313
<Button Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="360,239,0,0" VerticalAlignment="Top" Width="75" Click="btnCancel_Click"/>
1414
<Label Content="Object" HorizontalAlignment="Left" Margin="9,37,0,0" VerticalAlignment="Top"/>
15-
<ComboBox x:Name="cboObject" HorizontalAlignment="Left" Margin="80,39,0,0" VerticalAlignment="Top" Width="337" ItemsSource="{Binding Path=object_name}" DisplayMemberPath="object_name" SelectedValuePath="object_name" IsEditable="False" SelectionChanged="objectComboBox_SelectionChanged"/>
15+
<ComboBox x:Name="cboObject" HorizontalAlignment="Left" Margin="82,39,0,0" VerticalAlignment="Top" Width="337" ItemsSource="{Binding Path=object_name}" DisplayMemberPath="object_name" SelectedValuePath="object_name" IsEditable="False" SelectionChanged="objectComboBox_SelectionChanged"/>
1616
<Label Content="Suffix" HorizontalAlignment="Left" Margin="230,99,0,0" VerticalAlignment="Top"/>
1717
<ComboBox x:Name="cboProperty" HorizontalAlignment="Left" Margin="80,68,0,0" VerticalAlignment="Top" Width="337" ItemsSource="{Binding Path=property_name}" DisplayMemberPath="property_name" SelectedValuePath="property_name" IsEditable="False"/>
1818
<TextBox x:Name="txtFont" HorizontalAlignment="Left" Height="23" Margin="81,130,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="145" PreviewMouseDown="txtFont_MouseLeftButtonUp"/>

UI/OSAE.UI.Controls/AddControlTimerLabel.xaml.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public partial class AddControlTimerLabel : UserControl
1616
{
1717
private string currentScreen;
1818
string sOriginalName = "";
19+
string sOriginalObject = "";
1920
string sMode = "";
2021

2122
public AddControlTimerLabel(string screen, string controlName = "")
@@ -39,8 +40,7 @@ public AddControlTimerLabel(string screen, string controlName = "")
3940
LoadCurrentScreenObject(controlName);
4041
}
4142
}
42-
43-
if (controlName == "")
43+
else
4444
{
4545
sMode = "Add";
4646
}
@@ -79,9 +79,7 @@ private void LoadColors()
7979
foreColorComboBox.Text = "Black";
8080
backColorComboBox.Text = "White";
8181
txtFont.Text = "Arial";
82-
// txtFont.FontFamily = new System.Windows.Media.FontFamily("Arial");
8382
txtSize.Text = "8.5";
84-
8583
}
8684

8785
private void txtFont_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
@@ -91,17 +89,15 @@ private void txtFont_MouseLeftButtonUp(object sender, System.Windows.Input.Mouse
9189
System.Windows.Forms.FontDialog dlgFont = null;
9290
dlgFont = new System.Windows.Forms.FontDialog();
9391

94-
9592
if (dlgFont.ShowDialog() == System.Windows.Forms.DialogResult.OK)
9693
{
9794
txtFont.Text = dlgFont.Font.FontFamily.Name;
9895
txtFont.FontFamily = new System.Windows.Media.FontFamily(dlgFont.Font.FontFamily.Name);
9996
txtSize.Text = dlgFont.Font.Size.ToString();
10097
}
10198
}
102-
catch (Exception ex)
99+
catch
103100
{
104-
105101
}
106102
}
107103

@@ -134,8 +130,10 @@ private void btnUpdate_Click(object sender, RoutedEventArgs e)
134130
OSAEObjectPropertyManager.ObjectPropertySet(sName, "X", txtX.Text, "GUI");
135131
OSAEObjectPropertyManager.ObjectPropertySet(sName, "Y", txtY.Text, "GUI");
136132
OSAEObjectPropertyManager.ObjectPropertySet(sName, "Zorder", "1", "GUI");
137-
138-
OSAEScreenControlManager.ScreenObjectAdd(currentScreen, objectComboBox.Text, sName);
133+
if ((sOriginalObject != objectComboBox.Text) && (sOriginalName != sName))
134+
{
135+
OSAEScreenControlManager.ScreenObjectUpdate(currentScreen, objectComboBox.Text, sName);
136+
}
139137
NotifyParentFinished();
140138
}
141139

@@ -171,8 +169,11 @@ private void NotifyParentFinished()
171169
private void LoadCurrentScreenObject(string controlName)
172170
{
173171
objectComboBox.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Object Name").Value;
172+
sOriginalObject = objectComboBox.Text;
174173
txtFont.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Name").Value;
175174
txtSize.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Font Size").Value;
175+
foreColorComboBox.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Fore Color").Value;
176+
backColorComboBox.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Back Color").Value;
176177
txtX.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "X").Value;
177178
txtY.Text = OSAEObjectPropertyManager.GetObjectPropertyValue(controlName, "Y").Value;
178179
}
@@ -187,14 +188,14 @@ private void Enable_Buttons()
187188
btnDelete.IsEnabled = false;
188189
}
189190
//Now we handle Updates with no name changes
190-
if (sMode == "Update" && sOriginalName == objectComboBox.Text)
191+
if (sMode == "Update" && sOriginalObject == objectComboBox.Text)
191192
{
192193
btnAdd.IsEnabled = false;
193194
btnUpdate.IsEnabled = true;
194195
btnDelete.IsEnabled = true;
195196
}
196197
//Now we handle Updates WITH name changes
197-
if (sMode == "Update" && sOriginalName != objectComboBox.Text)
198+
if (sMode == "Update" && sOriginalObject != objectComboBox.Text)
198199
{
199200
btnAdd.IsEnabled = true;
200201
btnUpdate.IsEnabled = true;

UI/OSAE.UI.Controls/TimerLabel.xaml.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ public TimerLabel(OSAEObject sObj)
4040
screenName = Name;
4141

4242
ObjectName = screenObject.Property("Object Name").Value;
43-
OSAEObject timerObj = OSAEObjectManager.GetObjectByName(ObjectName);
44-
if (timerObj.Property("OFF TIMER").Value != "")
45-
OffTimer = Int32.Parse(timerObj.Property("OFF TIMER").Value);
46-
else
47-
OffTimer = 0;
48-
CurrentState = timerObj.State.Value;
49-
TimeInState = (int)timerObj.State.TimeInState;
43+
44+
OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);
45+
CurrentState = os.Value;
46+
47+
OffTimer = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName,"OFF TIMER").Value);
48+
TimeInState = (int)os.TimeInState;
5049

5150
string sValue;
5251
string sBackColor = screenObject.Property("Back Color").Value;
@@ -55,7 +54,7 @@ public TimerLabel(OSAEObject sObj)
5554
string sFontName = screenObject.Property("Font Name").Value;
5655

5756
if (CurrentState == "OFF")
58-
sValue = "OFF";
57+
sValue = os.StateLabel;
5958
else
6059
{
6160
span = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
@@ -72,9 +71,8 @@ public TimerLabel(OSAEObject sObj)
7271
SolidColorBrush brush = conv.ConvertFromString(sBackColor) as SolidColorBrush;
7372
timerLabel.Background = brush;
7473
}
75-
catch (Exception myerror)
74+
catch
7675
{
77-
7876
}
7977
}
8078
if (sForeColor != "")
@@ -85,7 +83,7 @@ public TimerLabel(OSAEObject sObj)
8583
SolidColorBrush brush = conv.ConvertFromString(sForeColor) as SolidColorBrush;
8684
timerLabel.Foreground = brush;
8785
}
88-
catch (Exception myerror)
86+
catch
8987
{
9088
}
9189
}
@@ -95,7 +93,7 @@ public TimerLabel(OSAEObject sObj)
9593
{
9694
timerLabel.FontSize = Convert.ToDouble(iFontSize);
9795
}
98-
catch (Exception myerror)
96+
catch
9997
{
10098
}
10199
}
@@ -105,7 +103,6 @@ public TimerLabel(OSAEObject sObj)
105103
{
106104
timerLabel.Content = "";
107105
}
108-
109106
timer.Interval = 1000;
110107
timer.Enabled = true;
111108
timer.Elapsed += new ElapsedEventHandler(timer_tick);
@@ -122,13 +119,15 @@ public void Update()
122119
TimeSpan ts = DateTime.Now - LastUpdated;
123120
TimeInState = (int)ts.TotalSeconds;
124121
if (os.Value == "OFF")
125-
sValue = "OFF";
122+
{
123+
sValue = os.StateLabel;
124+
timerLabel.Content = sValue;
125+
}
126126
else
127127
{
128128
span = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
129129
sValue = span.ToString(@"mm\:ss");
130130
}
131-
timerLabel.Content = sValue;
132131
}));
133132
}
134133

0 commit comments

Comments
 (0)