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

Commit

Permalink
53X Again 16!
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor authored and Taiizor committed Apr 12, 2021
1 parent 036a56f commit 7b0a0dc
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 76 deletions.
80 changes: 74 additions & 6 deletions src/Taskbar/Taskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ public class Taskbar
/// </summary>
private class Shared
{
/// <summary>
///
/// </summary>
/// <param name="Screen"></param>
/// <param name="Edge"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="Pixel"></param>
/// <param name="Type"></param>
/// <returns></returns>
public static Point Location(Screen Screen, Enums.EdgeLocationType Edge, int Width, int Height, int Pixel = 32, Enums.Type Type = Enums.Type.Simple)
{
try
{
Enums.LocationType LocationType = Type switch
{
Enums.Type.Advanced => Simple.Detect(Screen), //Change function advanced detection
Enums.Type.Advanced => Advanced.Position,
_ => Simple.Detect(Screen),
};

Expand Down Expand Up @@ -372,7 +382,7 @@ static Advanced()
};

//Get the taskbar window rect in screen coordinates
GetWindowRect(Handle, ref Values.BarData.Rect);
_ = GetWindowRect(Handle, ref Values.BarData.Rect);
}
catch
{
Expand Down Expand Up @@ -561,6 +571,65 @@ public static void Show()
}
}

/// <summary>
/// Gets taskbar size.
/// </summary>
/// <returns></returns>
public static Size Size()
{
try
{
//Detecting position
//width - height
return new(0, 0);
}
catch
{
throw new Exception(Values.Exception);
}
}

/// <summary>
///
/// </summary>
/// <param name="Screen"></param>
/// <param name="Edge"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="Pixel"></param>
/// <returns></returns>
public static Point Location(Screen Screen, Enums.EdgeLocationType Edge, int Width, int Height, int Pixel = 32)
{
try
{
return Shared.Location(Screen, Edge, Width, Height, Pixel, Enums.Type.Advanced);
}
catch
{
throw new Exception(Values.Exception);
}
}

/// <summary>
///
/// </summary>
/// <param name="Edge"></param>
/// <param name="Width"></param>
/// <param name="Height"></param>
/// <param name="Pixel"></param>
/// <returns></returns>
public static Point SingleLocation(Enums.EdgeLocationType Edge, int Width, int Height, int Pixel = 32)
{
try
{
return Location(Screen.PrimaryScreen, Edge, Width, Height, Pixel);
}
catch
{
throw new Exception(Values.Exception);
}
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -729,11 +798,10 @@ public static bool RefreshAll()
{
try
{
//! SHAppBarMessage returns IntPtr.Zero **if it fails**
//return SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData) != IntPtr.Zero;
SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData);
RefreshData();

return RefreshData();
//! SHAppBarMessage returns IntPtr.Zero **if it fails**
return SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData) != IntPtr.Zero;
}
catch
{
Expand Down
25 changes: 19 additions & 6 deletions src/Taskbar_CR/Main.Designer.cs

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

151 changes: 87 additions & 64 deletions src/Taskbar_CR/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,66 +40,6 @@ private void Button2_Click(object sender, EventArgs e)
}
}

private void Button3_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.AlwaysOnTop.ToString());
}

private void Button4_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.AutoHide.ToString());
}

private void Button5_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.Position.ToString());
}

private void Button6_Click(object sender, EventArgs e)
{
Advanced.Hide();
}

private void Button7_Click(object sender, EventArgs e)
{
Advanced.Show();
}

private void Button9_Click(object sender, EventArgs e)
{
List<Rectangle> Rectangle = Advanced.FindDockedTaskbarsList;

foreach (Rectangle Var in Rectangle)
{
MessageBox.Show("X: " + Var.X + "\nY: " + Var.Y + "\nWidth: " + Var.Width + "\nHeight: " + Var.Height);
}
}

private void Button10_Click(object sender, EventArgs e)
{
Dictionary<int, Rectangle> Rectangle = Advanced.FindDockedTaskbarsDictionary;

foreach (KeyValuePair<int, Rectangle> Var in Rectangle)
{
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y + "\n\tWidth: " + Var.Value.Width + "\n\tHeight: " + Var.Value.Height);
}
}

private void Button11_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.Data.Rect.Left + "\n" + Advanced.Data.Rect.Top + "\n" + Advanced.Data.Rect.Right + "\n" + Advanced.Data.Rect.Bot);
}

private void Button13_Click(object sender, EventArgs e)
{
Advanced.RefreshData();
}

private void Button12_Click(object sender, EventArgs e)
{
Advanced.RefreshAll();
}

private void Button14_Click(object sender, EventArgs e)
{
Location = Simple.SingleLocation(Enums.EdgeLocationType.TopLeft, Width, Height, 32);
Expand All @@ -114,9 +54,9 @@ private void Button14_Click(object sender, EventArgs e)
Thread.Sleep(750);
Location = Simple.SingleLocation(Enums.EdgeLocationType.BotRight, Width, Height, 32);
Thread.Sleep(750);
Location = Simple.SingleLocation(Enums.EdgeLocationType.LeftCenter, Width, Height);
Location = Simple.SingleLocation(Enums.EdgeLocationType.LeftCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Simple.SingleLocation(Enums.EdgeLocationType.RightCenter, Width, Height);
Location = Simple.SingleLocation(Enums.EdgeLocationType.RightCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Simple.SingleLocation(Enums.EdgeLocationType.CalcCenter, Width, Height);
Thread.Sleep(750);
Expand Down Expand Up @@ -256,15 +196,15 @@ private void Button16_Click(object sender, EventArgs e)
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y);
}

Location = Simple.MultiLocationDictionary(Enums.EdgeLocationType.LeftCenter, Width, Height);
Location = Simple.MultiLocationDictionary(Enums.EdgeLocationType.LeftCenter, Width, Height, 32);

foreach (KeyValuePair<int, Point> Var in Location)
{
this.Location = Var.Value;
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y);
}

Location = Simple.MultiLocationDictionary(Enums.EdgeLocationType.RightCenter, Width, Height);
Location = Simple.MultiLocationDictionary(Enums.EdgeLocationType.RightCenter, Width, Height, 32);

foreach (KeyValuePair<int, Point> Var in Location)
{
Expand All @@ -288,5 +228,88 @@ private void Button16_Click(object sender, EventArgs e)
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y);
}
}

private void Button3_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.AlwaysOnTop.ToString());
}

private void Button4_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.AutoHide.ToString());
}

private void Button5_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.Position.ToString());
}

private void Button6_Click(object sender, EventArgs e)
{
Advanced.Hide();
}

private void Button7_Click(object sender, EventArgs e)
{
Advanced.Show();
}

private void Button17_Click(object sender, EventArgs e)
{
Location = Advanced.SingleLocation(Enums.EdgeLocationType.TopLeft, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.TopCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.TopRight, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.BotLeft, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.BotCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.BotRight, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.LeftCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.RightCenter, Width, Height, 32);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.CalcCenter, Width, Height);
Thread.Sleep(750);
Location = Advanced.SingleLocation(Enums.EdgeLocationType.FullCenter, Width, Height);
}

private void Button9_Click(object sender, EventArgs e)
{
List<Rectangle> Rectangle = Advanced.FindDockedTaskbarsList;

foreach (Rectangle Var in Rectangle)
{
MessageBox.Show("X: " + Var.X + "\nY: " + Var.Y + "\nWidth: " + Var.Width + "\nHeight: " + Var.Height);
}
}

private void Button10_Click(object sender, EventArgs e)
{
Dictionary<int, Rectangle> Rectangle = Advanced.FindDockedTaskbarsDictionary;

foreach (KeyValuePair<int, Rectangle> Var in Rectangle)
{
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y + "\n\tWidth: " + Var.Value.Width + "\n\tHeight: " + Var.Value.Height);
}
}

private void Button11_Click(object sender, EventArgs e)
{
MessageBox.Show(Advanced.Data.Rect.Left + "\n" + Advanced.Data.Rect.Top + "\n" + Advanced.Data.Rect.Right + "\n" + Advanced.Data.Rect.Bot);
}

private void Button13_Click(object sender, EventArgs e)
{
Advanced.RefreshData();
}

private void Button12_Click(object sender, EventArgs e)
{
Advanced.RefreshAll();
}
}
}
Loading

0 comments on commit 7b0a0dc

Please sign in to comment.