Skip to content

Commit

Permalink
use coloring for record and stream buttons
Browse files Browse the repository at this point in the history
The code for the indicator circles is commented out.
  • Loading branch information
dl1rf committed May 6, 2024
1 parent b59ac71 commit 0e15b6d
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 64 deletions.
32 changes: 18 additions & 14 deletions MediaSources/Longmynd/LongmyndProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ private DynamicPropertyGroup ConfigureTunerProperties(int tuner)
private int indicatorStatus = 0;


public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput |= (byte)(1 << (int)indicator);
}
// public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput |= (byte)(1 << (int)indicator);
// }

public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput &= (byte)~(1 << (int)indicator);
}
// public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput &= (byte)~(1 << (int)indicator);
// }

private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function)
{
Expand All @@ -146,24 +146,26 @@ private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function)
break;
case 1: // snapshot
Log.Information("Snapshot");
_media_player.SnapShot(_mediaPath + CommonFunctions.GenerateTimestampFilename() + ".png");

if (playing)
_media_player.SnapShot(_mediaPath + CommonFunctions.GenerateTimestampFilename() + ".png");
break;
case 2: // record
Log.Information("Record");

if (_recorder.record)
{
_recorder.record = false; // stop recording
ClearIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.Transparent);
}
else
{
// are we locked onto a signal ?
if (demodState >= 3)
{
_recorder.record = true; // start recording
SetIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
// SetIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.PaleVioletRed);
}
else
{
Expand All @@ -182,14 +184,16 @@ private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function)
if ( _streamer.stream)
{
_streamer.stream = false;
ClearIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent);
}
else
{
if (demodState >= 3)
{
_streamer.stream = true;
SetIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
// SetIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.PaleTurquoise);
}
}

Expand Down
6 changes: 4 additions & 2 deletions MediaSources/Longmynd/LongmyndWS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ private void UpdatePropertiesWs(monitorMessage monitor_message)
if (_recorder.record)
{
_recorder.record = false; // stop recording
ClearIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref indicatorStatus, PropertyIndicators.RecordingIndicator);
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.Transparent);
_tuner1_properties.UpdateValue("media_controls", indicatorStatus.ToString());
}

// stop streaming if we lost lock
if (_streamer.stream)
{
_streamer.stream = false;
ClearIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref indicatorStatus, PropertyIndicators.StreamingIndicator);
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent);
_tuner1_properties.UpdateValue("media_controls", indicatorStatus.ToString());
}

Expand Down
79 changes: 61 additions & 18 deletions MediaSources/Minitiouner/MinitiounerProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ private DynamicPropertyGroup ConfigureTunerProperties(int tuner)



public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput |= (byte)(1 << (int)indicator);
}
// public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput |= (byte)(1 << (int)indicator);
// }

public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput &= (byte)~(1 << (int)indicator);
}
// public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput &= (byte)~(1 << (int)indicator);
// }

private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function)
{
Expand Down Expand Up @@ -220,44 +220,83 @@ private void DynamicPropertyGroup_OnMediaButtonPressed(string key, int function)
_media_players[tuner].SnapShot(_mediapath + CommonFunctions.GenerateTimestampFilename() + ".png");

break;
case 2: // mute
case 2: // record
Log.Information("Record: " + tuner.ToString());

if (_ts_recorders[tuner].record)
{
ClearIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.RecordingIndicator);
_ts_recorders[tuner].record = false; // stop recording
}
else
{
SetIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.RecordingIndicator);
// SetIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.RecordingIndicator);
_ts_recorders[tuner].record = true; // start recording
}

if (tuner == 0)
{
if (_ts_recorders[0].record == true)
{
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.PaleVioletRed);
}
else
{
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.Transparent);
}
_tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString());
}
else
{
if (_ts_recorders[1].record == true)
{
_tuner2_properties.UpdateRecordButtonColor("media_controls_2", Color.PaleVioletRed);
}
else
{
_tuner2_properties.UpdateRecordButtonColor("media_controls_2", Color.Transparent);
}
_tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString());

}
break;
case 3: // udp stream
Log.Information("UDP Stream: " + tuner.ToString());

if (_ts_streamers[tuner].stream)
{
ClearIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.StreamingIndicator);
_ts_streamers[tuner].stream = false;
}
else
{
SetIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.StreamingIndicator);
// SetIndicator(ref ((tuner == 0) ? ref indicatorStatus1 : ref indicatorStatus2), PropertyIndicators.StreamingIndicator);
_ts_streamers[tuner].stream = true;
}

if (tuner == 0)
{
if (_ts_streamers[0].stream == true)
{
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.PaleTurquoise);
}
else
{
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent);
}
_tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString());
}
else
{
if (_ts_streamers[1].stream == true)
{
_tuner2_properties.UpdateStreamButtonColor("media_controls_2", Color.PaleTurquoise);
}
else
{
_tuner2_properties.UpdateStreamButtonColor("media_controls_2", Color.Transparent);
}
_tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString());
}

break;
}
Expand Down Expand Up @@ -404,16 +443,18 @@ private void UpdateTunerProperties(TunerStatus new_status)
// stop recording if recording
if (_ts_recorders[0].record)
{
ClearIndicator(ref indicatorStatus1, PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref indicatorStatus1, PropertyIndicators.RecordingIndicator);
_ts_recorders[0].record = false; // stop recording
_tuner1_properties.UpdateRecordButtonColor("media_controls_1", Color.Transparent);
_tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString());
}

// stop streaming
if (_ts_streamers[0].stream)
{
ClearIndicator(ref indicatorStatus1, PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref indicatorStatus1, PropertyIndicators.StreamingIndicator);
_ts_streamers[0].stream = false; // stop streaming
_tuner1_properties.UpdateStreamButtonColor("media_controls_1", Color.Transparent);
_tuner1_properties.UpdateValue("media_controls_1", indicatorStatus1.ToString());
}

