Code Search for Developers
 
 
  

Utility.cs from MASE: Agile Software Engineering at Krugle


Show Utility.cs syntax highlighted

using System;
using System.Drawing;
using System.Xml;
using System.Windows.Forms;
using System.IO;
using System.Collections;

using Microsoft.Ink;
using Whiteboard.MaseWS;

namespace Whiteboard
{
	/// <summary>
	/// Summary description for Utility.
	/// </summary>
	public class Utility
	{
		private static float workSPWidth = Convert.ToSingle(ApplicationProperties.clientSizeWidth);
		private static float workSPHeight = Convert.ToSingle(ApplicationProperties.clientSizeHeight);
		public Utility()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static void loadInkImg(ref Image gifImg, string base64string)
		{
			if(!base64string.Equals("AA==")) // base64 string representation of empty string seems to of equivalent string value "AA=="
			{
				Control control = new Control();
				InkOverlay inkOverlay = new InkOverlay(control.Handle);
				inkOverlay.Enabled = false;
				Ink ink = inkOverlay.Ink;
				ink.Load(Convert.FromBase64String(base64string));
				inkOverlay.Enabled = true;

				byte[] gifBytes = ink.Save(PersistenceFormat.Gif, CompressionMode.NoCompression);
				MemoryStream memStream = new MemoryStream(gifBytes);
				gifImg = (Image)new Bitmap((Stream) memStream);
				control.Dispose();
			}
		}

		public static void constructCompositeImg(Image nameImg, Image descriptionImg, Image effortImg, ref Image compositeImg)
		{
			ArrayList sortedList = new ArrayList();
			sortedList.Add(nameImg.Width);
			sortedList.Add(descriptionImg.Width);
			sortedList.Add(effortImg.Width+100);
			sortedList.Sort();
			Pen pen = new Pen(ApplicationProperties.storyFGColor, 1);
			int compositeWidth = (int)sortedList[2];
			int separationHeight = 10;
			int compositeHeight = nameImg.Height+separationHeight+descriptionImg.Height+separationHeight+effortImg.Height;

			compositeImg = (Image)new Bitmap(compositeWidth, compositeHeight);
			Graphics gf = Graphics.FromImage(compositeImg);
			float x = 0.0f;
			float y = 0.0f;
			float width = nameImg.Width;
			float height = nameImg.Height;
			gf.DrawImage(nameImg, x, y, width, height);
			y = y + height + separationHeight;
			gf.DrawLine(pen, x, y, compositeWidth, y);
			width = descriptionImg.Width;
			height = descriptionImg.Height;
			gf.DrawImage(descriptionImg, x, y, width, height);
			y = y +  height + separationHeight;
			gf.DrawLine(pen, x, y, compositeWidth, y);
			width = effortImg.Width;
			height = effortImg.Height;
			Font descFont = new Font("Arial", 10);
			gf.DrawString("Estimated Effort: ", descFont, new SolidBrush(ApplicationProperties.storyFGColor), new PointF(5, (float)(compositeHeight-15)));
			gf.DrawImage(effortImg, x+100, y, width, height);

			gf.Save();
		}

		public static bool checkWithinBoundry(PointF TopLeft, PointF TopRight, PointF BottomLeft, PointF BottomRight)
		{
			bool checkResult = checkPtWithBoundry(TopLeft)&&checkPtWithBoundry(TopRight)&&checkPtWithBoundry(BottomLeft)&&checkPtWithBoundry(BottomRight);
			return checkResult;
		}

		public static bool checkPtWithBoundry(PointF checkedPt)
		{
			float checkPtX = checkedPt.X;
			float checkPtY = checkedPt.Y;
			bool checkResult = false;
			
			if(checkPtX > 0.0f && checkPtX < workSPWidth)
				if(checkPtY > 0.0f && checkPtY < workSPHeight)
					checkResult = true;

			return checkResult;
		}

		public static bool checkWithinBoundry(float[] outSideBoundry)
		{
			
			bool checkResult = true;
			int pointCount = outSideBoundry.Length/2;

			for(int i=0; i<pointCount; i = i+2)
			{
				PointF nextPoint = new PointF(outSideBoundry[i], outSideBoundry[i+1]);
				checkResult = checkPtWithBoundry(nextPoint);
				if(checkResult == false)
					return checkResult;
			}
			
			return checkResult;
		}

