/// <summary> /// Given the root to an element tree, synthesize a "yellow box" bitmap to describe it /// </summary> /// <param name="rootElement">The root element for the tree</param> /// <returns>A bitmap representing the element tee (normalized to having the app window at location (0,0)</returns> internal static Bitmap SynthesizeBitmapFromElements(this IA11yElement rootElement) { const int penWidth = 4; // This is the same width as our highlighter if (rootElement == null) { return(null); } Rectangle rootBoundingRectangle = rootElement.BoundingRectangle; // Synthesize the bitmap bool isHighContrast = HighContrast.Create().IsOn; Color brushColor = isHighContrast ? SystemColors.Window : Color.DarkGray; Color penColor = isHighContrast ? SystemColors.WindowFrame : Color.Yellow; Bitmap bitmap = new Bitmap(rootBoundingRectangle.Width, rootBoundingRectangle.Height); using (Graphics graphics = Graphics.FromImage(bitmap)) using (SolidBrush brush = new SolidBrush(brushColor)) using (Pen pen = new Pen(penColor, penWidth)) { graphics.FillRectangle(brush, 0, 0, rootBoundingRectangle.Width, rootBoundingRectangle.Height); graphics.TranslateTransform(-rootBoundingRectangle.Left, -rootBoundingRectangle.Top); AddBoundingRectsRecursively(graphics, pen, rootElement); } return(bitmap); }
public async Task <object> TurnOffHighContrast(dynamic input) { var highContrast = new HighContrast(); highContrast.IsHighContrastOn = false; highContrast.Apply(); return(true); }
public async Task <object> TurnOnHighContrast(dynamic input) { var highContrast = new HighContrast(); highContrast.IsHighContrastOn = true; highContrast.Theme = HighContrast.ColorSchemes.HighContrastBlack; highContrast.Apply(); return(true); }
/// <summary> /// A previous marshalling bug caused crashing if multiple HighContrasts were created in rapid succession /// </summary> private void TestMultipleInstantionations() { Logger.Debug("Entering TestMultipleInstantionations"); var hc3 = new HighContrast(); for (int i = 0; i < 10; i++) { Logger.Debug("creating HighContrast #" + i.ToString()); new HighContrast(); } }
public void PollHighConttrastUntilSettingIs(bool until) { Logger.Debug("Entering PollHighConttrastUntilSettingIs"); HighContrast hc = new HighContrast(); do { hc = new HighContrast(); Logger.Debug(string.Format("HighContrast setting: {0}", hc.IsHighContrastOn)); } while (until != hc.IsHighContrastOn); }
public async void Update_ColorOnPreview(int index, BandTheme _BandTheme) { switch (index) { case -1: try { while (await ContentIsLoaded() == false) { await Task.Delay(100); System.Diagnostics.Debug.WriteLine("Task Delayed"); } Base.Set_Color(_BandTheme); HighContrast.Set_Color(_BandTheme); LowLight.Set_Color(_BandTheme); Hightlight.Set_Color(_BandTheme); Muted.Set_Color(_BandTheme); Secondary.Set_Color(_BandTheme); } catch (Exception e) { System.Diagnostics.Debug.Write(e); } break; case 0: Base.Set_Color(_BandTheme); break; case 1: HighContrast.Set_Color(_BandTheme); break; case 2: LowLight.Set_Color(_BandTheme); break; case 3: Hightlight.Set_Color(_BandTheme); break; case 4: Muted.Set_Color(_BandTheme); break; case 5: Secondary.Set_Color(_BandTheme); break; } }
private void TestEmptyStringTheme() { var highContrast = new HighContrast(); highContrast.Theme = HighContrast.ColorSchemes.HighContrastBlack; highContrast.Apply(); Assert(new HighContrast().Theme == HighContrast.ColorSchemes.HighContrastBlack); highContrast.Theme = HighContrast.ColorSchemes.HighContrastWhite; highContrast.Apply(); Assert(new HighContrast().Theme == HighContrast.ColorSchemes.HighContrastWhite); highContrast.Theme = HighContrast.ColorSchemes.Default; // value of Default is empty string highContrast.Apply(); Assert(new HighContrast().Theme != HighContrast.ColorSchemes.Default); // This will NOT equal because the Theme value is still HighContrastWhite. }
/* * private static void TurnOnDefaultHighContrast() * { * var highContrast = new HighContrast(); * highContrast.IsHighContrastOn = true; * highContrast.Theme = HighContrast.ColorSchemes.HighContrastBlack; * highContrast.Apply(); * } */ private void ToggleHighContrast() { Logger.Debug("Entering ToggleHighContrast"); HighContrast highContrast = new HighContrast(); highContrast.IsHighContrastOn = true; highContrast.Theme = HighContrast.ColorSchemes.HighContrastBlack; highContrast.Apply(); Logger.Debug("High contrast should be ON: HighContrastBlack"); Assert(new HighContrast().IsHighContrastOn == true); PollHighConttrastUntilSettingIs(true); WaitForContrastChange(); highContrast.IsHighContrastOn = false; highContrast.Apply(); PollHighConttrastUntilSettingIs(false); Assert(new HighContrast().IsHighContrastOn == false); Logger.Debug("High contrast should be OFF"); WaitForContrastChange(); highContrast.IsHighContrastOn = true; highContrast.Theme = HighContrast.ColorSchemes.HighContrastWhite; highContrast.Apply(); PollHighConttrastUntilSettingIs(true); Assert(new HighContrast().IsHighContrastOn); Logger.Debug("High contrast should be ON: HighContrastWhite"); WaitForContrastChange(); highContrast.IsHighContrastOn = false; highContrast.Apply(); PollHighConttrastUntilSettingIs(false); Assert(new HighContrast().IsHighContrastOn == false); Logger.Debug("High contrast should be OFF"); WaitForContrastChange(); }