Esempio n. 1
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;
        }
Esempio n. 2
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();
        }
Esempio n. 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
        }
Esempio n. 4
0
        private void DrawTapeSpool(Graphics g, PointF center, float angleDegrees)
        {
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            g.FillEllipse(backgroundBrush, center.X - spoolInnerRadius, center.Y - spoolInnerRadius,
                          spoolInnerRadius * 2, spoolInnerRadius * 2);

            g.FillEllipse(Common.BlackWheelBrush, center.X - blackWheelRadius, center.Y - blackWheelRadius,
                          blackWheelRadius * 2, blackWheelRadius * 2);

            g.FillEllipse(Common.AxisBrush, center.X - axisRadius, center.Y - axisRadius,
                          axisRadius * 2, axisRadius * 2);

            for (int i = 0; i < 6; ++i)
            {
                float a = 60 * i + angleDegrees;
                if (CassetteInserted)
                {
                    g.FillPolygon(Common.SpoolBrush, new PointF[]
                    {
                        PolarToCartesian(center, scaler.S(55.0f), a - 2),
                        PolarToCartesian(center, scaler.S(55.0f), a + 22),
                        PolarToCartesian(center, spoolInnerRadius, a + 20),
                        PolarToCartesian(center, spoolInnerRadius, a),
                    });
                }

                g.FillPolygon(Common.BlackWheelBrush, new PointF[]
                {
                    PolarToCartesian(center, scaler.S(60.0f), a + 30),
                    PolarToCartesian(center, scaler.S(60.0f), a + 50),
                    PolarToCartesian(center, blackWheelRadius, a + 55),
                    PolarToCartesian(center, blackWheelRadius, a + 25),
                });
            }
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            RectangleF destRect = scaler.S(new RectangleF(0, 0, img.Width, img.Height));

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            if (loadedTapeSide != null)
            {
                DrawTapeSpoolOuter(e.Graphics, centerLeft, spoolLeftRadius);
                DrawTapeSpoolOuter(e.Graphics, centerRight, spoolRightRadius);

                e.Graphics.DrawLine(Common.TapePen, 0.1f * Width, (int)(capstan.Y + capstanRadius),
                                    0.9f * Width, (int)(capstan.Y + capstanRadius));
            }

            e.Graphics.FillEllipse(Common.AxisBrush, capstan.X - capstanRadius, capstan.Y - capstanRadius,
                                   capstanRadius * 2, capstanRadius * 2);
            e.Graphics.FillEllipse(Common.BlackWheelBrush, roller.X - rollerRadius, roller.Y - rollerRadius,
                                   rollerRadius * 2, rollerRadius * 2);
            e.Graphics.FillEllipse(Common.AxisBrush, roller.X - capstanRadius, roller.Y - capstanRadius,
                                   capstanRadius * 2, capstanRadius * 2);

            float headWidth       = scaler.S(120.0f);
            float headRoundHeight = scaler.S(25.0f);
            float headHeight      = scaler.S(70.0f);

            e.Graphics.FillPie(Common.AxisBrush, head.X - headWidth / 2, head.Y,
                               headWidth, headRoundHeight * 2, 180, 180);
            e.Graphics.FillRectangle(Common.AxisBrush, head.X - headWidth / 2, head.Y + headRoundHeight - 1,
                                     headWidth, headHeight);
            e.Graphics.FillRectangle(Common.AxisBrush, head.X + headWidth / 2, head.Y - headRoundHeight / 4,
                                     scaler.S(5.0f), headRoundHeight / 4 + headRoundHeight + headHeight);

            Color cassetteColor = loadedTapeSide?.Parent.Color ?? Color.Transparent;

            if (imgScaled == null ||
                imgScaled.Width != (int)destRect.Width ||
                imgScaled.Height != (int)destRect.Height ||
                prevCassetteColor != cassetteColor)
            {
                imgScaled?.Dispose();
                imgScaled = new Bitmap((int)destRect.Width, (int)destRect.Height);

                prevCassetteColor = cassetteColor;

                using (Graphics g = Graphics.FromImage(imgScaled))
                    using (var b = new SolidBrush(cassetteColor))
                    {
                        g.FillRectangle(b, scaler.S(new RectangleF(50, 200, 230, 400)));
                        g.FillRectangle(b, scaler.S(new RectangleF(980, 200, 230, 400)));
                        g.FillRectangle(b, scaler.S(new RectangleF(50, 200, 1200, 70)));
                        g.FillRectangle(b, scaler.S(new RectangleF(50, 480, 1200, 130)));
                        g.DrawImage(img, destRect, new RectangleF(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
                    }
            }

            if (loadedTapeSide != null)
            {
                e.Graphics.DrawImage(imgScaled, cassetteOffset);

                TextRenderer.DrawText(e.Graphics, loadedTapeSide.Label, tapeLabelFont,
                                      scaler.S(new Rectangle(266, 153, 813, 70)),
                                      Color.Black, TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.EndEllipsis);

                TextRenderer.DrawText(e.Graphics, (loadedTapeSide.Parent.SideA == loadedTapeSide) ? "A" : "B", tapeSideFont,
                                      scaler.S(new Rectangle(180, 142, 90, 90)),
                                      Color.White, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPadding);

                TextRenderer.DrawText(e.Graphics, ((int)Math.Round(loadedTapeSide.Parent.Length / 900.0f) * 30).ToString(), tapeSideFont,
                                      scaler.S(new Rectangle(1112, 410, 90, 90)),
                                      Color.Black, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter | TextFormatFlags.NoPadding);
            }

            e.Graphics.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
        }