Example #1
0
        /// <summary>
        /// Nimmt eine Videotextseite entgegen.
        /// </summary>
        /// <param name="page">Die gewünschte Videotextseite, eventuell leer.</param>
        /// <returns>Gesetzt, wenn eine Seite erfolgreich angezeigt wurde.</returns>
        public bool ShowPage(TTXPage page)
        {
            // Helper
            DigitManager digits;

            // Forward
            return(ShowPage(page, out digits));
        }
Example #2
0
        /// <summary>
        /// Nimmt eine Videotextseite entgegen.
        /// </summary>
        /// <param name="page">Die gewünschte Videotextseite, eventuell leer.</param>
        /// <param name="digits">Informationen zum Auftreten von Zahlen in der Darstellung.</param>
        /// <returns>Gesetzt, wenn eine Seite erfolgreich angezeigt wurde.</returns>
        public bool ShowPage(TTXPage page, out DigitManager digits)
        {
            // Safe create
            try
            {
                // Create the bitmap from the page
                RectangleF extend;
                using (var ttx = page.CreatePage(this, out digits, out extend))
                {
                    // Default position
                    double left = GetNormalizedBorder(0.8), top = 0.1;
                    double right = 1.0 - left, bottom = 1.0 - top;

                    // Get the transparency color
                    if (page.IsTransparent)
                    {
                        // There is nothing to show
                        if (extend.IsEmpty)
                        {
                            return(true);
                        }

                        // Check mode
                        if (UseLegacyOverlay)
                        {
                            // Get size
                            double width = right - left, height = bottom - top;

                            // Correct against bounds
                            left += width * extend.Left;
                            top  += height * extend.Top;

                            // Correct against bounds
                            right  = left + width * extend.Width;
                            bottom = top + height * extend.Height;

                            // Get the range of interest
                            var srcRange =
                                new RectangleF
                                (
                                    (float)(extend.Left * ttx.Width),
                                    (float)(extend.Top * ttx.Height),
                                    (float)(extend.Width * ttx.Width),
                                    (float)(extend.Height * ttx.Height)
                                );

                            // Create new bitmap
                            using (var clipped = new Bitmap(ttx, (int)Math.Round(srcRange.Width), (int)Math.Round(srcRange.Height)))
                            {
                                // Prepare to update
                                using (var dest = Graphics.FromImage(clipped))
                                {
                                    // Get full ranges
                                    var destRange = new RectangleF(0, 0, clipped.Width, clipped.Height);

                                    // Fill
                                    dest.DrawImage(ttx, destRange, srcRange, GraphicsUnit.Pixel);
                                }

                                // Simpy show up
                                ShowOverlay(clipped, left, top, right, bottom, null, null);
                            }
                        }
                        else
                        {
                            // Simpy show up
                            ShowOverlay(ttx, left, top, right, bottom, null, TTXPage.TransparentColor.Color);
                        }
                    }
                    else
                    {
                        // Simpy show up
                        ShowOverlay(ttx, left, top, right, bottom, null, null);
                    }
                }

                // Did it
                return(true);
            }
            catch
            {
                // Reset
                digits = null;

                // Leave
                return(false);
            }
        }