FrmPrincipal: Lista de ventanas (tipo tabs)
This commit is contained in:
56
ServerExplorer/Controls/WindowButton.cs
Normal file
56
ServerExplorer/Controls/WindowButton.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace ServerExplorer.Controls
|
||||
{
|
||||
public class WindowButton : Button
|
||||
{
|
||||
#region Properties
|
||||
|
||||
private Form window = null;
|
||||
public Form Window
|
||||
{
|
||||
get { return window; }
|
||||
set { window = value; }
|
||||
}
|
||||
|
||||
private bool active = false;
|
||||
public bool Active
|
||||
{
|
||||
get { return active; }
|
||||
set
|
||||
{
|
||||
active = value;
|
||||
//Font = active ? fntActive : fntNormal;
|
||||
ForeColor = active ? Color.Black : Color.Gray;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creator
|
||||
|
||||
public WindowButton()
|
||||
{
|
||||
AutoSize = true;
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
Click += WindowButton_Click;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
void WindowButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (window == null) { return; }
|
||||
window.Activate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,9 @@
|
||||
<Compile Include="Controls\CustomTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\WindowButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\FrmBaseDatos.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
15
ServerExplorer/UI/FrmBaseDatos.Designer.cs
generated
15
ServerExplorer/UI/FrmBaseDatos.Designer.cs
generated
@@ -69,6 +69,7 @@
|
||||
this.txtConString.ReadOnly = true;
|
||||
this.txtConString.Size = new System.Drawing.Size(616, 20);
|
||||
this.txtConString.TabIndex = 0;
|
||||
this.txtConString.TabWidth = 8;
|
||||
//
|
||||
// lblConString
|
||||
//
|
||||
@@ -137,7 +138,7 @@
|
||||
// btnGenerar
|
||||
//
|
||||
this.btnGenerar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnGenerar.Location = new System.Drawing.Point(401, 485);
|
||||
this.btnGenerar.Location = new System.Drawing.Point(392, 485);
|
||||
this.btnGenerar.Name = "btnGenerar";
|
||||
this.btnGenerar.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnGenerar.TabIndex = 10;
|
||||
@@ -165,7 +166,7 @@
|
||||
this.lblTituloTabla.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.lblTituloTabla.Location = new System.Drawing.Point(3, 0);
|
||||
this.lblTituloTabla.Name = "lblTituloTabla";
|
||||
this.lblTituloTabla.Size = new System.Drawing.Size(473, 37);
|
||||
this.lblTituloTabla.Size = new System.Drawing.Size(464, 37);
|
||||
this.lblTituloTabla.TabIndex = 12;
|
||||
this.lblTituloTabla.Text = "lblTituloTabla";
|
||||
this.lblTituloTabla.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -179,7 +180,7 @@
|
||||
this.lblTituloDB.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.lblTituloDB.Location = new System.Drawing.Point(3, 0);
|
||||
this.lblTituloDB.Name = "lblTituloDB";
|
||||
this.lblTituloDB.Size = new System.Drawing.Size(317, 37);
|
||||
this.lblTituloDB.Size = new System.Drawing.Size(326, 37);
|
||||
this.lblTituloDB.TabIndex = 13;
|
||||
this.lblTituloDB.Text = "lblTituloDB";
|
||||
this.lblTituloDB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -187,7 +188,7 @@
|
||||
// btnDocGen
|
||||
//
|
||||
this.btnDocGen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnDocGen.Location = new System.Drawing.Point(320, 485);
|
||||
this.btnDocGen.Location = new System.Drawing.Point(311, 485);
|
||||
this.btnDocGen.Name = "btnDocGen";
|
||||
this.btnDocGen.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnDocGen.TabIndex = 14;
|
||||
@@ -243,7 +244,7 @@
|
||||
this.splitContainer1.Panel2.Controls.Add(this.btnProcs);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.btnVerDatos);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(806, 511);
|
||||
this.splitContainer1.SplitterDistance = 323;
|
||||
this.splitContainer1.SplitterDistance = 332;
|
||||
this.splitContainer1.TabIndex = 17;
|
||||
//
|
||||
// lsvTablas
|
||||
@@ -260,7 +261,7 @@
|
||||
this.lsvTablas.FullRowSelect = true;
|
||||
this.lsvTablas.Location = new System.Drawing.Point(3, 40);
|
||||
this.lsvTablas.Name = "lsvTablas";
|
||||
this.lsvTablas.Size = new System.Drawing.Size(317, 468);
|
||||
this.lsvTablas.Size = new System.Drawing.Size(326, 468);
|
||||
this.lsvTablas.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.lsvTablas.TabIndex = 4;
|
||||
this.lsvTablas.UseCompatibleStateImageBehavior = false;
|
||||
@@ -296,7 +297,7 @@
|
||||
this.lsvColumnas.FullRowSelect = true;
|
||||
this.lsvColumnas.Location = new System.Drawing.Point(3, 40);
|
||||
this.lsvColumnas.Name = "lsvColumnas";
|
||||
this.lsvColumnas.Size = new System.Drawing.Size(473, 439);
|
||||
this.lsvColumnas.Size = new System.Drawing.Size(464, 439);
|
||||
this.lsvColumnas.TabIndex = 6;
|
||||
this.lsvColumnas.UseCompatibleStateImageBehavior = false;
|
||||
this.lsvColumnas.View = System.Windows.Forms.View.Details;
|
||||
|
||||
@@ -232,8 +232,7 @@ namespace ServerExplorer.UI
|
||||
|
||||
// Crear y mostrar el formulario de los datos.
|
||||
FrmDatos form = new FrmDatos(dt, nombreTabla);
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();
|
||||
FrmPrincipal.AddForm(form);
|
||||
|
||||
}
|
||||
|
||||
@@ -254,21 +253,18 @@ namespace ServerExplorer.UI
|
||||
|
||||
// Crear y mostrar el formulario de los datos.
|
||||
frmDatos form = new frmDatos(dt, "Procedimientos");
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();*/
|
||||
FrmPrincipal.AddForm(form);*/
|
||||
|
||||
// Crear y mostrar el formulario de los procedimientos.
|
||||
FrmProcedimientos form = new FrmProcedimientos(config.ConnectionString);
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();
|
||||
FrmPrincipal.AddForm(form);
|
||||
}
|
||||
|
||||
private void btnExec_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Crear y mostrar el formulario de exec.
|
||||
FrmExec form = new FrmExec(config.ConnectionString);
|
||||
form.MdiParent = this.MdiParent;
|
||||
form.Show();
|
||||
FrmPrincipal.AddForm(form);
|
||||
}
|
||||
|
||||
|
||||
|
||||
19
ServerExplorer/UI/FrmPrincipal.Designer.cs
generated
19
ServerExplorer/UI/FrmPrincipal.Designer.cs
generated
@@ -34,6 +34,7 @@
|
||||
this.menuBaseDatos = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuConectarA = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuConectarPRUEBAS = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.flowpnlWindows = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.menuPrincipal.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -86,16 +87,29 @@
|
||||
this.menuConectarPRUEBAS.Text = "Conectar a PRUEBAS";
|
||||
this.menuConectarPRUEBAS.Click += new System.EventHandler(this.menuConectarPRUEBAS_Click);
|
||||
//
|
||||
// frmPrincipal
|
||||
// flowpnlWindows
|
||||
//
|
||||
this.flowpnlWindows.AutoSize = true;
|
||||
this.flowpnlWindows.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowpnlWindows.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.flowpnlWindows.Location = new System.Drawing.Point(0, 24);
|
||||
this.flowpnlWindows.Name = "flowpnlWindows";
|
||||
this.flowpnlWindows.Size = new System.Drawing.Size(800, 0);
|
||||
this.flowpnlWindows.TabIndex = 6;
|
||||
//
|
||||
// FrmPrincipal
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 601);
|
||||
this.Controls.Add(this.flowpnlWindows);
|
||||
this.Controls.Add(this.menuPrincipal);
|
||||
this.IsMdiContainer = true;
|
||||
this.MainMenuStrip = this.menuPrincipal;
|
||||
this.Name = "frmPrincipal";
|
||||
this.Name = "FrmPrincipal";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Explorador de Servidores";
|
||||
this.MdiChildActivate += new System.EventHandler(this.FrmPrincipal_MdiChildActivate);
|
||||
this.menuPrincipal.ResumeLayout(false);
|
||||
this.menuPrincipal.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
@@ -111,5 +125,6 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem menuBaseDatos;
|
||||
private System.Windows.Forms.ToolStripMenuItem menuConectarA;
|
||||
private System.Windows.Forms.ToolStripMenuItem menuConectarPRUEBAS;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowpnlWindows;
|
||||
}
|
||||
}
|
||||
@@ -7,33 +7,100 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using ServerExplorer.Code;
|
||||
using ServerExplorer.Controls;
|
||||
|
||||
namespace ServerExplorer.UI
|
||||
{
|
||||
public partial class FrmPrincipal : Form
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private static FrmPrincipal currentInstance;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Creator
|
||||
|
||||
public FrmPrincipal()
|
||||
{
|
||||
currentInstance = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#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
|
||||
|
||||
#region Menus
|
||||
|
||||
private void menuConectarPRUEBAS_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Crear ventana de la base de datos de pruebas
|
||||
FrmBaseDatos frm = new FrmBaseDatos("Data Source=SSSRV3;Initial Catalog=PRUEBAS;User ID=sa;Password=SLsssrv3");
|
||||
//frmBaseDatos frm = new frmBaseDatos("Data Source=DANTE;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True");
|
||||
//frmBaseDatos frm = new frmBaseDatos("Data Source=OSKURITO;Initial Catalog=BD_AlfonsoRodriguez;Integrated Security=True");
|
||||
frm.MdiParent = this;
|
||||
frm.WindowState = FormWindowState.Maximized;
|
||||
frm.Show();
|
||||
FrmPrincipal.AddForm(frm);
|
||||
}
|
||||
|
||||
private void menuBuscarServidor_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Mostrar ventana de buscador de servidores
|
||||
FrmServidores frm = new FrmServidores();
|
||||
frm.MdiParent = this;
|
||||
frm.Show();
|
||||
FrmPrincipal.AddForm(frm);
|
||||
}
|
||||
|
||||
private void menuConectarA_Click(object sender, EventArgs e)
|
||||
@@ -46,10 +113,10 @@ namespace ServerExplorer.UI
|
||||
|
||||
// Crear y mostrar ventana
|
||||
FrmBaseDatos frm = new FrmBaseDatos(config);
|
||||
frm.MdiParent = this;
|
||||
frm.WindowState = FormWindowState.Maximized;
|
||||
frm.Show();
|
||||
FrmPrincipal.AddForm(frm);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,9 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuPrincipal.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
<value>14, 6</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>32</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -127,8 +127,7 @@ namespace ServerExplorer.UI
|
||||
|
||||
// Llamar a la venta de la base de datos
|
||||
FrmBaseDatos frm = new FrmBaseDatos(constructor.ConnectionString);
|
||||
frm.MdiParent = this.MdiParent;
|
||||
frm.Show();
|
||||
FrmPrincipal.AddForm(frm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user