Пример #1
0
		public Document(int width, int height)
		{
			Width = width;
			Height = height;

			map = new Map(width, height);
			topCollection = new TopDigitGroupCollection(width);
			leftCollection = new LeftDigitGroupCollection(height);
		}
Пример #2
0
		public void RebuildDigitGroupCollectionsFromMap() {
			leftCollection = new LeftDigitGroupCollection(Height);
			DigitGroup digitGroup = null;
			int currentBarLength = 0;
			for (int i = 0; i < Height; i++) {
				Cell[] row = map.GetRow(i);
				digitGroup = new DigitGroup();
				for(int j = 0; j < Width; j++) {
					switch(row[j].State) {
						case CellStateEnum.Filled:
							currentBarLength++;
							break;
						case CellStateEnum.Normal:
						case CellStateEnum.Space:
							if(currentBarLength > 0) {
								digitGroup.Add(currentBarLength);
							}
							currentBarLength = 0;
							break;
					}
					if(j == Width - 1 && currentBarLength > 0) {
						digitGroup.Add(currentBarLength);
						currentBarLength = 0;
					}
				}
				leftCollection.Add(digitGroup);
			}
			
			topCollection = new TopDigitGroupCollection(Width);
			currentBarLength = 0;
			for (int i = 0; i < Width; i++) {
				Cell[] column = map.GetColumn(i);
				digitGroup = new DigitGroup();
				for(int j = 0; j < Height; j++) {
					switch(column[j].State) {
						case CellStateEnum.Filled:
							currentBarLength++;
							break;
						case CellStateEnum.Normal:
						case CellStateEnum.Space:
							if(currentBarLength > 0) {
								digitGroup.Add(currentBarLength);
							}
							currentBarLength = 0;
							break;
					}
					if(j == Height - 1 && currentBarLength > 0) {
						digitGroup.Add(currentBarLength);
						currentBarLength = 0;
					}
				}
				topCollection.Add(digitGroup);
			}
		}