Пример #1
0
        private void DoLayout()
        {
            Scaler scaler = new Scaler();

            float contentRatio  = 416 / 457.0f;
            int   contentMargin = scaler.S(20);

            int contentWidth     = listBox.Left - contentMargin * 2;
            int contentHeight    = (int)(contentWidth / contentRatio);
            int maxContentHeight = ClientRectangle.Height - contentMargin * 2;

            if (contentHeight > maxContentHeight)
            {
                contentHeight = maxContentHeight;
                contentWidth  = (int)(contentHeight * contentRatio);
            }

            float cassetteRatio = 422 / 275.0f;

            cassetteControl.Location = new Point(contentMargin, contentMargin);
            cassetteControl.Size     = new Size(contentWidth, (int)(contentWidth / cassetteRatio));

            float counterRatio  = 141 / 57.0f;
            int   counterWidth  = contentWidth / 3;
            int   counterMargin = (int)(contentWidth * 0.02f);

            counter.Location = new Point(contentMargin, cassetteControl.Bottom + counterMargin);
            counter.Size     = new Size(counterWidth, (int)(counterWidth / counterRatio));

            float buttonsRatio = 422 / 123.0f;

            cassetteButtons.Location = new Point(contentMargin, counter.Bottom);
            cassetteButtons.Size     = new Size(contentWidth, (int)(contentWidth / buttonsRatio));
            cassetteButtons.Invalidate();
        }
Пример #2
0
        private void DoLayout()
        {
            Scaler scaler = new Scaler(Width / 141.0f);

            counterDepth    = scaler.S(5);
            buttonDepthUp   = scaler.S(8);
            buttonDepthDown = scaler.S(2);

            font?.Dispose();
            font = new Font(FontFamily.GenericMonospace, Math.Max(scaler.S(20.0f / DpiScaler.DpiScaleFactor), 1.0f), FontStyle.Bold);
            var digitSize = TextRenderer.MeasureText("0", font);

            digitWidth  = (int)(digitSize.Width * 0.8);
            digitHeight = (int)(digitSize.Height * 0.8);

            wheelBitmap?.Dispose();
            wheelBitmap = new Bitmap(digitWidth, digitHeight * 11);
            using (var g = Graphics.FromImage(wheelBitmap))
            {
                g.FillRectangle(Brushes.Black, new RectangleF(0, 0, wheelBitmap.Width, wheelBitmap.Height));

                for (int i = 0; i <= 10; ++i)
                {
                    //wheel background
                    g.FillRectangle(Common.CounterWheelBrush,
                                    new RectangleF(digitWidth * 0.1f, i * digitHeight,
                                                   digitWidth * 0.7f, digitHeight));

                    //right gears
                    g.FillRectangle(Common.CounterWheelBrush,
                                    new RectangleF(digitWidth * 0.8f, i * digitHeight,
                                                   digitWidth * 0.1f, digitHeight * 0.25f));
                    g.FillRectangle(Common.CounterWheelBrush,
                                    new RectangleF(digitWidth * 0.8f, i * digitHeight + digitHeight * 0.5f,
                                                   digitWidth * 0.1f, digitHeight * 0.25f));

                    TextRenderer.DrawText(g, (i % 10).ToString(), font,
                                          new Rectangle(0, i * digitHeight - (int)(digitHeight * 0.1f),
                                                        digitWidth, digitHeight),
                                          Color.White, Common.CounterWheelColor,
                                          TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
                }

                //left gears (next to "7")
                g.FillRectangle(Common.CounterWheelBrush,
                                new RectangleF(digitWidth * 0.0f, 7 * digitHeight,
                                               digitWidth * 0.1f, digitHeight * 0.25f));
                g.FillRectangle(Common.CounterWheelBrush,
                                new RectangleF(digitWidth * 0.0f, 7 * digitHeight + digitHeight * 0.5f,
                                               digitWidth * 0.1f, digitHeight * 0.25f));
            }

            counterRect      = new RectangleF(0, 0, digitWidth * 3 + counterDepth, digitHeight + counterDepth);
            counterOrigin    = new PointF(counterDepth, counterDepth);
            buttonOrigin     = new Point((int)counterRect.Right + counterDepth * 2, counterDepth);
            buttonFaceWidth  = digitWidth + counterDepth;
            buttonFaceHeight = digitWidth + counterDepth;
        }
Пример #3
0
        private void DoLayout()
        {
            scaler = new Scaler(Width / baseSize.Width);

            if (baseSize.Height * scaler.ScalingFactor > Height)
            {
                scaler.ScalingFactor = Height / baseSize.Height;
            }

            tapeLabelFont?.Dispose();
            tapeLabelFont = new Font(FontFamily.GenericSansSerif, Math.Max(scaler.S(27.5f / DpiScaler.DpiScaleFactor), 1.0f), FontStyle.Regular);

            tapeSideFont?.Dispose();
            tapeSideFont = new Font(FontFamily.GenericSansSerif, Math.Max(scaler.S(45.0f / DpiScaler.DpiScaleFactor), 1.0f), FontStyle.Bold);

            cassetteOffset = Point.Truncate(scaler.S(new PointF(img.Width * 0.05f, img.Height * 0.05f)));

            var spoolSize = scaler.S(new Size(160, 160));

            try
            {
                WinApi.SuspendRedraw(spoolControlLeft.Handle);
                WinApi.SuspendRedraw(spoolControlRight.Handle);

                spoolControlLeft.scaler   = scaler;
                spoolControlLeft.Location = new Point((int)centerLeft.X - spoolSize.Width / 2, (int)centerLeft.Y - spoolSize.Height / 2);
                spoolControlLeft.Size     = spoolSize;
                spoolControlLeft.Invalidate();

                spoolControlRight.scaler   = scaler;
                spoolControlRight.Location = new Point((int)centerRight.X - spoolSize.Width / 2, (int)centerRight.Y - spoolSize.Height / 2);
                spoolControlRight.Size     = spoolSize;
                spoolControlRight.Invalidate();
            }
            finally
            {
                WinApi.ResumeRedraw(spoolControlLeft.Handle);
                WinApi.ResumeRedraw(spoolControlRight.Handle);
            }

            UpdateRadiusesOfSpools();

            Refresh(); //force full repaint
        }
Пример #4
0
        private void DoLayout()
        {
            Scaler scaler = new Scaler(Width / 416.0f);

            Size  buttonSize    = scaler.S(new Size(65, 65));
            Point buttonsOrigin = scaler.S(new Point(25, 25));
            int   offset        = scaler.S(60);

            RecButton.Location       = new Point(buttonsOrigin.X + offset * 0, buttonsOrigin.Y);
            PlayButton.Location      = new Point(buttonsOrigin.X + offset * 1, buttonsOrigin.Y);
            RewButton.Location       = new Point(buttonsOrigin.X + offset * 2, buttonsOrigin.Y);
            FfButton.Location        = new Point(buttonsOrigin.X + offset * 3, buttonsOrigin.Y);
            StopEjectButton.Location = new Point(buttonsOrigin.X + offset * 4, buttonsOrigin.Y);
            PauseButton.Location     = new Point(buttonsOrigin.X + offset * 5, buttonsOrigin.Y);

            RecButton.Size = PlayButton.Size = RewButton.Size
                                                   = FfButton.Size = StopEjectButton.Size = PauseButton.Size = buttonSize;

            depthUp      = scaler.S(15);
            depthDown    = scaler.S(6);
            depthPressed = scaler.S(3);

            hole = scaler.S(new Rectangle(28, 28, 354, 54));
        }