private IEnumerable <IEnumerable <KleKey> > ConvertToKleLayout(PhysicalLayoutModel physicalLayout, LogicalLayoutModel logicalLayout) { return(physicalLayout.PhysicalRows .Select(x => { return x.PhysicalKeys .Select(y => { var logicalKey = logicalLayout.LogicalRows .SelectMany(x => x.LogicalKeys) .FirstOrDefault(z => z.Tag.Equals(y.Tag)); var option = new KleOptionJsonModel { Width = y.Width, Height = y.Height, }; return new KleKey { LegendTopLeft = $"{logicalKey.Row},{logicalKey.Col}", LegendCenterLeft = y.Label, Option = option, }; }); })); }
private IEnumerable <IEnumerable <KleKey> > ConvertToKleLayout(KleContext context, PhysicalLayoutModel physicalLayout, LogicalLayoutModel logicalLayout) { return(physicalLayout.PhysicalRows .Select(row => { return row.PhysicalKeys .Select(key => { var logicalKey = logicalLayout.LogicalRows .SelectMany(x => x.LogicalKeys) .FirstOrDefault(x => x.Tag.Equals(key.Tag)); var option = new KleOptionJsonModel { OffsetX = key.OffsetX, OffsetY = key.OffsetY, Width = key.Width, Height = key.Height, }; return context.ConvertKind switch { ConvertKind.KLE => new KleKey { LegendTopLeft = key.Label, Option = option, }, _ => new KleKey { LegendTopLeft = $"{logicalKey.Row},{logicalKey.Col}", LegendCenterLeft = key.Label, Option = option, }, }; }); })); }