📄 ambienceservice.cs
字号:
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version value="$version"/>
// </file>
using System;
using ICSharpCode.Core.AddIns;
using ICSharpCode.Core.Properties;
using ICSharpCode.Core.Services;
namespace ICSharpCode.SharpDevelop.Services
{
public class AmbienceService : AbstractService
{
static readonly string ambienceProperty = "SharpDevelop.UI.CurrentAmbience";
static readonly string codeGenerationProperty = "SharpDevelop.UI.CodeGenerationOptions";
public IProperties CodeGenerationProperties {
get {
PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
return (IProperties)propertyService.GetProperty(codeGenerationProperty, new DefaultProperties());
}
}
public bool GenerateDocumentComments {
get {
return CodeGenerationProperties.GetProperty("GenerateDocumentComments", true);
}
}
public bool GenerateAdditionalComments {
get {
return CodeGenerationProperties.GetProperty("GenerateAdditionalComments", true);
}
}
public bool UseFullyQualifiedNames {
get {
return CodeGenerationProperties.GetProperty("UseFullyQualifiedNames", true);
}
}
public AmbienceReflectionDecorator CurrentAmbience {
get {
PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
string language = propertyService.GetProperty(ambienceProperty, "CSharp");
IAmbience ambience = (IAmbience)AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/Ambiences").BuildChildItem(language, this);
if (ambience == null) {
IMessageService messageService =(IMessageService)ServiceManager.Services.GetService(typeof(IMessageService));
messageService.ShowError("${res:ICSharpCode.SharpDevelop.Services.AmbienceService.AmbienceNotFoundError}");
return null;
}
return new AmbienceReflectionDecorator(ambience);
}
}
void PropertyChanged(object sender, PropertyEventArgs e)
{
if (e.Key == ambienceProperty) {
OnAmbienceChanged(EventArgs.Empty);
}
}
public override void InitializeService()
{
PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
propertyService.PropertyChanged += new PropertyEventHandler(PropertyChanged);
}
protected virtual void OnAmbienceChanged(EventArgs e)
{
if (AmbienceChanged != null) {
AmbienceChanged(this, e);
}
}
public event EventHandler AmbienceChanged;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -