Image CreatePreviewImage(string s,int pos,char c)
		{
			int height = 80;
			int width = 530;
			int space = 2;
			int size = 35;
			int leftSpan = 15;
			int topSpan = 40;
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<s.Length;i++)
			{
				glyph = new Square(leftSpan + i*(size + space),topSpan,size,Color.HotPink,GlyphAppearance.Flat,s[i].ToString());
				squareArray.Add(glyph);
			}
			SquareLine squareLine = new SquareLine(1,1,1,squareArray);

			Rectangle rec = new Rectangle(0,0,0,0);
			if(pos >= 1 && pos <= s.Length)
			{
				rec = ((IGlyph)squareArray[pos-1]).Bounds;
			}
			else if(pos == s.Length + 1)
			{
				Rectangle lastRectangle = ((IGlyph)squareArray[pos-2]).Bounds;
				rec = new Rectangle(lastRectangle.X + lastRectangle.Width + space,lastRectangle.Y - lastRectangle.Height,lastRectangle.Width,lastRectangle.Height);
			}
			Square insertSquare = new Square(rec.X,topSpan - size - 2,rec.Width,Color.Green,GlyphAppearance.Flat,c.ToString());

			//最后初始化所有的迭代器
			IIterator arrayIterator = squareLine.CreateIterator();
			IIterator nullIterator = insertSquare.CreateIterator();

			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			for(IIterator iterator = arrayIterator.First();!arrayIterator.IsDone();iterator = arrayIterator.Next())
			{
				iterator.CurrentItem.Draw(g);
			}
			nullIterator.CurrentItem.Draw(g);

			return bmp;

		}
示例#2
0
		Image CreatePreviewImage(string r,char key)
		{
			int height = 80;
			int width = 530;
			int space = 2;
			int size = 29;
			int leftSpan = 5;
			int topSpan = 5;

			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			glyph = new Square(leftSpan,topSpan + size + 2,size,Color.HotPink,GlyphAppearance.Flat,"?");
			squareArray.Add(glyph);
			for(int i=0;i<r.Length;i++)
			{
				glyph = new Square(leftSpan + (i + 1)*(size + space),topSpan + size + 2,size,Color.Teal,GlyphAppearance.Flat,r[i].ToString());
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(0,0,1,squareArray);

			//最后初始化所有的迭代器
			IIterator arrayIterator = squareLine.CreateIterator();
			
			IIterator nullIterator = null;
			glyph = ((ArrayIterator)arrayIterator).GetGlyphByIndex((r.Length + 1) / 2);
			if(glyph != null)
			{
				nullIterator = new Square(glyph.Bounds.X,glyph.Bounds.Y - size - 2,size,Color.Red,GlyphAppearance.Flat,key.ToString()).CreateIterator();
			}

			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			for(IIterator iterator = arrayIterator.First();!arrayIterator.IsDone();iterator = arrayIterator.Next())
			{
				iterator.CurrentItem.Draw(g);
			}
			if(nullIterator != null)
			{
				nullIterator.CurrentItem.Draw(g);
			}

			return bmp;

		}
		Image CreatePreviewImage(string s,int pos)
		{
			int height = 80;
			int width = 530;
			int space = 2;
			int size = 35;
			int leftSpan = 15;
			int topSpan = 20;
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			for(int i = 0;i < s.Length;i++)
			{
				if(pos - 1 != i)
				{
					glyph = new Square(leftSpan + i*(size + space),topSpan,size,Color.DarkCyan,GlyphAppearance.Flat,s[i].ToString());
				
				}
				else  //用红色表示要删除的元素
				{
					glyph = new Square(leftSpan + i*(size + space),topSpan,size,Color.Red,GlyphAppearance.Flat,s[i].ToString());				
				}
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(1,1,1,squareArray);

			IIterator arrayIterator = squareLine.CreateIterator();

			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			for(IIterator iterator = arrayIterator.First();!arrayIterator.IsDone();iterator = arrayIterator.Next())
			{
				iterator.CurrentItem.Draw(g);
			}

			return bmp;

		}
		public override void InitGraph() 
		{
			SquareLine squareLine;
			Square insertSquare;
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<status.Length;i++)
			{
				glyph = new Square(40 + i*(squareSize + squareSpace),20 + squareSize + 10,squareSize,status.图形背景色,status.图形外观,status.L[i].ToString());
				squareArray.Add(glyph);
			}
			//最后再添加一个额外的元素,以保存插入元素后的数组的最后一个元素
			squareArray.Add(new Square(1,1,2,Color.Transparent,""));
			squareLine = new SquareLine(20,80,status.Length*(squareSize+20+10),squareArray);

			Rectangle rec = new Rectangle(0,0,0,0);
			if(status.I >= 1 && status.I <= status.Length)
			{
				rec = ((IGlyph)squareArray[status.I-1]).Bounds;
			}
			else if(status.I == status.Length + 1)
			{
				Rectangle lastRectangle = ((IGlyph)squareArray[status.I-2]).Bounds;
				rec = new Rectangle(lastRectangle.X + lastRectangle.Width + squareSpace,lastRectangle.Y - 10 - lastRectangle.Height,lastRectangle.Width,lastRectangle.Height);
			}
			insertSquare = new Square(rec.X,20,rec.Width,status.插入元素背景色,status.图形外观,status.E.ToString());

			//最后初始化所有的迭代器
			arrayIterator = squareLine.CreateIterator();
			nullIterator = insertSquare.CreateIterator();

		}
示例#5
0
		Image CreatePreviewImage(string r)
		{
			int width = 530;
			int startX = 10;
			int maxHeight = 145;
			int heightUnit;
			int histogramWidth = 20;
			int histogramSpace = 15;
			int bottomY = 30;

			heightUnit = (maxHeight - bottomY - 15) / r.Length;
			int height = 0;
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			glyph = new MyRectangle(startX,maxHeight - bottomY - 45,histogramWidth,45,Color.Gold,GlyphAppearance.Popup,"?");
			squareArray.Add(glyph);
			for(int i=0;i<r.Length;i++)
			{
				height = GetHeight(r,i,heightUnit);
				glyph = new MyRectangle(startX + (i + 1)*(histogramWidth + histogramSpace),maxHeight - bottomY - height,histogramWidth,height,Color.HotPink,GlyphAppearance.Popup,r[i].ToString());
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(1,1,1,squareArray);

			//最后初始化所有的迭代器
			IIterator arrayIterator = squareLine.CreateIterator();

			Bitmap bmp = new Bitmap(width,maxHeight);
			Graphics g = Graphics.FromImage(bmp);

			if(arrayIterator != null)
			{
				for(IIterator iterator = arrayIterator.First();!arrayIterator.IsDone();iterator = arrayIterator.Next())
				{
					iterator.CurrentItem.Draw(g);
				}
			}


			return bmp;

		}
示例#6
0
		public override void InitGraph() 
		{
			heightUnit = (maxHeight - bottomY - 15) / (status.High - status.Low + 1);
			int height = 0;
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			glyph = new MyRectangle(startX,maxHeight - bottomY - 100,histogramWidth,100,status.头元素背景色,status.图形外观,"?");
			squareArray.Add(glyph);
			for(int i = 0;i < (status.High - status.Low + 1);i++)
			{
				height = GetHeight(status.R,i,heightUnit);
				glyph = new MyRectangle(startX + (i + 1)*(histogramWidth + histogramSpace),maxHeight - bottomY - height,histogramWidth,height,status.图形背景色,status.图形外观,status.R[i].ToString());
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(1,1,1,squareArray);

			//最后初始化所有的迭代器
			arrayIterator = squareLine.CreateIterator();

		}
示例#7
0
		public override void InitGraph() 
		{
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			glyph = new Square(40,20 + squareSize + 10,squareSize,status.头元素颜色,status.图形外观,"?");
			squareArray.Add(glyph);
			for(int i=0;i<status.N;i++)
			{
				glyph = new Square(40 + (i + 1)*(squareSize + squareSpace),20 + squareSize + 10,squareSize,status.线性表颜色,status.图形外观,status.R[i].ToString());
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(20,80,(status.N + 1)*(squareSize+20+10),squareArray);

			arrayIterator = squareLine.CreateIterator();

			glyph = ((ArrayIterator)arrayIterator).GetGlyphByIndex((status.N + 1) / 2);
			if(glyph != null)
			{
				nullIterator = new Square(glyph.Bounds.X,glyph.Bounds.Y - squareSize - 10,squareSize,status.当前元素颜色,status.图形外观,status.Key.ToString()).CreateIterator();
			}

		}
示例#8
0
		Image CreatePreviewImage(string s,string t,int pos)
		{
			int height = 80;
			int width = 530;
			int space = 2;
			int size = 30;
			int leftSpan = 15;
			int topSpan = 3;

			SquareLine squareLineS;
			SquareLine squareLineT;

			ArrayList squareArrayS = new ArrayList();
			ArrayList squareArrayT = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<s.Length;i++)
			{
				glyph = new Square(leftSpan + i*(size + space),topSpan,size,SystemColors.InactiveBorder,GlyphAppearance.Popup,s[i].ToString());
				squareArrayS.Add(glyph);
			}
			int startX = ((IGlyph)squareArrayS[pos - 1]).Bounds.X;
			for(int i=0;i<t.Length;i++)
			{
				glyph = new Square(startX + i*(size + space),topSpan + size + 2,size,SystemColors.InactiveBorder,GlyphAppearance.Popup,t[i].ToString());
				squareArrayT.Add(glyph);
			}
			squareLineS = new SquareLine(0,0,1,squareArrayS);
			squareLineT = new SquareLine(0,0,1,squareArrayT);
			//最后初始化所有的迭代器
			IIterator arrayIteratorS = squareLineS.CreateIterator();
			IIterator arrayIteratorT = squareLineT.CreateIterator();

			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			for(IIterator iterator = arrayIteratorS.First();!arrayIteratorS.IsDone();iterator = arrayIteratorS.Next())
			{
				iterator.CurrentItem.Draw(g);
			}
			for(IIterator iterator = arrayIteratorT.First();!arrayIteratorT.IsDone();iterator = arrayIteratorT.Next())
			{
				iterator.CurrentItem.Draw(g);
			}

			return bmp;

		}
示例#9
0
		public override void InitGraph() 
		{
			SquareLine squareLineS;
			SquareLine squareLineT;

			ArrayList squareArrayS = new ArrayList();
			ArrayList squareArrayT = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<status.SLength;i++)
			{
				glyph = new Square(40 + i*(squareSize + squareSpace),40 + 5,squareSize,status.串S元素颜色,status.图形外观,status.S[i].ToString());
				squareArrayS.Add(glyph);
			}
			int startX = ((IGlyph)squareArrayS[status.Pos - 1]).Bounds.X;
			for(int i=0;i<status.TLength;i++)
			{
				glyph = new Square(startX + i*(squareSize + squareSpace),40 + squareSize + 2 * 5,squareSize,status.串T元素颜色,status.图形外观,status.T[i].ToString());
				squareArrayT.Add(glyph);
			}
			squareLineS = new SquareLine(20,30,status.SLength*(squareSize+20+10),squareArrayS);
			squareLineT = new SquareLine(20,110,status.TLength*(squareSize+20+10),squareArrayT);
			//最后初始化所有的迭代器
			arrayIteratorS = squareLineS.CreateIterator();
			arrayIteratorT = squareLineT.CreateIterator();
		}
示例#10
0
		Image CreatePreviewImage(string s1,string s2)
		{
			int height = 80;
			int width = 530;
			int space = 2;
			int size = 30;
			int leftSpan = 15;
			int topSpan = 5;
			SquareLine squareLineLa;
			SquareLine squareLineLb;

			ArrayList squareArrayLa = new ArrayList();
			ArrayList squareArrayLb = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<s1.Length;i++)
			{
				glyph = new Square(leftSpan + i*(size + space),topSpan,size,Color.DarkCyan,GlyphAppearance.Flat,s1[i].ToString());
				squareArrayLa.Add(glyph);
			}
			for(int i=0;i<s2.Length;i++)
			{
				glyph = new Square(leftSpan + i*(size + space),topSpan + size + 2,size,Color.DarkCyan,GlyphAppearance.Flat,s2[i].ToString());
				squareArrayLb.Add(glyph);
			}

			squareLineLa = new SquareLine(1,1,1,squareArrayLa);
			squareLineLb = new SquareLine(1,1,1,squareArrayLb);

			IIterator arrayIteratorLa = squareLineLa.CreateIterator();
			IIterator arrayIteratorLb = squareLineLb.CreateIterator();

			Bitmap bmp = new Bitmap(width,height);
			Graphics g = Graphics.FromImage(bmp);

			if(arrayIteratorLa != null)
			{
				for(IIterator iterator = arrayIteratorLa.First();!arrayIteratorLa.IsDone();iterator = arrayIteratorLa.Next())
				{
					iterator.CurrentItem.Draw(g);
				}
			}

			if(arrayIteratorLb != null)
			{
				for(IIterator iterator = arrayIteratorLb.First();!arrayIteratorLb.IsDone();iterator = arrayIteratorLb.Next())
				{
					iterator.CurrentItem.Draw(g);
				}
			}

			return bmp;

		}
示例#11
0
		public override void InitGraph() 
		{
			SquareLine squareLineLa;
			SquareLine squareLineLb;
			SquareLine squareLineLc;

			ArrayList squareArrayLa = new ArrayList();
			ArrayList squareArrayLb = new ArrayList();
			ArrayList squareArrayLc = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<status.LaLength;i++)
			{
				glyph = new Square(40 + i*(squareSize + squareSpace),10 + 5,squareSize,status.图形背景色,status.图形外观,status.La[i].ToString());
				squareArrayLa.Add(glyph);
			}
			for(int i=0;i<status.LbLength;i++)
			{
				glyph = new Square(40 + i*(squareSize + squareSpace),10 + squareSize + 2 * 5,squareSize,status.图形背景色,status.图形外观,status.Lb[i].ToString());
				squareArrayLb.Add(glyph);
			}

			squareLineLa = new SquareLine(20,30,status.LaLength*(squareSize+20+10),squareArrayLa);
			squareLineLb = new SquareLine(20,110,status.LbLength*(squareSize+20+10),squareArrayLb);
			squareLineLc = new SquareLine(20,190,status.LaLength*(squareSize+20+10) + status.LbLength*(squareSize+20+10),squareArrayLc);
			//最后初始化所有的迭代器
			arrayIteratorLa = squareLineLa.CreateIterator();
			arrayIteratorLb = squareLineLb.CreateIterator();
			arrayIteratorLc = squareLineLc.CreateIterator();

		}
示例#12
0
		public override void InitGraph() 
		{
			ArrayList squareArray = new ArrayList();
			IGlyph glyph;
			for(int i=0;i<status.Length;i++)
			{
				if(status.I-1 != i)
				{
					glyph = new Square(40 + i*(squareSize + squareSpace),40,squareSize,status.图形背景色,status.图形外观,status.L[i].ToString());
				
				}
				else  //用红色表示要删除的元素
				{
					glyph = new Square(40 + i*(squareSize + squareSpace),40,squareSize,status.删除元素背景色,status.图形外观,status.L[i].ToString());
				}
				squareArray.Add(glyph);
			}
			squareLine = new SquareLine(20,80,status.Length*(squareSize+20+10),squareArray);

			arrayIterator = squareLine.CreateIterator();

		}