125 lines
3.5 KiB
C#
125 lines
3.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Drawing;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
using System.Threading;
|
|||
|
using AppLauncher.Models;
|
|||
|
|
|||
|
namespace AppLauncher.Windows.Forms
|
|||
|
{
|
|||
|
public partial class TileContainer : AUserControl
|
|||
|
{
|
|||
|
protected int collapseIncrement = 6;
|
|||
|
protected int expandIncrement = 8;
|
|||
|
protected TileGroupModel groupInfo = null;
|
|||
|
|
|||
|
public TileContainer(TileGroupModel model) : base()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
label1.TileGroupPanel = this;
|
|||
|
|
|||
|
groupInfo = model;
|
|||
|
|
|||
|
label1.TitleText = groupInfo.Title;
|
|||
|
panel1.SetGridSize(groupInfo.GridSize.Width, groupInfo.GridSize.Height);
|
|||
|
label1.Checked = groupInfo.IsExpanded;
|
|||
|
|
|||
|
//label1.Width = panel1.Width;
|
|||
|
//label1.PanelHeight = panel1.Height;
|
|||
|
|
|||
|
//this.Margin = new Padding(0);
|
|||
|
//this.Size = new Size(panel1.Width, (label1.Height + panel1.Height));
|
|||
|
//this.MaximumSize = this.Size;
|
|||
|
//this.MinimumSize = this.Size;
|
|||
|
|
|||
|
panel1.LoadTiles(model.Items);
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnLoad(EventArgs e)
|
|||
|
{
|
|||
|
base.OnLoad(e);
|
|||
|
|
|||
|
label1.Width = panel1.Width;
|
|||
|
|
|||
|
this.Margin = new Padding(0);
|
|||
|
this.MaximumSize = new Size(panel1.Width, (label1.Height + panel1.ExpandedHeight));
|
|||
|
this.MinimumSize = new Size(panel1.Width, label1.Height);
|
|||
|
this.Size = this.MaximumSize;
|
|||
|
}
|
|||
|
|
|||
|
protected int collapseHeight => label1.Height + panel1.CollapseHeight;
|
|||
|
|
|||
|
protected int expandedHeight => label1.Height + panel1.ExpandedHeight;
|
|||
|
|
|||
|
public async Task Collapse()
|
|||
|
{
|
|||
|
await Task.Run(() =>
|
|||
|
{
|
|||
|
while (this.Height > collapseHeight)
|
|||
|
{
|
|||
|
if (this.InvokeRequired)
|
|||
|
{
|
|||
|
this.Invoke(new MethodInvoker(() => {
|
|||
|
this.Height -= collapseIncrement;
|
|||
|
}));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Height -= collapseIncrement;
|
|||
|
}
|
|||
|
|
|||
|
Thread.Sleep(10);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public async Task CollapseNow()
|
|||
|
{
|
|||
|
await Task.Run(() =>
|
|||
|
{
|
|||
|
if (this.InvokeRequired)
|
|||
|
{
|
|||
|
this.Invoke(new MethodInvoker(() => {
|
|||
|
this.Height = collapseHeight;
|
|||
|
}));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Height = collapseHeight;
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
public async Task Expand()
|
|||
|
{
|
|||
|
await Task.Run(() =>
|
|||
|
{
|
|||
|
while (this.Height < expandedHeight)
|
|||
|
{
|
|||
|
if (this.InvokeRequired)
|
|||
|
{
|
|||
|
this.Invoke(new MethodInvoker(() => {
|
|||
|
this.Height += expandIncrement;
|
|||
|
this.Invalidate();
|
|||
|
}));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Height += expandIncrement;
|
|||
|
this.Invalidate();
|
|||
|
}
|
|||
|
|
|||
|
Thread.Sleep(10);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|