⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wndmain.h

📁 Mathematical expressions parser library
💻 H
📖 第 1 页 / 共 2 页
字号:
#pragma once

#include "../ParserLib/muParser.h"
#include "../ParserLib/muParserInt.h"
#include "WndError.h"
#include <cstdio>
#include <sstream>

#include "muParserTest.h"

#define VARCOUNT 100

namespace Example2
{
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
  using namespace System::Collections::Specialized;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
  using namespace System::Runtime::InteropServices;


  /// <summary> 
	/// Zusammenfassung f黵 Form1
	///
	/// Achtung: Wenn Sie den Namen dieser Klasse 鋘dern, m黶sen Sie die Eigenschaft
	///          'Ressourcendateiname' f黵 das Compilertool f黵 verwaltete Ressourcen 鋘dern, 
	///          das allen .resx-Dateien zugewiesen ist, von denen diese Klasse abh鋘gt. 
	///          Anderenfalls k鰊nen die Designer nicht korrekt mit den lokalisierten Ressourcen
	///          arbeiten, die diesem Formular zugewiesen sind.
	/// </summary>
	public __gc class WinCalc : public System::Windows::Forms::Form
	{	
  private:
      // Example function for String callbacks
      // these can be used for Database queries
      static double ValueOf(const char*)
      {

        // insert fancy side effect here...
        // ...
        // ...
        // ...

        return 23;  
      }

  public:
		WinCalc(void)
      :m_pParser(0)
      ,m_pParserDbl(new mu::Parser())
      ,m_pParserInt(new mu::ParserInt())
      ,m_pfVar(0)
      ,m_iHistLine(0)
      ,m_iVarCount(0)
      ,m_History(new StringCollection())
      ,dlgError(new WndError())
		{
      // Allocating variables that way is a workaround for managed 
      // C++ normally its too complicated to alloc it that way
      m_pfVar = new double[VARCOUNT];
      m_pfVar[0] = 0;

      InitializeComponent();
      dlgError->Hide();

      // Select double parser
      cbParser->BeginUpdate();
      cbParser->Items->Clear();
      cbParser->Items->Add(new BoxItem("Parser for double (muParser)", m_pParserDbl));
      cbParser->Items->Add(new BoxItem("Parser for int (muParserInt)", m_pParserInt));
      cbParser->SelectedIndex = 0;
      cbParser->EndUpdate();

      // Add the variable that stores the answer
      m_pParserDbl->DefineFun("valueof", (strfun_type1)ValueOf);

      m_pParser = m_pParserDbl;
      m_pParserDbl->DefineVar("ans", &m_pfVar[m_iVarCount] ); 
      m_pParserInt->DefineVar("ans", &m_pfVar[m_iVarCount++] ); 
      // ans always takes the lowest slot in the variable array
		}
  
   ~WinCalc()
    {
      delete [] m_pfVar;
    }

	protected:
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}

  private: System::Windows::Forms::Panel *  paBase;
  private: System::Windows::Forms::Panel *  paTitle;
  private: System::Windows::Forms::Label *  lbAuthor;
  private: System::Windows::Forms::Label *  label1;
  private: System::Windows::Forms::GroupBox *  gbCalc;
  private: System::Windows::Forms::RichTextBox *  reMain;
  private: System::Windows::Forms::Button *  btnUnit;
  private: System::Windows::Forms::Button *  btnReset;
  private: System::Windows::Forms::CheckBox *  cbShowVar;
  private: System::Windows::Forms::PictureBox *  pbCalc;
  private: System::Windows::Forms::TextBox *  edInput;
  private: System::Windows::Forms::Label *  label2;
  private: System::Windows::Forms::Button *  btnListFun;
  private: System::Windows::Forms::Button *  btnListConst;
  private: System::Windows::Forms::Button *  btnListVar;
  private: System::Windows::Forms::ComboBox *  cbParser;
  private: System::Windows::Forms::Label *  lbSelector;

  private:
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		System::ComponentModel::Container * components;

