private void SetFontSmoothingIfNotAlready(FontSmoothingOrientation orientation) { if (FontSmoothing.GetFontSmoothingOrientation() != orientation) { FontSmoothing.SetFontSmoothingOrientation(orientation); dirty = true; } }
private void UpdateStatus() { dirty = false; if (InvokeRequired) { Dispatcher.Invoke(UpdateStatus); } else { // Read font settings bool aaEnabled = FontSmoothing.GetAntialiasingEnabled(); FontSmoothingOrientation orientation = FontSmoothing.GetFontSmoothingOrientation(); FontSmoothingType smoothingType = FontSmoothing.GetFontSmoothingType(); uint contrast = FontSmoothing.GetContrast(); // Update UI controls DisableEvents(); cbEnableFontAntialiasing.IsChecked = aaEnabled; if (smoothingType == FontSmoothingType.Standard) { rbGrayscale.IsChecked = true; btnSetContrast.IsEnabled = txtContrast.IsEnabled = false; } else { if (orientation == FontSmoothingOrientation.RGB) { rbRGB.IsChecked = true; btnSetContrast.IsEnabled = txtContrast.IsEnabled = true; } else if (orientation == FontSmoothingOrientation.BGR) { rbBGR.IsChecked = true; btnSetContrast.IsEnabled = txtContrast.IsEnabled = true; } else if (orientation == FontSmoothingOrientation.Unknown) { rbGrayscale.IsChecked = rbRGB.IsChecked = rbBGR.IsChecked = false; btnSetContrast.IsEnabled = txtContrast.IsEnabled = false; } } txtContrast.Text = Clamp(contrast, 0, 2200).ToString(); if (contrast < 1000 || contrast > 2200) { txtContrast.Foreground = Brushes.Red; } else { txtContrast.Foreground = defaultWindowTextColor; } rbGrayscale.IsEnabled = rbRGB.IsEnabled = rbBGR.IsEnabled = aaEnabled; if (!aaEnabled) { txtContrast.IsEnabled = btnSetContrast.IsEnabled = false; } EnableEvents(); string quick = "The quick brown fox jumps over the lazy dog. "; // Update status text if (aaEnabled) { if (smoothingType == FontSmoothingType.ClearType) { lblStatus.Content = quick + orientation + " (Contrast " + contrast + ")"; } else { lblStatus.Content = quick + "Grayscale (Contrast " + contrast + ")"; } } else { lblStatus.Content = quick + "Font Antialiasing is disabled."; } if (initialized) { // Snapshot the sample text and render it zoomed-in CopyZoomedSnapshot(); } } }
private void UpdateStatus() { dirty = false; if (InvokeRequired) { Invoke((Action)UpdateStatus); } else { // Read font settings bool aaEnabled = FontSmoothing.GetAntialiasingEnabled(); FontSmoothingOrientation orientation = FontSmoothing.GetFontSmoothingOrientation(); FontSmoothingType smoothingType = FontSmoothing.GetFontSmoothingType(); uint contrast = FontSmoothing.GetContrast(); // Update UI controls DisableEvents(); cbFontAntialiasing.Checked = aaEnabled; if (smoothingType == FontSmoothingType.Standard) { rbGrayscale.Checked = true; btnSet.Enabled = nudContrast.Enabled = false; } else { if (orientation == FontSmoothingOrientation.RGB) { rbRGB.Checked = true; btnSet.Enabled = nudContrast.Enabled = true; } else if (orientation == FontSmoothingOrientation.BGR) { rbBGR.Checked = true; btnSet.Enabled = nudContrast.Enabled = true; } else if (orientation == FontSmoothingOrientation.Unknown) { rbGrayscale.Checked = rbRGB.Checked = rbBGR.Checked = false; btnSet.Enabled = nudContrast.Enabled = false; } } nudContrast.Value = Clamp(contrast, (uint)nudContrast.Minimum, (uint)nudContrast.Maximum); if (contrast < 1000 || contrast > 2200) { nudContrast.ForeColor = Color.Red; } else { nudContrast.ForeColor = defaultWindowTextColor; } rbGrayscale.Enabled = rbRGB.Enabled = rbBGR.Enabled = aaEnabled; if (!aaEnabled) { nudContrast.Enabled = btnSet.Enabled = false; } EnableEvents(); string quick = "The quick brown fox jumps over the lazy dog. "; // Update status text if (aaEnabled) { if (smoothingType == FontSmoothingType.ClearType) { status.Text = quick + orientation + " (Contrast " + contrast + ")"; } else { status.Text = quick + "Grayscale (Contrast " + contrast + ")"; } } else { status.Text = quick + "Font Antialiasing is disabled."; } // Snapshot the sample text and render it zoomed-in CopyZoomedSnapshot(); } }
/// <summary> /// Sets the current font smoothing orientation (subpixel structure). /// </summary> /// <returns></returns> public static void SetFontSmoothingOrientation(FontSmoothingOrientation orientation) { User32.SystemParametersInfoW(SPI.SPI_SETFONTSMOOTHINGORIENTATION, 0, (uint)orientation, SPIF.SPIF_UPDATEINIFILE | SPIF.SPIF_SENDCHANGE); }