Code Search for Developers
 
 
  

StoryObj.cs from MASE: Agile Software Engineering at Krugle


Show StoryObj.cs syntax highlighted

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Resources;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

using Microsoft.Ink;

using Tao.Platform.Windows;
using Tao.OpenGl;

using New_Study_Project;
using EStory;
using Whiteboard.MaseWS;

namespace Whiteboard
{
	/// <summary>
	/// Summary description for TabletRNTObj
	/// 
	/// This class is the class that is currently setup to extract information
	/// from the RNT dll.
	/// 
	/// It should be refactored to actually extend the RNTObject.dll rather than
	/// just provide an interface to it.
	///
	/// </summary>
	/// 


	public class StoryObj : Business_Interfaces.Displayable_Interface, Business_Interfaces.MaseBusinessObj_Interface
	{
		private TabletVO tabVO;
		private Bitmap storyImage;
		private Color storyBGColor;
		private Color storyFGColor;
		private int imgWidth;
		private int imgHeight;
		private Font nameFont;
		private Font descFont;
		private ResourceManager resources;
		private ImageList iconImgList; 
		private TabletContentandUtil originalTabletContent;

		public TabletContentandUtil getOriginalTabletContent()
		{
			return this.originalTabletContent;
		}

		public void setOriginalTabletContent(TabletContentandUtil originalTabletContent)
		{
			this.originalTabletContent = originalTabletContent;
		}

		public TabletVO getTabletVO()
		{
			return tabVO;
		}

		public void setTabletVO(TabletVO tabVO)
		{
			this.tabVO = tabVO;
		}
	
		public Bitmap getImage(int imgWidth, int imgHeight, bool foreignUpdate)
		{
			if(this.imgWidth != imgWidth) this.imgWidth = imgWidth;
			if(this.imgHeight != imgHeight) this.imgHeight = imgHeight;
			return createStoryImage(foreignUpdate);
		}

		public Bitmap getImage(int imgWidth, int imgHeight)
		{
			if(this.imgWidth != imgWidth) this.imgWidth = imgWidth;
			if(this.imgHeight != imgHeight) this.imgHeight = imgHeight;
			return createStoryImage(false);
		}

