Finite Element Method Magnetics : CSharp

HomePage :: Search :: PageIndex :: RecentChanges :: Login/Register

Revision [432]

Most recent edit made on 2011-01-30 18:00:02 by DavidMeeker [Contributed code for connecting to FEMM from C#]

Additions:
%%(csharp)


Deletions:
%%(language-ref)




Revision [431]

The oldest known version of this page was edited on 2011-01-30 17:55:39 by DavidMeeker
Dave,

Following the C# code which can access FEMM.
I used the C# 2008 express edition.
In the case of distributing for the general users, feel free.

Anderson Nunes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Femm;

namespace CallFEMM
{
	static class Programa
	{
		static void Main(string[] args)
		{
			ComandosFEMM enviarFEMM = new ComandosFEMM();
			string texto = enviarFEMM.Prompt("Write a text").Replace("\n","");
			bool teste2 = enviarFEMM.MsgBox(texto);
			Console.ReadKey();
			Controle.CloseFemm();
		}
	}
	
	public static class Controle
	{
		private static IActiveFEMM acessoFemm = null;
		internal static IActiveFEMM MyFEMM
		{
			get
			{
				if (acessoFemm == null)
				{
					acessoFemm = new ActiveFEMMClass();
				}
				
				return acessoFemm;
			}
			
		   private set
			{
				acessoFemm = value;
			}
		}
		
		public static void CloseFemm()
		{
			MyFEMM = null;
		}
	}
	
	public class ComandosFEMM
	{
		public string Prompt(string TextPrompt)
		{
			return Controle.MyFEMM.call2femm("prompt (\"" + TextPrompt + "\")");
		}

		public bool MsgBox(string TextMsgBox)
		{
			Controle.MyFEMM.call2femm("messagebox(\"" + TextMsgBox + "\")");
			return true;
		}
	}
}