WinForms - Dynamic Control Creation

本文介绍了一个使用C#和Windows Forms构建的互动式调查表系统,该系统能够自动生成问卷并处理多种类型的用户输入,如单选、多选、文本框等,并通过XML文件提供灵活的问题定义。
//Copyright (C) 2002 Microsoft Corporation
//All rights reserved.
//THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 
//EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF 
//MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
// Since the survey form uses an XML document to provide information
//   the System.Xml namespace is imported for simplicity.

using System;
using System.Drawing;
using System.Xml;
using System.Windows.Forms;

public class frmMain: System.Windows.Forms.Form 
{

	// Create constants to use in the form.

	private const int CONTROL_WIDTH= 300;
	private const int CHARS_PER_LINE = 30;
	private const int HEIGHT_PER_LINE= 19;

	// Create class variables to use during the form.

	private int m_ControlCount = 0;
	private Point m_Location = new Point(10, 10);

	

	/// 
	/// The main entry point for the application.
	/// 
	[STAThread]
	static void Main() 
	{
		Application.Run(new frmMain());
	}


	#region " Windows Form Designer generated code "

	public frmMain() 
	{
		//This call is required by the Windows Form Designer.
		InitializeComponent();
		//Add any initialization after the InitializeComponent() call
		// So that we only need to set the title of the application once,
		// we use the AssemblyInfo class (defined in the AssemblyInfo.cs file)
		// to read the AssemblyTitle attribute.
		GetAssemblyAttributes();
	}

	private void GetAssemblyAttributes()
	{
		AssemblyInfo ainfo = new AssemblyInfo();
		this.Text = ainfo.Title;
		this.mnuAbout.Text = string.Format("&About {0} ...", ainfo.Title);
	}

	//Form overrides dispose to clean up the component list.
	protected override void Dispose(bool disposing)
	{
			if (disposing) 
			 {
				 if (components != null) 
				 {
					 components.Dispose();
				 }
			 }
		base.Dispose(disposing);
	}

	//Required by the Windows Form Designer
	private System.ComponentModel.IContainer components = null;

	//NOTE: The following procedure is required by the Windows Form Designer
	//It can be modified using the Windows Form Designer.  
	//Do not modify it using the code editor.

	private System.Windows.Forms.MainMenu mnuMain;
	private System.Windows.Forms.MenuItem mnuFile;
	private System.Windows.Forms.MenuItem mnuExit;
	private System.Windows.Forms.MenuItem mnuHelp;
	private System.Windows.Forms.MenuItem mnuAbout;
	private System.Windows.Forms.Button btnClearControls;
	private System.Windows.Forms.Button btnTightlyBoundControls;
	private System.Windows.Forms.Button btnAddButton;
	private System.Windows.Forms.Button btnCreateSurvey;
	private System.Windows.Forms.Label Label1;
	private System.Windows.Forms.Label Label2;
	private System.Windows.Forms.Label Label3;
	private System.Windows.Forms.Label Label4;


