stumpii / scintillanet.wpf Goto Github PK
View Code? Open in Web Editor NEWA WPF Wrapper around the ScintillaNET v3 control
License: MIT License
A WPF Wrapper around the ScintillaNET v3 control
License: MIT License
Hello,
There is a method incompatibility in ScintillaNET between .NET Framework and .NET Core which
means it needs to be re-targeted if .NET Core needs to be supported (see this issue). As one of my projects using ScintillaNET is also targeting both frameworks, I have gone ahead and created a ScintillaNET fork that supports multi-targeting. It is available here in GitHub and here in NuGet. ScintillaNET.WPF could also support multi-targeting if using this version of ScintillaNET instead.
Now, my project also uses ScintillaNET.WPF, currently as a slightly modified of the project embedded in my solution. However, I was planning to do the same I did with ScintillaNET: fork your repo, make the changes I need, and then release a new NuGet package.
If you are interested in multi-targeting .NET Core and .NET Framework, I could also make the changes I need directly in this repo as pull requests instead.
Regards,
Fernando
Hi,
I am trying to set the logical focus and the keyboard focus within a DocumentForm object in WPF.
This does not seem to work:
this.Scintilla.Scintilla.Focus ();
Keyboard.Focus (this.Scintilla);
Thanks!
When you press for example Ctrl-S in an editor window, a control character (for Ctrl-S it is [SO]) is added to the text. I expected the document to be saved. When I put the focus outside the editor, it works as expected.
In DocumentForm.xaml.cs, the Save(string filePath) method trims the trailing NULL in line:
bw.Write(scintilla.Text.ToCharArray(), 0, scintilla.Text.Length - 1); // Omit trailing NULL
My experience is that that just strips off the last character. Omitting the -1 gives the desired result.
Trying to create the control in XAML, I have set the lexer to Cpp but no syntax highlighting seems to occur. Just a generic white textbox.
<sc:ScintillaWPF Content="{Binding value, UpdateSourceTrigger=PropertyChanged}" Height="300" Lexer="Cpp"/>
Hi!
How can I set the focus to this control programmatically? The .Focus()
method is not working, no matters if the control is at root level of the window or inside a tabcontrol, I must click the editor or press TAB key to set the focus manually.
Any suggestion?
<Window x:Class="Scitest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Scitest"
mc:Ignorable="d"
xmlns:sn="http://scintillanet.codeplex.com"
Title="MainWindow" Height="450" Width="800">
<Grid>
<sn:ScintillaWPF Margin="253,67,234,157" Name="TestEditor"></sn:ScintillaWPF>
<Button Name="TestButton" Margin="305,292,272,47" Click="TestButton_Click">Set the Focus!</Button>
</Grid>
</Window>
private void TestButton_Click(object sender, RoutedEventArgs e)
{
// Not working
TestEditor.Focus();
}
When you File | New, I expect a new document to open and be able to start typing in it. As it is, it does open a new document but I have to explicitly put mouse-focus on it (there may be a keyboard way, haven't found it). In NewDocument()
, there is doc.IsActive = true;
, but I think that only makes it the active document in the document tabs. How would you go about actually focussing the new document so you can start typing right away? I've done quite a bit of research and so far haven't come up with a solution. Just to be clear: I know there is the Focus()
method, but in certain circumstances, like this one, it just doesn't do anything.
This happens fairly often when using the IDE.
File: MainWindow.xaml.cs
Code
private void dockPanel_ActiveContentChanged(object sender, EventArgs e)
{
// Update the main form _text to show the current document
if (ActiveDocument != null)
{
this.Title = string.Format(CultureInfo.CurrentCulture, "{0} - {1}", ActiveDocument.Title, Program.Title);
MyFindReplace.Scintilla = ActiveDocument.Scintilla.Scintilla;
ActiveDocument.FindReplace = MyFindReplace; // Exception happens here ActiveDocument is null
}
else
this.Title = Program.Title;
}
Stack trace
at SCide.WPF.MainWindow.dockPanel_ActiveContentChanged(Object sender, EventArgs e) in E:\AlsProjects\Spi-o-Matic\solution\SCide.WPF\MainWindow.xaml.cs:line 480
at Xceed.Wpf.AvalonDock.DockingManager.OnActiveContentChanged(DependencyPropertyChangedEventArgs e)
at Xceed.Wpf.AvalonDock.DockingManager.OnActiveContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Xceed.Wpf.AvalonDock.DockingManager.OnLayoutRootPropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at Xceed.Wpf.AvalonDock.Layout.LayoutElement.RaisePropertyChanged(String propertyName)
at Xceed.Wpf.AvalonDock.Layout.LayoutRoot.InternalSetActiveContent(LayoutContent currentValue, LayoutContent newActiveContent)
at Xceed.Wpf.AvalonDock.Layout.LayoutRoot.set_ActiveContent(LayoutContent value)
at Xceed.Wpf.AvalonDock.Layout.LayoutContent.set_IsActive(Boolean value)
at Xceed.Wpf.AvalonDock.Controls.LayoutDocumentControl.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.Input.FocusManager.OnFocusedElementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.Input.FocusManager.SetFocusedElement(DependencyObject element, IInputElement value)
at System.Windows.Forms.Integration.WindowsFormsHost.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndHost.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I discovered an issue likely pertaining to the docking manager. When you drag a window outside the container (i.e., make it a floating window), it cannot be saved. At this point, the ActiveDocument
property in MainWindow.xaml.cs
returns null
.
Also, when you create a new tab group, you also cannot save documents from there.
I wonder if this is by design?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.