这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
5 changes: 0 additions & 5 deletions Control/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ class Region : Panel
/// </summary>
public int scheduleId = 0;

/// <summary>
/// Track a hash of this region at the point it was created
/// </summary>
public string hash = "";

private BlackList _blackList;
public delegate void DurationElapsedDelegate();
public event DurationElapsedDelegate DurationElapsedEvent;
Expand Down
4 changes: 2 additions & 2 deletions Logic/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class ApplicationSettings
private List<string> _globalProperties;

// Application Specific Settings we want to protect
private string _clientVersion = "1.8.8";
private string _clientVersion = "1.8.10";
private string _version = "5";
private int _clientCodeVersion = 131;
private int _clientCodeVersion = 132;

public string ClientVersion { get { return _clientVersion; } }
public string Version { get { return _version; } }
Expand Down
18 changes: 15 additions & 3 deletions Logic/RequiredFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,27 @@ private void SetRequiredFiles()

try
{
updated = int.Parse(attributes["updated"].Value);
updated = (attributes["updated"] != null) ? int.Parse(attributes["updated"].Value) : 0;
}
catch (Exception e)
{
Debug.WriteLine("Can't read Updated attribute from Resource node. e = " + e.Message, "RequiredFiles");
}
catch (Exception) {}

DateTime updatedDt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
updatedDt = updatedDt.AddSeconds(updated);

