Esempio n. 1
0
		protected Rectangle[] DrawPattern(Pattern pattern, State state)
		{
			List<Rectangle> rects = new List<Rectangle>();

			int offset = (state.Settings.MediumHeight - state.Settings.ShortHeight);
			int left = state.Left;
			Rectangle rect;
			foreach (Elements item in pattern.Elements)
			{
				switch (item)
				{
					case Elements.WideBlack:
						rect = new Rectangle(left, state.Top, state.Settings.WideWidth, state.Settings.BarHeight);
						left += state.Settings.WideWidth;

						rects.Add(rect);
						break;
					case Elements.WideWhite:
						left += state.Settings.WideWidth;
						break;
					case Elements.NarrowBlack:
						rect = new Rectangle(left, state.Top, state.Settings.NarrowWidth, state.Settings.BarHeight);
						left += state.Settings.NarrowWidth;

						rects.Add(rect);
						break;
					case Elements.NarrowWhite:
						left += state.Settings.NarrowWidth;
						break;
					case Elements.Tracker:
						rect = new Rectangle(left, state.Top + offset, state.Settings.NarrowWidth, state.Settings.ShortHeight);
						left += state.Settings.NarrowWidth;
						rects.Add(rect);
						break;
					case Elements.Ascender:
						rect = new Rectangle(left, state.Top, state.Settings.NarrowWidth, state.Settings.MediumHeight);
						left += state.Settings.NarrowWidth;
						rects.Add(rect);
						break;
					case Elements.Descender:
						rect = new Rectangle(left, state.Top + offset, state.Settings.NarrowWidth, state.Settings.MediumHeight);
						left += state.Settings.NarrowWidth;
						rects.Add(rect);
						break;
				}
			}

			return rects.ToArray();
		}