예제 #1
0
        private static Control NumberBitsSelectorControl(V pos, long number, long changeNumberEventId)
        {
            var bits = number.GetBitsFixedWidth(64);

            var(x, y) = pos;
            var hBorder = CollectionsModule.Range(8).Map(i => DrawFilledCenteredSquare(1).ShiftVectors(Vec(x + i * 3, y - 3))).Flatten();
            var vBorder = CollectionsModule.Range(8).Map(i => DrawFilledCenteredSquare(1).ShiftVectors(Vec(x - 3, y + i * 3))).Flatten();
            var border  = new Control(null, List(hBorder.Concat(vBorder)));

            return(CombineControls(border.AppendTo(bits.MapWithIndex((bit, i) => RenderBit(number, pos, bit, i, changeNumberEventId), 0))));
        }
예제 #2
0
        private static Control RenderBit(long number, V origin, long bit, long i, long changeNumberEventId)
        {
            var shift = Vec(3 * (i % 8), 3 * (i / 8));
            var pos   = origin.AddVec(shift);

            var(x, y) = pos;
            if (bit == 1)
            {
                return(ImageButton(pos, DrawFilledCenteredSquare(1), changeNumberEventId, number - CollectionsModule.Power2(i)));
            }
            var num       = number + CollectionsModule.Power2(i);
            var clickArea = new ClickArea(Rect(x - 1, y - 1, 3, 3), changeNumberEventId, num);

            return(new Control(List(clickArea), List(List(pos))));
        }