Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Setting the ResultFormat in a ASP.NET WebApplication.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55007] Re: Setting the ResultFormat in a ASP.NET WebApplication.
  • From: "Hans Michel" <hmichel at sdc.cox.net>
  • Date: Wed, 9 Mar 2005 06:34:32 -0500 (EST)
  • References: <d0e6mf$orp$1@smc.vnet.net> <d0jut4$n6c$1@smc.vnet.net>
  • Reply-to: "Hans Michel" <hmichel at sdc.cox.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Javier:

Sorry this is VB.NET you'll have to translate.

            MathKernel1.GraphicsHeight = 100
            MathKernel1.GraphicsWidth = 100
            MathKernel1.CaptureGraphics = True
            MathKernel1.ResultFormat = 
MathKernel.ResultFormatType.TraditionalForm
            MathKernel1.Compute("3 + 2")

            If TypeOf MathKernel1.Result Is System.Drawing.Image Then
                MathKernel1.Result.Save(Response.OutputStream, 
System.Drawing.Imaging.ImageFormat.Gif)
            End If

I'm using the latest .NET/Link I did not need a temp image Bitmap Object. 
Result.Save when TraditionalForm is enumerated takes on the type 
System.Drawing.Image

I think all you need is
C#

if(Global.mathKernel.Result is System.Drawing.Image)
    {
        Global.mathKernel.Result.Save(Response.OutputStream, 
System.Drawing.Imaging.ImageFormat.Jpeg) ;
    };
Else you can output blank bitmap.

Hans

I think some of you may need to use some "using" declaration to include 
class namespaces thus you can keep your scope short.

On another note which IDE are you using to generate the ASP.NET code?

If you are doing this from scratch consider using
WebMatrix
http://www.asp.net/webmatrix/default.aspx?tabIndex=4&tabId=46
It allows class browsing which is what I think you need so you can look at 
what the properties /methods need as input.
No intellisense.
Review about it http://aspnet.4guysfromrolla.com/articles/061803-1.aspx

Eclispse and .NET Framework SDK
http://www.sys-con.com/webservices/article.cfm?id=360

I would not recommend using the Free Microsoft Express tools. (But its free)
http://lab.msdn.microsoft.com/express/

They require using the .NET Framework 2.0 which is a beta.I don't know it it 
can exist side by side with .NET Framework 1.0 or 1.1.


"Javier Chicote" <goraperas at hotmail.com> wrote in message 
news:d0jut4$n6c$1 at smc.vnet.net...
> Hi again,
>
> I've been trying the different types of ResultFormat. I'm interested to 
> show
> in my application the result of a computation in a smart way, rather than
> the string that I get when the ResultFormatType is OutputForm.
>
> I looked at the documentation and saw that the mathKernel.result is a 
> string
> when the ResultFormat is InputForm, OutputForm or MahML, a Image when the
> ResultFormat is StandardForm or TraditionalForm and a Expr when the
> ResultFormat is Expr. However, I got some errors when I'm using these 
> types:
>
> 1) OutputForm is the default, and it worked OK.
>
> 2) InputForm and Expr worked OK too, but it is not exactly what I am 
> looking
> for.
>
> 3) With MathML, I obtanined an error here:
>        Global.mathKernel.ResultFormat =
> Wolfram.NETLink.MathKernel.ResultFormatType.MathML;
>        Global.mathKernel.Compute("2+3"); //ERROR
>
> 4) With StandardForm or TraditionalForm I cannot see the image in the
> WebApplication if I take the following steps:
>
> * On WebForm1 HTML code:
>        <IMG id="resultsImage" style="Z-INDEX: 102; LEFT: 24px; WIDTH:
> 360px; POSITION: absolute; TOP: 312px; HEIGHT: 88px" height="88" alt=""
> src="Results.aspx" width="360" runat="server">
>
> * Results.aspx. code:
>        <%@ Page language="c#" Codebehind="Results.aspx.cs"
> AutoEventWireup="false" Inherits="MathKernelAppWeb.Results"
> enableViewState="False" contentType="image/jpeg"%>
>
> * Results.aspx.cs code:
>        protected System.Drawing.Image image;
>        private void Page_Load(object sender, System.EventArgs e) {
>               image = (System.Drawing.Image) Global.mathKernel.Result;
>                image.Save(Response.OutputStream, ImageFormat.Jpeg);
>        }
>
> Thank you very much for your time.
>
> Best regards,
>
> Javier Chicote
>
> "Todd Gayley" <tgayley at wolfram.com> escribió en el mensaje
> news:d0e6mf$orp$1 at smc.vnet.net...
>> At 12:34 AM 3/5/2005, Javier Chicote wrote:
>> >Hi,
>> >
>> >The ResultFormat of the MathKernel is set to "OutputForm" as default, 
>> >and
> I
>> >would like to set it to other ResultFormatTypes, like "StandardForm" or
>> >"MathML". How can I do this? It says that I cannot convert a string to
>> >'Wolfram.NETLink.MathKernel.ResultFormatType' when I do like this:
>> >
>> >Global.mathKernel.ResultFormat = "StandardForm";
>> >
>> >or like this:
>> >
>> >Global.mathKernel.ResultFormat =
>> >(Wolfram.NETLink.MathKernel.ResultFormatType) "StandardForm";
>> >
>> >How can I set the ResultFormat then?
>>
>>
>> Javier,
>>
>> ResultFormatType is an enum, so you use its values like this:
>>
>>      Global.mathKernel.ResultFormat =
> MathKernel.ResultFormatType.StandardForm;
>>
>>
>> Todd Gayley
>> Wolfram Research
>>
>
> 


  • Prev by Date: Google's aptitude test equation
  • Next by Date: Re: SQLSelect
  • Previous by thread: Re: Setting the ResultFormat in a ASP.NET WebApplication.
  • Next by thread: Re: Setting the ResultFormat in a ASP.NET WebApplication.