		public Bitmap reRenderStoryImage()
		{
			return createStoryImage(false);
		}
		public int getOpenGLImageID(int imgWidth, int imgHeight)
		{
			int[] texture = new int[1];
			Bitmap image = new Bitmap(imgWidth, imgHeight);
			Rectangle rect = new Rectangle(0, 0, imgWidth, imgHeight);
			System.Drawing.Imaging.BitmapData bitmapdata = image.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
			bitmapdata.PixelFormat= System.Drawing.Imaging.PixelFormat.Format16bppArgb1555;
			Gl.glGenTextures(1, texture);
			Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture[0]);
			Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, imgWidth, imgHeight,0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapdata.Scan0);
			Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MAG_FILTER,Gl.GL_LINEAR);
			Gl.glTexParameteri(Gl.GL_TEXTURE_2D,Gl.GL_TEXTURE_MIN_FILTER,Gl.GL_LINEAR);
			image.UnlockBits(bitmapdata);
			image.Dispose();
			return texture[0];
		}

		private Bitmap drawWaterMarkIcon(Bitmap imageToWaterMarked, int index)
		{
			Graphics grWatermark =Graphics.FromImage(imageToWaterMarked);
			ImageAttributes imageAttributes =
				new ImageAttributes();

			float[][] colorMatrixElements = { 
				new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},
				new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},
				new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},
				new float[] {0.0f,  0.0f,  0.0f,  0.3f, 0.0f},
				new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}
			};

			ColorMatrix wmColorMatrix = new
				ColorMatrix(colorMatrixElements);

			imageAttributes.SetColorMatrix(wmColorMatrix, 
				ColorMatrixFlag.Default, 
				ColorAdjustType.Bitmap);

			Image imgWatermark = (Image)iconAryList[index];
			
			int phWidth = imageToWaterMarked.Width;
			int phHeight = imageToWaterMarked.Height;
			int wmWidth = imgWatermark.Width*5;
			int wmHeight = imgWatermark.Height*5;

			int xPosOfWm = ((phWidth - wmWidth)-10);
			int yPosOfWm = 10;

			grWatermark.DrawImage(imgWatermark, 
				new Rectangle(xPosOfWm,yPosOfWm,wmWidth,
				wmHeight),
				0,                  
				0,                   
				imgWatermark.Width,            
				imgWatermark.Width,		    
				GraphicsUnit.Pixel, 
				imageAttributes);

			grWatermark.Dispose();
			return imageToWaterMarked;
		}

		private Bitmap createStoryImage(bool foreignUpdate)
		{
			storyImage = new Bitmap(imgWidth, imgHeight);
			
			Graphics gf = Graphics.FromImage(storyImage);
			
			// Set the size of the sting for drawing the ellipsises (for title)
			StringFormat titleFormat = new StringFormat();
			titleFormat.Trimming = StringTrimming.EllipsisCharacter;
			RectangleF titleRec = new RectangleF(2,2,imgWidth,15);

			// Set the size of the sting for drawing the ellipsises (for description)
			StringFormat descFormat = new StringFormat();
			descFormat.Trimming = StringTrimming.EllipsisCharacter;
			RectangleF descRec = new RectangleF(4,25,imgWidth,imgHeight-50);
			
			if(!foreignUpdate)
			{
				if(tabVO.tabletProcess.activityType == EStoryForm.FEATURE)
					gf.Clear(ApplicationProperties.FeatureColor);
				else if(tabVO.tabletProcess.activityType == EStoryForm.ENHANCEMENT)
					gf.Clear(ApplicationProperties.RefactorColor);
				else
					gf.Clear(ApplicationProperties.BugFixColor);
			}else
				gf.Clear(Color.Brown);
			
			Pen pen = new Pen(storyFGColor, 1);
			
			if(tabVO.tabletProcess.handWritten == null)
			{
				gf.DrawString(tabVO.tabletProcess.name, nameFont, new SolidBrush(storyFGColor), titleRec,titleFormat);
				gf.DrawString(tabVO.tabletProcess.description, descFont, new SolidBrush(storyFGColor), descRec, descFormat);
				gf.DrawString("Estimated Effort: " + tabVO.tabletProcess.initialEffort.ToString(), descFont, new SolidBrush(storyFGColor), new PointF( 5, imgHeight-15));
				
			}
			else
			{
				HandWrittenObj handWrittenObj = new HandWrittenObj();
				Utility.loadHandWrittenObj(tabVO.tabletProcess.handWritten.ToString(), ref handWrittenObj);
				int fakeWidth = 5;
				int fakeHeight = 5;
				Image nameImg = (Image)new Bitmap(fakeWidth, fakeHeight);
				Image descriptionImg = (Image)new Bitmap(fakeWidth, fakeHeight);
				Image effortImg = (Image)new Bitmap(fakeWidth, fakeHeight);
				Image compositeImg = (Image)new Bitmap(fakeWidth, fakeHeight);

				Utility.loadInkImg(ref nameImg, handWrittenObj.storyNameBase64String);
				Utility.loadInkImg(ref descriptionImg, handWrittenObj.descriptionBase64String);
				Utility.loadInkImg(ref effortImg, handWrittenObj.mostLikelyCaseBase64String);
				Utility.constructCompositeImg(nameImg, descriptionImg, effortImg, ref compositeImg);
				
				Rectangle sourceRec = new Rectangle(0, 0, compositeImg.Width, compositeImg.Height);
				Rectangle destRec = new Rectangle(0, 0, imgWidth, imgHeight);
				gf.DrawImage(compositeImg, destRec, sourceRec, GraphicsUnit.Pixel);
			}
			gf.Save();
			storyImage = drawWaterMarkIcon(storyImage, tabVO.tabletProcess.activityType);
			return storyImage;
		}

		private string fixBase64ForImage(string base64String)
		{
			StringBuilder sbText = new StringBuilder(base64String, base64String.Length);
			sbText.Replace("\r\n", String.Empty);
			sbText.Replace(" ", String.Empty);
			return sbText.ToString();
		}
		private static ArrayList iconAryList = null;		
		public static void loadIcons()
		{	
			iconAryList = new ArrayList();

			Assembly workSpaceDLL = Assembly.GetExecutingAssembly();
			Stream file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.MASE_feature.gif");
			Bitmap image = new Bitmap(file);
			iconAryList.Add(image);
			file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.MASE_bug.gif");
			image = new Bitmap(file);
			iconAryList.Add(image);
			file = workSpaceDLL.GetManifestResourceStream("TableWhiteboard_HCI_Intergration.MASE_refactor.gif");
			image = new Bitmap(file);
			iconAryList.Add(image);
		}

		public StoryObj(TabletVO tabletVO,int imgWidth, int imgHeight)
		{
			this.imgWidth = imgWidth;
			this.imgHeight = imgHeight;
			this.storyBGColor = ApplicationProperties.storyBGColor;
			this.storyFGColor = ApplicationProperties.storyFGColor;
			this.descFont = new Font("Arial", 10);
			this.nameFont = new Font("Arial", 10, System.Drawing.FontStyle.Bold); 
			this.tabVO = tabletVO;
			this.originalTabletContent = new TabletContentandUtil(this.tabVO);
			if(iconAryList == null)
				loadIcons();
		}
		public void setStoryName(String s)
		{
			tabVO.tabletProcess.name = s;
			reRenderStoryImage();	
		}
		public String getStoryName()
		{
			return tabVO.tabletProcess.name;
		}
		public void setStoryDescription(String s)
		{
			tabVO.tabletProcess.description = s;
			reRenderStoryImage();	
		}
		public String getStoryDescription()
		{
			return tabVO.tabletProcess.description;
		}
		public void setColor(Color value)
		{
			storyFGColor = value;
		}
		public Color getColor()
		{
			return storyFGColor;
		}
	}
}




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