if (File.GetLastWriteTimeUtc(ApplicationSettings.Default.LibraryPath + @"\" + rf.MediaId + ".htm") > updatedDt)
DateTime fileUpdatedDt = File.GetLastWriteTimeUtc(ApplicationSettings.Default.LibraryPath + @"\" + rf.MediaId + ".htm");

if (fileUpdatedDt > updatedDt)
{
Debug.WriteLine("Resource node does not need updating. Current: " + fileUpdatedDt + ", XMDS: " + updatedDt + ", updated: " + updated, "RequiredFiles");
rf.Complete = true;
}
else
{
Debug.WriteLine("Resource node needs updating. Current: " + fileUpdatedDt + ", XMDS: " + updatedDt, "RequiredFiles");
}
}

// Add to the Rf Node
Expand Down
30 changes: 18 additions & 12 deletions Logic/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,11 @@ public void InitializeComponents()
/// </summary>
private void _scheduleManager_OnNewScheduleAvailable()
{
_overlaySchedule = _scheduleManager.CurrentOverlaySchedule;
Debug.WriteLine("New Schedule Available", "Schedule");
Debug.WriteLine(_scheduleManager.CurrentOverlaySchedule.Count + " overlays", "Schedule");
Debug.WriteLine(_scheduleManager.CurrentSchedule.Count + " normal schedules", "Schedule");

_overlaySchedule = new Collection<ScheduleItem>(_scheduleManager.CurrentOverlaySchedule);
_layoutSchedule = _scheduleManager.CurrentSchedule;

// Set the current pointer to 0
Expand Down Expand Up @@ -488,25 +492,26 @@ private void LayoutFileModified(string layoutPath)
{
Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "Layout file changed: " + layoutPath), LogType.Info.ToString());

// Are we set to expire modified layouts? If not then just return as if
// nothing had happened.
if (!ApplicationSettings.Default.ExpireModifiedLayouts)
return;

// Determine if we need to reassess the overlays
bool changeRequired = false;

foreach (ScheduleItem item in _overlaySchedule)
{
if (item.layoutFile == ApplicationSettings.Default.LibraryPath + @"\" + layoutPath)
{
if (OverlayChangeEvent != null)
OverlayChangeEvent(_overlaySchedule);

break;
// We should mark this item as being one to remove and re-add.
item.Refresh = true;
changeRequired = true;
}
}

// Tell the schedule to refresh
_scheduleManager.RefreshSchedule = true;

// Are we set to expire modified layouts? If not then just return as if
// nothing had happened.
if (!ApplicationSettings.Default.ExpireModifiedLayouts)
return;
if (OverlayChangeEvent != null && changeRequired)
OverlayChangeEvent(_overlaySchedule);

// If the layout that got changed is the current layout, move on
try
Expand Down Expand Up @@ -534,6 +539,7 @@ private void LayoutFileModified(string layoutPath)
Trace.WriteLine(new LogMessage("Schedule - LayoutFileModified", "The current layout is now invalid, refreshing the current schedule."), LogType.Audit.ToString());

// We should not force a change and we should tell the schedule manager to run now
_scheduleManager.RefreshSchedule = true;
_scheduleManager.RunNow();
}
else
Expand Down
2 changes: 2 additions & 0 deletions Logic/ScheduleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class ScheduleItem

public List<string> Dependents = new List<string>();

public bool Refresh = false;

/// <summary>
/// ToString
/// </summary>
Expand Down
28 changes: 23 additions & 5 deletions Logic/ScheduleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ private bool IsNewScheduleAvailable()
// Log
List<string> currentScheduleString = new List<string>();
List<string> newScheduleString = new List<string>();
List<string> newOverlaysString = new List<string>();

// Are all the items that were in the _currentSchedule still there?
foreach (ScheduleItem layout in _currentSchedule)
Expand All @@ -354,22 +355,39 @@ private bool IsNewScheduleAvailable()
currentScheduleString.Add(layout.ToString());
}

foreach (ScheduleItem layout in _currentSchedule)
foreach (ScheduleItem layout in newSchedule)
{
newScheduleString.Add(layout.ToString());
}

Trace.WriteLine(new LogMessage("ScheduleManager - IsNewScheduleAvailable", "Layouts in Current Schedule: " + string.Join(Environment.NewLine, currentScheduleString)), LogType.Audit.ToString());
Trace.WriteLine(new LogMessage("ScheduleManager - IsNewScheduleAvailable", "Layouts in New Schedule: " + string.Join(Environment.NewLine, newScheduleString)), LogType.Audit.ToString());

// Old layout overlays
foreach (ScheduleItem layout in overlaySchedule)
{
newOverlaysString.Add(layout.ToString());
}

// Are all the items that were in the _currentOverlaySchedule still there?
foreach (ScheduleItem layout in _currentOverlaySchedule)
// Try to work out whether the overlay schedule has changed or not.
// easiest way to do this is to see if the sizes have changed
if (_currentOverlaySchedule.Count != overlaySchedule.Count)
{
if (!overlaySchedule.Contains(layout))
forceChange = true;
forceChange = true;
}
else
{
// Compare them on an object by object level.
// Are all the items that were in the _currentOverlaySchedule still there?
foreach (ScheduleItem layout in _currentOverlaySchedule)
{
// New overlay schedule doesn't contain the layout?
if (!overlaySchedule.Contains(layout))
forceChange = true;
}
}

Trace.WriteLine(new LogMessage("ScheduleManager - IsNewScheduleAvailable", "Overlay Layouts: " + string.Join(Environment.NewLine, newOverlaysString)), LogType.Audit.ToString());

// Set the new schedule
_currentSchedule = newSchedule;
Expand Down
93 changes: 77 additions & 16 deletions MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Xibo - Digitial Signage - http://www.xibo.org.uk
* Copyright (C) 2006-17 Spring Signage Ltd
* Xibo - Digital Signage - http://www.xibo.org.uk
* Copyright (C) 2006-2018 Spring Signage Ltd
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -662,7 +662,7 @@ private void PrepareLayout(string layoutPath)
// Deal with the color
try
{
if (layoutAttributes["bgcolor"].Value != "")
if (layoutAttributes["bgcolor"] != null && layoutAttributes["bgcolor"].Value != "")
{
this.BackColor = ColorTranslator.FromHtml(layoutAttributes["bgcolor"].Value);
options.backgroundColor = layoutAttributes["bgcolor"].Value;
Expand Down Expand Up @@ -815,11 +815,7 @@ private void PrepareLayout(string layoutPath)
listRegions = null;
listMedia = null;

// Bring overlays to the front
foreach (Region region in _overlays)
{
region.BringToFront();
}
bringOverlaysForward();
}

/// <summary>
Expand Down Expand Up @@ -1075,30 +1071,50 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)
try
{
// Parse all overlays and compare what we have now to the overlays we have already created (see OverlayRegions)
Debug.WriteLine("Arrived at Manage Overlays with " + overlays.Count + " overlay schedules to show. We're already showing " + _overlays.Count + " overlay Regions", "Overlays");

// Take the ones we currently have up and remove them if they aren't in the new list
// Take the ones we currently have up and remove them if they aren't in the new list or if they've been set to refresh
// We use a for loop so that we are able to remove the region from the collection
for (int i = 0; i < _overlays.Count; i++)
{
Debug.WriteLine("Assessing Overlay Region " + i, "Overlays");

Region region = _overlays[i];
bool found = false;
bool refresh = false;

foreach (ScheduleItem item in overlays)
{
if (item.scheduleid == region.scheduleId && _cacheManager.GetMD5(item.id + ".xlf") == region.hash)
if (item.scheduleid == region.scheduleId)
{
found = true;
refresh = item.Refresh;
break;
}
}

if (!found)
if (!found || refresh)
{
Debug.WriteLine("Removing overlay which is no-longer required. Overlay: " + region.scheduleId, "Overlays");
if (refresh)
{
Trace.WriteLine(new LogMessage("MainForm - ManageOverlays", "Refreshing item that has changed."), LogType.Info.ToString());
}
Debug.WriteLine("Removing overlay " + i + " which is no-longer required. Overlay: " + region.scheduleId, "Overlays");

// Remove the Region from the overlays collection
_overlays.Remove(region);

// As we've removed the thing we're iterating over, reduce i
i--;

// Clear down and dispose of the region.
region.Clear();
region.Dispose();
Controls.Remove(region);
_overlays.Remove(region);
}
else
{
Debug.WriteLine("Overlay Region found and not needing refresh " + i, "Overlays");
}
}

Expand All @@ -1117,7 +1133,13 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)
}

