82 lines
2.0 KiB
C#
82 lines
2.0 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AppLauncher.Windows.Forms
|
|
{
|
|
public partial class TileGroupLabel : AUserControl
|
|
{
|
|
protected bool isChecked = false;
|
|
|
|
public TileGroupLabel() : 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;
|
|
}
|
|
}
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
public TileContainer TileGroupPanel { get; set; } = null;
|
|
|
|
protected async override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
await invalidateToggle(false);
|
|
}
|
|
|
|
protected async void panel_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.Button != MouseButtons.Left)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.Checked = !this.Checked;
|
|
|
|
await invalidateToggle();
|
|
}
|
|
|
|
protected async Task invalidateToggle(bool animate = true)
|
|
{
|
|
if (this.TileGroupPanel == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (this.Checked)
|
|
{
|
|
await this.TileGroupPanel.Expand();
|
|
}
|
|
else
|
|
{
|
|
if (animate)
|
|
{
|
|
await this.TileGroupPanel.Collapse();
|
|
}
|
|
else
|
|
{
|
|
await this.TileGroupPanel.CollapseNow();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |