Click here to Skip to main content
15,884,388 members
Articles / Mobile Apps / Windows Mobile

Resort Companion

Rate me:
Please Sign up or sign in to vote.
3.95/5 (20 votes)
2 Jun 2004CPOL7 min read 55.1K   178   18  
Presenting the Resort Companion, a data-navigation application for vacation resorts
// Resort Companion Mobile Edition
// Copyright (c) 2004 Wolf Logan

using System;
using System.Drawing;
using System.Windows.Forms;
using org.CircleCross.ResortCompanion.Data;

namespace org.CircleCross.ResortCompanion.Mobile {
	/// <summary>
	/// detail view for attraction records
	/// </summary>
	public class AttractionDetail: DetailView {
		private const string HEIGHT_RESTRICTION_LABEL = "Height Restricted :";
		private const string WARNING_TEXT = "Warning! Pregnant women and those who suffer from heart conditions, motion sickness, weak backs, and other limitations should not ride.";
		private const string FASTPASS_LABEL = "FastPass Available";

		private static string[] scaleDetailLabels;
		private static string[] ratingDetailLabels;

		public override Type TargetType {
			get {
				return typeof(AttractionPlaceRecord);
			}
		}
		public override string TargetLabel {
			get {
				return "Attractions";
			}
		}

		private AttractionPlaceRecord attractionPlace {
			get {
				return (AttractionPlaceRecord)place;
			}
		}

		private Label heightLabel;
		private Label accessLabel;
		private Label ratingDetail;
		private Label scaleDetail;
		private Label warningLabel;
		private Label fastpassLabel;
		private Label typeLabel;
		private Label scaleLabel;
		private Label ratingLabel;
		private PictureBox warningIcon;
		private ProgressBar scaleBar;
		private ProgressBar ratingBar;

		static AttractionDetail() {
			AttractionDetail.scaleDetailLabels = new string[] {"(Diversion)", "(Minor Attraction)", "(Major Attraction)", "(Headliner)", "(Super Headliner)"};
			AttractionDetail.ratingDetailLabels = new string [] {"(Poor)", "(Fair)", "(Good)", "(Excellent)", "(Must-see)"};
		}

		public AttractionDetail(): base() {
			this.heightLabel = new Label();
			this.accessLabel = new Label();
			this.ratingDetail = new Label();
			this.scaleDetail = new Label();
			this.warningLabel = new Label();
			this.fastpassLabel = new Label();
			this.typeLabel = new Label();
			this.scaleLabel = new Label();
			this.ratingLabel = new Label();
			this.warningIcon = new PictureBox();
			this.scaleBar = new ProgressBar();
			this.ratingBar = new ProgressBar();

			this.heightLabel.Parent = this;
			this.accessLabel.Parent = this;
			this.ratingDetail.Parent = this;
			this.scaleDetail.Parent = this;
			this.warningLabel.Parent = this;
			this.fastpassLabel.Parent = this;
			this.typeLabel.Parent = this;
			this.scaleLabel.Parent = this;
			this.ratingLabel.Parent = this;
			this.warningIcon.Parent = this;
			this.scaleBar.Parent = this;
			this.ratingBar.Parent = this;

			Font smallFont = new Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular);

			this.heightLabel.Font = smallFont;
			this.heightLabel.Bounds = new System.Drawing.Rectangle(4, 82, 224, 12);

			this.accessLabel.Font = smallFont;
			this.accessLabel.Bounds= new System.Drawing.Rectangle(4, 66, 224, 12);

			this.ratingDetail.Font = smallFont;
			this.ratingDetail.Bounds= new System.Drawing.Rectangle(104, 34, 124, 12);

			this.scaleDetail.Font = smallFont;
			this.scaleDetail.Bounds= new System.Drawing.Rectangle(104, 18, 124, 12);

			this.fastpassLabel.Font = smallFont;
			this.fastpassLabel.Bounds= new System.Drawing.Rectangle(4, 50, 224, 12);
			this.fastpassLabel.Text = FASTPASS_LABEL;

			this.warningIcon.Bounds= new System.Drawing.Rectangle(8, 98, 16, 16);
			// fetch the assembly containing the DetailView type...
			System.Reflection.Assembly thisAssembly = Type.GetType("org.CircleCross.ResortCompanion.Mobile.DetailView").Assembly;
			// ...fetch the warningIcon.bmp data from that assembly...
			System.IO.Stream bmpStream = thisAssembly.GetManifestResourceStream("org.CircleCross.ResortCompanion.Mobile.Icons.warningIcon.bmp");
			// ...and add it to the controls
			this.warningIcon.Image = new Bitmap(bmpStream);

			this.warningLabel.Font = smallFont;
			this.warningLabel.Bounds= new System.Drawing.Rectangle(28, 98, 200, 48);
			this.warningLabel.Text = WARNING_TEXT;

			this.typeLabel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);
			this.typeLabel.Bounds= new System.Drawing.Rectangle(4, 2, 224, 12);

			this.scaleBar.Maximum = 5;
			this.scaleBar.Minimum = 1;
			this.scaleBar.Bounds= new System.Drawing.Rectangle(48, 18, 53, 12);

			this.scaleLabel.Font = smallFont;
			this.scaleLabel.Bounds= new System.Drawing.Rectangle(4, 18, 44, 12);
			this.scaleLabel.Text = "Scale:";

			this.ratingBar.Maximum = 5;
			this.ratingBar.Minimum = 1;
			this.ratingBar.Bounds= new System.Drawing.Rectangle(48, 34, 53, 12);

			this.ratingLabel.Font = smallFont;
			this.ratingLabel.Bounds= new System.Drawing.Rectangle(4, 34, 44, 12);
			this.ratingLabel.Text = "Rating:";
		}

		protected override void bindData() {
			this.typeLabel.Text = this.attractionPlace.Type;

			// build height restriction label, if needed
			if(this.attractionPlace.HeightRestricted != String.Empty) {
				this.heightLabel.Text = HEIGHT_RESTRICTION_LABEL + this.attractionPlace.HeightRestricted;
			} else {
				this.heightLabel.Text = String.Empty;
			}

			this.accessLabel.Text = this.attractionPlace.Access;
			
			if(this.attractionPlace.FastPass) {
				this.fastpassLabel.Visible = true;
			} else {
				this.fastpassLabel.Visible = false;
			}
			
			if(this.attractionPlace.Warning) {
				this.warningIcon.Visible = true;
				this.warningLabel.Visible = true;
			} else {
				this.warningIcon.Visible = false;
				this.warningLabel.Visible = false;
			}
			
			this.scaleBar.Value = this.attractionPlace.Scale;
			this.ratingBar.Value = this.attractionPlace.Rating;
			this.ratingDetail.Text = AttractionDetail.ratingDetailLabels[this.attractionPlace.Rating-1];
			this.scaleDetail.Text = AttractionDetail.scaleDetailLabels[this.attractionPlace.Scale-1];
		}
	}
}

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
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions