Beispiel #1
0
		public static string PositionToString(Position position) {
			switch (position.anchor) {
				case AnchoringEnum.Fixed: return "fixed";
				case AnchoringEnum.NotPositioned: return "np";
				case AnchoringEnum.TopLeft: return "lt(" + Utils.ToStringInvariantInt(position.left) + "," + Utils.ToStringInvariantInt(position.top) + ")";
				default: throw new Exception("Invalid anchor");
			}
		}
Beispiel #2
0
		public static void ApplyPosition(Element el, Position pos) {
			switch (pos.anchor) {
				case AnchoringEnum.NotPositioned:
					el.Style.Position = "";
					el.Style.Left     = "";
					el.Style.Top      = "";
					break;
				case AnchoringEnum.Fixed:
					el.Style.Position = "relative";
					el.Style.Left     = "0px";
					el.Style.Top      = "0px";
					break;
				case AnchoringEnum.TopLeft:
					el.Style.Position = "absolute";
					el.Style.Left     = Utils.ToStringInvariantInt(pos.left) + "px";
					el.Style.Top      = Utils.ToStringInvariantInt(pos.top) + "px";
					break;
			}
		}
Beispiel #3
0
		public static string CreateStyle(Position pos, int width, int height) {
			StringBuilder sb = new StringBuilder();
			switch (pos.anchor) {
				case AnchoringEnum.NotPositioned:
					break;
				case AnchoringEnum.Fixed:
					sb.Append("position: relative; left: 0px; top: 0px; ");
					break;
				case AnchoringEnum.TopLeft:
					sb.Append("position: absolute; left: " + Utils.ToStringInvariantInt(pos.left) + "px; top: " + Utils.ToStringInvariantInt(pos.top) + "px;");
					break;
				default:
					throw new Exception("Invalid position anchor " + pos.anchor);
			}
			if (width >= 0)
				sb.Append("width:" + Utils.ToStringInvariantInt(width) + "px;");
			if (height >= 0)
				sb.Append("height:" + Utils.ToStringInvariantInt(height) + "px;");
			return sb.ToString();
		}
		private void AssertPositionsEqual(Position[] expected, Position[] actual) {
			Assert.AreEqual(expected.Length, actual.Length);
			for (int i = 0; i < expected.Length; i++)
				AssertPositionsEqual(expected[i], actual[i]);
		}
		private void AssertPositionsEqual(Position expected, Position actual) {
			Assert.IsTrue(expected.anchor == actual.anchor && expected.left == actual.left && expected.top == actual.top);
		}
Beispiel #6
0
		public static string IdAndStyle(string id, Position p, int width, int height, string additionalStyles = null) {
			string s = PositionHelper.CreateStyle(p, width, height);
			if (!string.IsNullOrEmpty(additionalStyles))
				s = (!string.IsNullOrEmpty(s) ? s + "; " : "") + additionalStyles;
			return "id=\"" + id + "\"" + (!string.IsNullOrEmpty(s) ? " style=\"" + s + "\"" : "");
		}
		protected virtual void InitDefault() {
			position = PositionHelper.NotPositioned;
			controlIds = new List<string>();
			controls = new List<IControl>();
			controlData = new List<object>();
		}
Beispiel #8
0
		protected virtual void InitDefault() {
			position = PositionHelper.NotPositioned;
		}