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

📄 formoptions.h

📁 一个可视化的编译器
💻 H
字号:
#pragma once

#include "IDEOptions.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace LeastLIDE {

	/// <summary>
	/// Summary for FormOptions
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class FormOptions : public System::Windows::Forms::Form
	{
	public:
		FormOptions(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~FormOptions()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  buttonOK;
	protected: 

	protected: 



	private: System::Windows::Forms::Button^  buttonCancel;


	private: System::Windows::Forms::FontDialog^  fontDlg;

	private: System::Windows::Forms::Label^  labelFontName;
	private: System::Windows::Forms::Button^  buttonFont;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::GroupBox^  groupBox1;
	private: System::Windows::Forms::GroupBox^  groupBox2;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  labelInterpreterPath;
	private: System::Windows::Forms::Button^  buttonInterpreterPath;



	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::CheckedListBox^  listBoxInterpreterParams;

	private: System::Windows::Forms::Label^  labelInterpreterParams;
	private: System::Windows::Forms::OpenFileDialog^  openFileDlg;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  labelFontSize;











	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->buttonOK = (gcnew System::Windows::Forms::Button());
			this->buttonCancel = (gcnew System::Windows::Forms::Button());
			this->fontDlg = (gcnew System::Windows::Forms::FontDialog());
			this->labelFontName = (gcnew System::Windows::Forms::Label());
			this->buttonFont = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->labelFontSize = (gcnew System::Windows::Forms::Label());
			this->groupBox2 = (gcnew System::Windows::Forms::GroupBox());
			this->listBoxInterpreterParams = (gcnew System::Windows::Forms::CheckedListBox());
			this->labelInterpreterParams = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->labelInterpreterPath = (gcnew System::Windows::Forms::Label());
			this->buttonInterpreterPath = (gcnew System::Windows::Forms::Button());
			this->openFileDlg = (gcnew System::Windows::Forms::OpenFileDialog());
			this->groupBox1->SuspendLayout();
			this->groupBox2->SuspendLayout();
			this->SuspendLayout();
			// 
			// buttonOK
			// 
			this->buttonOK->Location = System::Drawing::Point(381, 259);
			this->buttonOK->Name = L"buttonOK";
			this->buttonOK->Size = System::Drawing::Size(85, 23);
			this->buttonOK->TabIndex = 1;
			this->buttonOK->Text = L"确定";
			this->buttonOK->UseVisualStyleBackColor = true;
			this->buttonOK->Click += gcnew System::EventHandler(this, &FormOptions::buttonOK_Click);
			// 
			// buttonCancel
			// 
			this->buttonCancel->Location = System::Drawing::Point(245, 259);
			this->buttonCancel->Name = L"buttonCancel";
			this->buttonCancel->Size = System::Drawing::Size(90, 23);
			this->buttonCancel->TabIndex = 2;
			this->buttonCancel->Text = L"取消";
			this->buttonCancel->UseVisualStyleBackColor = true;
			this->buttonCancel->Click += gcnew System::EventHandler(this, &FormOptions::buttonCancel_Click);
			// 
			// fontDlg
			// 
			this->fontDlg->ShowColor = true;
			// 
			// labelFontName
			// 
			this->labelFontName->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->labelFontName->Location = System::Drawing::Point(124, 18);
			this->labelFontName->Name = L"labelFontName";
			this->labelFontName->Padding = System::Windows::Forms::Padding(0, 2, 0, 0);
			this->labelFontName->Size = System::Drawing::Size(239, 20);
			this->labelFontName->TabIndex = 7;
			this->labelFontName->Text = L"Courier New";
			// 
			// buttonFont
			// 
			this->buttonFont->Location = System::Drawing::Point(369, 18);
			this->buttonFont->Name = L"buttonFont";
			this->buttonFont->Size = System::Drawing::Size(75, 23);
			this->buttonFont->TabIndex = 6;
			this->buttonFont->Text = L"浏览字体";
			this->buttonFont->UseVisualStyleBackColor = true;
			this->buttonFont->Click += gcnew System::EventHandler(this, &FormOptions::buttonFont_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(30, 19);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(71, 12);
			this->label1->TabIndex = 5;
			this->label1->Text = L"编辑器字体:";
			// 
			// groupBox1
			// 
			this->groupBox1->Controls->Add(this->label3);
			this->groupBox1->Controls->Add(this->labelFontSize);
			this->groupBox1->Controls->Add(this->label1);
			this->groupBox1->Controls->Add(this->labelFontName);
			this->groupBox1->Controls->Add(this->buttonFont);
			this->groupBox1->Location = System::Drawing::Point(12, 12);
			this->groupBox1->Name = L"groupBox1";
			this->groupBox1->Size = System::Drawing::Size(456, 89);
			this->groupBox1->TabIndex = 9;
			this->groupBox1->TabStop = false;
			this->groupBox1->Text = L"编辑器选项:";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(29, 48);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(71, 12);
			this->label3->TabIndex = 8;
			this->label3->Text = L"编辑器字号:";
			// 
			// labelFontSize
			// 
			this->labelFontSize->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->labelFontSize->Location = System::Drawing::Point(123, 47);
			this->labelFontSize->Name = L"labelFontSize";
			this->labelFontSize->Padding = System::Windows::Forms::Padding(0, 2, 0, 0);
			this->labelFontSize->Size = System::Drawing::Size(239, 20);
			this->labelFontSize->TabIndex = 9;
			// 
			// groupBox2
			// 
			this->groupBox2->Controls->Add(this->listBoxInterpreterParams);
			this->groupBox2->Controls->Add(this->labelInterpreterParams);
			this->groupBox2->Controls->Add(this->label4);
			this->groupBox2->Controls->Add(this->label2);
			this->groupBox2->Controls->Add(this->labelInterpreterPath);
			this->groupBox2->Controls->Add(this->buttonInterpreterPath);
			this->groupBox2->Location = System::Drawing::Point(12, 107);
			this->groupBox2->Name = L"groupBox2";
			this->groupBox2->Size = System::Drawing::Size(456, 146);
			this->groupBox2->TabIndex = 10;
			this->groupBox2->TabStop = false;
			this->groupBox2->Text = L"解释器选项:";
			// 
			// listBoxInterpreterParams
			// 
			this->listBoxInterpreterParams->FormattingEnabled = true;
			this->listBoxInterpreterParams->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L" -s\t\t同时输出源文件内容", L" -t\t\t同时输出记号(token)"});
			this->listBoxInterpreterParams->Location = System::Drawing::Point(124, 85);
			this->listBoxInterpreterParams->Name = L"listBoxInterpreterParams";
			this->listBoxInterpreterParams->Size = System::Drawing::Size(238, 36);
			this->listBoxInterpreterParams->TabIndex = 13;
			this->listBoxInterpreterParams->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &FormOptions::listBoxInterpreterParams_ItemCheck);
			// 
			// labelInterpreterParams
			// 
			this->labelInterpreterParams->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->labelInterpreterParams->Location = System::Drawing::Point(124, 57);
			this->labelInterpreterParams->Name = L"labelInterpreterParams";
			this->labelInterpreterParams->Padding = System::Windows::Forms::Padding(0, 2, 0, 0);
			this->labelInterpreterParams->Size = System::Drawing::Size(239, 20);
			this->labelInterpreterParams->TabIndex = 12;
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(30, 57);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(65, 12);
			this->label4->TabIndex = 11;
			this->label4->Text = L"解释器参数";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(30, 24);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(71, 12);
			this->label2->TabIndex = 8;
			this->label2->Text = L"解释器路径:";
			// 
			// labelInterpreterPath
			// 
			this->labelInterpreterPath->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->labelInterpreterPath->Location = System::Drawing::Point(124, 22);
			this->labelInterpreterPath->Name = L"labelInterpreterPath";
			this->labelInterpreterPath->Padding = System::Windows::Forms::Padding(0, 2, 0, 0);
			this->labelInterpreterPath->Size = System::Drawing::Size(239, 20);
			this->labelInterpreterPath->TabIndex = 10;
			// 
			// buttonInterpreterPath
			// 
			this->buttonInterpreterPath->Location = System::Drawing::Point(369, 19);
			this->buttonInterpreterPath->Name = L"buttonInterpreterPath";
			this->buttonInterpreterPath->Size = System::Drawing::Size(75, 23);
			this->buttonInterpreterPath->TabIndex = 9;
			this->buttonInterpreterPath->Text = L"设置路径";
			this->buttonInterpreterPath->UseVisualStyleBackColor = true;
			this->buttonInterpreterPath->Click += gcnew System::EventHandler(this, &FormOptions::buttonInterpreterPath_Click);
			// 
			// FormOptions
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(478, 288);
			this->Controls->Add(this->groupBox2);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->buttonCancel);
			this->Controls->Add(this->buttonOK);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"FormOptions";
			this->Text = L"IDE首选项";
			this->Load += gcnew System::EventHandler(this, &FormOptions::FormOptions_Load);
			this->groupBox1->ResumeLayout(false);
			this->groupBox1->PerformLayout();
			this->groupBox2->ResumeLayout(false);
			this->groupBox2->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
