using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
//using DiagramUI;
namespace ToolBox
{
/// <summary>
/// Summary description for FormTools.
/// </summary>
public class FormTools : System.Windows.Forms.Form
{
private System.Windows.Forms.Button buttonEdit;
private System.Windows.Forms.Button buttonPicture;
private IToolBox parent;
static private Image pictImage;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public FormTools()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
if (pictImage == null)
{
pictImage = buttonPicture.Image;
}
}
public FormTools(IToolBox parent)
{
InitializeComponent();
this.parent = parent;
if (pictImage == null)
{
pictImage = buttonPicture.Image;
}
}
public static Image PictImage
{
get
{
return pictImage;
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
if (parent != null)
{
parent.ToolBox = null;
}
base.Dispose( disposing );
}
#region Windows Form 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormTools));
this.buttonEdit = new System.Windows.Forms.Button();
this.buttonPicture = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonEdit
//
this.buttonEdit.AllowDrop = true;
this.buttonEdit.Image = ((System.Drawing.Image)(resources.GetObject("buttonEdit.Image")));
this.buttonEdit.Location = new System.Drawing.Point(8, 24);
this.buttonEdit.Name = "buttonEdit";
this.buttonEdit.Size = new System.Drawing.Size(48, 48);
this.buttonEdit.TabIndex = 0;
this.buttonEdit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.buttonEdit_MouseDown);
//
// buttonPicture
//
this.buttonPicture.Image = ((System.Drawing.Image)(resources.GetObject("buttonPicture.Image")));
this.buttonPicture.Location = new System.Drawing.Point(72, 24);
this.buttonPicture.Name = "buttonPicture";
this.buttonPicture.Size = new System.Drawing.Size(48, 48);
this.buttonPicture.TabIndex = 1;
this.buttonPicture.MouseDown += new System.Windows.Forms.MouseEventHandler(this.buttonPicture_MouseDown);
//
// FormTools
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(152, 341);
this.Controls.Add(this.buttonPicture);
this.Controls.Add(this.buttonEdit);
this.Name = "FormTools";
this.Text = "Toolbox";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
private void buttonEdit_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
buttonEdit.DoDragDrop("MovedEditor", DragDropEffects.All);
}
public static void GetCoordinates(Control c, ref int x, ref int y)
{
x = c.Left;
y = c.Top;
Control p = c.Parent;
if (p == null)
{
return;
}
int xp = 0;
int yp = 0;
GetCoordinates(p, ref xp, ref yp);
x += xp;
y += yp;
}
private void buttonPicture_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
buttonEdit.DoDragDrop("MovedPicture", DragDropEffects.All);
}
public static void GetCoordinates(Control s, Control t, int xi, int yi, ref int x, ref int y)
{
int xs = 0, ys = 0, xt = 0, yt = 0;
GetCoordinates(s, ref xs, ref ys);
GetCoordinates(t, ref xt, ref yt);
x = xi + xs - xt;
y = yi + xs - xt;
}
}
}