Skip to content

Commit

Permalink
open record folder only when user stops recording (if application clo…
Browse files Browse the repository at this point in the history
…ses, just save)
  • Loading branch information
tommasobertoni committed Sep 17, 2015
1 parent c1a0125 commit fa97303
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public ContextMenuController(IController controller)
APPLICATION_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
_recorder.Save();
_recorder.Close();
_recorder.Close(true);
_controller.RemoveObserver(_recorder);
_recorder = null;
Expand Down Expand Up @@ -360,6 +360,8 @@ private class HardwareValuesRecorderMenuController : ITemperatureObserver
private Dictionary<HardwareMonitorType, ICollection<Tuple<float, DateTime>>> _hardwareValuesMap;
private Dictionary<HardwareMonitorType, ToolStripLabel> _hardwareLabelsMap;

private string _currentRecordFolderName;

ContextMenuController _cmc;

public HardwareValuesRecorderMenuController(ContextMenuController cmc, HardwareMonitorType hwmTypes)
Expand Down Expand Up @@ -394,27 +396,26 @@ void ITemperatureObserver.OnAvgCPUsTemperatureChanged(float temperature)
}
}

public void Close()
public void Close(bool openRecordFolder = false)
{
_hardwareValuesMap.Clear();
_hardwareLabelsMap.Clear();
_cmc._logsItem.DropDown.Items.RemoveByKey(_TEMPERATURE_TEXT);

if (openRecordFolder && _currentRecordFolderName != null)
{
_cmc._notifyIcon.ContextMenuStrip.Close();
Start(_currentRecordFolderName);
}
}

public void Save()
{
string currentFolderName = null;
ICollection<Tuple<float, DateTime>> collection;
lock (_hardwareValuesMap)
{
if (_hardwareValuesMap.TryGetValue(HardwareMonitorType.Temperature, out collection))
HardwareRecordsManager.Save(HardwareMonitorType.Temperature, collection, out currentFolderName);
}

if (currentFolderName != null)
{
_cmc._notifyIcon.ContextMenuStrip.Close();
Start(currentFolderName);
HardwareRecordsManager.Save(HardwareMonitorType.Temperature, collection, out _currentRecordFolderName);
}
}

Expand Down

0 comments on commit fa97303

Please sign in to comment.