Exemplo n.º 1
0
 private void ControlsChanged(object sender, EventArgs e)
 {
     if (initialized)
     {
         SetLegacyKeys();
         if (rbGrayscale.Checked)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.Standard);
         }
         else if (rbRGB.Checked)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.ClearType);
             SetFontSmoothingIfNotAlready(FontSmoothingOrientation.RGB);
         }
         else if (rbBGR.Checked)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.ClearType);
             SetFontSmoothingIfNotAlready(FontSmoothingOrientation.BGR);
         }
         if (FontSmoothing.GetContrast() != (uint)nudContrast.Value)
         {
             FontSmoothing.SetContrast((uint)nudContrast.Value);
             dirty = true;
         }
         if (FontSmoothing.GetAntialiasingEnabled() != cbFontAntialiasing.Checked)
         {
             FontSmoothing.SetAntialiasingEnabled(cbFontAntialiasing.Checked);
             dirty = true;
         }
         if (dirty)
         {
             UpdateStatus();
         }
     }
     setDefaults = false;
 }
Exemplo n.º 2
0
 private void ControlsChanged()
 {
     if (initialized)
     {
         SetLegacyKeys();
         if (rbGrayscale.IsChecked.Value)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.Standard);
         }
         else if (rbRGB.IsChecked.Value)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.ClearType);
             SetFontSmoothingIfNotAlready(FontSmoothingOrientation.RGB);
         }
         else if (rbBGR.IsChecked.Value)
         {
             SetFontSmoothingTypeIfNotAlready(FontSmoothingType.ClearType);
             SetFontSmoothingIfNotAlready(FontSmoothingOrientation.BGR);
         }
         if (FontSmoothing.GetContrast() != (uint)ParseInt(txtContrast.Text, 0))
         {
             FontSmoothing.SetContrast((uint)ParseInt(txtContrast.Text, 0));
             dirty = true;
         }
         if (FontSmoothing.GetAntialiasingEnabled() != cbEnableFontAntialiasing.IsChecked.Value)
         {
             FontSmoothing.SetAntialiasingEnabled(cbEnableFontAntialiasing.IsChecked.Value);
             dirty = true;
         }
         if (dirty)
         {
             UpdateStatus();
         }
     }
     setDefaults = false;
 }
Exemplo n.º 3
0
        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();
                }
            }
        }
Exemplo n.º 4
0
        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();
            }
        }