WIP: dialog box

This commit is contained in:
Ray committed 2020-04-27 13:17:13 +01:00
1 parent 7fd6c06c78
commit caec9c7317
109 files changed
+7397 -62

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
namespace RyzStudio.Windows.Forms
{
partial class HorizontalSeparator
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RyzStudio.Windows.Forms
{
public partial class HorizontalSeparator : System.Windows.Forms.UserControl
{
public HorizontalSeparator()
{
InitializeComponent();
this.MaximumSize = new Size(SystemInformation.VirtualScreen.Width, 2);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(Color.FromArgb(213, 223, 229)), new Rectangle(this.DisplayRectangle.Left, 0, this.DisplayRectangle.Width, 1));
g.FillRectangle(new SolidBrush(Color.FromArgb(249, 251, 253)), new Rectangle(this.DisplayRectangle.Left, 1, this.DisplayRectangle.Width, 1));
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.ComponentModel;
using System.Drawing;
namespace RyzStudio.Windows.Forms
{
public class ImageBox : System.Windows.Forms.PictureBox
{
public ImageBox() : base()
{
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.ErrorImage = null;
this.InitialImage = null;
this.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
}
protected override void OnCreateControl()
{
OnMouseLeave(null);
base.OnCreateControl();
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Image Image { get => base.Image; set { base.Image = value; } }
[Category("Appearance"), Browsable(true)]
public Image NormalImage { get; set; }
[Category("Appearance"), Browsable(true)]
public Image HighlightImage { get; set; }
protected override void OnMouseEnter(EventArgs e)
{
this.Image = this.HighlightImage;
base.OnMouseEnter(e);
}
protected override void OnMouseLeave(EventArgs e)
{
this.Image = this.NormalImage;
base.OnMouseLeave(e);
}
protected override void OnLostFocus(EventArgs e)
{
this.Image = this.NormalImage;
base.OnLostFocus(e);
}
}
}
+37
View File
@@ -0,0 +1,37 @@
namespace RyzStudio.Windows.Forms
{
partial class PanelBook
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}
+159
View File
@@ -0,0 +1,159 @@
namespace RyzStudio.Windows.Forms
{
using System;
using System.ComponentModel;
using System.Windows.Forms;
[ToolboxItem(true)]
public partial class PanelBook : UserControl
{
protected PanelCollection panelCollection = null;
public PanelBook()
{
InitializeComponent();
panelCollection = new PanelCollection(this);
}
public Panel ActivePanel { get; set; } = null;
[Category("Collection")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public PanelCollection Pages
{
get { return panelCollection; }
}
[Category("Collection")]
public int SelectedIndex
{
get
{
if (panelCollection.Count <= 0)
{
return -1;
}
return panelCollection.IndexOf(this.ActivePanel);
}
set
{
if (panelCollection.Count <= 0)
{
return;
}
if (value < 0)
{
return;
}
if (value > (panelCollection.Count - 1))
{
return;
}
if (value == this.SelectedIndex)
{
return;
}
ActivatePanel(value);
}
}
protected internal int PageIndex
{
get
{
return panelCollection.IndexOf(this.ActivePanel);
}
set
{
if (panelCollection.Count <= 0)
{
ActivatePanel(-1);
return;
}
if ((value < -1) || (value >= panelCollection.Count))
{
throw new ArgumentOutOfRangeException("PageIndex", value, "The page index must be between 0 and " + Convert.ToString(panelCollection.Count - 1));
}
ActivatePanel(value);
}
}
protected internal void ActivatePanel(int index)
{
if ((panelCollection.Count == 0) && (index >= panelCollection.Count) && (index <= 0))
{
return;
}
Panel p = (Panel)panelCollection[index];
ActivatePage(p);
}
protected internal void ActivatePage(Panel page)
{
if (this.ActivePanel != null)
{
this.ActivePanel.Visible = false;
}
this.ActivePanel = page;
if (this.ActivePanel != null)
{
this.ActivePanel.Parent = this;
if (!this.Contains(this.ActivePanel))
{
this.Container.Add(this.ActivePanel);
}
this.ActivePanel.Dock = DockStyle.Fill;
this.ActivePanel.Visible = true;
this.ActivePanel.BringToFront();
}
if (this.ActivePanel != null)
{
this.ActivePanel.Invalidate();
}
else
{
this.Invalidate();
}
}
#if DEBUG
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
if (this.DesignMode)
{
this.Invalidate();
}
}
#endif
protected override void DestroyHandle()
{
base.DestroyHandle();
foreach (Panel p in panelCollection)
{
p.Dispose();
}
}
}
}
@@ -0,0 +1,80 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RyzStudio.Windows.Forms
{
[ToolboxItem(true)]
public class PanelCollection : CollectionBase
{
protected PanelBook panelBook = null;
public PanelCollection()
{
}
public PanelCollection(PanelBook parent) : base()
{
panelBook = parent;
}
public PanelBook Parent => panelBook;
public Panel this[int index] { get => (Panel)List[index]; set => List[index] = value; }
public int Add(Panel value) => List.Add(value);
public void AddRange(Panel[] pages)
{
foreach (Panel page in pages)
{
this.Add(page);
}
}
public int IndexOf(Panel value) => (List.IndexOf(value));
public void Insert(int index, Panel value) => List.Insert(index, value);
public void Remove(Panel value) => List.Remove(value);
public bool Contains(Panel value) => List.Contains(value);
protected override void OnInsertComplete(int index, object value)
{
base.OnInsertComplete(index, value);
if (panelBook != null)
{
panelBook.PageIndex = index;
}
}
protected override void OnRemoveComplete(int index, object value)
{
base.OnRemoveComplete(index, value);
if (panelBook != null)
{
if (panelBook.PageIndex == index)
{
if (index < InnerList.Count)
{
panelBook.PageIndex = index;
}
else
{
panelBook.PageIndex = InnerList.Count - 1;
}
}
}
}
}
}
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RyzStudio.Windows.Forms
{
public class StackLayoutPanel : FlowLayoutPanel
{
public StackLayoutPanel() : base()
{
this.AutoScroll = true;
this.FlowDirection = FlowDirection.TopDown;
this.WrapContents = false;
}
protected override void OnResize(EventArgs eventargs)
{
base.OnResize(eventargs);
//int w = this.ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth;
int w = this.ClientRectangle.Width - 1;
foreach (Control item in this.Controls)
{
if (item.Width != w)
{
item.Width = w;
}
}
}
protected override void OnControlAdded(ControlEventArgs e)
{
base.OnControlAdded(e);
OnResize(null);
}
protected override void OnControlRemoved(ControlEventArgs e)
{
base.OnControlRemoved(e);
OnResize(null);
}
public void AddControl(Control value)
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(() =>
{
value.Margin = new Padding(0, 3, 0, 3);
this.Controls.Add(value);
}));
}
else
{
value.Margin = new Padding(0, 3, 0, 3);
this.Controls.Add(value);
}
}
}
}