Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / C#

Universal Framework for Science and Engineering - Part 4: Space elevator

Rate me:
Please Sign up or sign in to vote.
4.56/5 (6 votes)
14 Aug 20066 min read 36.6K   2.2K   37  
An article on framework applications to the space elevator.
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;
		}
	}

			
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions