public SceneCommandInfo Load(XElement node, string basePath) { var info = new SceneFillCommandInfo(); var nameAttr = node.Attribute("name"); if (nameAttr != null) info.Name = nameAttr.Value; var colorAttr = node.RequireAttribute("color"); var color = colorAttr.Value; var split = color.Split(','); info.Red = byte.Parse(split[0]); info.Green = byte.Parse(split[1]); info.Blue = byte.Parse(split[2]); info.X = node.GetAttribute<int>("x"); info.Y = node.GetAttribute<int>("y"); info.Width = node.GetAttribute<int>("width"); info.Height = node.GetAttribute<int>("height"); info.Layer = node.TryAttribute<int>("layer"); return info; }
private void FillCommand(SceneFillCommandInfo command) { Color color = new Color(command.Red, command.Green, command.Blue); var obj = new HandlerFill(color, command.X, command.Y, command.Width, command.Height, command.Layer); obj.Start(); var name = command.Name ?? Guid.NewGuid().ToString(); if (!objects.ContainsKey(name)) objects.Add(name, obj); }
public static SceneFillCommandInfo FromXml(XElement node) { var info = new SceneFillCommandInfo(); var nameAttr = node.Attribute("name"); if (nameAttr != null) info.Name = nameAttr.Value; var colorAttr = node.RequireAttribute("color"); var color = colorAttr.Value; var split = color.Split(','); info.Red = byte.Parse(split[0]); info.Green = byte.Parse(split[1]); info.Blue = byte.Parse(split[2]); info.X = node.GetInteger("x"); info.Y = node.GetInteger("y"); info.Width = node.GetInteger("width"); info.Height = node.GetInteger("height"); int layer = 1; if (node.TryInteger("layer", out layer)) info.Layer = layer; return info; }