Skip to content

Commit

Permalink
fixed: error when opening a file associated with LogWatch
Browse files Browse the repository at this point in the history
  • Loading branch information
SHSE committed Jun 18, 2013
1 parent f552acb commit ab9f417
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions LogWatch/Features/Formats/LexPresetView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Input;
using System.Xml;
using ICSharpCode.AvalonEdit;
Expand All @@ -19,14 +20,14 @@ public LexPresetView() {
(sender, args) =>
this.ShowCompletionWindow(
args,
this.ViewModel.SegmentCodeCompletion,
this.ViewModel.SegmentCodeCompletion,
this.SegmentCodeEditor);

this.RecordCodeEditor.TextArea.TextEntered +=
(sender, args) =>
this.ShowCompletionWindow(
args,
this.ViewModel.RecordCodeCompletion,
this.ViewModel.RecordCodeCompletion,
this.RecordCodeEditor);

this.SegmentCodeEditor.TextArea.TextEntering += this.OnTextAreaOnTextEntering;
Expand All @@ -39,7 +40,7 @@ public LexPresetViewModel ViewModel {

private void ShowCompletionWindow(
TextCompositionEventArgs args,
IEnumerable<LexCodeCompletionData> lexCodeCompletionDatas,
IEnumerable<LexCodeCompletionData> lexCodeCompletionDatas,
TextEditor editor) {
if (args.Text == " " && Keyboard.IsKeyDown(Key.LeftCtrl) || args.Text == "." || args.Text == "<" ||
args.Text == "{") {
Expand All @@ -62,8 +63,11 @@ private void OnTextAreaOnTextEntering(object sender, TextCompositionEventArgs ar
}

private static void RegisterDefinition(string fileName) {
var definition = HighlightingLoader.Load(new XmlTextReader(fileName), HighlightingManager.Instance);
HighlightingManager.Instance.RegisterHighlighting(definition.Name, new string[0], definition);
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LogWatch." + fileName))
if (stream != null) {
var definition = HighlightingLoader.Load(new XmlTextReader(stream), HighlightingManager.Instance);
HighlightingManager.Instance.RegisterHighlighting(definition.Name, new string[0], definition);
}
}
}
}
4 changes: 2 additions & 2 deletions LogWatch/LogWatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@
<SubType>Designer</SubType>
</None>
<AppDesigner Include="Properties\" />
<Content Include="Lex.xshd">
<EmbeddedResource Include="Lex.xshd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config">
Expand Down

0 comments on commit ab9f417

Please sign in to comment.