if (found)
{
Debug.WriteLine("Region already found for overlay - we're assuming here that if we've found one, they are all there.", "Overlays");
continue;
}

// Reset refresh
item.Refresh = false;

// Parse the layout for regions, and create them.
string layoutPath = item.layoutFile;
Expand Down Expand Up @@ -1181,6 +1203,20 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)
// New region and region options objects
RegionOptions options = new RegionOptions();

// Deal with the color
// this is imperfect, but we haven't any way to make these controls transparent.
try
{
if (layoutAttributes["bgcolor"] != null && layoutAttributes["bgcolor"].Value != "")
{
options.backgroundColor = layoutAttributes["bgcolor"].Value;
}
}
catch
{
options.backgroundColor = "#000000";
}

// Get the regions
XmlNodeList listRegions = layoutXml.SelectNodes("/layout/region");

Expand Down Expand Up @@ -1222,7 +1258,6 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)

Region temp = new Region(ref _statLog, ref _cacheManager);
temp.scheduleId = item.scheduleid;
temp.hash = _cacheManager.GetMD5(item.id + ".xlf");
temp.BorderStyle = _borderStyle;

// Dont be fooled, this innocent little statement kicks everything off
Expand All @@ -1243,6 +1278,17 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)
{
Trace.WriteLine(new LogMessage("MainForm - _schedule_OverlayChangeEvent", "Unknown issue managing overlays. Ex = " + e.Message), LogType.Info.ToString());
}

bringOverlaysForward();
}

private void bringOverlaysForward()
{
// Bring overlays to the front
foreach (Region region in _overlays)
{
region.BringToFront();
}
}

/// <summary>
Expand All @@ -1251,16 +1297,31 @@ public void ManageOverlays(Collection<ScheduleItem> overlays)
private void SetMainWindowSize()
{
// Override the default size if necessary
if (ApplicationSettings.Default.SizeX != 0)
if (ApplicationSettings.Default.SizeX != 0 || ApplicationSettings.Default.SizeY != 0)
{
_clientSize = new Size((int)ApplicationSettings.Default.SizeX, (int)ApplicationSettings.Default.SizeY);
// Determine the client size
int sizeX = (int)ApplicationSettings.Default.SizeX;
if (sizeX <= 0)
{
sizeX = SystemInformation.PrimaryMonitorSize.Width;
}

int sizeY = (int)ApplicationSettings.Default.SizeY;
if (sizeY <= 0)
{
sizeY = SystemInformation.PrimaryMonitorSize.Height;
}

_clientSize = new Size(sizeX, sizeY);

Size = _clientSize;
WindowState = FormWindowState.Normal;
Location = new Point((int)ApplicationSettings.Default.OffsetX, (int)ApplicationSettings.Default.OffsetY);
StartPosition = FormStartPosition.Manual;
}
else
{
// Use the primary monitor size
_clientSize = SystemInformation.PrimaryMonitorSize;
ApplicationSettings.Default.SizeX = _clientSize.Width;
ApplicationSettings.Default.SizeY = _clientSize.Height;
Expand Down
Loading