Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads
 
Add your own
alternative version

CooksMate

, 21 Jan 2008
A simple program to help get the timing of a roast dinner
cooksmate-bin-mono.zip
cooksmate-bin-mono
CooksMate
mono
cooksmate.exe
cooksmate.exe.mdb
cooksmate.sh
log4net.dll
uk.org.aspellclark.common.dll
uk.org.aspellclark.common.gui.dll
cooksmate-bin-net.zip
cooksmate-bin-net
CooksMate
bin
Debug
cooksmate.exe
cooksmate.log
log4net.dll
uk.org.aspellclark.common.dll
uk.org.aspellclark.common.gui.dll
cooksmate-src.zip
cooksmate-src
Common
common.build
Properties
src
main
csharp
NotImplementedDlg.resources
CommonFile
common.file.build
CommonGui
common.gui.build
CooksMate
cooksmate.build
cooksmate.sh
cooksmate_norm.png
DlgAction.resources
DlgEditRecipe.resources
MainForm.resources
libs
mono
log4net.dll
Mono.GetOptions.dll
sqlite-3.5.4.so
net
log4net.dll
Mono.GetOptions.dll
sqlite3.def
sqlite3.dll
/*
 * Created by SharpDevelop.
 * User: andy
 * Date: 26/12/2007
 * Time: 09:04
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Xml;

namespace uk.org.aspellclark.cooksmate.engine
{
	/// <summary>
	/// This enumeration contains the methods of cooking.
	/// this is used to display a picture depicting 
	/// how to do the next action
	/// </summary>
	public enum ActionStepType
	{
		Oven,
		Hob,
		Steamer
	};
	
	/// <summary>
	/// Description of ActionStep.
	/// </summary>
	public class ActionStep
	{		
		private int seqNbr;
		private string name;
		private int minsDuration;
		private int weightGrams;
		private int minsPerKilo;
		private int minsStanding;
		private bool done = false;
		private ActionStepType type;
		

		public bool Done
		{
			get { return done; }
			set { done = value;}
		}
		public ActionStepType Type
		{
			get {return type;}
			set {type=value;}
		}
		public string TypeString
		{
			set {
				switch (value.ToLower())
				{
					case "hob":
					{
						type=ActionStepType.Hob;
						break;
					}
					case "steamer":
					{
						type=ActionStepType.Steamer;
						break;
					}
					case "oven":
					{
						type=ActionStepType.Oven;
						break;
					}
				}
			}
		}
		public int SequenceNbr
		{
			get {return seqNbr;}
			set {seqNbr=value;}
		}
		public string Name
		{
			get {return name;}
			set {name=value;}
		}
		public int MinsDuration
		{
			get {
					if ( minsDuration > 0)
					{
						return minsDuration;
					}
					else
					{
						int mins  = (int)(MinsPerKilo * WeightKg);
						mins += MinsStanding;
						return mins;
					}
				}
			set {minsDuration=value;}
		}
		public double WeightKg
		{
			get {return (double)weightGrams/1000;}
		}
		public int WeightGrams
		{
			get {return weightGrams;}
			set {weightGrams=value;}
		}
		public int MinsPerKilo
		{
			get {return minsPerKilo;}
			set {minsPerKilo=value;}
		}
		public int MinsStanding
		{
			get {return minsStanding;}
			set {minsStanding=value;}
		}
		
		public DateTime StartTime(DateTime serveTime)
		{
			DateTime start = serveTime;
			int days=0;
			int hrs=0;
			int mins=this.MinsDuration;
			int secs=0;
			if (mins==0)
			{
				mins  = (int)(MinsPerKilo * WeightKg);
				mins += MinsStanding;
			}
			start = start - new TimeSpan(days, hrs, mins, secs);
			return start;
		}

		
		public ActionStep()
		{}

		#region XMLCode

		/// <summary>
		/// This constructor reads in it's contained
		/// information from an xml file
		/// </summary>
		/// <param name="reader"></param>
		public ActionStep(XmlReader reader)
		{
			while (reader.Read())
			{
				switch (reader.NodeType)
				{
					case XmlNodeType.EndElement:
						if (reader.Name.Equals(Constants.XML_TAG_ACTION))
						{
							return;
						}
						break;
					case XmlNodeType.Element:
						if (reader.Name.Equals(Constants.XML_TAG_NAME))
						{
							reader.Read();
							this.Name = reader.Value;
						}
						else if (reader.Name.Equals(Constants.XML_TAG_MINSDURATION))
						{
							reader.Read();
							this.MinsDuration = Convert.ToInt16(reader.Value);
						}
						else if (reader.Name.Equals(Constants.XML_TAG_TYPE))
						{
							reader.Read();
							this.TypeString = reader.Value;
						}
						else if (reader.Name.Equals(Constants.XML_TAG_MINSPERKILO))
						{
							reader.Read();
							this.MinsPerKilo = Convert.ToInt16(reader.Value);
						}
						else if (reader.Name.Equals(Constants.XML_TAG_MINSSTANDING))
						{
							reader.Read();
							this.MinsStanding = Convert.ToInt16(reader.Value);
						}
						else if (reader.Name.Equals(Constants.XML_TAG_WEIGHTGRAMS))
						{
							reader.Read();
							this.WeightGrams = Convert.ToInt16(reader.Value);
						}
						break;
				}//switch
			}//while
		}
		

		/// <summary>
		/// this method write the current step out to an xml file
		/// </summary>
		/// <param name="xmlWriter"></param>
		public void WriteToXml(XmlWriter xmlWriter)
		{
            xmlWriter.WriteStartElement(Constants.XML_TAG_ACTION);

            xmlWriter.WriteElementString(Constants.XML_TAG_NAME, this.Name);
            xmlWriter.WriteElementString(Constants.XML_TAG_SEQ_NBR, this.SequenceNbr.ToString());
            xmlWriter.WriteElementString(Constants.XML_TAG_TYPE, this.Type.ToString());
            xmlWriter.WriteElementString(Constants.XML_TAG_MINSDURATION, this.MinsDuration.ToString());
            xmlWriter.WriteElementString(Constants.XML_TAG_MINSPERKILO, this.MinsPerKilo.ToString());
            xmlWriter.WriteElementString(Constants.XML_TAG_MINSSTANDING, this.MinsStanding.ToString());
            xmlWriter.WriteElementString(Constants.XML_TAG_WEIGHTGRAMS, this.WeightGrams.ToString());

            xmlWriter.WriteEndElement();
		}		
		
		#endregion
		
		public string ToString()
		{
            return String.Format("{0}, ({1:d})", 
        	                     this.name,
        	                     this.MinsDuration);
        }
		public string ToString(DateTime srveTime)
		{
            return String.Format("{0}, {1:d}", 
        	                     this.name,
        	                     this.StartTime(srveTime));
        }

	}//class
}//namespace

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 GNU General Public License (GPLv3)

About the Author

Andy Aspell-Clark
Software Developer (Senior) Airbus Defense and Space
United Kingdom United Kingdom
No Biography provided
Follow on   Twitter   LinkedIn

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 21 Jan 2008
Article Copyright 2007 by Andy Aspell-Clark
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid