1
0
This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
linear-app-launcher/Windows/Forms/HeadingPanel.cs
2020-04-05 13:36:39 +01:00

78 lines
1.9 KiB
C#

using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AppLauncher.Windows.Forms
{
public partial class HeadingPanel : AUserControl
{
protected bool isChecked = false;
public HeadingPanel() : base()
{
InitializeComponent();
this.Checked = false;
}
[Category("Appearance"), Browsable(true)]
public string TitleText { get => label1.Text; set => label1.Text = value; }
[Category("Appearance"), Browsable(true)]
public bool Checked
{
get => isChecked;
set
{
isChecked = value;
pictureBox1.BackgroundImage = (value) ? Properties.Resources.toggle_right_ea_16 : Properties.Resources.toggle_left_ea_16;
}
}
public TilePanelContainer TilePanelContainer { get; set; } = null;
protected async override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.TilePanelContainer != null)
{
if (this.Checked)
{
await this.TilePanelContainer.Expand(120);
}
else
{
await this.TilePanelContainer.Collapse(0);
}
}
}
private async void HeadingPanel_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
return;
}
this.Checked = !this.Checked;
if (this.TilePanelContainer != null)
{
if (this.Checked)
{
await this.TilePanelContainer.Expand(120);
}
else
{
await this.TilePanelContainer.Collapse(0);
}
}
}
}
}