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

📄 formmain.h

📁 一个可视化的编译器
💻 H
📖 第 1 页 / 共 5 页
字号:
			this->toolStripButton4->Name = L"toolStripButton4";
			this->toolStripButton4->Size = System::Drawing::Size(28, 28);
			this->toolStripButton4->Text = L"toolStripButton4";
			this->toolStripButton4->ToolTipText = L"Save as";
			this->toolStripButton4->Click += gcnew System::EventHandler(this, &FormMain::saveAsToolStripMenuItem_Click);
			// 
			// toolStripSeparator1
			// 
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
			this->toolStripSeparator1->Size = System::Drawing::Size(6, 31);
			// 
			// toolStripButton5
			// 
			this->toolStripButton5->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton5->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton5.Image")));
			this->toolStripButton5->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton5->Name = L"toolStripButton5";
			this->toolStripButton5->Size = System::Drawing::Size(28, 28);
			this->toolStripButton5->Text = L"toolStripButton5";
			this->toolStripButton5->ToolTipText = L"Cut";
			this->toolStripButton5->Click += gcnew System::EventHandler(this, &FormMain::cutToolStripMenuItem_Click);
			// 
			// toolStripButton6
			// 
			this->toolStripButton6->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton6->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton6.Image")));
			this->toolStripButton6->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton6->Name = L"toolStripButton6";
			this->toolStripButton6->Size = System::Drawing::Size(28, 28);
			this->toolStripButton6->Text = L"toolStripButton6";
			this->toolStripButton6->ToolTipText = L"Copy";
			this->toolStripButton6->Click += gcnew System::EventHandler(this, &FormMain::copyToolStripMenuItem_Click);
			// 
			// toolStripButton7
			// 
			this->toolStripButton7->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton7->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton7.Image")));
			this->toolStripButton7->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton7->Name = L"toolStripButton7";
			this->toolStripButton7->Size = System::Drawing::Size(28, 28);
			this->toolStripButton7->Text = L"toolStripButton7";
			this->toolStripButton7->ToolTipText = L"Paste";
			this->toolStripButton7->Click += gcnew System::EventHandler(this, &FormMain::pasteToolStripMenuItem_Click);
			// 
			// toolStripSeparator2
			// 
			this->toolStripSeparator2->Name = L"toolStripSeparator2";
			this->toolStripSeparator2->Size = System::Drawing::Size(6, 31);
			// 
			// toolStripButton8
			// 
			this->toolStripButton8->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton8->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton8.Image")));
			this->toolStripButton8->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton8->Name = L"toolStripButton8";
			this->toolStripButton8->Size = System::Drawing::Size(28, 28);
			this->toolStripButton8->Text = L"toolStripButton8";
			this->toolStripButton8->ToolTipText = L"Undo";
			this->toolStripButton8->Click += gcnew System::EventHandler(this, &FormMain::undoToolStripMenuItem_Click);
			// 
			// toolStripButton9
			// 
			this->toolStripButton9->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButton9->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton9.Image")));
			this->toolStripButton9->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButton9->Name = L"toolStripButton9";
			this->toolStripButton9->Size = System::Drawing::Size(28, 28);
			this->toolStripButton9->Text = L"toolStripButton9";
			this->toolStripButton9->ToolTipText = L"Redo";
			this->toolStripButton9->Click += gcnew System::EventHandler(this, &FormMain::redoToolStripMenuItem_Click);
			// 
			// toolStripSeparator3
			// 
			this->toolStripSeparator3->Name = L"toolStripSeparator3";
			this->toolStripSeparator3->Size = System::Drawing::Size(6, 31);
			// 
			// toolStripButtonCompile
			// 
			this->toolStripButtonCompile->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButtonCompile->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButtonCompile.Image")));
			this->toolStripButtonCompile->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButtonCompile->Name = L"toolStripButtonCompile";
			this->toolStripButtonCompile->Size = System::Drawing::Size(28, 28);
			this->toolStripButtonCompile->Text = L"toolStripButton10";
			this->toolStripButtonCompile->ToolTipText = L"Compile";
			this->toolStripButtonCompile->Click += gcnew System::EventHandler(this, &FormMain::compileToolStripMenuItem_Click);
			// 
			// toolStripButtonRun
			// 
			this->toolStripButtonRun->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButtonRun->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButtonRun.Image")));
			this->toolStripButtonRun->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButtonRun->Name = L"toolStripButtonRun";
			this->toolStripButtonRun->Size = System::Drawing::Size(28, 28);
			this->toolStripButtonRun->Text = L"toolStripButton11";
			this->toolStripButtonRun->ToolTipText = L"Run";
			this->toolStripButtonRun->Click += gcnew System::EventHandler(this, &FormMain::runToolStripMenuItem_Click);
			// 
			// toolStripSeparator4
			// 
			this->toolStripSeparator4->Name = L"toolStripSeparator4";
			this->toolStripSeparator4->Size = System::Drawing::Size(6, 31);
			// 
			// toolStripLabel1
			// 
			this->toolStripLabel1->Name = L"toolStripLabel1";
			this->toolStripLabel1->Size = System::Drawing::Size(53, 28);
			this->toolStripLabel1->Text = L"快速查找";
			// 
			// toolStripComboBoxFind
			// 
			this->toolStripComboBoxFind->AutoCompleteCustomSource->AddRange(gcnew cli::array< System::String^  >(4) {L"begin", L"end", 
				L"write", L"read"});
			this->toolStripComboBoxFind->AutoCompleteMode = System::Windows::Forms::AutoCompleteMode::Suggest;
			this->toolStripComboBoxFind->AutoCompleteSource = System::Windows::Forms::AutoCompleteSource::HistoryList;
			this->toolStripComboBoxFind->Name = L"toolStripComboBoxFind";
			this->toolStripComboBoxFind->Size = System::Drawing::Size(121, 31);
			this->toolStripComboBoxFind->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &FormMain::toolStripComboBoxFind_KeyPress);
			// 
			// toolStripButtonFind
			// 
			this->toolStripButtonFind->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
			this->toolStripButtonFind->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButtonFind.Image")));
			this->toolStripButtonFind->ImageTransparentColor = System::Drawing::Color::Magenta;
			this->toolStripButtonFind->Name = L"toolStripButtonFind";
			this->toolStripButtonFind->Size = System::Drawing::Size(28, 28);
			this->toolStripButtonFind->Text = L"toolStripButton11";
			this->toolStripButtonFind->Click += gcnew System::EventHandler(this, &FormMain::toolStripButtonFind_Cick);
			// 
			// FormMain
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(670, 449);
			this->Controls->Add(this->tableLayoutPanel1);
			this->Controls->Add(this->menuStripMain);
			this->MainMenuStrip = this->menuStripMain;
			this->Name = L"FormMain";
			this->Text = L"C0 IDE";
			this->Load += gcnew System::EventHandler(this, &FormMain::FormMain_Load);
			this->menuStripMain->ResumeLayout(false);
			this->menuStripMain->PerformLayout();
			this->tableLayoutPanel1->ResumeLayout(false);
			this->tableLayoutPanel1->PerformLayout();
			this->splitContainerH->Panel1->ResumeLayout(false);
			this->splitContainerH->Panel2->ResumeLayout(false);
			this->splitContainerH->ResumeLayout(false);
			this->splitContainerV->Panel1->ResumeLayout(false);
			this->splitContainerV->Panel2->ResumeLayout(false);
			this->splitContainerV->ResumeLayout(false);
			this->tabCtrlSide->ResumeLayout(false);
			this->tabPageFiles->ResumeLayout(false);
			this->splitContainer1->Panel1->ResumeLayout(false);
			this->splitContainer1->Panel2->ResumeLayout(false);
			this->splitContainer1->ResumeLayout(false);
			this->tableLayoutPanelFile->ResumeLayout(false);
			this->tableLayoutPanelFile->PerformLayout();
			this->tabControlCode->ResumeLayout(false);
			this->tabPage4->ResumeLayout(false);
			this->tabControlBtm->ResumeLayout(false);
			this->tabPageOutput->ResumeLayout(false);
			this->tabPageOutput->PerformLayout();
			this->tabPageErrorList->ResumeLayout(false);
			this->statusStrip1->ResumeLayout(false);
			this->statusStrip1->PerformLayout();
			this->toolStripMain->ResumeLayout(false);
			this->toolStripMain->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion




