Esempio n. 1
0
		public virtual void Add(Control control, bool client) {
			if (client) {
				clientArea.Add(control);
			} else {
				base.Add(control);
			}
		}
Esempio n. 2
0
		private static Control LoadControl(Manager manager, XmlNode node, Type type, Control parent) {
			Control c = null;

			Object[] args = new Object[] { manager };

			c = (Control)type.InvokeMember(null, BindingFlags.CreateInstance, null, null, args);
			if (parent != null)
				c.Parent = parent;
			c.Name = node.Attributes["Name"].Value;

			if (node != null && node["Properties"] != null && node["Properties"].HasChildNodes) {
				LoadProperties(node["Properties"].GetElementsByTagName("Property"), c);
			}

			if (node != null && node["Controls"] != null && node["Controls"].HasChildNodes) {
				foreach (XmlElement e in node["Controls"].GetElementsByTagName("Control")) {
					string cls = e.Attributes["Class"].Value;
					Type t = Type.GetType(cls);

					if (t == null) {
						cls = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls;
						t = Type.GetType(cls);
					}
					LoadControl(manager, e, t, c);
				}
			}

			return c;
		}
Esempio n. 3
0
		public static string DeriveControlName(Control control) {
			if (control != null) {
				try {
					string str = control.ToString();
					int i = str.LastIndexOf(".");
					return str.Remove(0, i + 1);
				} catch {
					return control.ToString();
				}
			}
			return control.ToString();
		}
Esempio n. 4
0
		private static void LoadProperties(XmlNodeList node, Control c) {
			foreach (XmlElement e in node) {
				string name = e.Attributes["Name"].Value;
				string val = e.Attributes["Value"].Value;

				PropertyInfo i = c.GetType().GetProperty(name);

				if (i != null) {
					{
						try {
							i.SetValue(c, Convert.ChangeType(val, i.PropertyType, null), null);
						} catch {
						}
					}
				}
			}
		}
Esempio n. 5
0
		public virtual void Show(Control sender, int x, int y) {
			AutoSize();
			base.Show();
			if (!Initialized)
				Init();
			if (sender != null && sender.Root != null && sender.Root is Container) {
				(sender.Root as Container).Add(this, false);
			} else {
				Manager.Add(this);
			}

			this.sender = sender;

			if (sender != null && sender.Root != null && sender.Root is Container) {
				Left = x - Root.AbsoluteLeft;
				Top = y - Root.AbsoluteTop;
			} else {
				Left = x;
				Top = y;
			}

			if (AbsoluteLeft + Width > Manager.TargetWidth) {
				Left = Left - Width;
				if (ParentMenu != null && ParentMenu is ContextMenu) {
					Left = Left - ParentMenu.Width + 2;
				} else if (ParentMenu != null) {
					Left = Manager.TargetWidth - (Parent != null ? Parent.AbsoluteLeft : 0) - Width - 2;
				}
			}
			if (AbsoluteTop + Height > Manager.TargetHeight) {
				Top = Top - Height;
				if (ParentMenu != null && ParentMenu is ContextMenu) {
					Top = Top + LineHeight();
				} else if (ParentMenu != null) {
					Top = ParentMenu.Top - Height - 1;
				}
			}

			Focused = true;
		}
Esempio n. 6
0
		public virtual void ScrollTo(Control control) {
			if (control != null && ClientArea != null && ClientArea.Contains(control, true)) {
				if (control.AbsoluteTop + control.Height > ClientArea.AbsoluteTop + ClientArea.Height) {
					sbVert.Value = sbVert.Value + control.AbsoluteTop - ClientArea.AbsoluteTop - sbVert.PageSize + control.Height;
				} else if (control.AbsoluteTop < ClientArea.AbsoluteTop) {
					sbVert.Value = sbVert.Value + control.AbsoluteTop - ClientArea.AbsoluteTop;
				}
				if (control.AbsoluteLeft + control.Width > ClientArea.AbsoluteLeft + ClientArea.Width) {
					sbHorz.Value = sbHorz.Value + control.AbsoluteLeft - ClientArea.AbsoluteLeft - sbHorz.PageSize + control.Width;
				} else if (control.AbsoluteLeft < ClientArea.AbsoluteLeft) {
					sbHorz.Value = sbHorz.Value + control.AbsoluteLeft - ClientArea.AbsoluteLeft;
				}
			}
		}
