Archived
Changed: tile container size invalidation
This commit is contained in:
1 parent
d8af3d4279
commit
9c293dd4f0
3 files changed
+95
-65
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using RyzStudio.Windows.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -12,6 +13,8 @@ namespace FizzyLauncher.Windows.Forms
|
||||
{
|
||||
public class TileContainer : Panel
|
||||
{
|
||||
protected const int DEFAULT_COLUMN = 6;
|
||||
|
||||
protected FlowLayoutPanel flowLayoutPanel1 = null;
|
||||
|
||||
|
||||
@@ -38,6 +41,10 @@ namespace FizzyLauncher.Windows.Forms
|
||||
}
|
||||
|
||||
|
||||
[Browsable(false)]
|
||||
public event EventHandler OnColumnSizeChanged;
|
||||
|
||||
|
||||
public int CalcWidth
|
||||
{
|
||||
get => flowLayoutPanel1.Padding.Horizontal + flowLayoutPanel1.Margin.Horizontal + this.Left + this.Padding.Horizontal + this.Margin.Horizontal;
|
||||
@@ -65,25 +72,76 @@ namespace FizzyLauncher.Windows.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<TileGroupModel> GroupModels
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (TilePanelLayout item in this.Groups)
|
||||
{
|
||||
yield return item.Model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int TileWidthCount { get; private set; } = DEFAULT_COLUMN;
|
||||
|
||||
|
||||
public void Add(TilePanelLayout tilePanelLayout)
|
||||
{
|
||||
ThreadControl.Add(flowLayoutPanel1, tilePanelLayout);
|
||||
}
|
||||
|
||||
public void Add()
|
||||
{
|
||||
ThreadControl.Add(flowLayoutPanel1, new TilePanelLayout(new TileGroupModel()
|
||||
{
|
||||
Title = "New Group",
|
||||
IsExpanded = true,
|
||||
GridSize = new Size(6, 1)
|
||||
}));
|
||||
|
||||
this.TileWidthCount = Math.Max(this.TileWidthCount, 6);
|
||||
}
|
||||
|
||||
public void Clear(bool addDefault = false)
|
||||
{
|
||||
ThreadControl.Clear(flowLayoutPanel1);
|
||||
|
||||
this.TileWidthCount = DEFAULT_COLUMN;
|
||||
|
||||
if (addDefault)
|
||||
{
|
||||
flowLayoutPanel1.Controls.Add(new TilePanelLayout(new TileGroupModel()
|
||||
{
|
||||
Title = "New Group",
|
||||
IsExpanded = true,
|
||||
GridSize = new Size(6, 1)
|
||||
}));
|
||||
this.Add();
|
||||
}
|
||||
|
||||
ColumnSizeChanged();
|
||||
}
|
||||
|
||||
public void Load(List<TileGroupModel> groupList)
|
||||
{
|
||||
this.Clear();
|
||||
|
||||
if (groupList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (TileGroupModel item in groupList)
|
||||
{
|
||||
this.TileWidthCount = Math.Max(this.TileWidthCount, item.GridSize.Width);
|
||||
|
||||
TilePanelLayout panel = new TilePanelLayout(item);
|
||||
|
||||
this.Add(panel);
|
||||
}
|
||||
|
||||
ColumnSizeChanged();
|
||||
}
|
||||
|
||||
|
||||
protected void ColumnSizeChanged()
|
||||
{
|
||||
this.OnColumnSizeChanged?.Invoke(this, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user