包含和测试gui的类库 [英] class library to include and test gui

查看:85
本文介绍了包含和测试gui的类库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我想开始说这是家庭作业的一部分,但是我不需要任何代码.我必须创建一个带有2个子类的抽象基类,其中包括一个虚拟方法和一个接口.我已经制作了所有的类和接口,但是仍然无法创建一个类来测试GUI.我已经使用子类和接口引用了所有类库,但是在示例中,我的书中还有另一个名为PresentationGUI.cs的类.我已经在表单之前创建了该类,但是不知道如何实现该类以与表单一起使用",我已经将presentation类设置为启动项目,但是无法弄清楚如何使其与Windows Form进行通信.设计者代码.在这本书中,演示文稿类具有Windows Forms代码以及该演示文稿类中对不同类的名称空间的引用以及子类的某些部分,但是我对如何实现这一点迷失了.本书中的代码如下所示(为了节省时间,我将其缩短了):

Hello,
I want to start out saying this is part of a homework assignment, but I''m not asking for any code. I have to create a abstract base class, with 2 subclasses, including a virtual method, and a interface. I have made all my classes and the interface, but I am stuck in creating a class to test the GUI. I have referenced all the class libraries with subclasses and the interface, but my book has another class called PresentationGUI.cs in the example. I have created the class before the form, but do not know how to implement this class to "work" with the form, I have set the presentation class as a startup project, but cannot figure out how to make it communicate with the Windows Form Designer code. In the book the presentation class, has Windows Forms code generated along with references to the namespaces of the different classes, within this presentation class, along with parts of the subclasses, but I am lost at how to accomplish this. The code in the book looks like this (I shortened it to save time):

01	using System;                //// I get an error if I type this in
02	using System.Drawing;
03	using System.Collections.Generic;
04	using System.ComponentModel;
05	using System.Windows.Forms;
06	using System.Data;
07	using ClubNamespace;       //// to reference the subclasses
08	using IntermuralNamespace;
09	 
10	namespace PresentationGUI
11	{
12	public class PresentationGUI : System.Windows.Forms.Form
13	{
14	private Club aClub;
15	private Intermural aIntermural;
16	private System.Windows.Forms.GroupBox groupbox1;
17	private System.Windows.Forms.Label label1;
18	//// and other Windows.Forms object oriented buttons and so-forth
19	 
20	public PresentationGUI ()
21	{
22	Initialize Component ();
23	}
24	/// #Windows Designer Code to add controls
25	static void Main()
26	{
27	Application.Run(new PresentationGUI());
28	}
29	private void Presentation_Load(object sender, System.EventArgs e)
30	{
31	aClub = new Club ("ACM", "Jones", "Davis 203", "Tuesday");
32	aIntermural = new Intermural ("Winners", "Joe Smith", "Gym 3", "VolleyBall")
33	}



我的讲师说,通过创建PresentationGUI类并将其设置为启动,在向表单添加控件之前,将创建私有的Systems.Windows.Forms.Label label1;.类本身,但这在我创建类时不会发生.在将它作为一个启动项目甚至是接口之后,我什至将我的子类添加为对PresentationGUI类的引用,在上面的代码中我省略了它(我使用了本书的确切代码,但没有使用接口).这是否与在顶部添加using系统部分有关,还是我必须自己添加私有Windows.Forms部分以引用控件?还是我需要创建PresentationGUI类库的另一种方式?如何使用Initialize Component()和Main()方法创建类?如果要使它成为表单设计的一部分,我是否需要在表单设计中对其进行引用,或者它是否属于表单设计的一部分?对所有问题都感到抱歉,我知道答案可能很简单,但是在我的书和在线上对此几乎没有什么了解,我无法弄清楚实现此目的需要做什么.谢谢您的所有帮助!



My instructor said that by creating the PresentationGUI class and setting it as startup, before adding controls to the form will create the private Systems.Windows.Forms.Label label1; to the class itself, but that doesn''t happen when I create my class. I have even added my subclasses as references to the PresentationGUI class after I made it a startup project, even the interface, I omitted it in my code above (I used my exact code from the book which is not using a interface). Does this have to do with adding the using System part at the top, or do I have to add the private Windows.Forms part myself to reference the controls? Or is there a different way that I need to create the PresentationGUI class library? How can I make a class with a Initialize Component() and Main() method? Do I somehow need to reference this with the Form Design, or is it part of the Form Design, if it is how can I make it part of the Form design? Sorry for all the questions and I know the answer is probably simple, but there is extremely little about this in my book and online, and I can''t figure out what I need to do to implement this. Thank you for all your help!

推荐答案

您好

首先,Initialize Component ();是错误的.真的是InitializeComponent();

您不能运行ClassLibrary.您可以在其他项目中使用它.
打开一个新的WinForm项目,然后将Refrence添加到classLibrary的DLL文件中. 然后您可以使用PresentationGUI

Hello

Firstly, Initialize Component (); is wrong. it''s really InitializeComponent();

You can''t run ClassLibrary. You can use it from another projects.
Open a new WinForm project and Add Refrence to DLL file of classLibrary.
Then you can use PresentationGUI

PresentationGUI presentationGUI = new PresentationGUI();
presentationGUI.Show();


这篇关于包含和测试gui的类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