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

Commit

Permalink
Fixed some stuff + Screenswitcher
Browse files Browse the repository at this point in the history
idk if the screenswitcher works or nah probably doesnt
  • Loading branch information
Sárdi Károly committed Jan 12, 2019
1 parent f9a786e commit d645d90
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 60 deletions.
123 changes: 103 additions & 20 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,36 @@ public static void HideTaskBar()
}
}
#endregion

public int offset = 40;
public Main()
{
InitializeComponent();
if (File.Exists(appdata + "/x1custom"))
{
string checklenght;
using (StreamReader readdata = File.OpenText(appdata + "/x1custom")){
using (StreamReader readdata = File.OpenText(appdata + "/x1custom"))
{
checklenght = readdata.ReadLine();
}
if (checklenght.Length < 3 && checklenght.Length > 0)
{
x1logo.Text = checklenght;
}
else {
else
{
x1logo.Text = "x1";
}
x1logo.TextAlign = ContentAlignment.MiddleCenter;
} else {
}
else
{
x1logo.Text = "x1";
}
if (File.Exists(appdata + "/x1color"))
{
using (StreamReader readdata = File.OpenText(appdata + "/x1color"))
{

this.BackColor = Color.FromArgb(Convert.ToInt32(readdata.ReadLine()));
}
}
Expand All @@ -122,6 +126,13 @@ public Main()
this.Opacity = Convert.ToDouble(igen / 100);
}
}
if (File.Exists(appdata + "/x1offset"))
{
using (StreamReader readdata = File.OpenText(appdata + "/x1offset"))
{
offset = Convert.ToInt32(readdata.ReadLine());
}
}
}

bool helpdialog = false;
Expand All @@ -131,6 +142,22 @@ public Main()
publicbool publicbool = new publicbool();
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

public Screen GetSecondaryScreen()
{
if (Screen.AllScreens.Length == 1)
{
return null;
}
foreach (Screen screen in Screen.AllScreens)
{
if (screen.Primary == false)
{
return screen;
}
}
return null;
}

private void Main_Load(object sender, EventArgs e)
{

Expand All @@ -150,13 +177,30 @@ private void Main_Load(object sender, EventArgs e)
}
else
{
spotifytrack.Anchor = AnchorStyles.Right;
seperator.Anchor = AnchorStyles.Right;
btry.Anchor = AnchorStyles.Right;
time.Anchor = AnchorStyles.Right;
panel_StuffHere.Anchor = AnchorStyles.Right;
if (File.Exists(appdata + "/x12nd"))
{
spotifytrack.Anchor = AnchorStyles.Right;
seperator.Anchor = AnchorStyles.Right;
btry.Anchor = AnchorStyles.Right;
time.Anchor = AnchorStyles.Right;
panel_StuffHere.Anchor = AnchorStyles.Right;

if (Screen.AllScreens.Length > 1)
{
Screen secscreen = GetSecondaryScreen();
Width = secscreen.Bounds.Width;
}
}
else
{
spotifytrack.Anchor = AnchorStyles.Right;
seperator.Anchor = AnchorStyles.Right;
btry.Anchor = AnchorStyles.Right;
time.Anchor = AnchorStyles.Right;
panel_StuffHere.Anchor = AnchorStyles.Right;

Width = Screen.PrimaryScreen.Bounds.Width;
Width = Screen.PrimaryScreen.Bounds.Width;
}
}

t1.Start();
Expand Down Expand Up @@ -246,19 +290,40 @@ private void t1_Tick(object sender, EventArgs e)

if (File.Exists(appdata + "/x1top"))
{
Width = Screen.PrimaryScreen.Bounds.Width;
Location = new Point(0, 0);
if (File.Exists(appdata + "/x12nd"))
{
Width = GetSecondaryScreen().Bounds.Width;
Location = GetSecondaryScreen().WorkingArea.Location;
}
else
{
Width = Screen.PrimaryScreen.Bounds.Width;
Location = new Point(0, 0);
}
}
else
{
if (!File.Exists(appdata + "/x1left"))
{
Width = Screen.PrimaryScreen.Bounds.Width;
var ScreenHeight = Screen.PrimaryScreen.Bounds.Height;
Location = new Point(0, ScreenHeight - 40);

if (File.Exists(appdata + "/x12nd"))
{
if (GetSecondaryScreen() != null)
{

Width = GetSecondaryScreen().Bounds.Width;
Location = new Point(GetSecondaryScreen().WorkingArea.X, GetSecondaryScreen().Bounds.Height - offset);
// label1.Text = Convert.ToString(GetSecondaryScreen().WorkingArea.X);
}
}
else
{
Width = Screen.PrimaryScreen.Bounds.Width;
var ScreenHeight = Screen.PrimaryScreen.Bounds.Height;
Location = new Point(0, ScreenHeight - 40);
}
}
}

Rectangle window = new Rectangle();
Rectangle edited = new Rectangle();
GetWindowRect(GetForegroundWindow(), out window);
Expand All @@ -273,13 +338,31 @@ private void t1_Tick(object sender, EventArgs e)

//this is so fucking retarded that i dont even know why it doesnt work only if i add a retarded bool that checks every process this is anoying. install gentoo

if (edited.Height >= Screen.PrimaryScreen.Bounds.Height && edited.Width >= Screen.PrimaryScreen.Bounds.Width && GetActiveWindowTitle() != "" && GetForegroundWindow() != null && GetForegroundWindow() != GetShellWindow() && GetForegroundWindow() != GetDesktopWindow() && !IsOnDesktop())
if (!File.Exists(appdata + "/x12nd"))
{
Hide();
if (edited.Height >= Screen.PrimaryScreen.Bounds.Height && edited.Width >= Screen.PrimaryScreen.Bounds.Width && GetActiveWindowTitle() != "" && GetForegroundWindow() != null && GetForegroundWindow() != GetShellWindow() && GetForegroundWindow() != GetDesktopWindow() && !IsOnDesktop())
{
Hide();
}
else
{
Show();
}
}
else
{
Show();
if (GetSecondaryScreen() != null)
{
if (edited.Height >= GetSecondaryScreen().Bounds.Height && edited.Width >= GetSecondaryScreen().Bounds.Width && GetActiveWindowTitle() != "" && GetForegroundWindow() != null && GetForegroundWindow() != GetShellWindow() && GetForegroundWindow() != GetDesktopWindow() && !IsOnDesktop())
{
Hide();
}
else
{
Show();
}

}
}

if (battery.BatteryChargeStatus.ToString() != "NoSystemBattery")
Expand Down
124 changes: 85 additions & 39 deletions help.Designer.cs

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

Loading

0 comments on commit d645d90

Please sign in to comment.