A terminal-like WPF textbox? - wpf

I am looking for an embeddable interactive console. I want the user to be able to type in some custom commands, and the application to write command responses in it. Would be awesome if it would understand powershell or python, ans supports command completion.
I already built my own bash-like terminal, but I do not want to totally reinvent the wheel, so I'm looking for a third-party stable component before going any further with it.
If someone is interested, I found PoshConsole, a powershell console:
http://poshconsole.codeplex.com/
Thanks
PS: you can find a screen of what I am trying to achieve here:
http://www.hiboox.fr/go/images-100/codein,0a2809b63e05c3d0cac678962e0e3d5a.jpg.html

Nothing found since I asked the question, and to stick with the "do it yourself" way of thinking:
I wrote a terminal-like control in .NET.
http://wpfterminal.codeplex.com/
You can see an example in this screenshot (terminal is integrated in a bigger project) :
http://images4.hiboox.com/images/4210/0a2809b63e05c3d0cac678962e0e3d5a.jpg
Basic mechanisms
Actually what I did was to define a lastPromptIndex integer, and everytime a user presses the ENTER key and a new prompt appears, this value is updated.
After that, it's simple, you just need to process any text input before the textbox validates the input. If the textbox caret was located before your lastPromptIndex, you need to raise an error (usually a beep sound) and you must invalidate the text input, so nothing is written in the textbox. I also automatically set the caret position to the end of the textbox, so the user can immediatly input some text.
Extensions
You can enable command completion by looking for an "UP key" input if the caret is before the prompt index, etc. What you need is just to process input events before they are sent to the textbox internal mechanisms. I don't know if SWT controls allow it, but I'm pretty sure they do, like any serious UI system.

Related

Best method in pyqt for assigning text to a variable according to whether or not the text box has been edited

I'm currently in the process of coding a GUI for one of the scientific instruments in my research lab. I have mild python experience, however pyqt is entirely new to me. I'm currently working on slots and signals for much of the interface and my current problem is one aspect of text edit.
You can see in the attached photo that I have placeholder text set in the text box for 'Path'. Normally this will never change, but I need it to have the capability to accept input if the user decides to change it. I need to assign this, whether it be the placeholder text or the user input, to a variable titled 'filePath'. What is my best method to accomplish this?
I was considering using an if statement that determines whether or not the text input has changed, but I cannot find the command on any website by which to do this. If there's a better method, I am open to that as well. Thanks for any help!

JAWS not reading AccessibilityDescriptionfor a button

I have a number of buttons on a WinForms User Control. I have given each button an AccessibilityName and an AccessibilityDescription. JAWS will read the AccessibilityName however doesn't read the description even if I press [INSERT+B]. I'm unsure why this is happening or if I need to set the AccessibilityRole.
Any help would be appreciated.
At the time of writing this, attempts to expose supplemental
information through the Button.AccessibleDescription property
typically do not work. This is because the AccessibleDescription
string value does not get exposed through the UIA properties that are
commonly used for supplemental information, (for example, the UIA
FullDescription or HelpText properties).
Source: https://learn.microsoft.com/en-us/accessibility-tools-docs/items/WinForms/Button_HelpText
The linked page suggests using Button.QueryAccessibilityHelp event handler.
I am not sure but this bug fix may be relevant, but I am not familiar enough with WinForms accessibility to know if this is the same issue.

how can I get selected text

I wonder how can I get selected text. (usually done by mouse dragging or shift + arrow on text)
From notepad, word, Internet explorer addressbar, etc.
sending WM_GETTEXT just copy caption, and unable to copy selected text while I rename file name on file explorer.
So, I am considering simulating Ctrl+C. but simulating key strokes seems not a good idea. because it will make side effects.(in case Ctrl+C assigned to other functionality)
I tried following code, wishing copy currently selected text into clipboard
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_TEXT,0);
CloseClipboard();
but no luck, it just emptyclipboard.
how can I copy currently selected text?
(simulating Ctrl+c with no unpredictable effect)
thanks!
(my environments are Windows 7, C programming language, winapi)
I'm not sure if there is a general answer because the various applications you mentioned use different window classes.
For Notepad in particular: The display area seems to be a simple EDIT control. You can use the EM_GETSEL message to retrieve the begin and end of selected text, then use WM_GETTEXT to get the complete text. Do not use GetWindowText because it does not work with windows of another process.
In general, you can try using the WM_COPY message. This should place the text in the clipboard. However, the result depends on how that message handler is implemented in the other application.
You are setting the clipboard using SetClipboardData(CF_TEXT, 0) -- MSDN Doc says that if the second parameter is NULL, the window must process the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages; the same article has a comment on how to allocate Global memory, fill it with the required text and pass it on to SetClipboardData().

Shortcut and bar code scanner

In my WPF Application I have a menu. One of the option from that menu has a shortcut assigned: CTRL+B. In my application I also need a possibility to scan a bar code using bar code scanner.
My bar code is configured in a way where CTRL+B combination is used to specify the bar code starting point. In other words: Bar code scanner sends CTRL+B combination to tell me: "Hey I now starting to send you the bar code numbers".
I listening for the bar code input on Window_PreviewKeyDown event handler. This however does not work because firstly, application recognizes that CTRL+B was pressed and wants to call the command's executed method associated with the shortcut CTRL+B. Is there a way to have a solution for this issue without changing the shortcut?
You may change the barcode scanner configuration to send some other keys at start.
Most barcode scanners provide a configuration manual where you can set such settings.
Please note that handling specific characters from barcode scanners can cause some trouble when the user changes his scanner or you have multiple users using different scanners.

WPF command not executable

I have a button on a toolbar that has its command set to "MyControl.Print" (for example).
In the control the command is added to the command bindings including both the Execute and CanExecute.
The control is within a window with other controls docked appropriately.
I am finding that for the Print button to be enabled I have to "select" MyControl first which does not provide a good user experience and indeed causes various "bugs" being raised and lots of confusion.
Is there a way that I can ensure that the button is enabled whether or not the control has been "selected"?
Since the CanExecute doesn't fire, I think you might be looking at the major downside to RoutedCommands - the way they tunnel and bubble can leave a highly composed interface unable to have commands arrive anywhere useful. For this reason we ended up moving to DelegateCommands from (I think) the Microsoft CAG. Not any of the other stuff, just the commands. Works a lot better, and isn't tied in to the interface so tightly.
Oh, the other response raises a good point. I assumed you meant that to ever print, your MyControl needed to have keyboard focus. Is it only the first time and after that it works?
I recommend http://msdn.microsoft.com/en-us/library/ff921126(PandP.20).aspx as a pretty good starting point. You don't have to worry too much about the IActiveAware up front, since you're hoping for this command to be available all the time (or at least let its availablity be determined by CanExecute).
CommandManager.InvalidateRequerySuggested will force the command manager to re-call all of your CanExecute methods and should disable the button. Perhaps call that onload?

Resources