		/// <summary>
		/// Erforderliche Methode f黵 die Designerunterst黷zung. 
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor ge鋘dert werden.
		/// </summary>
		void InitializeComponent(void)
		{
      System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(Example2::WinCalc));
      this->paBase = new System::Windows::Forms::Panel();
      this->gbCalc = new System::Windows::Forms::GroupBox();
      this->btnListVar = new System::Windows::Forms::Button();
      this->btnListConst = new System::Windows::Forms::Button();
      this->btnListFun = new System::Windows::Forms::Button();
      this->label2 = new System::Windows::Forms::Label();
      this->edInput = new System::Windows::Forms::TextBox();
      this->pbCalc = new System::Windows::Forms::PictureBox();
      this->cbShowVar = new System::Windows::Forms::CheckBox();
      this->btnReset = new System::Windows::Forms::Button();
      this->btnUnit = new System::Windows::Forms::Button();
      this->reMain = new System::Windows::Forms::RichTextBox();
      this->paTitle = new System::Windows::Forms::Panel();
      this->lbSelector = new System::Windows::Forms::Label();
      this->cbParser = new System::Windows::Forms::ComboBox();
      this->lbAuthor = new System::Windows::Forms::Label();
      this->label1 = new System::Windows::Forms::Label();
      this->paBase->SuspendLayout();
      this->gbCalc->SuspendLayout();
      this->paTitle->SuspendLayout();
      this->SuspendLayout();
      // 
      // paBase
      // 
      this->paBase->BackColor = System::Drawing::Color::White;
      this->paBase->Controls->Add(this->gbCalc);
      this->paBase->Controls->Add(this->paTitle);
      this->paBase->Dock = System::Windows::Forms::DockStyle::Fill;
      this->paBase->Location = System::Drawing::Point(0, 0);
      this->paBase->Name = S"paBase";
      this->paBase->Size = System::Drawing::Size(600, 349);
      this->paBase->TabIndex = 0;
      // 
      // gbCalc
      // 
      this->gbCalc->Anchor = (System::Windows::Forms::AnchorStyles)(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
        | System::Windows::Forms::AnchorStyles::Left) 
        | System::Windows::Forms::AnchorStyles::Right);
      this->gbCalc->Controls->Add(this->btnListVar);
      this->gbCalc->Controls->Add(this->btnListConst);
      this->gbCalc->Controls->Add(this->btnListFun);
      this->gbCalc->Controls->Add(this->label2);
      this->gbCalc->Controls->Add(this->edInput);
      this->gbCalc->Controls->Add(this->pbCalc);
      this->gbCalc->Controls->Add(this->cbShowVar);
      this->gbCalc->Controls->Add(this->btnReset);
      this->gbCalc->Controls->Add(this->btnUnit);
      this->gbCalc->Controls->Add(this->reMain);
      this->gbCalc->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->gbCalc->Location = System::Drawing::Point(8, 56);
      this->gbCalc->Name = S"gbCalc";
      this->gbCalc->Size = System::Drawing::Size(586, 290);
      this->gbCalc->TabIndex = 37;
      this->gbCalc->TabStop = false;
      this->gbCalc->Text = S"Formula parsing";
      // 
      // btnListVar
      // 
      this->btnListVar->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->btnListVar->BackColor = System::Drawing::Color::LightGray;
      this->btnListVar->Location = System::Drawing::Point(482, 88);
      this->btnListVar->Name = S"btnListVar";
      this->btnListVar->Size = System::Drawing::Size(88, 24);
      this->btnListVar->TabIndex = 13;
      this->btnListVar->Text = S"List Variables";
      this->btnListVar->Click += new System::EventHandler(this, btnListVar_Click);
      // 
      // btnListConst
      // 
      this->btnListConst->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->btnListConst->BackColor = System::Drawing::Color::LightGray;
      this->btnListConst->Location = System::Drawing::Point(482, 120);
      this->btnListConst->Name = S"btnListConst";
      this->btnListConst->Size = System::Drawing::Size(88, 24);
      this->btnListConst->TabIndex = 12;
      this->btnListConst->Text = S"List Constants";
      this->btnListConst->Click += new System::EventHandler(this, btnListConst_Click);
      // 
      // btnListFun
      // 
      this->btnListFun->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->btnListFun->BackColor = System::Drawing::Color::LightGray;
      this->btnListFun->Location = System::Drawing::Point(482, 152);
      this->btnListFun->Name = S"btnListFun";
      this->btnListFun->Size = System::Drawing::Size(88, 24);
      this->btnListFun->TabIndex = 11;
      this->btnListFun->Text = S"List Functions";
      this->btnListFun->Click += new System::EventHandler(this, btnListFun_Click);
      // 
      // label2
      // 
      this->label2->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left);
      this->label2->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->label2->Location = System::Drawing::Point(8, 258);
      this->label2->Name = S"label2";
      this->label2->Size = System::Drawing::Size(64, 16);
      this->label2->TabIndex = 10;
      this->label2->Text = S"Formula:";
      // 
      // edInput
      // 
      this->edInput->Anchor = (System::Windows::Forms::AnchorStyles)((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left) 
        | System::Windows::Forms::AnchorStyles::Right);
      this->edInput->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->edInput->Location = System::Drawing::Point(80, 258);
      this->edInput->Name = S"edInput";
      this->edInput->Size = System::Drawing::Size(394, 20);
      this->edInput->TabIndex = 9;
      this->edInput->Text = S"";
      this->edInput->KeyDown += new System::Windows::Forms::KeyEventHandler(this, edInput_KeyDown);
      // 
      // pbCalc
      // 
      this->pbCalc->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->pbCalc->Image = (__try_cast<System::Drawing::Image *  >(resources->GetObject(S"pbCalc.Image")));
      this->pbCalc->Location = System::Drawing::Point(498, 16);
      this->pbCalc->Name = S"pbCalc";
      this->pbCalc->Size = System::Drawing::Size(64, 64);
      this->pbCalc->TabIndex = 8;
      this->pbCalc->TabStop = false;
      // 
      // cbShowVar
      // 
      this->cbShowVar->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->cbShowVar->Checked = true;
      this->cbShowVar->CheckState = System::Windows::Forms::CheckState::Checked;
      this->cbShowVar->Location = System::Drawing::Point(490, 240);
      this->cbShowVar->Name = S"cbShowVar";
      this->cbShowVar->Size = System::Drawing::Size(72, 40);
      this->cbShowVar->TabIndex = 7;
      this->cbShowVar->Text = S"Show variables";
      // 
      // btnReset
      // 
      this->btnReset->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->btnReset->BackColor = System::Drawing::Color::LightGray;
      this->btnReset->Location = System::Drawing::Point(482, 216);
      this->btnReset->Name = S"btnReset";
      this->btnReset->Size = System::Drawing::Size(88, 24);
      this->btnReset->TabIndex = 6;
      this->btnReset->Text = S"Reset";
      this->btnReset->Click += new System::EventHandler(this, btnReset_Click);
      // 
      // btnUnit
      // 
      this->btnUnit->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->btnUnit->BackColor = System::Drawing::Color::LightGray;
      this->btnUnit->Location = System::Drawing::Point(482, 184);
      this->btnUnit->Name = S"btnUnit";
      this->btnUnit->Size = System::Drawing::Size(88, 24);
      this->btnUnit->TabIndex = 4;
      this->btnUnit->Text = S"Run unit test";
      this->btnUnit->Click += new System::EventHandler(this, btnUnit_Click);
      // 
      // reMain
      // 
      this->reMain->Anchor = (System::Windows::Forms::AnchorStyles)(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
        | System::Windows::Forms::AnchorStyles::Left) 
        | System::Windows::Forms::AnchorStyles::Right);
      this->reMain->DetectUrls = false;
      this->reMain->Font = new System::Drawing::Font(S"Arial", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->reMain->Location = System::Drawing::Point(8, 16);
      this->reMain->Name = S"reMain";
      this->reMain->ReadOnly = true;
      this->reMain->Size = System::Drawing::Size(466, 234);
      this->reMain->TabIndex = 1;
      this->reMain->Text = S"";
      // 
      // paTitle
      // 
      this->paTitle->BackColor = System::Drawing::Color::Transparent;
      this->paTitle->BackgroundImage = (__try_cast<System::Drawing::Image *  >(resources->GetObject(S"paTitle.BackgroundImage")));
      this->paTitle->Controls->Add(this->lbSelector);
      this->paTitle->Controls->Add(this->cbParser);
      this->paTitle->Controls->Add(this->lbAuthor);
      this->paTitle->Controls->Add(this->label1);
      this->paTitle->Dock = System::Windows::Forms::DockStyle::Top;
      this->paTitle->Location = System::Drawing::Point(0, 0);
      this->paTitle->Name = S"paTitle";
      this->paTitle->Size = System::Drawing::Size(600, 53);
      this->paTitle->TabIndex = 8;
      // 
      // lbSelector
      // 
      this->lbSelector->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->lbSelector->BackColor = System::Drawing::Color::Transparent;
      this->lbSelector->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->lbSelector->ForeColor = System::Drawing::Color::Black;
      this->lbSelector->Location = System::Drawing::Point(304, 16);
      this->lbSelector->Name = S"lbSelector";
      this->lbSelector->Size = System::Drawing::Size(88, 19);
      this->lbSelector->TabIndex = 15;
      this->lbSelector->Text = S"parser class";
      // 
      // cbParser
      // 
      this->cbParser->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Right);
      this->cbParser->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
      System::Object* __mcTemp__1[] = new System::Object*[2];
      __mcTemp__1[0] = S"double numbers (muParser)";
      __mcTemp__1[1] = S"int numbers (muParserInt)";
      this->cbParser->Items->AddRange(__mcTemp__1);
      this->cbParser->Location = System::Drawing::Point(394, 16);
      this->cbParser->Name = S"cbParser";
      this->cbParser->Size = System::Drawing::Size(176, 21);
      this->cbParser->TabIndex = 14;
      this->cbParser->SelectedIndexChanged += new System::EventHandler(this, cbParser_SelectedIndexChanged);
      // 
      // lbAuthor
      // 
      this->lbAuthor->BackColor = System::Drawing::Color::Transparent;
      this->lbAuthor->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->lbAuthor->ForeColor = System::Drawing::Color::White;
      this->lbAuthor->Location = System::Drawing::Point(8, 24);
      this->lbAuthor->Name = S"lbAuthor";
      this->lbAuthor->Size = System::Drawing::Size(192, 16);
      this->lbAuthor->TabIndex = 12;
      this->lbAuthor->Text = S"(C) 2005 Ingo Berg";
      // 
      // label1
      // 
      this->label1->BackColor = System::Drawing::Color::Transparent;
      this->label1->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
      this->label1->ForeColor = System::Drawing::Color::White;
      this->label1->Location = System::Drawing::Point(8, 3);
      this->label1->Name = S"label1";
      this->label1->Size = System::Drawing::Size(312, 26);
      this->label1->TabIndex = 13;
      this->label1->Text = S"Fast math parser ";
      // 
      // WinCalc
      // 
      this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
      this->ClientSize = System::Drawing::Size(600, 349);
      this->Controls->Add(this->paBase);
      this->MinimumSize = System::Drawing::Size(608, 376);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -