Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Default to all screens
Browse files Browse the repository at this point in the history
  • Loading branch information
kasthack committed Jan 4, 2023
1 parent 0000000 commit 0000000
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions src/TimeLapser/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

namespace kasthack.TimeLapser
{
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;

using Accord.Video.FFMPEG;

using kasthack.TimeLapser.Properties;

public partial class FrmMain : Form
{
{
private readonly BindingSource screenInfosBinding;
private readonly Recorder recorder = new();
private readonly ScreenInfo formScreenInfo;
Expand All @@ -31,8 +31,8 @@ public FrmMain()
this.ApplyLocale();
this.ConfigureLegacy();
this.trayIcon.Icon = this.Icon = Resources.icon;
this.formScreenInfo = new ScreenInfo { Id = 31337, Name = Locale.Locale.BehindThisWindowDragAndResizeToTune };
this.screenInfosBinding = new BindingSource();
this.formScreenInfo = new ScreenInfo { Id = 31337, Name = Locale.Locale.BehindThisWindowDragAndResizeToTune };
this.screenInfosBinding = new BindingSource();
this.cmbScreen.DataSource = this.screenInfosBinding;
}

Expand Down Expand Up @@ -106,34 +106,28 @@ private void FormLoad(object sender, EventArgs e)
this.cmbFormat.SelectedIndex = 0;

this.cmbSnapper.SelectedItem = this.isRunningOnLegacyOS ? SnapperType.Legacy : SnapperType.DirectX;

this.cmbScreen.SelectedIndex = this.cmbScreen.Items.Count - 1;
this.txtPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
//#if TESTING
// this.txtPath.Text = Path.Combine(this.txtPath.Text, "dbg_scr");
// this.chkSplit.Checked = true;
// this.nudSplitInterval.Value = 1;
// this.chkRealtime.Checked = true;
// this.cmbScreen.SelectedIndex = 1;
//#endif
this.txtPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
#if TESTING
this.txtPath.Text = Path.Combine(this.txtPath.Text, "dbg_scr");
#endif
}

private void UpdateScreenInfos()
{
// save selected option
var oldSelectedIndex = this.cmbScreen.SelectedIndex;

{
// save selected option
var oldSelectedIndex = this.cmbScreen.SelectedIndex;

// refresh screens
var screenInfos = ScreenInfo.GetScreenInfos();
screenInfos.Add(this.formScreenInfo);
this.UpdateFormScreenInfo();

// push to UI
this.screenInfosBinding.Clear();
this.screenInfosBinding.DataSource = screenInfos;

// restore selection
this.cmbScreen.SelectedIndex = oldSelectedIndex < this.cmbScreen.Items.Count && oldSelectedIndex != -1 ? oldSelectedIndex : this.cmbScreen.Items.Count - 1;
this.UpdateFormScreenInfo();

// push to UI
this.screenInfosBinding.Clear();
this.screenInfosBinding.DataSource = screenInfos;

// restore selection
this.cmbScreen.SelectedIndex = oldSelectedIndex < this.cmbScreen.Items.Count && oldSelectedIndex != -1 ? oldSelectedIndex : this.cmbScreen.Items.Count - 2;
}

private void ConfigureLegacy()
Expand Down Expand Up @@ -170,26 +164,26 @@ private void HandleSizeChanged(object sender, EventArgs e)

private void FrmMain_Move(object sender, EventArgs e) => this.UpdateFormScreenInfo();

private void UpdateFormScreenInfo() => this.formScreenInfo.Rect = ScreenInfo.NormalizeRectangle(new Rectangle(this.Location, this.Size));

private void btnRefresh_Click(object sender, EventArgs e) => this.UpdateScreenInfos();

private void FrmMain_ResizeBegin(object sender, EventArgs e) => this.UpdateFormScreenInfo();

private void btnBrowse_Click(object sender, EventArgs e)
{
var path = this.txtPath.Text;
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path))
{
new Process()
{
StartInfo =
{
UseShellExecute = true,
FileName = path,
},
}.Start();
}
}
private void UpdateFormScreenInfo() => this.formScreenInfo.Rect = ScreenInfo.NormalizeRectangle(new Rectangle(this.Location, this.Size));

private void btnRefresh_Click(object sender, EventArgs e) => this.UpdateScreenInfos();

private void FrmMain_ResizeBegin(object sender, EventArgs e) => this.UpdateFormScreenInfo();

private void btnBrowse_Click(object sender, EventArgs e)
{
var path = this.txtPath.Text;
if (!string.IsNullOrWhiteSpace(path) && Directory.Exists(path))
{
new Process()
{
StartInfo =
{
UseShellExecute = true,
FileName = path,
},
}.Start();
}
}
}
}

0 comments on commit 0000000

Please sign in to comment.