private void button1_Click(object sender, EventArgs e) { //Create Word document. Document document = new Document(); //Load the file from disk. document.LoadFromFile(@"..\..\..\..\..\..\Data\Template_Docx_2.docx"); //Set the background type as Gradient. document.Background.Type = BackgroundType.Gradient; BackgroundGradient Test = document.Background.Gradient; //Set the first color and second color for Gradient. Test.Color1 = Color.White; Test.Color2 = Color.LightBlue; //Set the Shading style and Variant for the gradient. Test.ShadingVariant = GradientShadingVariant.ShadingDown; Test.ShadingStyle = GradientShadingStyle.Horizontal; String result = "Result-SetGradientBackground.docx"; //Save to file. document.SaveToFile(result, FileFormat.Docx2013); //Launch the MS Word file. WordDocViewer(result); }
protected override void RenderOverride(ConsoleBuffer buffer) { base.RenderOverride(buffer); ConsoleColor color = EffectiveColor, background = EffectiveBackground; for (int i = 0; i < _lines.Length - 1; i++) { string line = _lines[i]; buffer.FillBackgroundRectangle(0, i, line.Length, 1, BackgroundGradient?.GetColor(i) ?? background); buffer.DrawString(0, i, ColorGradient?.GetColor(i) ?? color, line); } }
private void UpdateTheme() { BackgroundGradient.InvalidateSurface(); }