98 lines
2.6 KiB
C#
98 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using VAR.DatabaseExplorer.Controls;
|
|
|
|
namespace VAR.DatabaseExplorer.UI
|
|
{
|
|
public partial class FrmMain : Form
|
|
{
|
|
#region Declarations
|
|
|
|
private static FrmMain _currentInstance;
|
|
|
|
#endregion Declarations
|
|
|
|
#region Creator
|
|
|
|
public FrmMain()
|
|
{
|
|
_currentInstance = this;
|
|
InitializeComponent();
|
|
}
|
|
|
|
#endregion Creator
|
|
|
|
#region WindowList
|
|
|
|
private List<Form> listChilds = new List<Form>();
|
|
|
|
public static void AddForm(Form frm)
|
|
{
|
|
frm.MdiParent = _currentInstance;
|
|
frm.WindowState = FormWindowState.Maximized;
|
|
frm.Show();
|
|
_currentInstance.listChilds.Add(frm);
|
|
frm.FormClosed += _currentInstance.FrmPrincipal_OnChildClose;
|
|
_currentInstance.RefreshWindowButtons();
|
|
}
|
|
|
|
protected void FrmPrincipal_OnChildClose(object sender, FormClosedEventArgs e)
|
|
{
|
|
listChilds.Remove((Form)sender);
|
|
RefreshWindowButtons();
|
|
}
|
|
|
|
private void FrmPrincipal_MdiChildActivate(object sender, EventArgs e)
|
|
{
|
|
RefreshWindowButtons();
|
|
}
|
|
|
|
private void RefreshWindowButtons()
|
|
{
|
|
int childCount = listChilds.Count;
|
|
int delta = childCount - flowpnlWindows.Controls.Count;
|
|
if (delta < 0)
|
|
{
|
|
int dest = flowpnlWindows.Controls.Count + delta;
|
|
for (int i = flowpnlWindows.Controls.Count - 1; i >= dest; i--)
|
|
{
|
|
flowpnlWindows.Controls.RemoveAt(i);
|
|
}
|
|
}
|
|
else if (delta > 0)
|
|
{
|
|
for (int i = 0; i < delta; i++)
|
|
{
|
|
flowpnlWindows.Controls.Add(new WindowButton());
|
|
}
|
|
}
|
|
for (int i = 0; i < childCount; i++)
|
|
{
|
|
WindowButton btn = (WindowButton)flowpnlWindows.Controls[i];
|
|
Form frm = listChilds[i];
|
|
btn.Text = frm.Text;
|
|
btn.Window = frm;
|
|
btn.Active = (frm == ActiveMdiChild);
|
|
}
|
|
}
|
|
|
|
#endregion WindowList
|
|
|
|
#region Menus
|
|
|
|
private void menuSQLServerSearch_Click(object sender, EventArgs e)
|
|
{
|
|
var frm = new FrmSQLServerSearch();
|
|
FrmMain.AddForm(frm);
|
|
}
|
|
|
|
private void menuConectionString_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
#endregion Menus
|
|
|
|
}
|
|
} |