Fixed problem with scroll wheel impacting both the xquery window and the source window.
This commit is contained in:
Родитель
c28419059d
Коммит
1a1bdd3f66
|
@ -314,13 +314,10 @@ namespace XppReasoningWpf
|
|||
|
||||
private void QueryDirectoryChanged(object sender, FileSystemEventArgs e)
|
||||
{
|
||||
// In this simple solution, we reread all the files in the directory
|
||||
IList<QueryEntry> queries = new List<QueryEntry>();
|
||||
|
||||
if (e.ChangeType == WatcherChangeTypes.Deleted)
|
||||
{
|
||||
// Check if we have one in the model and delete if so.
|
||||
var entry = this.Queries.Where(q => q.Path == e.Name).FirstOrDefault();
|
||||
var entry = this.Queries.Where(q => q.Path == e.FullPath).FirstOrDefault();
|
||||
if (entry != null)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
|
@ -336,20 +333,21 @@ namespace XppReasoningWpf
|
|||
}
|
||||
else if (e.ChangeType == WatcherChangeTypes.Renamed)
|
||||
{
|
||||
var entry = this.Queries.Where(q => q.Path == e.Name).FirstOrDefault();
|
||||
var renamedArgs = e as RenamedEventArgs;
|
||||
var entry = this.Queries.Where(q => q.Path == renamedArgs.OldFullPath).FirstOrDefault();
|
||||
if (entry != null)
|
||||
{
|
||||
entry.Path = e.Name;
|
||||
entry.Path = renamedArgs.FullPath;
|
||||
}
|
||||
}
|
||||
else if (e.ChangeType == WatcherChangeTypes.Changed)
|
||||
{
|
||||
// This event may happen when the file is created, or at any time after than
|
||||
// when an existing file is actually changed.
|
||||
var entry = this.Queries.Where(q => q.Path == e.Name).FirstOrDefault();
|
||||
var entry = this.Queries.Where(q => q.Path == e.FullPath).FirstOrDefault();
|
||||
if (entry == null)
|
||||
{
|
||||
entry = new QueryEntry() { Path = e.Name, Description = this.GetDescription(e.FullPath) };
|
||||
entry = new QueryEntry() { Path = e.FullPath, Description = this.GetDescription(e.FullPath) };
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
this.Queries.Add(entry);
|
||||
|
@ -361,6 +359,8 @@ namespace XppReasoningWpf
|
|||
entry.Description = GetDescription(e.FullPath);
|
||||
}
|
||||
}
|
||||
|
||||
this.OnPropertyChanged("Queries");
|
||||
}
|
||||
|
||||
public Model()
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace XppReasoningWpf
|
|||
public class QueryEditor : SourceEditor
|
||||
{
|
||||
private static readonly Snippets snippets = new Snippets();
|
||||
//public Session Session { get; }
|
||||
|
||||
public QueryEditor(ViewModels.ViewModel viewModel)
|
||||
:this()
|
||||
|
@ -54,7 +53,7 @@ namespace XppReasoningWpf
|
|||
ICSharpCode.AvalonEdit.Search.SearchPanel.Install(this.TextArea);
|
||||
|
||||
this.IsReadOnly = false;
|
||||
this.PreviewMouseWheel += QueryEditor_PreviewMouseWheel;
|
||||
// this.PreviewMouseWheel += QueryEditorMouseWheelHandler;
|
||||
|
||||
// Adding to the context menu...
|
||||
var contextMenuItems = (this.ContextMenu.ItemsSource as Control[]).ToList();
|
||||
|
@ -62,7 +61,6 @@ namespace XppReasoningWpf
|
|||
var templatesMenuItem = new MenuItem
|
||||
{
|
||||
Header = "Snippets"
|
||||
// Command = ApplicationCommands.Copy,
|
||||
};
|
||||
contextMenuItems.Add(templatesMenuItem);
|
||||
|
||||
|
@ -84,7 +82,7 @@ namespace XppReasoningWpf
|
|||
this.ContextMenu.ItemsSource = contextMenuItems;
|
||||
}
|
||||
|
||||
private void QueryEditor_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
protected override void MouseWheelHandler(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl))
|
||||
{
|
||||
|
|
|
@ -130,24 +130,6 @@ namespace XppReasoningWpf
|
|||
}
|
||||
}
|
||||
|
||||
private void SourceEditor_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl))
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
if (Properties.Settings.Default.SourceFontSize < 48)
|
||||
Properties.Settings.Default.SourceFontSize += 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Properties.Settings.Default.SourceFontSize < 48)
|
||||
Properties.Settings.Default.SourceFontSize -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SourceEditor()
|
||||
{
|
||||
this.TextArea.Caret.PositionChanged += (object sender, EventArgs a) =>
|
||||
|
@ -159,7 +141,7 @@ namespace XppReasoningWpf
|
|||
// Install the search panel that appears in the upper left corner.
|
||||
ICSharpCode.AvalonEdit.Search.SearchPanel.Install(this.TextArea);
|
||||
|
||||
this.PreviewMouseWheel += SourceEditor_MouseWheel;
|
||||
this.PreviewMouseWheel += MouseWheelHandler;
|
||||
this.IsReadOnly = true;
|
||||
|
||||
var fontFamilyBinding = new Binding("SourceFont")
|
||||
|
@ -247,5 +229,23 @@ namespace XppReasoningWpf
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual void MouseWheelHandler(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (Keyboard.IsKeyDown(Key.LeftCtrl))
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
if (Properties.Settings.Default.SourceFontSize < 48)
|
||||
Properties.Settings.Default.SourceFontSize += 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Properties.Settings.Default.SourceFontSize < 48)
|
||||
Properties.Settings.Default.SourceFontSize -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace XppReasoningWpf
|
|||
{
|
||||
using ICSharpCode.AvalonEdit.Folding;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
class XppSourceEditor : SourceEditor
|
||||
{
|
||||
|
@ -31,5 +32,7 @@ namespace XppReasoningWpf
|
|||
xppFoldingStrategy.UpdateFoldings(xppFoldingManager, this.Document);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче