using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data;
using VBNET = Microsoft.VisualBasic;
using gmRTL.Core;
using Microsoft.VisualBasic.CompilerServices;
using System.Linq;
using System.Collections.Generic;

namespace Eval
{
   public partial class frmEval : System.Windows.Forms.Form
   {
      private bool _disposed = false;
      public frmEval()
      {
         //
         // Required for Windows Form Designer support
         //
         InitializeComponent();

         //
         // TODO: Add any constructor code after InitializeComponent call
         //
         if (DesignMode) return;
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
      protected override void Dispose(bool disposing)
      {
         if (_disposed)
         {
            return;
         }
         if (disposing)
         {
            if (components != null)
            {
               components.Dispose();
            }
         }
         _disposed = true;
         base.Dispose(disposing);
      }

      // Pretty short, Ha ?
      Evaluator cEval = new Evaluator();
      private void cmdEval_Click(object sender, EventArgs e)
      {


         if (modPlayWave.CanPlayWaves())
         {
            modPlayWave.PlayWave(gmRTL.Core.App.DefInstance.Path + ((gmRTL.Core.App.DefInstance.Path).EndsWith("\\") ? "" : "\\") + "Sounds\\pff.Wav",true,modPlayWave.APIWaveSourceTypeConstants.UseFileName,modPlayWave.APIWavePlayFlags.NoFlags);
         }
         double Result = 0.0;
         Result = cEval.Evaluate(Text1.Text,true);
         if (cEval.Error == Evaluator.EvalError.ERR_NONE)
         {
            txtResult.Text = Result.ToStr();
         }
         else
         {
            txtResult.Text = cEval.ErrorString;
         }

      }
      private void Text1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
      {
         if (modPlayWave.CanPlayWaves())
         {
            modPlayWave.PlayWave(gmRTL.Core.App.DefInstance.Path + ((gmRTL.Core.App.DefInstance.Path).EndsWith("\\") ? "" : "\\") + "Sounds\\flip.wav",true,modPlayWave.APIWaveSourceTypeConstants.UseFileName,modPlayWave.APIWavePlayFlags.NoFlags);
         }
      }
   }
}
