// 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); }
internal void SetMetrics(ScreenMetrics Metrics) { _metrics = Metrics; _adorner.FontHeight = Metrics.FontSize.Height; addLines(); }
public void Refresh(ScreenMetrics screenMetrics) { Orientation = screenMetrics.Orientation.ToString(); Rotation = screenMetrics.Rotation.ToString(); Width = screenMetrics.Width; Height = screenMetrics.Height; Density = screenMetrics.Density; }
public MainPage() { InitializeComponent(); _metrics = DeviceDisplay.ScreenMetrics; _formsWidth = Convert.ToInt32(_metrics.Width / _metrics.Density); _formsHeight = Convert.ToInt32(_metrics.Height / _metrics.Density); }
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); }
public void DeviceDisplay_Comparison( double width1, double height1, double density1, ScreenOrientation orientation1, ScreenRotation rotation1, double width2, double height2, double density2, ScreenOrientation orientation2, ScreenRotation rotation2, bool equals) { var device1 = new ScreenMetrics( width: width1, height: height1, density: density1, orientation: orientation1, rotation: rotation1); var device2 = new ScreenMetrics( width: width2, height: height2, density: density2, orientation: orientation2, rotation: rotation2); if (equals) { Assert.True(device1.Equals(device2)); Assert.True(device1 == device2); Assert.False(device1 != device2); Assert.Equal(device1, device2); Assert.Equal(device1.GetHashCode(), device2.GetHashCode()); } else { Assert.False(device1.Equals(device2)); Assert.True(device1 != device2); Assert.False(device1 == device2); Assert.NotEqual(device1, device2); Assert.NotEqual(device1.GetHashCode(), device2.GetHashCode()); } }
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(); }