private: 
	System::Void buttonFont_Click(System::Object^  sender, System::EventArgs^  e) {
		this->fontDlg->ShowDialog();
		this->labelFontName->Text = fontDlg->Font->Name;
		this->labelFontSize->Text = System::Convert::ToString(fontDlg->Font->Size);
	}

private: 
	System::Void buttonOK_Click(System::Object^  sender, System::EventArgs^  e) {
		IDEOptions ^ options = gcnew IDEOptions();
		options->SetInterpreter( gcnew String(this->labelInterpreterPath->Text)
			, gcnew String(this->labelInterpreterParams->Text ))	;
		options->SetEditor(gcnew String(this->labelFontName->Text)
			, float::Parse(this->labelFontSize->Text));

		this->Owner->Tag = options;
		RichTextBox ^ codeTextBox = ((RichTextBox ^)(this->Owner->Controls->Find("codeTextBox", true)[0]));
		codeTextBox->SelectAll();
		
		Drawing::Font ^nFont = gcnew Drawing::Font(options->GetEditorFontName(), options->GetEditorFontSize() );
		codeTextBox->SelectionFont = nFont;
		options->Save();
		this->Close();
	}

private: 
	System::Void buttonCancel_Click(System::Object^  sender, System::EventArgs^  e) {
		this->Close();		
	}

