mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-09 17:54:59 +00:00
Fixing shutdown timers; removing Timer from ModalDialog
This commit is contained in:
Binary file not shown.
@@ -10,6 +10,8 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class SecondsCountdownTimer: IKeyed
|
||||
{
|
||||
public event EventHandler<EventArgs> HasStarted;
|
||||
public event EventHandler<EventArgs> HasFinished;
|
||||
public event EventHandler<EventArgs> WasCancelled;
|
||||
|
||||
public string Key { get; private set; }
|
||||
@@ -74,28 +76,50 @@ namespace PepperDash.Essentials.Core
|
||||
_IsRunning = true;
|
||||
IsRunningFeedback.FireUpdate();
|
||||
|
||||
var handler = HasStarted;
|
||||
if (handler != null)
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Finish();
|
||||
var a = WasCancelled;
|
||||
if (a != null)
|
||||
a(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_IsRunning = false;
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
StopHelper();
|
||||
|
||||
var handler = WasCancelled;
|
||||
if (handler != null)
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called upon expiration, or calling this will force timer to finish.
|
||||
/// </summary>
|
||||
public void Finish()
|
||||
{
|
||||
StopHelper();
|
||||
|
||||
var handler = HasFinished;
|
||||
if (handler != null)
|
||||
handler(this, new EventArgs());
|
||||
}
|
||||
|
||||
void StopHelper()
|
||||
{
|
||||
if (SecondTimer != null)
|
||||
SecondTimer.Stop();
|
||||
_IsRunning = false;
|
||||
IsRunningFeedback.FireUpdate();
|
||||
IsRunningFeedback.FireUpdate();
|
||||
}
|
||||
|
||||
void SecondElapsedTimerCallback(object o)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -46,9 +46,9 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
Debug.Console(0, "Config failed: \r{0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static JObject MergeConfigs(JObject doubleConfig)
|
||||
{
|
||||
var system = JObject.FromObject(doubleConfig["system"]);
|
||||
|
||||
Binary file not shown.
@@ -30,11 +30,6 @@ namespace PepperDash.Essentials
|
||||
public BoolFeedback IsWarmingFeedback { get; private set; }
|
||||
public BoolFeedback IsCoolingFeedback { get; private set; }
|
||||
|
||||
//public BoolFeedback PowerOffPendingFeedback { get; private set; }
|
||||
//bool _PowerOffPending;
|
||||
//public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; }
|
||||
//public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Timer used for informing the UIs of a shutdown
|
||||
/// </summary>
|
||||
@@ -68,6 +63,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
ShutdownPromptSeconds = 60;
|
||||
ShutdownVacancySeconds = 120;
|
||||
ShutdownType = ShutdownType.None;
|
||||
|
||||
OnFeedback = new BoolFeedback(OnFeedbackFunc);
|
||||
}
|
||||
@@ -105,4 +101,14 @@ namespace PepperDash.Essentials
|
||||
Manual,
|
||||
Vacancy
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum WarmingCoolingMode
|
||||
{
|
||||
None,
|
||||
Warming,
|
||||
Cooling
|
||||
}
|
||||
}
|
||||
@@ -151,6 +151,8 @@ namespace PepperDash.Essentials
|
||||
|
||||
SourcesSrl = new SubpageReferenceList(TriList, 3200, 3, 3, 3);
|
||||
ActivityFooterSrl = new SubpageReferenceList(TriList, 15022, 3, 3, 3);
|
||||
ShareButtonSig = ActivityFooterSrl.BoolInputSig(1, 1);
|
||||
|
||||
SetupActivityFooterWhenRoomOff();
|
||||
|
||||
ShowVolumeGauge = true;
|
||||
@@ -350,7 +352,6 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
void ShareButtonPressed()
|
||||
{
|
||||
ShareButtonSig = ActivityFooterSrl.BoolInputSig(1, 1);
|
||||
if (!_CurrentRoom.OnFeedback.BoolValue)
|
||||
{
|
||||
ShareButtonSig.BoolValue = true;
|
||||
@@ -471,7 +472,8 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public void PowerButtonPressed()
|
||||
{
|
||||
if (!CurrentRoom.OnFeedback.BoolValue)
|
||||
var room = CurrentRoom;
|
||||
if (!room.OnFeedback.BoolValue || room.ShutdownPromptTimer.IsRunningFeedback.BoolValue)
|
||||
return;
|
||||
|
||||
//EndMeetingButtonSig.BoolValue = true;
|
||||
@@ -512,36 +514,88 @@ namespace PepperDash.Essentials
|
||||
// Fire shutdown cancelled event?
|
||||
//
|
||||
|
||||
void Shutdown_IsRunningFeedback_OutputChange(object sender, EventArgs e)
|
||||
//void Shutdown_IsRunningFeedback_OutputChange(object sender, EventArgs e)
|
||||
//{
|
||||
// var timer = CurrentRoom.ShutdownPromptTimer;
|
||||
// if (timer.IsRunningFeedback.BoolValue)
|
||||
// {
|
||||
// EndMeetingButtonSig.BoolValue = true;
|
||||
// ShareButtonSig.BoolValue = false;
|
||||
|
||||
// if (CurrentRoom.ShutdownType == ShutdownType.Manual)
|
||||
// {
|
||||
// var modal = new ModalDialog(TriList);
|
||||
// var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds);
|
||||
// modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||
// "End Meeting Now", "Cancel", 0, true,
|
||||
// but =>
|
||||
// {
|
||||
// if (but != 2) // any button except for End cancels
|
||||
// timer.Cancel();
|
||||
// else
|
||||
// ShareButtonSig.BoolValue = true; // restore Share fb
|
||||
// EndMeetingButtonSig.BoolValue = false;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// else // Timer stopped.
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_HasStarted(object sender, EventArgs e)
|
||||
{
|
||||
// Do we need to check where the UI is? No?
|
||||
var timer = CurrentRoom.ShutdownPromptTimer;
|
||||
if (timer.IsRunningFeedback.BoolValue)
|
||||
{
|
||||
EndMeetingButtonSig.BoolValue = true;
|
||||
ShareButtonSig.BoolValue = false;
|
||||
EndMeetingButtonSig.BoolValue = true;
|
||||
ShareButtonSig.BoolValue = false;
|
||||
|
||||
if (CurrentRoom.ShutdownType == ShutdownType.Manual)
|
||||
{
|
||||
var modal = new ModalDialog(TriList);
|
||||
var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds);
|
||||
modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||
"End Meeting Now", "Cancel", 0, true,
|
||||
but =>
|
||||
{
|
||||
if (but != 2) // any button except for End cancels
|
||||
timer.Cancel();
|
||||
else
|
||||
ShareButtonSig.BoolValue = true; // restore Share fb
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
if (CurrentRoom.ShutdownType == ShutdownType.Manual)
|
||||
{
|
||||
|
||||
var modal = new ModalDialog(TriList);
|
||||
var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds);
|
||||
modal.PresentModalTimerDialog(2, "End Meeting", "Power", message,
|
||||
"End Meeting Now", "Cancel", 0, true,
|
||||
but =>
|
||||
{
|
||||
if (but != 2) // any button except for End cancels
|
||||
timer.Cancel();
|
||||
else
|
||||
timer.Finish();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_HasFinished(object sender, EventArgs e)
|
||||
{
|
||||
ShareButtonSig.BoolValue = true; // restore Share fb
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e)
|
||||
{
|
||||
EndMeetingButtonSig.BoolValue = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void CancelPowerOffTimer()
|
||||
{
|
||||
if (PowerOffTimer != null)
|
||||
@@ -666,7 +720,10 @@ namespace PepperDash.Essentials
|
||||
TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name;
|
||||
|
||||
// Shutdown timer
|
||||
_CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.OutputChange += Shutdown_IsRunningFeedback_OutputChange;
|
||||
//_CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.OutputChange += Shutdown_IsRunningFeedback_OutputChange;
|
||||
_CurrentRoom.ShutdownPromptTimer.HasStarted += ShutdownPromptTimer_HasStarted;
|
||||
_CurrentRoom.ShutdownPromptTimer.HasFinished += ShutdownPromptTimer_HasFinished;
|
||||
_CurrentRoom.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled;
|
||||
|
||||
// Link up all the change events from the room
|
||||
_CurrentRoom.OnFeedback.OutputChange += _CurrentRoom_OnFeedback_OutputChange;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user