#pragma region //自定义成员变量

private:
	//当前编辑的文件的路径
	String ^currentFilePath;
	//当前编辑文件的名字
	String ^currentFileName;
	//当前文件是否被更改的标识
	bool isChanged;
	//当前文件是否保存的标识
	bool isSavedToDisk;
	//IDE选项
	IDEOptions ^options;
	//解释器的包装类
	Interpreter ^interpreter;

#pragma endregion

#pragma region //自定义成员函数
private:
	System::Void SetSubFolderNode(TreeNode ^ parent) {
		DirectoryInfo ^curDir = gcnew DirectoryInfo(parent->FullPath);
		array <DirectoryInfo ^> ^subDirs;
		try {
			subDirs = curDir->GetDirectories();

			for (int i = 0; i < subDirs->Length; ++i) 
			{
				TreeNode ^curNode = gcnew TreeNode();
				curNode->Text = subDirs[i]->Name;
				curNode->ImageIndex = 1;
				curNode->SelectedImageIndex = 2;
				parent->Nodes->Add(curNode);
			}
		}catch (...){}
	}

private:
	System::Void RunInterpreter(String ^fileName, int flag) {
		interpreter->SetPath(options->GetInterpreterPath());
		if (0 == flag) { 
			interpreter->SetParams(options->GetInterpreterParams() + " -c " + fileName);
		} else {
			interpreter->SetParams(options->GetInterpreterParams() + fileName);
		}
		interpreter->Run(flag);
		System::Threading::Thread::Sleep(500);
	}

