Skip to content

Commit

Permalink
Current Time size scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
phaselden committed Jan 23, 2021
1 parent 9fc38fc commit d2f4896
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 142 deletions.
2 changes: 1 addition & 1 deletion src/FlipIt/FlipItSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ScreenSaver
public class FlipItSettings
{
public bool Display24HrTime { get; set; }
public int Scale { get; set; }
public int Scale { get; set; } = 70;

public List<ScreenSetting> ScreenSettings { get; set; } = new List<ScreenSetting>();

Expand Down
23 changes: 8 additions & 15 deletions src/FlipIt/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,30 @@ public partial class MainForm : Form

private TimeScreen _timeScreen;

private readonly bool _display24HourTime;
private readonly FlipItSettings _settings;
private readonly ScreenSetting _screenSetting;
private Point _mouseLocation;
private readonly bool _isPreviewMode;
private readonly bool _showSeconds = false;
private int _lastMinute = -1;

private const int FontScaleFactor = 3;
private readonly int _fontSize = 350;

public MainForm()
public MainForm()
{
InitializeComponent();
}

public MainForm(Rectangle bounds, bool display24HourTime, ScreenSetting screenSetting)
public MainForm(Rectangle bounds, FlipItSettings settings, ScreenSetting screenSetting)
{
_display24HourTime = display24HourTime;
_settings = settings;
_screenSetting = screenSetting;
InitializeComponent();
Bounds = bounds;
_fontSize = bounds.Height / FontScaleFactor;
}

public MainForm(IntPtr previewWndHandle, bool display24HourTime, ScreenSetting screenSetting)
public MainForm(IntPtr previewWndHandle, FlipItSettings settings, ScreenSetting screenSetting)
{
_display24HourTime = display24HourTime;
_screenSetting = screenSetting;
_settings = settings;
_screenSetting = screenSetting;

InitializeComponent();

Expand All @@ -71,9 +67,6 @@ public MainForm(IntPtr previewWndHandle, bool display24HourTime, ScreenSetting s
Size = parentRect.Size;
Location = new Point(0, 0);

// Make text smaller for preview window
_fontSize = Size.Height / FontScaleFactor;

_isPreviewMode = true;
}

Expand Down Expand Up @@ -130,7 +123,7 @@ private void PaintTime()
{
if (_isPreviewMode || _screenSetting.DisplayType == DisplayType.CurrentTime)
{
_timeScreen = new CurrentTimeScreen(this, _display24HourTime, _isPreviewMode, 70);
_timeScreen = new CurrentTimeScreen(this, _settings.Display24HrTime, _isPreviewMode, _settings.Scale);
}
else if (_screenSetting.DisplayType == DisplayType.WorldTime)
{
Expand Down
5 changes: 3 additions & 2 deletions src/FlipIt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void Main(string[] args)
}

IntPtr previewWndHandle = new IntPtr(long.Parse(secondArgument));
Application.Run(new MainForm(previewWndHandle, settings.Display24HrTime, settings.ScreenSettings[0]));
Application.Run(new MainForm(previewWndHandle, settings, settings.ScreenSettings[0]));
}
else if (firstArgument == "/s") // Full-screen mode
{
Expand Down Expand Up @@ -77,7 +77,7 @@ static void ShowScreenSaver(FlipItSettings settings)
{
var cleanDeviceName = CleanDeviceName(screen.DeviceName);
var screenSettings = settings.GetScreen(cleanDeviceName);
var form = new MainForm(screen.Bounds, settings.Display24HrTime, screenSettings);
var form = new MainForm(screen.Bounds, settings, screenSettings);
form.Show();
}
}
Expand All @@ -95,6 +95,7 @@ private static FlipItSettings LoadSettings()
{
iniFile = new IniFile(iniFilePath);
settings.Display24HrTime = iniFile.ReadBool("General", "Display24Hr", false);
settings.Scale = iniFile.ReadInt("General", "Scale", 70);
}
else
{
Expand Down
85 changes: 68 additions & 17 deletions src/FlipIt/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/FlipIt/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private void SaveSettings()

var iniFile = new IniFile(iniFilePath);
iniFile.WriteBool("General", "Display24Hr", _settings.Display24HrTime);
iniFile.WriteInt("General", "Scale", scaleTrackBar.Value * 10);

foreach (var screenSetting in _settings.ScreenSettings)
{
var sectionName = $"Screen {screenSetting.DeviceName}";
Expand All @@ -51,8 +53,6 @@ private void cancelButton_Click(object sender, EventArgs e)

private void SettingsForm_Load(object sender, EventArgs e)
{
mainListView.Items.Clear();

if (_settings.Display24HrTime)
{
display24hrRadioButton.Checked = true;
Expand All @@ -61,8 +61,11 @@ private void SettingsForm_Load(object sender, EventArgs e)
{
display12hrRadioButton.Checked = true;
}

foreach (var screen in _settings.ScreenSettings)

scaleTrackBar.Value = _settings.Scale / 10;

mainListView.Items.Clear();
foreach (var screen in _settings.ScreenSettings)
{
var item = new ListViewItem(screen.ShortDescription)
{
Expand Down
Loading

0 comments on commit d2f4896

Please sign in to comment.