Esempio n. 7
0
		public override void Add(Control control, bool client) {
			base.Add(control, client);
			CalcScrolling();
		}
Esempio n. 8
0
		public override void Remove(Control control) {
			base.Remove(control);
			clientArea.Remove(control);
		}
Esempio n. 9
0
		public override void Add(Control control) {
			Add(control, true);
		}
Esempio n. 10
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy) {
			DrawString(control, layer, text, rect, margins, ox, oy, true);
		}
Esempio n. 11
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, EControlState state, bool margins) {
			DrawString(control, layer, text, rect, state, margins, 0, 0, true);
		}
Esempio n. 12
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect) {
			DrawString(control, layer, text, rect, true, 0, 0, true);
		}
Esempio n. 13
0
		public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect, EControlState state) {
			Color c = Color.White;
			Color oc = Color.White;
			int i = 0;
			int oi = -1;
			SkinLayer l = layer;

			if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1)) {
				c = l.States.Hovered.Color;
				i = l.States.Hovered.Index;

				if (l.States.Hovered.Overlay) {
					oc = l.Overlays.Hovered.Color;
					oi = l.Overlays.Hovered.Index;
				}
			} else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1)) {
				c = l.States.Focused.Color;
				i = l.States.Focused.Index;

				if (l.States.Focused.Overlay) {
					oc = l.Overlays.Focused.Color;
					oi = l.Overlays.Focused.Index;
				}
			} else if (state == EControlState.Pressed) {
				c = l.States.Pressed.Color;
				i = l.States.Pressed.Index;

				if (l.States.Pressed.Overlay) {
					oc = l.Overlays.Pressed.Color;
					oi = l.Overlays.Pressed.Index;
				}
			} else if (state == EControlState.Disabled) {
				c = l.States.Disabled.Color;
				i = l.States.Disabled.Index;

				if (l.States.Disabled.Overlay) {
					oc = l.Overlays.Disabled.Color;
					oi = l.Overlays.Disabled.Index;
				}
			} else {
				c = l.States.Enabled.Color;
				i = l.States.Enabled.Index;

				if (l.States.Enabled.Overlay) {
					oc = l.Overlays.Enabled.Color;
					oi = l.Overlays.Enabled.Index;
				}
			}

			if (control.Color != Control.UndefinedColor)
				c = control.Color * (control.Color.A / 255f);
			DrawLayer(l, rect, c, i);

			if (oi != -1) {
				DrawLayer(l, rect, oc, oi);
			}
		}
Esempio n. 14
0
		public virtual void DrawLayer(Control control, SkinLayer layer, Rectangle rect) {
			DrawLayer(control, layer, rect, control.ControlState);
		}
Esempio n. 15
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, EControlState state, bool margins, int ox, int oy, bool ellipsis) {
			Color col = Color.White;

			if (layer.Text != null) {
				if (margins) {
					Margins m = layer.ContentMargins;
					rect = new Rectangle(rect.Left + m.Left, rect.Top + m.Top, rect.Width - m.Horizontal, rect.Height - m.Vertical);
				}

				if (state == EControlState.Hovered && (layer.States.Hovered.Index != -1)) {
					col = layer.Text.Colors.Hovered;
				} else if (state == EControlState.Pressed) {
					col = layer.Text.Colors.Pressed;
				} else if (state == EControlState.Focused || (control.Focused && state == EControlState.Hovered && layer.States.Hovered.Index == -1)) {
					col = layer.Text.Colors.Focused;
				} else if (state == EControlState.Disabled) {
					col = layer.Text.Colors.Disabled;
				} else {
					col = layer.Text.Colors.Enabled;
				}

				if (text != null && text != "") {
					SkinText font = layer.Text;
					if (control.TextColor != Control.UndefinedColor && control.ControlState != EControlState.Disabled)
						col = control.TextColor;
					DrawString(font.Font.Resource, text, rect, col, font.Alignment, font.OffsetX + ox, font.OffsetY + oy, ellipsis);
				}
			}
		}
Esempio n. 16
0
		public virtual void DrawString(Control control, SkinLayer layer, string text, Rectangle rect, bool margins, int ox, int oy, bool ellipsis) {
			DrawString(control, layer, text, rect, control.ControlState, margins, ox, oy, ellipsis);
		}