public static Group Copy(Group Group) { var newGroup = new Group(Group.Text, Group.Location, Group.Size, Group.ControlPlugins); foreach (var control in Group.Controls.OfType<Control>()) { newGroup.Controls.Add(Control.Copy(control)); } return newGroup; }
public static void AssertIsCopy(Group Group, Group GroupCopy) { var controls = Group.Controls.OfType<Control>(); var controlsCopy = GroupCopy.Controls.OfType<Control>(); Assert.AreNotSame(Group, GroupCopy); Assert.IsTrue(Group.ControlPlugins.All(x => GroupCopy.ControlPlugins.Any(y => y.GetType() == x.GetType()))); Assert.AreEqual(Group.Text, GroupCopy.Text); Assert.AreEqual(Group.Location, GroupCopy.Location); Assert.AreEqual(controls.Count(), controlsCopy.Count()); for (var i = 0; i < controls.Count(); i++) { ControlTests.AssertIsCopy(controls.ElementAt(i), controlsCopy.ElementAt(i)); } }
public static Group FromConfig(IEnumerable<IControlPlugin> ControlPlugins, XElement Config, bool LoggingEnabled) { var x = Convert.ToInt32(Config.Element("x").Value); var y = Convert.ToInt32(Config.Element("y").Value); var width = Convert.ToInt32(Config.Element("width").Value); var height = Convert.ToInt32(Config.Element("height").Value); var group = new Group(Config.Element("label").Value, new Point(x, y), new Size(width, height), ControlPlugins); group.LoggingEnabled = LoggingEnabled; foreach (var controlConfig in Config.Descendants("control")) { var controlType = controlConfig.Element("type").Value; var controlPlugin = ControlPlugins.First(plugin => plugin.GetType().Assembly.GetName().Name == controlType); var control = Control.FromConfig(controlPlugin, controlConfig, LoggingEnabled); group.Controls.Add(control); } return group; }