Adding Mathcad to TW
Mathcad is a windows executable (Like MS Word) but it has a COM based API callable from VB.NET, C#.Net, javascript, vbscript and more.
What would be the best way to create a TW service to launch Mathcad on the server.
example C# code to launch and load Mathcad, push and pull data
private void Form1_Load(object sender, EventArgs e)
{
{
_mathcadPrimeApplication = new Ptc.MathcadPrime.Automation.ApplicationCreator();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
string dirname;
//lets find out where we are runing from and point our file open dialog to that directory.
dirname = System.AppDomain.CurrentDomain.BaseDirectory;
openFileDialog1.InitialDirectory = dirname;
openFileDialog1.ShowDialog();
try
{
_mathcadPrimeWorksheet = _mathcadPrimeApplication.Open(openFileDialog1.FileName) as IMathcadPrimeWorksheet3;
_mathcadPrimeApplication.Visible = true;
_mathcadPrimeInputs = _mathcadPrimeWorksheet.Inputs;
_mathcadPrimeOutputs = _mathcadPrimeWorksheet.Outputs;
}
catch {
MessageBox.Show("For some reason your Mathcad worksheet did not open \n Try again");
}
closeToolStripMenuItem.Enabled = true;
textBox5.Enabled = true;
textBox2.Enabled = true;
textBox3.Enabled = true;
textBox4.Enabled = true;
button1.Enabled = true;
}
//Close the worksheet
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
_mathcadPrimeWorksheet.Close(Ptc.MathcadPrime.Automation.SaveOption.spDiscardChanges)
closeToolStripMenuItem.Enabled = false;
}
//Close the Mathcad Prime Application
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
_mathcadPrimeApplication.Quit(Ptc.MathcadPrime.Automation.SaveOption.spDiscardChanges);
Close();
}