	private void InitializeComponent() 
	{
		System.Resources.ResourceManager resources  = new System.Resources.ResourceManager(typeof(frmMain));
		this.mnuMain = new System.Windows.Forms.MainMenu();
		this.mnuFile = new System.Windows.Forms.MenuItem();
		this.mnuExit = new System.Windows.Forms.MenuItem();
		this.mnuHelp = new System.Windows.Forms.MenuItem();
		this.mnuAbout = new System.Windows.Forms.MenuItem();
		this.btnAddButton = new System.Windows.Forms.Button();
		this.btnClearControls = new System.Windows.Forms.Button();
		this.btnTightlyBoundControls = new System.Windows.Forms.Button();
		this.btnCreateSurvey = new System.Windows.Forms.Button();
		this.Label1 = new System.Windows.Forms.Label();
		this.Label2 = new System.Windows.Forms.Label();
		this.Label3 = new System.Windows.Forms.Label();
		this.Label4 = new System.Windows.Forms.Label();
		this.SuspendLayout();
		//
		//mnuMain
		//
		this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {this.mnuFile, this.mnuHelp});
		this.mnuMain.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("mnuMain.RightToLeft");
		//
		//mnuFile
		//
		this.mnuFile.Enabled = (bool) resources.GetObject("mnuFile.Enabled");
		this.mnuFile.Index = 0;
		this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {this.mnuExit});
		this.mnuFile.Shortcut = (System.Windows.Forms.Shortcut) resources.GetObject("mnuFile.Shortcut");
		this.mnuFile.ShowShortcut = (bool) resources.GetObject("mnuFile.ShowShortcut");
		this.mnuFile.Text = resources.GetString("mnuFile.Text");
		this.mnuFile.Visible = (bool) resources.GetObject("mnuFile.Visible");
		//
		//mnuExit
		//
		this.mnuExit.Enabled = (bool) resources.GetObject("mnuExit.Enabled");
		this.mnuExit.Index = 0;
		this.mnuExit.Shortcut = (System.Windows.Forms.Shortcut) resources.GetObject("mnuExit.Shortcut");
		this.mnuExit.ShowShortcut = (bool) resources.GetObject("mnuExit.ShowShortcut");
		this.mnuExit.Text = resources.GetString("mnuExit.Text");
		this.mnuExit.Visible = (bool) resources.GetObject("mnuExit.Visible");
		//
		//mnuHelp
		//
		this.mnuHelp.Enabled = (bool) resources.GetObject("mnuHelp.Enabled");
		this.mnuHelp.Index = 1;
		this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {this.mnuAbout});
		this.mnuHelp.Shortcut = (System.Windows.Forms.Shortcut) resources.GetObject("mnuHelp.Shortcut");
		this.mnuHelp.ShowShortcut = (bool) resources.GetObject("mnuHelp.ShowShortcut");
		this.mnuHelp.Text = resources.GetString("mnuHelp.Text");
		this.mnuHelp.Visible = (bool) resources.GetObject("mnuHelp.Visible");
		//
		//mnuAbout
		//
		this.mnuAbout.Enabled = (bool) resources.GetObject("mnuAbout.Enabled");
		this.mnuAbout.Index = 0;
		this.mnuAbout.Shortcut = (System.Windows.Forms.Shortcut) resources.GetObject("mnuAbout.Shortcut");
		this.mnuAbout.ShowShortcut = (bool) resources.GetObject("mnuAbout.ShowShortcut");
		this.mnuAbout.Text = resources.GetString("mnuAbout.Text");
		this.mnuAbout.Visible = (bool) resources.GetObject("mnuAbout.Visible");
		//
		//btnAddButton
		//
		this.btnAddButton.AccessibleDescription = resources.GetString("btnAddButton.AccessibleDescription");
		this.btnAddButton.AccessibleName = resources.GetString("btnAddButton.AccessibleName");
		this.btnAddButton.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("btnAddButton.Anchor");
		this.btnAddButton.BackgroundImage = (System.Drawing.Image) resources.GetObject("btnAddButton.BackgroundImage");
		this.btnAddButton.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("btnAddButton.Dock");
		this.btnAddButton.Enabled = (bool) resources.GetObject("btnAddButton.Enabled");
		this.btnAddButton.FlatStyle = (System.Windows.Forms.FlatStyle) resources.GetObject("btnAddButton.FlatStyle");
		this.btnAddButton.Font = (System.Drawing.Font) resources.GetObject("btnAddButton.Font");
		this.btnAddButton.Image = (System.Drawing.Image) resources.GetObject("btnAddButton.Image");
		this.btnAddButton.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnAddButton.ImageAlign");
		this.btnAddButton.ImageIndex = (int) resources.GetObject("btnAddButton.ImageIndex");
		this.btnAddButton.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("btnAddButton.ImeMode");
		this.btnAddButton.Location = (System.Drawing.Point) resources.GetObject("btnAddButton.Location");
		this.btnAddButton.Name = "btnAddButton";
		this.btnAddButton.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("btnAddButton.RightToLeft");
		this.btnAddButton.Size = (System.Drawing.Size) resources.GetObject("btnAddButton.Size");
		this.btnAddButton.TabIndex = (int) resources.GetObject("btnAddButton.TabIndex");
		this.btnAddButton.Text = resources.GetString("btnAddButton.Text");
		this.btnAddButton.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnAddButton.TextAlign");
		this.btnAddButton.Visible = (bool) resources.GetObject("btnAddButton.Visible");
		//
		//btnClearControls
		//
		this.btnClearControls.AccessibleDescription = resources.GetString("btnClearControls.AccessibleDescription");
		this.btnClearControls.AccessibleName = resources.GetString("btnClearControls.AccessibleName");
		this.btnClearControls.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("btnClearControls.Anchor");
		this.btnClearControls.BackgroundImage = (System.Drawing.Image) resources.GetObject("btnClearControls.BackgroundImage");
		this.btnClearControls.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("btnClearControls.Dock");
		this.btnClearControls.Enabled = (bool) resources.GetObject("btnClearControls.Enabled");
		this.btnClearControls.FlatStyle = (System.Windows.Forms.FlatStyle) resources.GetObject("btnClearControls.FlatStyle");
		this.btnClearControls.Font = (System.Drawing.Font) resources.GetObject("btnClearControls.Font");
		this.btnClearControls.Image = (System.Drawing.Image) resources.GetObject("btnClearControls.Image");
		this.btnClearControls.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnClearControls.ImageAlign");
		this.btnClearControls.ImageIndex = (int) resources.GetObject("btnClearControls.ImageIndex");
		this.btnClearControls.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("btnClearControls.ImeMode");
		this.btnClearControls.Location = (System.Drawing.Point) resources.GetObject("btnClearControls.Location");
		this.btnClearControls.Name = "btnClearControls";
		this.btnClearControls.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("btnClearControls.RightToLeft");
		this.btnClearControls.Size = (System.Drawing.Size) resources.GetObject("btnClearControls.Size");
		this.btnClearControls.TabIndex = (int) resources.GetObject("btnClearControls.TabIndex");
		this.btnClearControls.Text = resources.GetString("btnClearControls.Text");
		this.btnClearControls.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnClearControls.TextAlign");
		this.btnClearControls.Visible = (bool) resources.GetObject("btnClearControls.Visible");
		//
		//btnTightlyBoundControls
		//
		this.btnTightlyBoundControls.AccessibleDescription = resources.GetString("btnTightlyBoundControls.AccessibleDescription");
		this.btnTightlyBoundControls.AccessibleName = resources.GetString("btnTightlyBoundControls.AccessibleName");
		this.btnTightlyBoundControls.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("btnTightlyBoundControls.Anchor");
		this.btnTightlyBoundControls.BackgroundImage = (System.Drawing.Image) resources.GetObject("btnTightlyBoundControls.BackgroundImage");
		this.btnTightlyBoundControls.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("btnTightlyBoundControls.Dock");
		this.btnTightlyBoundControls.Enabled = (bool) resources.GetObject("btnTightlyBoundControls.Enabled");
		this.btnTightlyBoundControls.FlatStyle = (System.Windows.Forms.FlatStyle) resources.GetObject("btnTightlyBoundControls.FlatStyle");
		this.btnTightlyBoundControls.Font = (System.Drawing.Font) resources.GetObject("btnTightlyBoundControls.Font");
		this.btnTightlyBoundControls.Image = (System.Drawing.Image) resources.GetObject("btnTightlyBoundControls.Image");
		this.btnTightlyBoundControls.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnTightlyBoundControls.ImageAlign");
		this.btnTightlyBoundControls.ImageIndex = (int) resources.GetObject("btnTightlyBoundControls.ImageIndex");
		this.btnTightlyBoundControls.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("btnTightlyBoundControls.ImeMode");
		this.btnTightlyBoundControls.Location = (System.Drawing.Point) resources.GetObject("btnTightlyBoundControls.Location");
		this.btnTightlyBoundControls.Name = "btnTightlyBoundControls";
		this.btnTightlyBoundControls.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("btnTightlyBoundControls.RightToLeft");
		this.btnTightlyBoundControls.Size = (System.Drawing.Size) resources.GetObject("btnTightlyBoundControls.Size");
		this.btnTightlyBoundControls.TabIndex = (int) resources.GetObject("btnTightlyBoundControls.TabIndex");
		this.btnTightlyBoundControls.Text = resources.GetString("btnTightlyBoundControls.Text");
		this.btnTightlyBoundControls.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnTightlyBoundControls.TextAlign");
		this.btnTightlyBoundControls.Visible = (bool) resources.GetObject("btnTightlyBoundControls.Visible");
		//
		//btnCreateSurvey
		//
		this.btnCreateSurvey.AccessibleDescription = resources.GetString("btnCreateSurvey.AccessibleDescription");
		this.btnCreateSurvey.AccessibleName = resources.GetString("btnCreateSurvey.AccessibleName");
		this.btnCreateSurvey.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("btnCreateSurvey.Anchor");
		this.btnCreateSurvey.BackgroundImage = (System.Drawing.Image) resources.GetObject("btnCreateSurvey.BackgroundImage");
		this.btnCreateSurvey.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("btnCreateSurvey.Dock");
		this.btnCreateSurvey.Enabled = (bool) resources.GetObject("btnCreateSurvey.Enabled");
		this.btnCreateSurvey.FlatStyle = (System.Windows.Forms.FlatStyle) resources.GetObject("btnCreateSurvey.FlatStyle");
		this.btnCreateSurvey.Font = (System.Drawing.Font) resources.GetObject("btnCreateSurvey.Font");
		this.btnCreateSurvey.Image = (System.Drawing.Image) resources.GetObject("btnCreateSurvey.Image");
		this.btnCreateSurvey.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnCreateSurvey.ImageAlign");
		this.btnCreateSurvey.ImageIndex = (int) resources.GetObject("btnCreateSurvey.ImageIndex");
		this.btnCreateSurvey.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("btnCreateSurvey.ImeMode");
		this.btnCreateSurvey.Location = (System.Drawing.Point) resources.GetObject("btnCreateSurvey.Location");
		this.btnCreateSurvey.Name = "btnCreateSurvey";
		this.btnCreateSurvey.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("btnCreateSurvey.RightToLeft");
		this.btnCreateSurvey.Size = (System.Drawing.Size) resources.GetObject("btnCreateSurvey.Size");
		this.btnCreateSurvey.TabIndex = (int) resources.GetObject("btnCreateSurvey.TabIndex");
		this.btnCreateSurvey.Text = resources.GetString("btnCreateSurvey.Text");
		this.btnCreateSurvey.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("btnCreateSurvey.TextAlign");
		this.btnCreateSurvey.Visible = (bool) resources.GetObject("btnCreateSurvey.Visible");
		//
		//Label1
		//
		this.Label1.AccessibleDescription = resources.GetString("Label1.AccessibleDescription");
		this.Label1.AccessibleName = resources.GetString("Label1.AccessibleName");
		this.Label1.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("Label1.Anchor");
		this.Label1.AutoSize = (bool) resources.GetObject("Label1.AutoSize");
		this.Label1.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("Label1.Dock");
		this.Label1.Enabled = (bool) resources.GetObject("Label1.Enabled");
		this.Label1.Font = (System.Drawing.Font) resources.GetObject("Label1.Font");
		this.Label1.Image = (System.Drawing.Image) resources.GetObject("Label1.Image");
		this.Label1.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label1.ImageAlign");
		this.Label1.ImageIndex = (int) resources.GetObject("Label1.ImageIndex");
		this.Label1.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("Label1.ImeMode");
		this.Label1.Location = (System.Drawing.Point) resources.GetObject("Label1.Location");
		this.Label1.Name = "Label1";
		this.Label1.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("Label1.RightToLeft");
		this.Label1.Size = (System.Drawing.Size) resources.GetObject("Label1.Size");
		this.Label1.TabIndex = (int) resources.GetObject("Label1.TabIndex");
		this.Label1.Text = resources.GetString("Label1.Text");
		this.Label1.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label1.TextAlign");
		this.Label1.Visible = (bool) resources.GetObject("Label1.Visible");
		//
		//Label2
		//
		this.Label2.AccessibleDescription = resources.GetString("Label2.AccessibleDescription");
		this.Label2.AccessibleName = resources.GetString("Label2.AccessibleName");
		this.Label2.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("Label2.Anchor");
		this.Label2.AutoSize = (bool) resources.GetObject("Label2.AutoSize");
		this.Label2.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("Label2.Dock");
		this.Label2.Enabled = (bool) resources.GetObject("Label2.Enabled");
		this.Label2.Font = (System.Drawing.Font) resources.GetObject("Label2.Font");
		this.Label2.Image = (System.Drawing.Image) resources.GetObject("Label2.Image");
		this.Label2.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label2.ImageAlign");
		this.Label2.ImageIndex = (int) resources.GetObject("Label2.ImageIndex");
		this.Label2.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("Label2.ImeMode");
		this.Label2.Location = (System.Drawing.Point) resources.GetObject("Label2.Location");
		this.Label2.Name = "Label2";
		this.Label2.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("Label2.RightToLeft");
		this.Label2.Size = (System.Drawing.Size) resources.GetObject("Label2.Size");
		this.Label2.TabIndex = (int) resources.GetObject("Label2.TabIndex");
		this.Label2.Text = resources.GetString("Label2.Text");
		this.Label2.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label2.TextAlign");
		this.Label2.Visible = (bool) resources.GetObject("Label2.Visible");
		//
		//Label3
		//
		this.Label3.AccessibleDescription = resources.GetString("Label3.AccessibleDescription");
		this.Label3.AccessibleName = resources.GetString("Label3.AccessibleName");
		this.Label3.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("Label3.Anchor");
		this.Label3.AutoSize = (bool) resources.GetObject("Label3.AutoSize");
		this.Label3.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("Label3.Dock");
		this.Label3.Enabled = (bool) resources.GetObject("Label3.Enabled");
		this.Label3.Font = (System.Drawing.Font) resources.GetObject("Label3.Font");
		this.Label3.Image = (System.Drawing.Image) resources.GetObject("Label3.Image");
		this.Label3.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label3.ImageAlign");
		this.Label3.ImageIndex = (int) resources.GetObject("Label3.ImageIndex");
		this.Label3.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("Label3.ImeMode");
		this.Label3.Location = (System.Drawing.Point) resources.GetObject("Label3.Location");
		this.Label3.Name = "Label3";
		this.Label3.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("Label3.RightToLeft");
		this.Label3.Size = (System.Drawing.Size) resources.GetObject("Label3.Size");
		this.Label3.TabIndex = (int) resources.GetObject("Label3.TabIndex");
		this.Label3.Text = resources.GetString("Label3.Text");
		this.Label3.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label3.TextAlign");
		this.Label3.Visible = (bool) resources.GetObject("Label3.Visible");
		//
		//Label4
		//
		this.Label4.AccessibleDescription = resources.GetString("Label4.AccessibleDescription");
		this.Label4.AccessibleName = resources.GetString("Label4.AccessibleName");
		this.Label4.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("Label4.Anchor");
		this.Label4.AutoSize = (bool) resources.GetObject("Label4.AutoSize");
		this.Label4.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("Label4.Dock");
		this.Label4.Enabled = (bool) resources.GetObject("Label4.Enabled");
		this.Label4.Font = (System.Drawing.Font) resources.GetObject("Label4.Font");
		this.Label4.Image = (System.Drawing.Image) resources.GetObject("Label4.Image");
		this.Label4.ImageAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label4.ImageAlign");
		this.Label4.ImageIndex = (int) resources.GetObject("Label4.ImageIndex");
		this.Label4.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("Label4.ImeMode");
		this.Label4.Location = (System.Drawing.Point) resources.GetObject("Label4.Location");
		this.Label4.Name = "Label4";
		this.Label4.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("Label4.RightToLeft");
		this.Label4.Size = (System.Drawing.Size) resources.GetObject("Label4.Size");
		this.Label4.TabIndex = (int) resources.GetObject("Label4.TabIndex");
		this.Label4.Text = resources.GetString("Label4.Text");
		this.Label4.TextAlign = (System.Drawing.ContentAlignment) resources.GetObject("Label4.TextAlign");
		this.Label4.Visible = (bool) resources.GetObject("Label4.Visible");
		//
		//frmMain
		//
		this.AccessibleDescription = (string) resources.GetObject("$this.AccessibleDescription");
		this.AccessibleName = (string) resources.GetObject("$this.AccessibleName");
		this.Anchor = (System.Windows.Forms.AnchorStyles) resources.GetObject("$this.Anchor");
		this.AutoScaleBaseSize = (System.Drawing.Size) resources.GetObject("$this.AutoScaleBaseSize");
		this.AutoScroll = (bool) resources.GetObject("$this.AutoScroll");
		this.AutoScrollMargin = (System.Drawing.Size) resources.GetObject("$this.AutoScrollMargin");
		this.AutoScrollMinSize = (System.Drawing.Size) resources.GetObject("$this.AutoScrollMinSize");
		this.BackgroundImage = (System.Drawing.Image) resources.GetObject("$this.BackgroundImage");
		this.ClientSize = (System.Drawing.Size) resources.GetObject("$this.ClientSize");
		this.Controls.AddRange(new System.Windows.Forms.Control[] {this.Label4, this.Label3, this.Label2, this.Label1, this.btnCreateSurvey, this.btnTightlyBoundControls, this.btnClearControls, this.btnAddButton});
		this.Dock = (System.Windows.Forms.DockStyle) resources.GetObject("$this.Dock");
		this.Enabled = (bool) resources.GetObject("$this.Enabled");
		this.Font = (System.Drawing.Font) resources.GetObject("$this.Font");
		this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
		this.Icon = (System.Drawing.Icon) resources.GetObject("$this.Icon");
		this.ImeMode = (System.Windows.Forms.ImeMode) resources.GetObject("$this.ImeMode");
		this.Location = (System.Drawing.Point) resources.GetObject("$this.Location");
		this.MaximizeBox = false;
		this.MaximumSize = (System.Drawing.Size) resources.GetObject("$this.MaximumSize");
		this.Menu = this.mnuMain;
		this.MinimumSize = (System.Drawing.Size) resources.GetObject("$this.MinimumSize");
		this.Name = "frmMain";
		this.RightToLeft = (System.Windows.Forms.RightToLeft) resources.GetObject("$this.RightToLeft");
		this.StartPosition = (System.Windows.Forms.FormStartPosition) resources.GetObject("$this.StartPosition");
		this.Text = resources.GetString("$this.Text");
		this.Visible = (bool) resources.GetObject("$this.Visible");
		this.ResumeLayout(false);

		// Add event handlers
		this.btnAddButton.Click += new System.EventHandler(this.btnAddButton_Click);
		this.btnClearControls.Click += new System.EventHandler(this.btnClearControls_Click);
		this.btnCreateSurvey.Click += new System.EventHandler(this.btnCreateSurvey_Click);
		this.btnTightlyBoundControls.Click += new System.EventHandler(this.btnTightlyBoundControls_Click);

	}

	#endregion

	#region " Standard Menu Code "

	// has been added to some procedures since they are

	// not the focus of the demo. Remove them if you wish to debug the procedures.

	// This code simply shows the About form.

	private void mnuAbout_Click(object sender, System.EventArgs e) 
	{

		// Open the About form in Dialog Mode

		frmAbout frm =  new frmAbout();

		frm.ShowDialog(this);

		frm.Dispose();

	}

	// This code will close the form.

	private void mnuExit_Click(object sender, System.EventArgs e)
	{
		// Close the current form
		this.Close();
	}

	#endregion

	// This subroutine adds a new button to the form, and sets up event handlers
	//   for it that will be fired on the Click and MouseHover events.

	private void btnAddButton_Click(object sender, System.EventArgs e)
	{
		// Increment the control count
		m_ControlCount += 1;
		// Only allow 5 buttons, just to simplify drawing of the user interface
		if (m_ControlCount <= 5) 
		{
			// Create a new Button
			Button x = new Button();
			// Add properties to the form
			x.Name = "btn" + m_ControlCount.ToString();
			x.Text = "btn" + m_ControlCount.ToString();
			x.Location = new Point(this.m_Location.X + 250, this.m_Location.Y);
			m_Location.Y += x.Height + 5;
			// Add the two event handlers  
			x.Click += new System.EventHandler(myButtonHandler_Click);
			x.MouseHover += new System.EventHandler(myButtonHandler_MouseHover);
			// Add the control to the collection of controls
			Controls.Add(x);
		}
		else 
		{
			// Just allow 5 controls to simplify UI.

			MessageBox.Show("You've reached 5 controls. Clear controls to start again.",this.Text, MessageBoxButtons.OK);

		}

	}

	// This subroutine clears all of the dynamically generated controls 

	//   on the page.  It does this by removing all of the controls, then calling

	//   the InitializeComponent() subroutine that was automatically generated

	//   by Visual Studio .NET.  This is a very easy way of resetting a form to

	//   its original state.

	private void btnClearControls_Click(object sender, System.EventArgs e)
		{
		// Clear all the controls.
		Controls.Clear();
		// Re-Add all of the original controls
		InitializeComponent();
		// Re-set properties such as the app title from Assembly attributes
		GetAssemblyAttributes();
		// Reset the m_Location to its original location.
		m_Location = new Point(10, 10);
		// Reset the number of controls.
		m_ControlCount = 0;
		// Show the form again.
		Show();
	}

    // This subroutine handles the btnCreateSurvey.Click event and creates
    //   a new frmSurveyForm. The controls that are generated are added to the
    //   created survey form. There are no event handlers associated with the 
    //   created controls.
    // The created form is fairly general, and creates a survey with questions
    //   that are based off information provided by the Questions.xml document.
    //   By changing, adding, or removing nodes in the XML document, you can 
    //   change the structure and form of the survey.

	private void btnCreateSurvey_Click(object sender, System.EventArgs e)
	{
		// Create a new Survey Form to display to the User.
		frmSurveyForm survey = new frmSurveyForm();
		// get {the controls collection of the Survey form.
		Control.ControlCollection surveyControls = survey.SurveyFormControls;
		// Reset the m_Location in case the user creates multiple forms
		m_Location = new Point(10, 10);
		// Create an XML document to read in the survey questions
		XmlDocument xr = new XmlDocument();
		xr.Load(@"../../Questions.xml");
		// get {the Tag used for each of the Controls we'll create. This may
		//   be useful later, if the example was extended to break apart
		//   different types of questions/responses for analysis.
		string myTag  = xr.SelectSingleNode("//survey").Attributes["name"].Value;
		// set {the Title on the survey form to the Display Name of the Survey
		survey.SurveyTitle = xr.SelectSingleNode("//survey").Attributes["displayName"].Value;
		// Create an XmlNodeList to contain each of the questions. Fill it.
		XmlNodeList nodeList;
		nodeList = xr.GetElementsByTagName("question");
		// Create a temporary XML Node to use when retrieving information
		//   about the nodes in the nodeList just created.
		foreach(XmlNode myNode in nodeList)
		{
			if (myNode.Attributes != null) 
			{
				// Determine what type of control should be created. Pass
				//   in the required information, including the Controls collection
				//   from the frmSurveyForm form.
				switch (myNode.Attributes["type"].Value)
				{
					case "dropdown":
						m_Location = Survey_AddComboBox(myNode, surveyControls, m_Location, myTag);
						break;
					case "multilist":
						m_Location = Survey_AddListBox(myNode, surveyControls, m_Location, myTag, true);
						break;
					case "text":
						m_Location = Survey_AddTextBox(myNode, surveyControls, m_Location, myTag);
						break;
					case "radio":
						m_Location = Survey_AddRadioButtons(myNode, surveyControls, m_Location, myTag);
						break;
				}
			}
		}

		// set {the size of the form, based off of how many controls
		//   have been placed on the form, and their dimensions.
		survey.Width = m_Location.X + CONTROL_WIDTH + 30;
		// Add a bit extra to leave room for the OK and Cancel buttons.
		survey.Height = m_Location.Y + 75;
		// Show the form.  You can also use the Show() method if you like.
		survey.ShowDialog();
		// Show the response to the user.
		MessageBox.Show(survey.SurveyResponse, this.Text, MessageBoxButtons.OK);

	}

    // This subroutine handles the btnTightlyBoundControls.Click event and creates
    //   two tightly bound controls. It uses the event handlers that have been 
    //   previously defined to handle the events. These event handlers are 
    //   have to be defined beforehand, unless Reflection.Emit is used.
    // The two controls are a Button and a TextBox. When the Button is pressed, the
    //   text in the TextBox is displayed in a MsgBox.  In order to ensure that
    //   we know which TextBox is being used, it is added to the Tag property of
    //   the Button. (We don't know the name of the TextBox while creating the 
    //   event handler, since the TextBox will be created dynamically.

    private void btnTightlyBoundControls_Click(object sender, System.EventArgs e)
		{
        // Increment the number of controls (only by one, even though two 
        //   will be added.
        m_ControlCount += 1;
        // Only allow 5 buttons, just to simplify drawing of the user interface
		if (m_ControlCount <= 5) 
		{
			// Create the TextBox that will contain the text to speak
			TextBox txtSpeakText =  new TextBox();
			// set {up some properties for the TextBox
			txtSpeakText.Text = "Hello, World";
			txtSpeakText.Name = "txtSpeakText";
			txtSpeakText.Location = new Point(m_Location.X + 250, m_Location.Y);
			txtSpeakText.Size = new Size(200, txtSpeakText.Height);
			// Add the TextBox to the controls collection.
			Controls.Add(txtSpeakText);
			// Increment the m_LocationY so the next control won't overwrite it
			m_Location.Y += txtSpeakText.Height + 5;
			// Create a button that will be used to react to clicks
			// Since this button is tightly coupled to the TextBox which will
			//   provide it with the text to display, we'll add the TextBox created
			//   above as the Tag of this Button. 
			Button btnSpeakText = new Button();
			// set {up some properties for the TextBox
			btnSpeakText.Text = "Speak Text";
			btnSpeakText.Name = "btnSpeakText";
			btnSpeakText.Location = new Point(m_Location.X + 250, m_Location.Y);
			btnSpeakText.Size = new Size(100, btnSpeakText.Height);
			// Add the previously created TextBox to this button
			btnSpeakText.Tag = txtSpeakText;
			// Add the TextBox to the controls collection.
			Controls.Add(btnSpeakText);
			// Increment the m_LocationY so the next control won't overwrite it
			m_Location.Y += btnSpeakText.Height + 5;
			// Add the event handler that will handle the event when the
			//   button is pressed.
			btnSpeakText.Click += new System.EventHandler(SpeakTextClickHandler);
		}
		else 
		{
			// Just allow 5 controls to simplify UI.
			MessageBox.Show("You've reached 5 controls. Clear controls to start again.", this.Text, MessageBoxButtons.OK);
		}
    }

    // This subroutine handles the Click events of all the dynamically generated
    //   buttons.  It is attached to all the buttons using the AddHandler function
    //   at the time of button creation.

    private void myButtonHandler_Click(object sender ,EventArgs e)
	{
        // Verify that the type of control triggering this event is indeed
        //   a Button. This is necessary since this handler can be attached
        //   to any event.
		Button btn = sender as Button;
		if (btn != null) 
		{
            // Let the user know what Button was pressed.
            MessageBox.Show(btn.Text + " was pressed!", this.Text,MessageBoxButtons.OK);
        }
    }

    // This subroutine handles the MouseHover events of all the dynamically generated
    //   buttons.  It is attached to all the buttons using the AddHandler function
    //   at the time of button creation.

    private void myButtonHandler_MouseHover(Object sender ,EventArgs e)
	{

        // Verify that the type of control triggering this event is indeed
        //   a Button. This is necessary since this handler can be attached
        //   to any event.

		Button btn = sender as Button;
        if (btn != null) {
            // Let the user know what Button was hovered over.
            MessageBox.Show( btn.Text + " was hovered over!", this.Text, MessageBoxButtons.OK);
        }
    }

    // This subroutine handles the Click event of the Button created in the
    //   tightly bound controls example. It displays in a MsgBox the text that
    //   is inside of the Tag of the Button (which is provided in the 'sender' 
    //   parameter.  Although those event handlers are sophisticated, 
    //   they do have to be defined beforehand, unless Reflection.Emit is used.

    private void SpeakTextClickHandler(object sender, System.EventArgs e)
	{
        // Check to see if the sender is a button, and that it has
        //   a valid, tightly-coupled TextBox object attached as its
        //   Tag property.
		Button btn = sender as Button;
		if (btn != null) 
		{
            // Create a button object to use in its place
            // Check to see if the Button has a TextBox in its Tag property
			TextBox tb = btn.Tag as TextBox;
            if (tb != null) 
				{
                // Display the text to the user
                MessageBox.Show(((TextBox)(btn.Tag)).Text, this.Text,MessageBoxButtons.OK);
            }
        }
    }

    // This function adds a ComboBox to the passed control collection, along

    //   with an associated Label control to display the survey question.

    private Point Survey_AddComboBox(XmlNode inNode ,Control.ControlCollection inControls,
			Point location ,string tag)
	{

        // Create a new control.
        ComboBox myCombo = new ComboBox();
        // set {up some properties for the control
        myCombo.Text = "";
        myCombo.Name = inNode.Attributes["name"].Value;
        myCombo.Tag = tag;
        myCombo.Width = CONTROL_WIDTH;
        // Create a temporary XML Node to use when retrieving information
        //   about the response nodes in the passed node.
        // get {the response nodes.
        foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
								  {
            // Add the InnerText of the response nodes as the values for
            //   the drop down options.
            myCombo.Items.Add(myNode.InnerText);
            // if a default has been specified, use it as the current text.
            if (myNode.Attributes["default"] != null) {
                if (myNode.Attributes["default"].Value == "true") 
					{
                    myCombo.Text = myNode.InnerText;
                }
            }
        }

        // Create a Label and add it to the collection

        Label myLabel = new Label();
        // set {up some properties for the control
        myLabel.Name = myCombo.Name + "Label";
        myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myCombo.Location = location;
        inControls.Add(myCombo);
        location.Y += myCombo.Height + 10;
        // Send back the location for the next control to be added.
        return location;
    }


    // This function adds a ListBox to the passed control collection, along
    //   with an associated Label control to display the survey question.

    private Point Survey_AddListBox(XmlNode inNode , Control.ControlCollection inControls ,
        Point location ,string tag, bool isMultiSelect)
	{
        // Create a new control.
        ListBox myList =  new ListBox();
        // set {up some properties for the control
        myList.Text = "";
        myList.Name = inNode.Attributes["name"].Value;
        myList.Tag = tag;
        myList.Width = CONTROL_WIDTH;
        // Since this function can be used with either multi or single select
        //   list boxes, set the proper SelectionMode based on the passed
        //   isMultiSelect bool variable.
		if (isMultiSelect) 
		{
			myList.SelectionMode = SelectionMode.MultiSimple;
		}
		else 
		{
			myList.SelectionMode = SelectionMode.One;
		}
        // Create a temporary XML Node to use when retrieving information
        //   about the response nodes in the passed node.
        // Add the InnerText of the response nodes as the values for
        //   the list box options.
        foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
			{
            myList.Items.Add(myNode.InnerText);
            // if a default has been specified, use it as the current text.
            if (myNode.Attributes["default"] != null) 
				{
                if (myNode.Attributes["default"].Value == "true") {
                    myList.Text = myNode.InnerText;
                }
            }
        }
        // Create a Label and add it to the collection
        Label myLabel = new Label();
        // set {up some properties for the control
        myLabel.Name = myList.Name + "Label";
        myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myList.Location = location;
        inControls.Add(myList);
        location.Y += myList.Height + 10;
        // Send back the location for the next control
        return location;
    }
    // This function adds a GroupBox to the passed control collection, along
    //   with all the appropriate radio buttons, one for each available response.
    //   It also adds an associated Label control to display the survey question.

    private Point Survey_AddRadioButtons(XmlNode inNode, Control.ControlCollection inControls ,
        Point location ,string tag)
		{
        // Must create a GroupBox to contain the radio buttons
        //   otherwise they are not logically distinct from the other
        //   radio buttons on the form.
        GroupBox myGroupBox = new GroupBox();
        // set {up some properties for the control.
        myGroupBox.Text = "";
        myGroupBox.Name = inNode.Attributes["name"].Value;
        myGroupBox.Tag = tag;
        myGroupBox.Width = CONTROL_WIDTH + 20;
        // Create some useful variables to use in the following block of code.
        Point myRadioPoint = new Point(5, 10);    
        // Loop through each response, and add it as a new radio button.
        foreach(XmlNode myNode in inNode.SelectNodes("responses/response"))
		{
            // Create the radio button.
            RadioButton myRadio = new RadioButton();
            // Add the appropriate properties.
            myRadio.Text = myNode.InnerText;
            myRadio.Location = myRadioPoint;
            myRadioPoint.Y += myRadio.Height;
            // set {the default value as the selected radio button, but
            //   only if the default attribute exists and is set to true.
            if (myNode.Attributes["default"] != null) 
				{
                if (myNode.Attributes["default"].Value == "true") 
				{
                    myRadio.Checked = true;
                }
            }
            // Add the control to the group box.
            myGroupBox.Controls.Add(myRadio);
        }
        // Reset the height for the textbox, based on the 
        //   contained Radio Buttons.
        myGroupBox.Height = myRadioPoint.Y + 5;
        // Create a Label and add it to the collection.
        Label myLabel = new Label();
        // Fix the label properties.
        myLabel.Name = myGroupBox.Name + "Label";
        myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height - 5;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myGroupBox.Location = location;
        inControls.Add(myGroupBox);
        location.Y += myGroupBox.Height + 10;
        // Send back the location for the next control
        return location;
    }
    // This function adds a TextBox to the passed control collection, along
    //   with an associated Label control to display the survey question.

    private Point Survey_AddTextBox(XmlNode inNode , Control.ControlCollection inControls,
        Point location ,string tag) 
{
        // Create a new control.
        TextBox myText = new TextBox();
        // Fill in some of the appropriate properties
        if (inNode.SelectSingleNode("defaultResponse") != null) 
			{
            myText.Text = inNode.SelectSingleNode("defaultResponse").InnerText;
        }
        if (inNode.Attributes["name"] != null) {
            myText.Name = inNode.Attributes["name"].Value;
        }
        myText.Tag = tag;
        myText.Width = CONTROL_WIDTH;
        // set {the MaxLength property based off of the XML node information.
        if (inNode.SelectSingleNode("maxCharacters") != null) {
            myText.MaxLength = int.Parse(inNode.SelectSingleNode("maxCharacters").InnerText);
        }
        // Calculate the number of lines that should be allowed for
        if (myText.MaxLength > 0) 
			{
            int numLines  = (myText.MaxLength / CHARS_PER_LINE ) + 1;
            // Calculate how large the textbox should be, and whether 
            //   scrollbars are necessary.
			if (numLines == 1) 
			{
				myText.Multiline = false;
			}
			else 
			{
				if (numLines >= 4) 
				{
					myText.Multiline = true;
					myText.Height = 4 * HEIGHT_PER_LINE;
					myText.ScrollBars = ScrollBars.Vertical;
				}
				else 
				{
					myText.Multiline = true;
					myText.Height = numLines * HEIGHT_PER_LINE;
					myText.ScrollBars = ScrollBars.None;
				}
			}
        }

        // Create a Label and add it to the collection
        Label myLabel = new Label();
        myLabel.Name = myText.Name + "Label";
        if (inNode.SelectSingleNode("text") != null) {
            myLabel.Text = inNode.SelectSingleNode("text").InnerText;
        }
        myLabel.Width = CONTROL_WIDTH;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myLabel.Location = location;
        inControls.Add(myLabel);
        location.Y += myLabel.Height;
        // Add the control to the Controls collection, and reset
        //   the location to the location for the next control.
        myText.Location = location;
        inControls.Add(myText);
        location.Y += myText.Height + 10;
        // Send back the location for the next control.
        return location;

    }

}

