Skip to content

Commit 70a67b2

Browse files
committed
Added PanelStack and DockedPanel controls.
Added PanelStack to OptionsForm and page switching buttons. Added Freeze and FreezeOnSelect properties to BilgeButton. Added design-time border to BilgeButton.
1 parent 5854747 commit 70a67b2

14 files changed

+410
-145
lines changed

Source/Controls/BilgeButton.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,48 @@
77
namespace ScriptFUSION.UpDown_Meter.Controls {
88
[DefaultEvent("Click")]
99
public partial class BilgeButton : Control {
10-
private bool mouseDown, mouseOver, selected;
10+
private bool mouseDown, mouseOver, selected, frozen;
1111

1212
public Image Image { get; set; }
1313

1414
[DefaultValue(false)]
1515
public bool ToggleButton { get; set; }
1616

17+
/// <summary>
18+
/// True to syncronize freeze state with selected state, otherwise false.
19+
/// </summary>
20+
[DefaultValue(false)]
21+
public bool FreezeOnSelect { get; set; }
22+
1723
[DefaultValue(false)]
1824
public bool Selected
1925
{
2026
get { return selected; }
2127
set
2228
{
2329
selected = value;
30+
31+
if (FreezeOnSelect) {
32+
Frozen = value;
33+
}
34+
2435
Invalidate();
2536
}
2637
}
2738

39+
[DefaultValue(false)]
40+
public bool Frozen
41+
{
42+
get { return frozen; }
43+
set
44+
{
45+
if ((frozen = value) == false) {
46+
// Force button to revert mouse over state.
47+
IsMouseOver = false;
48+
}
49+
}
50+
}
51+
2852
private bool IsMouseDown
2953
{
3054
get { return mouseDown; }
@@ -57,6 +81,10 @@ public void SimulateClick() {
5781
}
5882

5983
protected override void OnPaint(PaintEventArgs e) {
84+
if (DesignMode) {
85+
ControlPaint.DrawBorder(e.Graphics, ClientRectangle, ForeColor, ButtonBorderStyle.Dashed);
86+
}
87+
6088
if (Image == null) return;
6189

6290
var imageX = Width / 2 - Image.Width / 2;
@@ -95,7 +123,9 @@ private void BilgeButton_Click(object sender, EventArgs e) {
95123
}
96124

97125
private void BilgeButton_MouseEnter(object sender, EventArgs e) {
98-
IsMouseOver = true;
126+
if (!Frozen) {
127+
IsMouseOver = true;
128+
}
99129
}
100130

101131
private void BilgeButton_MouseLeave(object sender, EventArgs e) {

Source/Controls/DockedPanel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
using System.Windows.Forms;
5+
6+
namespace ScriptFUSION.UpDown_Meter.Controls {
7+
[Docking(DockingBehavior.Never)]
8+
public class DockedPanel : Panel {
9+
protected override void OnParentChanged(EventArgs e) {
10+
base.OnParentChanged(e);
11+
12+
Dock = DockStyle.Fill;
13+
}
14+
15+
[Browsable(false)]
16+
[DefaultValue(DockStyle.Fill)]
17+
public override DockStyle Dock
18+
{
19+
get { return base.Dock; }
20+
set { base.Dock = value; }
21+
}
22+
}
23+
}

Source/Controls/PanelStack.Designer.cs

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Controls/PanelStack.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Linq;
3+
using System.Windows.Forms;
4+
5+
namespace ScriptFUSION.UpDown_Meter.Controls {
6+
public partial class PanelStack : Control {
7+
private DockedPanel[] panels;
8+
9+
private DockedPanel selectedPanel;
10+
11+
public PanelStack() {
12+
InitializeComponent();
13+
}
14+
15+
public DockedPanel[] Panels
16+
{
17+
get { return panels; }
18+
set
19+
{
20+
panels = value;
21+
22+
foreach (var panel in value) {
23+
Controls.Add(panel);
24+
}
25+
26+
SelectedPanel = value.FirstOrDefault();
27+
}
28+
}
29+
30+
public DockedPanel SelectedPanel
31+
{
32+
get { return selectedPanel; }
33+
set
34+
{
35+
foreach (var panel in Panels) {
36+
panel.Visible = panel == value;
37+
}
38+
39+
selectedPanel = value;
40+
}
41+
}
42+
}
43+
}

Source/Forms/NetGraphForm.Designer.cs

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)