Пример #1
0
        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,
                    };
                });
            }));
        }
Пример #2
0
        private PhysicalLayoutModel InjectDesign(PhysicalLayoutModel physicalLayout, QcLayout qcLayout)
        {
            if (qcLayout == default)
            {
                return(physicalLayout);
            }

            var counter = 0;

            return(new PhysicalLayoutModel
            {
                PhysicalRows = physicalLayout.PhysicalRows
                               .Select(x =>
                {
                    return new PhysicalRow
                    {
                        PhysicalKeys = x.PhysicalKeys
                                       .Select(y =>
                        {
                            var key = qcLayout.QcKeys.ElementAtOrDefault(counter);

                            counter++;

                            return new PhysicalKey(y.Tag)
                            {
                                Label = key.Label,
                                Row = key.Row,
                                Col = key.Col,
                                Width = key.Width,
                                Height = key.Height,
                            };
                        }),
                    };
                }),
            });
        }
Пример #3
0
        private PhysicalLayoutModel InjectDesign(PhysicalLayoutModel physicalLayout, QcLayout qcLayout)
        {
            if (qcLayout == default)
            {
                return(physicalLayout);
            }

            double originY = 0;
            var    counter = 0;

            return(new PhysicalLayoutModel
            {
                PhysicalRows = physicalLayout.PhysicalRows
                               .Select((row, rowIndex) =>
                {
                    double offsetX = 0;
                    double offsetY = 0;

                    return new PhysicalRow
                    {
                        PhysicalKeys = row.PhysicalKeys
                                       .Select((key, colIndex) =>
                        {
                            var qcKey = qcLayout.QcKeys.ElementAtOrDefault(counter);

                            if (rowIndex == 0 && colIndex == 0)
                            {
                                originY = qcKey.Y;
                                offsetY = qcKey.Y;
                            }
                            else if (colIndex == 0)
                            {
                                offsetY = qcKey.Y - originY - rowIndex;
                            }
                            else
                            {
                                var preQcKey = qcLayout.QcKeys.ElementAtOrDefault(counter - 1);
                                offsetY = qcKey.Y - preQcKey.Y;
                            }

                            counter++;

                            var physKey = new PhysicalKey(key.Tag)
                            {
                                Label = qcKey.Label,
                                Row = rowIndex,
                                Col = colIndex,
                                OffsetX = Math.Round(qcKey.X - offsetX - colIndex, 3),
                                OffsetY = Math.Round(offsetY, 3),
                                Width = qcKey.Width,
                                Height = qcKey.Height,
                            };

                            if (physKey.Width != 0)
                            {
                                offsetX += physKey.Width - 1;
                            }

                            if (physKey.OffsetX != 0)
                            {
                                offsetX += physKey.OffsetX;
                            }

                            return physKey;
                        }),
                    };
                }),
            });
        }
Пример #4
0
        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,
                        },
                    };
                });
            }));
        }