Expand Down Expand Up @@ -502,16 +543,18 @@ private void UpdateTunerProperties(TunerStatus new_status)
// stop recording if recording
if (_ts_recorders[1].record)
{
ClearIndicator(ref indicatorStatus2, PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref indicatorStatus2, PropertyIndicators.RecordingIndicator);
_ts_recorders[1].record = false; // stop recording
_tuner2_properties.UpdateRecordButtonColor("media_controls_2", Color.Transparent);
_tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString());
}

// stop streaming
if (_ts_streamers[1].stream)
{
ClearIndicator(ref indicatorStatus2, PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref indicatorStatus2, PropertyIndicators.StreamingIndicator);
_ts_streamers[1].stream = false; // stop streaming
_tuner2_properties.UpdateStreamButtonColor("media_controls_2", Color.Transparent);
_tuner2_properties.UpdateValue("media_controls_2", indicatorStatus2.ToString());
}

Expand Down
36 changes: 19 additions & 17 deletions MediaSources/Winterhill/WinterhillProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,15 @@ private void properties_OnPropertyMenuSelect(LongmyndPropertyCommands command, i
}
}

public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput |= (byte)(1 << (int)indicator);
}

public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
{
indicatorInput &= (byte)~(1 << (int)indicator);
}
// public void SetIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput |= (byte)(1 << (int)indicator);
// }

// public void ClearIndicator(ref int indicatorInput, PropertyIndicators indicator)
// {
// indicatorInput &= (byte)~(1 << (int)indicator);
// }

private void MediaControlsHandler(int tuner, int function)
{
Expand All @@ -214,21 +213,24 @@ private void MediaControlsHandler(int tuner, int function)

break;
case 1: // snapshot
_media_player[tuner].SnapShot(_MediaPath + CommonFunctions.GenerateTimestampFilename() + ".png");
if (playing[tuner])
_media_player[tuner].SnapShot(_MediaPath + CommonFunctions.GenerateTimestampFilename() + ".png");
break;

case 2: // record
if (_recorders[tuner].record)
{
_recorders[tuner].record = false;
ClearIndicator(ref indicatorStatus[tuner], PropertyIndicators.RecordingIndicator);
// ClearIndicator(ref indicatorStatus[tuner], PropertyIndicators.RecordingIndicator);
_tuner_properties[tuner].UpdateRecordButtonColor("media_controls_" + tuner.ToString(), Color.Transparent);
}
else
{
if (demodstate[tuner] == 3 || demodstate[tuner] == 2)
{
_recorders[tuner].record = true;
SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.RecordingIndicator);
// SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.RecordingIndicator);
_tuner_properties[tuner].UpdateRecordButtonColor("media_controls_" + tuner.ToString(), Color.PaleVioletRed);
}
else
{
Expand All @@ -243,14 +245,16 @@ private void MediaControlsHandler(int tuner, int function)
if (_streamer[tuner].stream)
{
_streamer[tuner].stream = false;
ClearIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator);
// ClearIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator);
_tuner_properties[tuner].UpdateStreamButtonColor("media_controls_" + tuner.ToString(), Color.Transparent);
}
else
{
{
if (demodstate[tuner] == 3 || demodstate[tuner] == 2)
{
_streamer[tuner].stream = true;
SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator);
// SetIndicator(ref indicatorStatus[tuner], PropertyIndicators.StreamingIndicator);
_tuner_properties[tuner].UpdateStreamButtonColor("media_controls_" + tuner.ToString(), Color.PaleTurquoise);
}
else
{
Expand All @@ -261,8 +265,6 @@ private void MediaControlsHandler(int tuner, int function)
_tuner_properties[tuner].UpdateValue("media_controls_" + tuner.ToString(), indicatorStatus[tuner].ToString());

break;


}
}

Expand Down
26 changes: 26 additions & 0 deletions Utilities/DynamicPropertyGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,32 @@ public void UpdateMuteButtonColor(string Key, Color Col)
}
}

public void UpdateRecordButtonColor(string Key, Color Col)
{
// this can probably be done more efficient, but will do for now
for (int c = 0; c < _items.Count; c++)
{
if (_items[c].Key == Key)
{
_items[c].UpdateRecordButtonColor(Col);
break;
}
}
}

public void UpdateStreamButtonColor(string Key, Color Col)
{
// this can probably be done more efficient, but will do for now
for (int c = 0; c < _items.Count; c++)
{
if (_items[c].Key == Key)
{
_items[c].UpdateStreamButtonColor(Col);
break;
}
}
}

public Dictionary<string, string> GetAll()
{
Dictionary<string, string> data = new Dictionary<string, string>();
Expand Down
2 changes: 2 additions & 0 deletions Utilities/DynamicPropertyInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public abstract class DynamicPropertyInterface
public abstract void UpdateValue(string Value);
public abstract void UpdateColor(Color Col);
public abstract void UpdateMuteButtonColor(Color Col);
public abstract void UpdateRecordButtonColor(Color Col);
public abstract void UpdateStreamButtonColor(Color Col);
}
}
10 changes: 10 additions & 0 deletions Utilities/DynamicPropertyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,15 @@ public override void UpdateMuteButtonColor(Color Col)
{
throw new NotImplementedException();
}

public override void UpdateRecordButtonColor(Color Col)
{
throw new NotImplementedException();
}

public override void UpdateStreamButtonColor(Color Col)
{
throw new NotImplementedException();
}
}
}
Loading

0 comments on commit 0e15b6d

Please sign in to comment.