2013-04-02 7 views
0

좋아요. 그래서 무작위로 게임을 선택하고 해당 클래스를 기반으로 정보를 표시하는 프로그램을 만들고 있습니다. 지금 당장 가지고 있어요클래스에 포함 된 개인 이미지

다음으로 게임의 박스 아트가 될 이미지를 포함하고 싶습니다. 어떻게해야합니까?

+0

프로젝트 유형은 무엇입니까? wpf, winForm ... –

+0

gameName에 해당하는 클래스에 이미지를 포함하려면 어떻게해야합니까? 편집 해 주셔서 감사합니다. winForm은 프로젝트 유형입니다. – user1580598

+1

그냥 생각하지만'releaseDate'는'DateTime'이 아니고'genre'는'enum'과'numPlayers'''int'이어야합니까? –

답변

2
namespace Twitch_Roulette 
{ 
    class GameClass 
    { 
     private string gameName; 
     private string developer; 
     private string publisher; 
     private string releaseDate; 
     private string platform; 
     private string genre; 
     private string numPlayers; 
     private string description; 
     private Image boxArt; 
    } 
} 

이미지 클래스를 사용하면 아마의 상단에 using 문에 포함해야하는 System.Drawing에있는 파일.

using System.Drawing; 
+0

좋아요. 내가 GameClass()에 공개 할 때 boxArt = ?? – user1580598

+0

이미지는 [Bitmap] (http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx)과 같은 파생 클래스가 있어야 새 개체를 인스턴스화하는 추상 클래스입니다. boxArt = 새 비트 맵 ("drive : //folder//file.jpg"); 트릭을해야합니다. – nvoigt

0

(System.Drawing.dll은 당신의 참고 문헌에 포함되어 있어야합니다)이만큼 쉽게 :

class GameClass 
{ 
    //your fields 

    private System.Drawing.Bitmap image; 
} 
+0

호세인 감사합니다, 그냥하고 싶었어요. 내 과정에서 드로잉에 대해 아무 것도 배울 수 없었습니다./ – user1580598

1

당신은이 같은 클래스에 액세스 할 수 있습니다

public partial class Form1 : Form 
{ 
    public Form1() 
    { 
     InitializeComponent(); 
     GameClass gameclass = new GameClass(); 
     gameclass.GameName = "Name of Game"; 
     gameclass.GameGenre = GameClass.Genre.RPG; 
     //Add the rest of the fields here. 
    } 
} 

GameClass 클래스는 다음과 같습니다

class GameClass 
{ 
    public enum Genre 
    { 
     RPG, 
     MMO, 
     RTS, 
     Other 
    } 

    public enum Platform 
    { 
     Windows, 
     Linux, 
     MAC 
    } 

    private string gameName; 
    private string developer; 
    private string publisher; 
    private DateTime releaseDate; 
    private Platform platform; 
    private Genre genre; 
    private int numPlayers; 
    private string description; 
    private Bitmap picture; 

    public string GameName 
    { 
     get 
     { 
      return gameName; 
     } 
     set 
     { 
      gameName = value; 
     } 
    } 

    public Genre GameGenre 
    { 
     get 
     { 
      return genre; 
     } 
     set 
     { 
      genre = value; 
     } 
    } 

    //... Other get set methods 
} 
관련 문제