I have a custom class file in C# that I inherited and partially extended. I am trying to re factor it now as I have just enough knowhow to know that with something like generics(I think) I could greatly condense this class.
As an inexperienced solo dev I would greatly appreciate any direction or constructive critism any can provide.
Don't be gentle! I appreciate your time and have a blessed day! I am preemptively sorry for the length.
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraTab;
namespace psWinForms
{
public static class WinFormCustomHandling
{
public static void ShowXFormInControl(Form frm,
ref XtraTabPage ctl, FormBorderStyle style)
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
public static void ShowXFormInControl(Form frm,
ref XtraPanel ctl, FormBorderStyle style)
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
public static void ShowXFormInControl(XtraForm Xfrm,
ref XtraTabPage ctl, FormBorderStyle style)
{
Xfrm.TopLevel = false;
Xfrm.ControlBox = false;
Xfrm.Parent = ctl;
Xfrm.FormBorderStyle = style;
Xfrm.Left = 0;
Xfrm.Top = 0;
Xfrm.Width = ctl.Width + 4;
Xfrm.Dock = DockStyle.Fill;
Xfrm.Show();
//IMPORTANT: .Show() fires a form load event
Xfrm.BringToFront();
}
public static void ShowXFormInControl(XtraForm Xfrm,
ref XtraPanel ctl, FormBorderStyle style)
{
Xfrm.TopLevel = false;
Xfrm.ControlBox = false;
Xfrm.Parent = ctl;
Xfrm.FormBorderStyle = style;
Xfrm.Left = 0;
Xfrm.Top = 0;
Xfrm.Width = ctl.Width + 4;
Xfrm.Dock = DockStyle.Fill;
Xfrm.Show();
//IMPORTANT: .Show() fires a form load event
Xfrm.BringToFront();
}
public static void ShowFormInControl(Form frm,
ref Panel ctl, FormBorderStyle style)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
//.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)
}
public static void ShowFormInControl(Form frm,
ref TabPage ctl, FormBorderStyle style)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
}
public static void ShowFormInControl(Form frm,
Panel ctl, FormBorderStyle style, FormWindowState state)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.WindowState = state;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
//.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)
}
public static void ShowFormInControl(Form frm,
TabPage ctl, FormBorderStyle style, FormWindowState state)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = 0;
frm.Top = 0;
frm.Width = ctl.Width + 4;
frm.WindowState = state;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
}
public static void ShowFormInControl(Form frm,
ref Panel ctl, FormBorderStyle style, int left, int top)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = left;
frm.Top = top;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
//.Activate()
frm.BringToFront();
}
//.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)
}
public static void ShowFormInControl(Form frm,
ref TabPage ctl, FormBorderStyle style, int left, int top)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = left;
frm.Top = top;
frm.Width = ctl.Width + 4;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
//.Activate()
frm.BringToFront();
}
}
public static void ShowFormInControl(Form frm,
Panel ctl, FormBorderStyle style, int left, int top, string title)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = left;
frm.Top = top;
frm.Width = ctl.Width + 4;
frm.Text = title;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
//.SetBounds(ctl.Left, ctl.Top, ctl.Width, ctl.Height)
}
public static void ShowFormInControl(Form frm,
TabPage ctl, FormBorderStyle style, int left, int top, string title)
{
{
frm.TopLevel = false;
frm.ControlBox = false;
frm.Parent = ctl;
frm.FormBorderStyle = style;
frm.Left = left;
frm.Top = top;
frm.Width = ctl.Width + 4;
frm.Text = title;
frm.Dock = DockStyle.Fill;
frm.Show();
//IMPORTANT: .Show() fires a form load event
frm.BringToFront();
}
}
}
}
I have the darnedest time posting code here and it turning out looking decent!