using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Form2 mForm2;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (mForm2 == null)
{
mForm2 = new Form2();
mForm2.Show();
mForm2.FormClosed += new FormClosedEventHandler(mForm2_FormClosed);
}
}
void mForm2_FormClosed(object sender, FormClosedEventArgs e)
{
mForm2 = null;
}
private void DockForm(Form f)
{
if (tabPage1.Controls.Contains(f)) return;
f.TopLevel = false;
f.FormBorderStyle = FormBorderStyle.None;
tabPage1.Controls.Add(f);
f.Dock = DockStyle.Fill;
}
private void button2_Click(object sender, EventArgs e)
{
if (mForm2 != null) DockForm(mForm2);
}
}
}
dXNpbmcgU3lzdGVtOwoKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7Cgp1c2luZyBTeXN0ZW0uQ29tcG9uZW50TW9kZWw7Cgp1c2luZyBTeXN0ZW0uRGF0YTsKCnVzaW5nIFN5c3RlbS5EcmF3aW5nOwoKdXNpbmcgU3lzdGVtLkxpbnE7Cgp1c2luZyBTeXN0ZW0uVGV4dDsKCnVzaW5nIFN5c3RlbS5XaW5kb3dzLkZvcm1zOwoKCgpuYW1lc3BhY2UgV2luZG93c0Zvcm1zQXBwbGljYXRpb24xCgp7CgogICAgcHVibGljIHBhcnRpYWwgY2xhc3MgRm9ybTEgOiBGb3JtCgogICAgewoKICAgICAgICBwcml2YXRlIEZvcm0yIG1Gb3JtMjsKCgoKICAgICAgICBwdWJsaWMgRm9ybTEoKQoKICAgICAgICB7CgogICAgICAgICAgICBJbml0aWFsaXplQ29tcG9uZW50KCk7CgogICAgICAgIH0KCgoKICAgICAgICBwcml2YXRlIHZvaWQgYnV0dG9uMV9DbGljayhvYmplY3Qgc2VuZGVyLCBFdmVudEFyZ3MgZSkKCiAgICAgICAgewoKICAgICAgICAgICAgaWYgKG1Gb3JtMiA9PSBudWxsKQoKICAgICAgICAgICAgewoKICAgICAgICAgICAgICAgIG1Gb3JtMiA9IG5ldyBGb3JtMigpOwoKICAgICAgICAgICAgICAgIG1Gb3JtMi5TaG93KCk7CgogICAgICAgICAgICAgICAgbUZvcm0yLkZvcm1DbG9zZWQgKz0gbmV3IEZvcm1DbG9zZWRFdmVudEhhbmRsZXIobUZvcm0yX0Zvcm1DbG9zZWQpOwoKICAgICAgICAgICAgfQoKICAgICAgICB9CgoKCiAgICAgICAgdm9pZCBtRm9ybTJfRm9ybUNsb3NlZChvYmplY3Qgc2VuZGVyLCBGb3JtQ2xvc2VkRXZlbnRBcmdzIGUpCgogICAgICAgIHsKCiAgICAgICAgICAgIG1Gb3JtMiA9IG51bGw7CgogICAgICAgIH0KCgoKICAgICAgICBwcml2YXRlIHZvaWQgRG9ja0Zvcm0oRm9ybSBmKQoKICAgICAgICB7CgogICAgICAgICAgICBpZiAodGFiUGFnZTEuQ29udHJvbHMuQ29udGFpbnMoZikpIHJldHVybjsKCiAgICAgICAgICAgIGYuVG9wTGV2ZWwgPSBmYWxzZTsKCiAgICAgICAgICAgIGYuRm9ybUJvcmRlclN0eWxlID0gRm9ybUJvcmRlclN0eWxlLk5vbmU7CgogICAgICAgICAgICB0YWJQYWdlMS5Db250cm9scy5BZGQoZik7CgogICAgICAgICAgICBmLkRvY2sgPSBEb2NrU3R5bGUuRmlsbDsKCiAgICAgICAgfQoKCgogICAgICAgIHByaXZhdGUgdm9pZCBidXR0b24yX0NsaWNrKG9iamVjdCBzZW5kZXIsIEV2ZW50QXJncyBlKQoKICAgICAgICB7CgogICAgICAgICAgICBpZiAobUZvcm0yICE9IG51bGwpIERvY2tGb3JtKG1Gb3JtMik7CgogICAgICAgIH0KCiAgICB9Cgp9Cgo=