protected override WriteResult Write(OpenXMLWpfMathRenderer renderer, StyledAtom item) { bool foregroundPushed = false; bool backgroundPushed = false; if (item.Foreground is System.Windows.Media.SolidColorBrush scbf) { var c = scbf.Color; renderer.PushForegroundColor(c.R, c.G, c.B); foregroundPushed = true; } if (item.Background is System.Windows.Media.SolidColorBrush scbb) { var c = scbb.Color; renderer.PushBackgroundColor(c.R, c.G, c.B); backgroundPushed = true; } renderer.Write(item.RowAtom); if (foregroundPushed) { renderer.PopForegroundColor(); } if (backgroundPushed) { renderer.PopBackgroundColor(); } return(WriteResult.Completed); }