		public static void removeFromTabletVOAry(ref TabletVO[] tabletAry, TabletVO targetedTabletVO)
		{
			int checkedIndex = -1;
			retireveContainedTabletVO(tabletAry, targetedTabletVO, ref checkedIndex);
			
			if(checkedIndex == -1) 
				return;

			int processCount = tabletAry.Length;
			int index = 0;
			long targetedTabletVOID = targetedTabletVO.tabletProcess.id;
			TabletVO[] returnedAry = new TabletVO[processCount-1];
			
			for(int i=0; i<processCount; i++)
			{
				if(targetedTabletVOID != tabletAry[i].tabletProcess.id)
				{
					returnedAry[index] = tabletAry[i];
					index++;
				}
			}
			tabletAry = returnedAry;
		}

		public static void addToTabletVOAry(ref TabletVO[] tabletAry, TabletVO targetedTabletVO)
		{
			int checkedIndex = -1;
			retireveContainedTabletVO(tabletAry, targetedTabletVO, ref checkedIndex);
			
			if(checkedIndex != -1) 
				return;

			int processCount = tabletAry.Length;
			TabletVO[] returnedAry = new TabletVO[processCount+1];
			for(int i=0; i<processCount; i++)
			{
				returnedAry[i] = tabletAry[i];
			}
			returnedAry[processCount] = targetedTabletVO;
			tabletAry = returnedAry;
		}

		private static void retireveContainedTabletVO(TabletVO[] tabletVoAry, TabletVO checkedVO, ref int checkedIndex)
		{
			int count = tabletVoAry.Length;
			checkedIndex = -1;
			for(int index=0; index < count; index++)
			{
				if(tabletVoAry[index].tabletProcess.id == checkedVO.tabletProcess.id)
				{
					checkedIndex = index;
				}
			}
		}

		public static void loadHandWrittenObj(string loadedString, ref HandWrittenObj handWrittenObj)
		{
			XmlDocument doc = new XmlDocument();
			
			doc.LoadXml(loadedString);
			Boolean storyNameTag = false;
			Boolean descriptionTag = false;
			Boolean bestCaseTag = false;
			Boolean mostLikelyCaseTag = false;
			Boolean worstCaseTag = false;

			string storyNameBase64String = null;
			string descriptionBase64String = null;
			string bestCaseBase64String = null;
			string mostLikeyCaseBase64String = null;
			string worstCaseBase64String = null;

			XmlNodeReader reader = new XmlNodeReader(doc);

			while(reader.Read())
			{
				switch(reader.NodeType)
				{
					case XmlNodeType.Element:
						String eleName = reader.Name;
						if(eleName.Equals("storyName")) storyNameTag = true;
						else if(eleName.Equals("description")) descriptionTag = true;
						else if(eleName.Equals("bestCaseEstimate")) bestCaseTag = true;
						else if(eleName.Equals("mostLikelyCaseEstimate")) mostLikelyCaseTag = true;
						else if(eleName.Equals("worstCaseEstimate")) worstCaseTag = true;
						break;

					case XmlNodeType.Text:
						if(storyNameTag) storyNameBase64String = reader.Value;
						else if(descriptionTag) descriptionBase64String = reader.Value;
						else if(bestCaseTag) bestCaseBase64String = reader.Value;
						else if(mostLikelyCaseTag) mostLikeyCaseBase64String = reader.Value;
						else if(worstCaseTag) worstCaseBase64String = reader.Value;
						break;

					case XmlNodeType.EndElement:
						if(storyNameTag) storyNameTag = false;
						else if(descriptionTag) descriptionTag = false;
						else if(bestCaseTag) bestCaseTag = false;
						else if(mostLikelyCaseTag) mostLikelyCaseTag = false;
						else if(worstCaseTag) worstCaseTag = false;
						break;
				}

			}
			reader.Close();
			handWrittenObj.storyNameBase64String = storyNameBase64String;
			handWrittenObj.bestCaseBase64String = bestCaseBase64String;
			handWrittenObj.mostLikelyCaseBase64String = mostLikeyCaseBase64String;
			handWrittenObj.worstCaseBase64String = worstCaseBase64String;
			handWrittenObj.descriptionBase64String = descriptionBase64String;
		}
	}
}




See more files for this project here

MASE: Agile Software Engineering

The MASE project investigates methods to support the coordination and executable acceptance testing of software projects. Keywords: Agile methods, distributed teams, Extreme Programming. See http://ebe.cpsc.ucalgary.ca/ebe for more information.

Project homepage: http://sourceforge.net/projects/mase
Programming language(s): Java,XML
License: other

  ApplicationProperties.cs
  CardLocationWith4Corners.cs
  HandWrittenObj.cs
  HandwrittenStoryCard.cs
  Iteration.cs
  Iteration.resx
  MaseListen.cs
  MaseUpdate.cs
  ProcessNode.cs
  ProjectNode.cs
  RegisterObj.cs
  Serializer.cs
  SingleWS.cs
  StoryObj.cs
  TabletContentandUtil.cs
  Utility.cs
  VLabel.cs
  VLabel.resx