private:
	System::Void QuickFind(String ^word) {		
		codeTextBox->Focus();
		int newPos = codeTextBox->Find(word, codeTextBox->SelectionStart + word->Length, RichTextBoxFinds::None);
		if (newPos == -1){
			this->toolStripStatusLabelMain->Text = "查找完毕, 没找到单词\"" + word + "\".";
		}
	}
private:
	System::Void ParseErrors(String ^output) {	
		listBoxErrors->Items->Clear();
		array <String ^> ^ list = output->Split('\n');
		for (int i = 0; i < list->Length; ++i) {
			RegularExpressions::Regex ^r = gcnew Regex("(.*\(\d*\) : .*)");//匹配行号".*\\..*\\((\\d*)\\)"
			Match ^ret = r->Match(list[i]);
			if (ret->Success) {
				listBoxErrors->Items->Add(ret->Groups[0]);
			}
		}
		tabControlBtm->SelectedIndex = 1;
	}



#pragma endregion



private: 
	System::Void FormMain_Resize(System::Object^  sender, System::EventArgs^  e) {

	}


private: 
	System::Void openToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
		this->openFileDlg->Title="Open New LeastL Source File.";
		this->openFileDlg->Filter = "*.lls(leastL Source)|*.lls|*.*(All Files)|*.*";
		this->openFileDlg->ShowDialog();
	}

private: 
	System::Void openFileDlg_FileOk(System::Object^  sender, System::ComponentModel::CancelEventArgs^  e) {
		//if (! File::Exists(openFileDlg->FileName) )
		codeTextBox->Clear();
		FileStream ^ file = File::OpenRead(openFileDlg->FileName);
		array<Byte> ^ codeData = gcnew array<Byte>(1024);
		UTF8Encoding ^ temp = gcnew UTF8Encoding( true );
		while ( file->Read( codeData, 0, codeData->Length ) > 0 )
		{
			this->codeTextBox->Text += temp->GetString(codeData);
		}
		file->Close();

		currentFilePath = openFileDlg->FileName;
		array <String^> ^aPathList = openFileDlg->FileName->Split('\\');
		currentFileName = aPathList[aPathList->Length - 1];
		this->tabControlCode->TabPages[0]->Text = currentFileName;
		isChanged = false;
		isSavedToDisk = true;
	}
	

private: 
	System::Void saveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
		
		if (!isSavedToDisk)
		{
			saveAsToolStripMenuItem_Click(sender, e);
		}
		if (isChanged){
			isChanged = false;
			//write to file 
			if ( File::Exists(currentFilePath) )
			{
				File::Delete(currentFilePath);
			}
			FileStream ^ file = File::Create(currentFilePath);
			array<Byte>^info = (gcnew UTF8Encoding( true ))->GetBytes(codeTextBox->Text);
			file->Write( info, 0, info->Length );

⌨️ 快捷键说明

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