public static void WriteTemplate(Stream stream, LayerTemplate template) { using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { var json = JsonConvert.SerializeObject(template, Settings); writer.Write(json); } }
public Layer(LayerTemplate template) { _isLockCheckEnabled = false; Template = template; Width = template.Width; Height = template.Height; void BuildPin(Position pos, int width, int height) { for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { AddCellMetal(pos.Offset(i, j)); } } for (var i = 0; i < width - 1; i++) { for (var j = 0; j < height - 1; j++) { AddLink(pos.Offset(i, j), pos.Offset(i + 1, j), LinkType.MetalLink); AddLink(pos.Offset(i, j), pos.Offset(i, j + 1), LinkType.MetalLink); } } for (var i = 0; i < width; i++) { AddLink(pos.Offset(i, height - 1), pos.Offset(i + 1, height - 1), LinkType.MetalLink); } for (var i = 0; i < height; i++) { AddLink(pos.Offset(width - 1, i), pos.Offset(width - 1, i + 1), LinkType.MetalLink); } } _cellMatrix = new LayerCellMatrix(this); foreach (var pin in template.Pins) { var pos = new Position(pin.Col, pin.Row); BuildPin(pos, pin.Width, pin.Height); SetCellPin(pos, pin); } CommitChanges(false); _isLockCheckEnabled = true; }
public void OpenTemplate(LayerTemplate template) { Width = template.Width; Height = template.Height; Pins.Clear(); DeadZones.Clear(); foreach (var pin in template.Pins) { Pins.Add(new PinTemplate { X = pin.Col, Y = pin.Row, Width = pin.Width, Height = pin.Height, Name = pin.Name, IsSignificant = pin.IsSignificant, IsOutputPin = pin.IsOutputPin, ValuesFunction = new ValuesFunctionTemplate(pin.ValuesFunction) }); } foreach (var zone in template.DeadZones) { DeadZones.Add(new DeadZoneTemplate { X = zone.Origin.X, Y = zone.Origin.Y, Width = zone.Width, Height = zone.Height }); } foreach (var fun in template.Functions) { Functions.Add(new NamedFunctionTemplate { Name = fun.Key, Function = new ValuesFunctionTemplate(fun.Value) }); } }
public LayerTemplateVM() { TheLayerTemplate = new LayerTemplate(); TheLayerTemplate.Layer = new Layer(); }
public TemplateEditViewModel(LayerTemplate layerTemplate) { OpenTemplate(layerTemplate); }