コード例 #1
0
        internal void SetMetrics(ScreenMetrics Metrics)
        {
            _metrics = Metrics;

            _adorner.FontHeight = Metrics.FontSize.Height;

            addLines();
        }
コード例 #2
0
 public ScreenMetrics GetScreenMetrics()
 {
     //FIXME: Find a way to get size of font
     int font_w = 1;
     int font_h = 1;
     int screen_w = Console.WindowWidth;
     int screen_h = Console.WindowHeight;
     var sm = new ScreenMetrics(new ZSize(font_w, font_h), new ZSize(screen_w, screen_h), screen_h, screen_w, screen_w * screen_h);
     return sm;
 }
コード例 #3
0
ファイル: ScreenBase.cs プロジェクト: ChrisJamesSadler/Cosmos
        public void SetCharsAndLines()
        {
            double height = this.ActualHeight;
            double width = this.ActualWidth;

            FormattedText fixedFt = buildFormattedText("A", _fixedFont, _currentInfo, null);
            FormattedText propFt = buildFormattedText("A", _regularFont, _currentInfo, null);

            double w = fixedFt.Width;
            double h = fixedFt.Height;

            charHeight = Math.Max(fixedFt.Height, propFt.Height);
            charWidth = fixedFt.Width;

            double screenWidth = width - 20;
            double screenHeight = height - 20;

            if (os_._blorbFile != null)
            {
                var standard = os_._blorbFile.StandardSize;
                if (standard.Height > 0 && standard.Width > 0)
                {
                    int maxW = (int)Math.Floor(width / os_._blorbFile.StandardSize.Width);
                    int maxH = (int)Math.Floor(height / os_._blorbFile.StandardSize.Height);

                    scale = Math.Min(maxW, maxH);

                    screenWidth = os_._blorbFile.StandardSize.Width * scale;
                    screenHeight = os_._blorbFile.StandardSize.Height * scale;

                    double heightDiff = _parent.ActualHeight - this.ActualHeight;
                    double widthDiff = _parent.ActualWidth - this.ActualWidth;

                    _parent.Height = screenHeight + heightDiff;
                    _parent.Width = screenWidth + widthDiff;
                }
                else
                {
                    scale = 1;
                }
            }
            else
            {
                scale = 1;
            }

            ActualCharSize = new Size(propFt.Width, propFt.Height);

            chars = Convert.ToInt32(Math.Floor(screenWidth / charWidth)); // Determine chars based only on fixed width chars since proportional fonts are accounted for as they are written
            lines = Convert.ToInt32(Math.Floor(screenHeight / charHeight)); // Use the largest character height

            _metrics = new ScreenMetrics(
                new ZSize(charHeight, charWidth),// new ZSize(h, w),
                new ZSize(lines * charHeight, chars * charWidth), // The ZMachine wouldn't take screenHeight as round it down, so this takes care of that
                lines, chars, scale);

            _regularLines = new ScreenLines(_metrics.Rows, _metrics.Columns);
            _fixedWidthLines = new ScreenLines(_metrics.Rows, _metrics.Columns);

            AfterSetCharsAndLines();
        }
コード例 #4
0
        // TODO It might be easier to just grab the h/w in the funciton
        // TODO Find a way to hook this to an event
        public void SetCharsAndLines()
        {
            double height = this.ActualHeight;
            double width = this.ActualWidth;

            FormattedText fixedFt = buildFormattedText("A", _fixedFont, true, null, null);
            FormattedText propFt = buildFormattedText("A", _regularFont, true, null, null);

            double w = fixedFt.Width;
            double h = fixedFt.Height;

            charHeight = Math.Max(fixedFt.Height, propFt.Height);
            charWidth = fixedFt.Width;

            // Account for the margin of the Rich Text Box
            // TODO Find a way to determine what this should be, or to remove the margin
            double screenWidth = width - 20;
            double screenHeight = height - 20;

            if (os_._blorbFile != null)
            {
                var standard = os_._blorbFile.StandardSize;
                if (standard.Height > 0 && standard.Width > 0)
                {
                    int maxW = (int)Math.Floor(width / os_._blorbFile.StandardSize.Width);
                    int maxH = (int)Math.Floor(height / os_._blorbFile.StandardSize.Height);

                    scale = Math.Min(maxW, maxH);
                    // scale = 2; // Ok, so the rest of things are at the right scale, but we've pulled back the images to 1x

                    screenWidth = os_._blorbFile.StandardSize.Width * scale;
                    screenHeight = os_._blorbFile.StandardSize.Height * scale;
                }
            }
            else
            {
                scale = 1;
            }

            ActualCharSize = new Size(propFt.Width, propFt.Height);

            chars = Convert.ToInt32(Math.Floor(screenWidth / charWidth)); // Determine chars based only on fixed width chars since proportional fonts are accounted for as they are written
            lines = Convert.ToInt32(Math.Floor(screenHeight / charHeight)); // Use the largest character height

            _metrics = new ScreenMetrics(
                new ZSize(charHeight, charWidth),// new ZSize(h, w),
                new ZSize(lines * charHeight, chars * charWidth), // The ZMachine wouldn't take screenHeight as round it down, so this takes care of that
                lines, chars, scale);

            Conversion.Metrics = _metrics;

            _regularLines = new ScreenLines(_metrics.Rows, _metrics.Columns);
            _fixedWidthLines = new ScreenLines(_metrics.Rows, _metrics.Columns);

            _cursorCanvas.MinHeight = 2;
            _cursorCanvas.MinWidth = charWidth;

            ztc.SetMetrics(_metrics);
        }