Skip to content

Commit 36ee3b6

Browse files
committed
GUI - Minor Timer and State control tweeks.
1 parent 343fb3c commit 36ee3b6

2 files changed

Lines changed: 17 additions & 21 deletions

File tree

UI/Web/controls/ctrlStateImage.ascx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected void Page_Load(object sender, EventArgs e)
3838
{
3939
LightLevel = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "Light Level").Value);
4040
}
41-
catch (Exception ex)
41+
catch
4242
{
4343
LightLevel = 100.00;
4444
}
@@ -62,6 +62,7 @@ protected void Page_Load(object sender, EventArgs e)
6262
}
6363
}
6464

65+
/*
6566
public void Update()
6667
{
6768
if (OSAEObjectStateManager.GetObjectStateValue(hdnObjName.Value).Value != hdnCurState.Value)
@@ -86,7 +87,6 @@ public void Update()
8687
LightLevel = 100.00;
8788
}
8889
89-
9090
string imgName = screenObject.Property(StateMatch + " Image").Value;
9191
OSAEImage img = imgMgr.GetImage(imgName);
9292
imgStateImage.ImageUrl = "~/ImageHandler.ashx?id=" + img.ID;
@@ -101,5 +101,5 @@ public void Update()
101101
imgStateImage.Attributes.Add("onclick", "runMethod('" + ObjectName + "','ON','','');");
102102
}
103103
}
104-
}
104+
}*/
105105
}

UI/Web/controls/ctrlTimerLabel.ascx.cs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,32 @@ public partial class controls_ctrlTimerLabel : System.Web.UI.UserControl
1717
private string CurrentState;
1818
private int TimeInState;
1919
TimeSpan span;
20-
string time;
20+
string sValue;
2121

2222
protected void Page_Load(object sender, EventArgs e)
2323
{
2424
ObjectName = screenObject.Property("Object Name").Value;
25-
OSAEObject timerObj = OSAEObjectManager.GetObjectByName(ObjectName);
26-
if (timerObj.Property("OFF TIMER").Value != "")
27-
OffTimer = Int32.Parse(timerObj.Property("OFF TIMER").Value);
28-
else
29-
OffTimer = 0;
30-
CurrentState = timerObj.State.Value;
31-
32-
TimeSpan ts = DateTime.Now - DateTime.Parse(timerObj.LastUpd);
33-
TimeInState = (int)ts.TotalSeconds;
25+
OSAEObjectState os = OSAEObjectStateManager.GetObjectStateValue(ObjectName);
26+
CurrentState = os.Value;
3427

35-
if (CurrentState == "OFF")
36-
time = "OFF";
37-
else
38-
{
39-
span = TimeSpan.FromSeconds(OffTimer - TimeInState);
40-
time = span.ToString(@"mm\:ss");
41-
}
28+
OffTimer = Convert.ToUInt16(OSAEObjectPropertyManager.GetObjectPropertyValue(ObjectName, "OFF TIMER").Value);
29+
TimeInState = (int)os.TimeInState;
4230

4331
string sBackColor = screenObject.Property("Back Color").Value;
4432
string sForeColor = screenObject.Property("Fore Color").Value;
4533
string sPrefix = screenObject.Property("Prefix").Value;
4634
string sSuffix = screenObject.Property("Suffix").Value;
4735
string iFontSize = screenObject.Property("Font Size").Value;
4836

49-
TimerLabel.Text = time;
37+
if (CurrentState == "OFF")
38+
sValue = os.StateLabel;
39+
else
40+
{
41+
span = TimeSpan.FromSeconds(OffTimer - TimeInState); //Or TimeSpan.FromSeconds(seconds); (see Jakob C´s answer)
42+
sValue = span.ToString(@"mm\:ss");
43+
}
44+
45+
TimerLabel.Text = sValue;
5046
TimerLabel.Attributes.Add("Style", "position:absolute;top:" + (Int32.Parse(screenObject.Property("Y").Value) + 50).ToString() + "px;left:" + (Int32.Parse(screenObject.Property("X").Value) + 10).ToString() + "px;z-index:" + (Int32.Parse(screenObject.Property("ZOrder").Value) + 10).ToString() + ";");
5147

5248
if (sBackColor != "")

0 commit comments

Comments
 (0)