private void RenderObjects()
{
//the order we do this in is very important
try
{
foreach (objectsCamera oc in Cameras)
{
DisplayCamera(oc);
}
foreach (objectsMicrophone om in Microphones)
{
DisplayMicrophone(om);
}
foreach (objectsFloorplan ofp in FloorPlans)
{
DisplayFloorPlan(ofp);
}
//link em up
foreach (objectsCamera oc in Cameras)
{
var cw = GetCameraWindow(oc.id);
cw?.SetVolumeLevel(oc.settings.micpair);
}
foreach (objectsCamera oc in Cameras)
{
var cw = GetCameraWindow(oc.id);
if (Conf.AutoSchedule && oc.schedule.active && Schedule.Any(p => p.objectid == oc.id && p.objecttypeid == 2 && p.active))
{
oc.settings.active = false;
cw.ApplySchedule();
}
else
{
try
{
if (oc.settings.active)
cw.Enable();
}
catch (Exception ex)
{
Logger.LogExceptionToFile(ex);
}
}
}
foreach (objectsMicrophone om in Microphones)
{
var vl = GetVolumeLevel(om.id);
if (Conf.AutoSchedule && om.schedule.active && Schedule.Any(p => p.objectid == om.id && p.objecttypeid == 1 && p.active))
{
om.settings.active = false;
vl.ApplySchedule();
}
else
{
if (om.settings.active)
vl.Enable();
}
}
bool cam = false;
if (_pnlCameras.Controls.Count > 0)
{
//prevents layering issues
for (int index = 0; index < _pnlCameras.Controls.Count; index++)
{
var c = _pnlCameras.Controls[index];
var cw = c as CameraWindow;
if (cw?.VolumeControl != null)
{
cam = true;
cw.SendToBack();
cw.VolumeControl.SendToBack();
}
}
_pnlCameras.Controls[0].Focus();
}
if (!cam)
flowPreview.Loading = false;
}
catch (Exception ex)
{
Logger.LogExceptionToFile(ex);
}
NeedsSync = true;
}