Skip to content

Commit

Permalink
Multi-monitor support
Browse files Browse the repository at this point in the history
Multiple monitors are now supported.
  • Loading branch information
Jay committed Sep 1, 2013
1 parent 77af7ee commit 6475122
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
7 changes: 4 additions & 3 deletions DimScreen/DimScreen/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class frmMain : Form
{

public byte Dimness;
public System.Drawing.Rectangle Area;

#region Enum
public enum GWL
Expand Down Expand Up @@ -62,9 +63,9 @@ public frmMain()

private void Form1_Load(object sender, EventArgs e)
{
System.Drawing.Rectangle workingRectangle = Screen.PrimaryScreen.WorkingArea;
this.Size = new System.Drawing.Size(workingRectangle.Width, workingRectangle.Height);
this.Location = new System.Drawing.Point(0, 0);
// use working space rectangle info
this.Size = new System.Drawing.Size(Area.Width, Area.Height);
this.Location = new System.Drawing.Point(Area.X, Area.Y);
}


Expand Down
31 changes: 23 additions & 8 deletions DimScreen/DimScreen/frmTray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace DimScreen
{
public partial class frmTray : Form
{
// list of overlays currently displayed
private System.Collections.Generic.List<Form> overlays = new System.Collections.Generic.List<Form>();

public frmTray()
{
InitializeComponent();
Expand All @@ -28,8 +31,8 @@ private void frmTray_FormClosing(object sender, FormClosingEventArgs e)
//Clean up any used memeory.
GC.Collect();

Form fc = Application.OpenForms["frmMain"];
if (fc != null) fc.Dispose();
// remove all overlays
clearOverlays();

//Remove tray Icon
notifyIcon1.Dispose();
Expand All @@ -43,16 +46,28 @@ private void frmTray_FormClosing(object sender, FormClosingEventArgs e)

public void DimWindow(byte DimAmount)
{
Form fc = Application.OpenForms["frmMain"];
if (fc != null) fc.Dispose();
// remove exiting overlays
clearOverlays();

// apply dimness onto all screens
foreach (var screen in Screen.AllScreens)
{
frmMain overlay = new frmMain();
overlay.Dimness = DimAmount;
overlay.Area = screen.WorkingArea;
overlay.Show();

frmMain Main = new frmMain();
Main.Dimness = DimAmount;
Main.Show();
overlays.Add(overlay);
}
}

private void clearOverlays()
{
foreach (var form in overlays)
form.Dispose();


overlays.Clear();
}


private void frmTray_Load(object sender, EventArgs e)
Expand Down

0 comments on commit 6475122

Please sign in to comment.