WIP: begin support for list tile

This commit is contained in:
Ray committed 2020-05-10 11:03:55 +01:00
1 parent 9575ae8ffb
commit adeb97dbb5
16 files changed
+981 -171

No files matched your search

+112
View File
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RyzStudio.Windows.Forms
{
public class FlatButton : Label
{
public class Style
{
public Color BackColour { get; set; } = Color.Transparent;
public Color PenColour { get; set; } = Color.Transparent;
}
public enum State
{
Idle = 0,
Hover,
Down
}
protected State controlState = State.Idle;
public FlatButton() : base()
{
this.AutoSize = false;
this.ImageAlign = ContentAlignment.MiddleCenter;
this.TextAlign = ContentAlignment.MiddleCenter;
// customise
this.StyleOver = new Style()
{
BackColour = Color.FromArgb(51, 51, 51),
PenColour = Color.White
};
this.StyleDown = new Style()
{
BackColour = Color.FromArgb(179, 179, 179),
PenColour = Color.Black
};
this.StyleDefault = new Style()
{
BackColour = Color.White,
PenColour = Color.Black
};
this.VisualState = State.Idle;
this.Click += delegate { this.OnClick(null); };
this.MouseEnter += delegate { this.VisualState = State.Hover; };
this.MouseLeave += delegate { this.VisualState = State.Idle; };
this.MouseDown += delegate { this.VisualState = State.Down; };
this.MouseUp += delegate { this.VisualState = State.Idle; };
}
protected State VisualState
{
get { return controlState; }
set
{
switch (value)
{
case State.Idle:
if (this.VisualState == State.Down)
{
updateButton(StyleOver);
}
else
{
updateButton(StyleDefault);
}
break;
case State.Hover:
updateButton(StyleOver);
break;
case State.Down:
updateButton(StyleDown);
break;
default:
updateButton(StyleDefault);
break;
}
controlState = value;
}
}
protected void updateButton(Style style)
{
this.ForeColor = style.PenColour;
this.BackColor = style.BackColour;
}
[Browsable(false)]
public Style StyleOver { get; set; } = new Style();
[Browsable(false)]
public Style StyleDown { get; set; } = new Style();
[Browsable(false)]
public Style StyleDefault { get; set; } = new Style();
public void PerformClick() => this.OnClick(null);
}
}
+56 -36
View File
@@ -1,13 +1,26 @@
namespace RyzStudio.Windows.ThemedForms
{
using RyzStudio.Drawing;
using System;
using System.ComponentModel;
using System.Drawing;
using System.ComponentModel;
using System.Drawing;
public partial class Button : RyzStudio.Windows.ThemedForms.UserControl
public partial class Button : RyzStudio.Windows.ThemedForms.UserControl
{
protected ButtonState buttonState = ButtonState.Normal;
public class Style
{
public Color BackColour { get; set; } = Color.Transparent;
public Color PenColour { get; set; } = Color.Transparent;
public Image ForeImage { get; set; } = null;
}
public enum State
{
Idle = 0,
Hover,
Down
}
protected State controlState = State.Idle;
public Button() : base()
{
@@ -16,34 +29,48 @@
label1.ImageAlign = ContentAlignment.MiddleCenter;
label1.Click += delegate { this.OnClick(null); };
label1.MouseEnter += delegate { this.VisualState = ButtonState.Hover; };
label1.MouseLeave += delegate { this.VisualState = ButtonState.Normal; };
label1.MouseDown += delegate { this.VisualState = ButtonState.Down; };
label1.MouseUp += delegate { this.VisualState = ButtonState.Normal; };
label1.MouseEnter += delegate { this.VisualState = State.Hover; };
label1.MouseLeave += delegate { this.VisualState = State.Idle; };
label1.MouseDown += delegate { this.VisualState = State.Down; };
label1.MouseUp += delegate { this.VisualState = State.Idle; };
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// customise
this.StyleOver = new ButtonStyle(Color.FromArgb(51, 51, 51), Color.White, this.OverImage);
this.StyleDown = new ButtonStyle(Color.FromArgb(179, 179, 179), Color.Black, this.DownImage);
this.StyleDefault = new ButtonStyle(Color.White, Color.Black, this.DefaultImage);
this.StyleOver = new Style()
{
BackColour = Color.FromArgb(51, 51, 51),
PenColour = Color.White,
ForeImage = this.OverImage
};
this.StyleDown = new Style()
{
BackColour = Color.FromArgb(179, 179, 179),
PenColour = Color.Black,
ForeImage = this.DownImage
};
this.StyleDefault = new Style()
{
BackColour = Color.White,
PenColour = Color.Black,
ForeImage = this.DefaultImage
};
this.VisualState = ButtonState.Normal;
this.VisualState = State.Idle;
}
protected ButtonState VisualState
protected State VisualState
{
get { return buttonState; }
get { return controlState; }
set
{
switch (value)
{
case ButtonState.Normal:
if (this.VisualState == ButtonState.Down)
case State.Idle:
if (this.VisualState == State.Down)
{
updateButton(StyleOver);
}
@@ -53,10 +80,10 @@
}
break;
case ButtonState.Hover:
case State.Hover:
updateButton(StyleOver);
break;
case ButtonState.Down:
case State.Down:
updateButton(StyleDown);
break;
default:
@@ -64,22 +91,15 @@
break;
}
buttonState = value;
controlState = value;
}
}
protected void updateButton(ButtonStyle style)
protected void updateButton(Style style)
{
label1.ForeColor = style.PenColour;
label1.BackColor = style.BackColour;
label1.Image = style.ForeImage;
//var rect = label1.ClientRectangle;
////rect.Inflate(-3, -3);
//Rectangoid area = new Rectangoid(rect, 3, 1);
//label1.Region = new Region(area.ToGraphicsPath());
}
[Browsable(true)]
@@ -98,14 +118,14 @@
[Category("Appearance")]
public Image DefaultImage { get; set; } = null;
[Browsable(false)]
public ButtonStyle StyleOver { get; set; } = new ButtonStyle(Color.FromArgb(71, 142, 203), Color.FromArgb(250, 250, 250));
[Browsable(false)]
public Style StyleOver { get; set; } = new Style();
[Browsable(false)]
public ButtonStyle StyleDown { get; set; } = new ButtonStyle(Color.FromArgb(61, 132, 193), Color.FromArgb(250, 250, 250));
public Style StyleDown { get; set; } = new Style();
[Browsable(false)]
public ButtonStyle StyleDefault { get; set; } = new ButtonStyle(Color.FromArgb(51, 122, 183), Color.FromArgb(250, 250, 250));
public Style StyleDefault { get; set; } = new Style();
public void PerformClick() => this.OnClick(null);
}