Posted 6 years ago
by (Anonymous)
Version: 18.1.0673
Platform: .NET 4.7
Environment: Windows 10 (64-bit)

If you create a WPF app and add a WPF SyntaxEditor control, it sets the colours as per the current theme as expected.
However, if you create a WinForms app and add a WPF SyntaxEditor as the child of the ElementHost control, all theme aspects are correct appart from the scrollbars.
- Create a WinForms application called 'WindowsFormsApp1' and references for ActiproSoftware.Shared / SyntaxEditor / Text WPF dlls.
- Add the file from the Actipro Samples 'Dark.vssettings' as an embedded resource
- Copy the following code into 'WindowsFormsApp1.cs'
- Run the application, and you should see the MetroDark theme is used for everything except the scrollbars?
using ActiproSoftware.Windows.Controls.SyntaxEditor;
using ActiproSoftware.Windows.Controls.SyntaxEditor.Highlighting;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation;
using ActiproSoftware.Windows.Themes;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private ElementHost elementHost;
private SyntaxEditor syntaxEditor;
public Form1()
{
InitializeComponent();
elementHost = new ElementHost();
this.Controls.Add(elementHost);
elementHost.Dock = DockStyle.Fill;
syntaxEditor = new SyntaxEditor();
elementHost.Child = syntaxEditor;
}
protected override void OnLoad(EventArgs e)
{
ThemeManager.BeginUpdate();
try
{
ThemeManager.AreNativeThemesEnabled = true;
ThemeManager.CurrentTheme = ThemeName.MetroDark.ToString();
}
finally
{
ThemeManager.EndUpdate();
}
var classificationTypes = AmbientHighlightingStyleRegistry.Instance.ClassificationTypes.ToArray();
foreach (var classificationType in classificationTypes)
AmbientHighlightingStyleRegistry.Instance.Unregister(classificationType);
new DisplayItemClassificationTypeProvider().RegisterAll();
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApp1.Dark.vssettings"))
{
AmbientHighlightingStyleRegistry.Instance.ImportHighlightingStyles(stream);
}
CommonImageSourceProvider.DefaultImageSet = CommonImageSet.MetroDark;
base.OnLoad(e);
}
}
}
[Modified 6 years ago]