内容概要:本文档详细介绍了基于直驱永磁同步发电机(PMSG)的1.5MW风力发电系统在Simulink环境下的建模与仿真全过程,涵盖了风力机空气动力学模型、PMSG电磁特性建模、不可控整流与逆变电路、直流环节、空间矢量脉宽调制(SVPWM)技术以及核心控制策略的设计。重点实现了最大功率点跟踪(MPPT)控制以提升风能捕获效率,并构建了电压外环与电流内环协同工作的双闭环控制系统,通过仿真验证了系统在不同风速条件下稳定运行的能力及动态响应性能。; 适合人群:适用于具备电力系统、电机控制理论基础及Simulink仿真操作经验的研究生、科研人员和从事新能源发电系统开发的工程技术人员;特别适合正在进行风电系统建模、控制算法研究或完成相关毕业设计的专业人士。; 使用场景及目标:①深入理解直驱式PMSG风力发电系统的整体架构与工作机理;②掌握从物理部件建模到控制策略实现的完整Simulink仿真流程;③学习并复现MPPT控制、双闭环控制等关键技术方案;④为后续开展低电压穿越、并网稳定性分析、故障诊断等高级课题提供可靠的仿真平台支撑。; 阅读建议:建议结合Matlab/Simulink软件动手实践,逐模块搭建模型,重点关注各控制环节的参数设计与调试方法,同时可参照文中提供的其他风电相关资源进行拓展学习与对比分析。
已经博主授权,源码转载自 https://pan.quark.cn/s/868afdd63918 在信息技术领域中,前端开发构成了Web应用程序构建的关键环节,而登录注册页面则是用户与网站进行互动的起始界面。"150款web登录注册页面模板(附带效果图+源码)"这一资源为前端工程师们提供了一系列预先设计的界面组件,支持他们迅速构建既美观又实用的登录及注册界面,从而有效缩减开发周期并增强工作效率。 这些模板囊括了多样化的风格和设计潮流,涵盖了扁平化设计、Material Design、渐变色彩、暗黑模式等,能够适应不同项目的特定要求。在设计中强调用户体验,通过科学的布局安排,提升了表单的便捷操作性和可辨识度,并且不忽视视觉层面的吸引力。设计师通常会关注自适应设计,保证页面在多种设备(涵盖手机、平板及桌面电脑)上均能呈现良好的视觉效果。 这些模板均配备了源代码,使得开发者得以深入探究并个性化定制每个构成部分,涉及HTML的页面构造、CSS的样式修饰以及JavaScript的交互逻辑。HTML主要承担着页面基础结构的搭建,CSS用于实现页面美化与布局控制,JavaScript则常用于处理表单验证和交互效果。对于那些精通这三种技术的开发者而言,他们可以根据个人需求对模板进行功能扩展和样式调整。 在实际部署时,登录注册页面通常需要集成基础的输入项,例如用户名、密码、电子邮箱等,并且必须重视安全性考量,诸如密码强度指引、验证码系统等。除此之外,为了优化用户体验,还可能集成记住密码、自动填充、社交平台登录(例如微信、QQ、微博)等功能。 在开发阶段,前端工程师还需关注Web标准和无障碍访问(WCAG)规范,确保页面的通用友好性,这包括视障、听障或其他有特殊需求的用户群体。具体措施涉及标...
源码直接下载地址: https://pan.quark.cn/s/9af8b9f95652 ### Multisim模型的导入和使用 ### 一、引言 随着电子设计自动化(EDA)工具的进步,Multisim已经成为电子工程师进行电路仿真、分析和设计的关键工具之一。借助Multisim,工程师们能够便捷地构建电路模型,并对电路进行仿真验证。本文将系统阐述如何在Multisim中导入并运用芯片仿真模型,这对于提升电子产品的研发效能具有显著价值。 ### 二、Multisim中构建新元器件 构建新元器件是Multisim中的核心功能,特别是对于那些需要特定模型或无法从Multisim库中直接获取的元器件来说更为关键。以下为构建新元器件的具体流程: ##### 步骤1:录入元器件信息 在Multisim中启动“Component Wizard”,即元器件向导,开始创建新的元器件。首先需要录入元器件的基本资料,包括型号、主要功能、类型等。这些资料将有助于用户更高效地管理和检索元器件。 ##### 步骤2:录入封装信息 接下来需要设定元器件的封装信息。在这一环节中,用户需要依据实际芯片的封装规格来选择适宜的引脚数量。同时,还需明确是构建单一部件元器件还是复合部件元器件。如果是复合部件元器件,则必须确保引脚数量与符号中使用的引脚数量保持一致。 ##### 步骤3:录入符号信息 在此步骤中,用户可以编辑元器件在仿真过程中的显示符号。编辑符号可以通过三种途径进行:直接编辑、从数据库中复制现有符号或复制当前符号以备将来使用。编辑符号时应注重其在电路图中的可辨识度和清晰度。 ##### 步骤4:设定管脚参数 在该步骤中,用户需要参照数据手册上的管脚顺序为每个管脚命名,并选择恰当的类型。...
代码转载自:https://pan.quark.cn/s/7b1a6710052c Vivado 2018.2 与 ModelSim 的协同仿真操作 Vivado 2018.2 是由 Xilinx 公司开发的一款用于 FPGA 设计的工具,它包含了丰富的设计和仿真功能。然而,在实际应用过程中,用户可能会遇到其自带的仿真工具运行效率不高的问题。为了提升仿真效率并简化设计验证流程,可以考虑采用第三方仿真工具 ModelSim。ModelSim 是一款性能卓越且市场应用广泛的仿真软件,接下来的内容将详细阐述如何实现 Vivado 2018.2 与 ModelSim 的联合使用。 配置 ModelSim 的安装路径 在使用 Vivado 2018.2 时,首先需要配置 ModelSim 的安装位置。用户可以通过点击 Vivado 菜单中的“Tools”——>“Settings...”选项,然后在弹出的设置界面中,选择“Tool Settings”下的“3rd Party Simulators”选项卡。在“Install Paths”区域,找到“ModelSim”条目,并在此输入或选择 ModelSim 的具体安装路径。 执行器件库编译操作 在 ModelSim 的安装目录下,创建一个名为 xilinx_lib 的子文件夹。随后,在 Vivado 菜单中通过“Tools”——>“Compile Simulation Libraries...”选项启动器件库编译流程,并设定相应的编译参数。在打开的对话框里,将仿真工具选择为“ModelSim Simulator”,保持语言和库的默认设置不变,同时指定编译器件库的存放位置和 ModelSim 可执行文件的路径。 ...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值