/// <summary> /// Creates a new CodeLanguage Implementation for AHK v 1.1 /// </summary> public CodeLanguageAHKv1() : base("ahk-v1.1") { Name = "AHK v 1.1"; SELFREF_CAN_BE_OMITTED = false; SUPPORTS_STARTUP_CODEDOCUMENT = true; if(File.Exists(_settingsFilePath)){ _settings = SerializerHelper.DeserializeObjectFromFile<AHKSettings>(_settingsFilePath); _settings.SettingsSerialisationPath = _settingsFilePath; }else{ // load default settings _settings = new AHKSettings(_settingsFilePath); _settings.Save(); } var viewmodelMapping = ServiceLocator.Instance.Resolve<IWorkBenchService>().MappingService; viewmodelMapping.RegisterMapping(typeof(CodeLanguageSettingsViewModel), typeof(CodeLanguageSettingsView)); #region Define Language Syntax // todo // those data is actually thougt to be read out of confic files // this.LanguageKeywords.AddRange(new CodeKeyWord[] { new CodeKeyWord("if"), new CodeKeyWord("else"), new CodeKeyWord("class"), new CodeKeyWord("new"), new CodeKeyWord("this"),new CodeKeyWord("base"), new CodeKeyWord("extends"), new CodeKeyWord("return"), new CodeKeyWord("break"), new CodeKeyWord("continue"), new CodeKeyWord("global"), new CodeKeyWord("static"), new CodeKeyWord("local"), new CodeKeyWord("byref"), new CodeKeyWord("GoTo"), new CodeKeyWord("GoSub"), new CodeKeyWord("loop"), new CodeKeyWord("for"), new CodeKeyWord("while"), new CodeKeyWord("in") }); this.LanguageDirectives.AddRange(CodeLanguageAHKBuildinMethods.GetDirectives()); var buildins = CodeLanguageAHKBuildinMethods.ReadMembers(); BuildInMembers.AddRange(buildins); #endregion #region Load Syntax Definition of AHK IHighlightingDefinition customHighlighting; Brush b = new SolidColorBrush(Colors.GreenYellow); var greenYellowBrush = new HighlightingBrushStaticColor(b); var orangeBrush = new HighlightingBrushStaticColor(new SolidColorBrush(Colors.Orange)); var sr = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Syntax\\Autohotkey.xshd")); using(var reader = new XmlTextReader(sr)) { customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd. HighlightingLoader.Load(reader, HighlightingManager.Instance); } var commandColor = new HighlightingColor() { Foreground = orangeBrush, FontWeight = FontWeights.Bold }; var directiveColor = new HighlightingColor() { Foreground = greenYellowBrush }; string regexstr = ""; foreach(var m in buildins) { var command = m as CodeMemberMethodExAHK; if(command != null && command.IsTraditionalCommand && !command.IsFlowCommand) { //regexstr += command.Name.ToLowerInvariant() + "|"; // Add custom but static highligning rule customHighlighting.MainRuleSet.Rules.Add(new HighlightingRule() { Color = commandColor, Regex = GetRegexForCommand(command.Name.ToLowerInvariant()) }); } } HighlightingManager.Instance.RegisterHighlighting("ahk-v1.1", new string[] { ".ahk" }, customHighlighting); #endregion _emptyTemplate = new ProjectTemplateEmpty(this); _templates = new ProjectTemplate[] { _emptyTemplate, new ProjectTemplateDemo(this) }; }
public ProjectTemplateVM(ProjectTemplate template) { _template = template; }