-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to control 12/24hr display and what appears on each screen
- Loading branch information
Showing
12 changed files
with
713 additions
and
115 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ScreenSaver | ||
{ | ||
public enum DisplayType | ||
{ | ||
None = 0, | ||
CurrentTime = 1, | ||
WorldTime = 6 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace ScreenSaver | ||
{ | ||
public class FlipItSettings | ||
{ | ||
public bool Display24HrTime { get; set; } | ||
public int Scale { get; set; } | ||
|
||
public List<ScreenSetting> ScreenSettings { get; set; } = new List<ScreenSetting>(); | ||
|
||
public ScreenSetting GetScreen(string screenDeviceName) | ||
{ | ||
return ScreenSettings.SingleOrDefault(s => s.DeviceName == screenDeviceName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Initially from https://stackoverflow.com/a/14906422/1899 | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace ScreenSaver | ||
{ | ||
public class IniFile | ||
{ | ||
private const int BufferSize = 1024; | ||
private readonly string _path; | ||
|
||
[DllImport("kernel32", CharSet = CharSet.Unicode)] | ||
static extern long WritePrivateProfileString(string section, string key, string value, string filePath); | ||
|
||
[DllImport("kernel32", CharSet = CharSet.Unicode)] | ||
static extern int GetPrivateProfileString(string section, string key, string @default, StringBuilder retVal, int size, string filePath); | ||
|
||
public IniFile(string iniPath) | ||
{ | ||
_path = iniPath; | ||
} | ||
|
||
public string ReadString(string section, string key) | ||
{ | ||
var retVal = new StringBuilder(BufferSize); | ||
GetPrivateProfileString(section, key, "", retVal, BufferSize, _path); | ||
return retVal.ToString(); | ||
} | ||
|
||
public void WriteBool(string section, string key, bool value) | ||
{ | ||
WriteString(section, key, value ? "1": "0"); | ||
} | ||
|
||
public bool ReadBool(string section, string key, bool defaultValue) | ||
{ | ||
var val = ReadString(section, key); | ||
if (val == "") | ||
return defaultValue; | ||
Debug.Assert(val == "1" || val == "0"); | ||
return val == "1"; | ||
} | ||
|
||
public int ReadInt(string section, string key, int defaultValue) | ||
{ | ||
var val = ReadString(section, key); | ||
if (val == "") | ||
return defaultValue; | ||
return Int32.Parse(val); | ||
} | ||
|
||
public void WriteInt(string section, string key, int value) | ||
{ | ||
WriteString(section, key, value.ToString()); | ||
} | ||
|
||
public string[] ReadSections() | ||
{ | ||
var keyNames = ReadString(null, null); | ||
return keyNames.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); | ||
} | ||
|
||
public bool SectionExists(string section) | ||
{ | ||
var keyNames = ReadSection(section); | ||
return keyNames.Length > 0; | ||
} | ||
|
||
public string[] ReadSection(string section) | ||
{ | ||
var keyNames = ReadString(section, null); | ||
return keyNames.Split(new []{'\n'}, StringSplitOptions.RemoveEmptyEntries); | ||
} | ||
|
||
public void WriteString(string section, string key, string value) | ||
{ | ||
var res = WritePrivateProfileString(section, key, value, _path); | ||
} | ||
|
||
public void DeleteKey(string section, string key) | ||
{ | ||
WriteString(section, key, null); | ||
} | ||
|
||
public void DeleteSection(string section = null) | ||
{ | ||
WriteString(section, null, null); | ||
} | ||
|
||
public bool KeyExists(string key, string section = null) | ||
{ | ||
return ReadString(section, key).Length > 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace ScreenSaver | ||
{ | ||
public class ScreenSetting | ||
{ | ||
public ScreenSetting(int screenNumber, string deviceName, int width, int height) | ||
{ | ||
ScreenNumber = screenNumber; | ||
DeviceName = deviceName; | ||
Width = width; | ||
Height = height; | ||
} | ||
|
||
public int ScreenNumber { get; } | ||
public string DeviceName { get; } | ||
public int Width { get; } | ||
public int Height { get; } | ||
|
||
public DisplayType DisplayType { get; set; } | ||
|
||
public string ShortDescription => $"Screen {ScreenNumber}"; | ||
public string Description => $"{ShortDescription} - {Width} x {Height}"; | ||
} | ||
} |
Oops, something went wrong.