Click here to Skip to main content
15,892,674 members
Articles / Programming Languages / C#

Mars Mission (2) : Explore the Solar System

Rate me:
Please Sign up or sign in to vote.
4.97/5 (36 votes)
20 Nov 2010CPOL19 min read 50.6K   2.2K   45  
strategy/action game defending the solar system : interplanetary space
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GraphicText;
using BitmapRegion;

namespace Mars_Mission
{
	public partial class formReport : Form
	{
		public enum enuLayoutStyle { Left, Center, Right };
		classReport[] cReportsPending = new classReport[0];
		Panel_GraphicText pnlGrText;
		static classGraphicText cGrText;

		public static Font fntRegular = new Font("ms sans-serif", 12);
		public static Font fntItalic = new Font(fntRegular.FontFamily, fntRegular.Size, FontStyle.Italic);
		public static Font fntBold = new Font(fntRegular.FontFamily, fntRegular.Size, FontStyle.Bold);

		public static formReport frmReport = new formReport();
		public formReport()
		{
			InitializeComponent();
			FormBorderStyle = FormBorderStyle.None;
			ShowInTaskbar = false;
			Visible = false;
			TopMost = true;
			BitmapRegion.BitmapRegion.CreateControlRegion(this, (Bitmap)Mars_Mission.Properties.Resources.frame);
			pnlGrText = new Panel_GraphicText(this);
			pnlGrText.Size = new System.Drawing.Size(542, 248);
			pnlGrText.Location = new Point(27, 24);
			pnlGrText.BringToFront();

			pnlGrText.BackColor 
				= pnlGrText.pic.BackColor 
				= Color.FromArgb(255, 240, 240, 240);

			lbtnOk.BringToFront();

			cGrText = new classGraphicText(this);
			lbtnOk.Click += new EventHandler(lbtnOk_Click);
			lbtnNext.Click += new EventHandler(lbtnNext_Click);
			VisibleChanged += new EventHandler(formReport_VisibleChanged);
			Hide();
			Controls.Add(pnlGrText);
		}

		void lbtnNext_Click(object sender, EventArgs e)
		{
			publishNextReport();
		}

		void formReport_VisibleChanged(object sender, EventArgs e)
		{
			if (Visible)
			{
				Top = (Screen.PrimaryScreen.WorkingArea.Height - Height) / 2;
				Left = (Screen.PrimaryScreen.WorkingArea.Width - Width) / 2;
			}
		}

		void lbtnOk_Click(object sender, EventArgs e)
		{
			Hide();
			setLabelButtonVisible();
		}

		void setLabelButtonVisible()
		{
			formMarsMission.lbtnReport.Visible = cReportsPending.Length > 0;
		}

		public void quickReport(string strText)
		{
			classReport cNewReport = new classReport();
			cNewReport.appendReport(strText, formReport.fntRegular);
			newReport(ref cNewReport);
		}

		public void newReport(ref classReport cNewReport)
		{
			Array.Resize<classReport>(ref cReportsPending, cReportsPending.Length + 1);
			cReportsPending[cReportsPending.Length - 1] = cNewReport;
			setLabelButtonVisible();
		}

		public void publishNextReport()
		{ // put next report onto screen
			if (cReportsPending.Length > 0)
			{
				classReport cThisReport = cReportsPending[0];
				for (int intReportCounter = 0; intReportCounter < cReportsPending.Length - 1; intReportCounter++)
				{
					cReportsPending[intReportCounter] = cReportsPending[intReportCounter + 1];
				}
				Array.Resize<classReport>(ref cReportsPending, cReportsPending.Length - 1);
				pnlGrText.udrWordArray = cThisReport.udrWordArray;
				pnlGrText.putWordArrayToScreen();
				pnlGrText.BringToFront();
				Show();
				lbtnNext.Visible = cReportsPending.Length > 0;
				pnlGrText.resize();
			}
			else
			{
				Hide();
				setLabelButtonVisible();
			}
		}
		
		public void clearReports()
		{
			cReportsPending = new classReport[0];
			setLabelButtonVisible();
		}

		public class classReport
		{
			public classWordImage[] udrWordArray;

			static Font fntLast = new Font("Ms sans-serif", 12);
			static Color clrLast = Color.Black;

			public void appendReport(string strNewText) { appendReport(strNewText, fntLast, clrLast, enuWordPositionRelativeToPreviousWord.right, enuScript.normal); }
			public void appendReport(string strNewText, Color clrForeground) { appendReport(strNewText, fntLast, clrForeground, enuWordPositionRelativeToPreviousWord.right, enuScript.normal); }
			public void appendReport(string strNewText, Font fntNew) { appendReport(strNewText, fntNew, clrLast, enuWordPositionRelativeToPreviousWord.right, enuScript.normal); }
			public void appendReport(string strNewText, Font fntNew, Color clrForeground, enuWordPositionRelativeToPreviousWord ePos, enuScript eScript)
			{
				clrLast = clrForeground;
				fntLast = fntNew;
				if (udrWordArray == null)
				{
					udrWordArray = new classWordImage[0];
					cGrText.appendArrayWordImage(ref udrWordArray, strNewText, new classMyFont(fntNew, clrForeground), enuWordPositionRelativeToPreviousWord.NL, eScript);
				}
				else
					cGrText.appendArrayWordImage(ref udrWordArray, strNewText, new classMyFont(fntNew, clrForeground), ePos, eScript);
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO unemployable
Canada Canada
Christ Kennedy grew up in the suburbs of Montreal and is a bilingual Quebecois with a bachelor’s degree in computer engineering from McGill University. He is unemployable and currently living in Moncton, N.B. writing his next novel.

Comments and Discussions