private: 
	System::Void FormOptions_Load(System::Object^  sender, System::EventArgs^  e) {
		IDEOptions ^ options = (IDEOptions^)this->Owner->Tag;
		this->labelFontName->Text = options->GetEditorFontName();
		this->labelFontSize->Text = System::Convert::ToString(options->GetEditorFontSize());
		this->labelInterpreterPath->Text = options->GetInterpreterPath();
		this->labelInterpreterParams->Text = options->GetInterpreterParams();
		if (this->labelInterpreterParams->Text->IndexOf("-s"))
		{
			listBoxInterpreterParams->SetItemChecked(0, true);
		}
		else if (this->labelInterpreterParams->Text->IndexOf("-t")) 
		{
			listBoxInterpreterParams->SetItemChecked(1, true);
		}
	}

private: 
	System::Void buttonInterpreterPath_Click(System::Object^  sender, System::EventArgs^  e) {
		openFileDlg->Title = "请选择解释器";
		openFileDlg->ShowDialog();
		this->labelInterpreterPath->Text = openFileDlg->FileName;

	}
private: 
	System::Void listBoxInterpreterParams_ItemCheck(System::Object^  sender, System::Windows::Forms::ItemCheckEventArgs^  e) {
		String ^buff = gcnew String("");
		for (int i = 0; i < listBoxInterpreterParams->CheckedIndices->Count; ++i) 
		{
			if (i == e->Index)
				continue;
			if (listBoxInterpreterParams->CheckedIndices[i] == 0)
			{
				buff += " -s ";
			} 
			else if (listBoxInterpreterParams->CheckedIndices[i] == 1)
			{
				buff += " -t ";
			}
		}

		if (e->Index == 1 && e->NewValue == CheckState::Checked) 
		{
			buff += " -t ";
		} 
		else if (e->Index == 0 && e->NewValue == CheckState::Checked) 
		{
			buff += " -s ";
		}
		
		this->labelInterpreterParams->Text = buff;	
	}
};
}

⌨️ 快捷键说明

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