[gme-users] Decorators in Windows.Forms.

Peter Volgyesi peter.volgyesi at vanderbilt.edu
Thu Apr 21 22:37:41 CDT 2005


Hi,

Although you can implement custom decorators as managed  components, you
will encounter several minor problems.  Our idl files (type libraries) are
not tested rigorously with managed code. You can overcome many of the
problems by disassembling the generated (tlbimp) wrappers, slighlty modify
them and reassemble again.
I've attached the most basic custom decorator I could come up with. Even for
this one, I had to modify the MgaDecorator and Mga wrappers and change
 - the MgaFCOs class to have a public (not assembly) constructor
 - the IMgaDecorator:Draw method to pass the hDC parameter as an int32 value

--
Peter Volgyesi
ISIS, Vanderbilt University

> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu 
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
> Of Vamshi Raghu
> Sent: Thursday, April 21, 2005 4:54 PM
> To: gme-users at list.isis.vanderbilt.edu
> Subject: [gme-users] Decorators in Windows.Forms.
> 
> Hi!
> Can a decorator be written using "managed" components? If so, 
> any pointers to information on where to find out how to 
> expose the .NET equivalent of a custom control as a COM 
> component implementing IMgaDecorator? Is there a 
> gme-developers list or equivalent?
> Thanks in advance!
> -Vamshi
> 
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
-------------- next part --------------
using System;
using MGADECORATORLib;
using MGALib;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;


namespace Decorators
{
	/// <summary>
	/// Summary description for NETDecorator.
	/// </summary>
	public class NETDecorator : IMgaDecorator
	{
		public NETDecorator()
		{
			//
			// TODO: Add constructor logic here
			//
		}
	
		#region IMgaDecorator Members

		public void GetLabelLocation(out int sx, out int sy, out int ex, out int ey)
		{
			// TODO:  Add NETDecorator.GetLabelLocation implementation
			sx = 0;
			sy = 0;
			ex = 0;
			ey = 0;
		}

		public void GetFeatures(out uint features)
		{
			// TODO:  Add NETDecorator.GetFeatures implementation
			features = 0;
		}

		public void SetLocation(int sx, int sy, int ex, int ey)
		{
			m_sx = sx;
			m_sy = sy;
			m_ex = ex;
			m_ey = ey;
		}

		public void SetActive(bool isActive)
		{
			// TODO:  Add NETDecorator.SetActive implementation
		}

		public void SetParam(string Name, object Value)
		{
			// TODO:  Add NETDecorator.SetParam implementation
		}

		public void Destroy()
		{
			// TODO:  Add NETDecorator.Destroy implementation
		}

		public void GetLocation(out int sx, out int sy, out int ex, out int ey)
		{
			// TODO:  Add NETDecorator.GetLocation implementation
			sx = m_sx;
			sy = m_sy;
			ex = m_ex;
			ey = m_ey;
		}

		public void GetPortLocation(MGADECORATORLib.IMgaFCO FCO, out int sx, out int sy, out int ex, out int ey)
		{
			// TODO:  Add NETDecorator.GetPortLocation implementation
			sx = 0;
			sy = 0;
			ex = 0;
			ey = 0;
		}

		public void Initialize(MGADECORATORLib.IMgaProject Project, IMgaMetaPart Meta, MGADECORATORLib.IMgaFCO obj)
		{
			// TODO:  Add NETDecorator.Initialize implementation
		}

		public void GetMnemonic(out string mnemonic)
		{
			// TODO:  Add NETDecorator.GetMnemonic implementation
			mnemonic = "NETDecorator";
		}

		public void GetParam(string Name, out object Value)
		{
			// TODO:  Add NETDecorator.GetParam implementation
			Value = null;
		}

		public MGADECORATORLib.IMgaFCOs GetPorts()
		{
			// TODO:  Add NETDecorator.GetPorts implementation
			MGADECORATORLib.IMgaFCOs ports = (MGADECORATORLib.IMgaFCOs)new MGALib.MgaFCOsClass();
			return ports;
		}

		public void SaveState()
		{
			// TODO:  Add NETDecorator.SaveState implementation
		}

		public void Draw(System.Int32 hdc)
		{
			Graphics g = Graphics.FromHdc((System.IntPtr)hdc);
			Pen blackPen = new Pen(Color.Black, 3);
			g.DrawRectangle(blackPen, m_sx, m_sy, m_ex-m_sx, m_ey-m_sy);
			g.Dispose();
		}

		public void GetPreferredSize(out int sizex, out int sizey)
		{
			// TODO:  Add NETDecorator.GetPreferredSize implementation
			sizex = 100;
			sizey = 100;
		}

		#endregion

		private int m_sx;
		private int m_sy;
		private int m_ex;
		private int m_ey;
	}
}


More information about the gme-users mailing list