Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / C#

Integration: Mechanics + Hydraulics + Navigation

Rate me:
Please Sign up or sign in to vote.
5.00/5 (46 votes)
3 Feb 2011CPOL21 min read 61.7K   6.1K   88  
Sample of integration of branches of engineering.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.Configuration.Assemblies;

using CategoryTheory;
using DiagramUI;
using DiagramUI.Labels;

namespace DataPerformerUI
{
	/// <summary>
	/// Panel for reflection of arrow
	/// </summary>
	public class ArrowPanel : System.Windows.Forms.Panel
	{
		private readonly string[] texts = new string[]{"Source", "Target"};
		private IObjectLabel[] objects;
		private int y = 0;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="source">Arrow source</param>
        /// <param name="target">Arrow target</param>
		public ArrowPanel(IObjectLabel source, IObjectLabel target)
		{
			objects = new IObjectLabel[2];
			objects[0] = source;
			objects[1] = target;
			initialize();
		}
		
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="theLabel">The arrow label</param>
		public ArrowPanel(IArrowLabel theLabel)
		{
			PictureBox box = new PictureBox();
			box.Left = 5;
			box.Top = y + 5;
			Image im = NamedComponent.GetImage(theLabel);
			box.Width = im.Width;
			box.Height = im.Height;
			box.Image = im;
			Controls.Add(box);
			Label label = new Label();
			label.Top = box.Top;
			label.Left = box.Left + box.Width + 5;
			label.Text = theLabel.RootName;//NamedComponent.GetText(theLabel);
			Controls.Add(label);
			objects = new IObjectLabel[2];
			objects[0] = theLabel.Source;
			objects[1] = theLabel.Target;
			y = box.Top + box.Height;
			Name = theLabel.RootName;//NamedComponent.GetText(theLabel) + "";
			initialize();

		}

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="theLabel">The arrow label</param>
        /// <param name="source">Arrow source</param>
        /// <param name="target">Arrow target</param>
        public ArrowPanel(IArrowLabel theLabel, IObjectLabel source, IObjectLabel target)
		{
			PictureBox box = new PictureBox();
			box.Left = 5;
			box.Top = y + 5;
			box.Width = 50;
			box.Height = 50;
			box.Image = NamedComponent.GetImage(theLabel);
			Controls.Add(box);
			Label label = new Label();
			label.Top = box.Top;
			label.Left = box.Left + box.Width + 5;
			label.Text = theLabel.RootName;//NamedComponent.GetText(theLabel);
			Controls.Add(label);
			objects = new IObjectLabel[2];
			objects[0] = source;
			objects[1] = target;
			y = box.Top + box.Height;
			Name = label.Text + "";
			initialize();

		}

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="theObject">Base object</param>
        /// <param name="source">Arrow source</param>
        /// <param name="target">Arrow target</param>
        public ArrowPanel(IObjectLabel theObject, IObjectLabel source, IObjectLabel target)
		{
		
			PictureBox box = new PictureBox();
			box.Left = 5;
			box.Top = y + 5;
			Image im = NamedComponent.GetImage(theObject);
			box.Width = im.Width;
			box.Height = im.Height;
			box.Image = im;
			Controls.Add(box);
			Label label = new Label();
			label.Top = box.Top;
			label.Left = box.Left + box.Width + 5;
			label.Text = theObject.RootName;//NamedComponent.GetText(theObject);
			Controls.Add(label);
			objects = new IObjectLabel[2];
			objects[0] = source;
			objects[1] = target;
			y = box.Top + box.Height;
			initialize();

		}

		/// <summary>
		/// Initialization
		/// </summary>
		private void initialize()
		{
			Width = 300;
			Height = 100;
			for (int i = 0; i < 2; i++)
			{
				Label label = new Label();
				label.Top = y + 5;
				label.Left = 5;
				label.Text = texts[i];
				int yy = label.Top + label.Height;
				Controls.Add(label);
				PictureBox box = new PictureBox();
				Image im = NamedComponent.GetImage(objects[i]);
				box.Width = im.Width;
				box.Height = im.Height;
				box.Left = 5;
				box.Top = yy + 5;
				box.Image = im;
				Controls.Add(box);
				Label labelObj = new Label();
				labelObj.Top = box.Top;
				labelObj.Left = box.Left + box.Width + 5;
				string text = objects[i].RootName;//NamedComponent.GetText(objects[i]) + "";
				labelObj.Text = text;
				Controls.Add(labelObj);
				y = 5 + box.Top + box.Height;
			}
			Height = y;
		}
	}



}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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