Visual Studio Extension: Pass Selected Text to WPF Window - wpf

I've got a basic extension that - highlights text (currently an xml open tag ) and provides a context menu button which will open a WPF form. What I'd love is an easy way to pass the content of ... to the form when the button is clicked (and back from the form later). What would be fine as well is doing the same with selected text (select the text, hit the button on the context menu...). The thing is, I can't find a reasonably easy way to pass text (selected or processed) to the form from the editor window to the form.
Is there an easy way to do this?

Related

Winform - multi line Textbox changes scroll position on refresh

I have a winform application that has a textbox, multiline, readonly where I display a kind of log that is refreshed each second. The text box can have more than 100 lines of text.
On each refresh, if the user scroll and selection are lost.
I need a way to allow to the user to keep the scroll and selected text.
I tried to replace only the line that changes - didn't work (using Lines property)
I tried to save the selection before update and re-select it after - didn't work.
I tried to use RichTextBox instead - didn't work.
Anyone did something like this before? Is any library (custom control) I can use instead?
Thank you.

Creating select event on text component and creating custom view upon text

My aim is create custom event on Text Component. When I choose one word or when I highlight couple of words, event should fire to open a "buble view" upon, below or near that specific text.
I have found this package here react-native-selectable-text but it does not provide the functionality that I want.
https://github.com/Astrocoders/react-native-selectable-text
Two steps
1) How to create that selectable action. I am not talking about Text prop selectable which only opens a menu of copy, paste, select all options. I want to open a view like that menu. A view which will contain information about highlighted text.
2) How I can render a small box(View comp.) with specific coordinates. Like when I choose that text, box has to be rendered upon or below of the text.
I know direct manipulation. But hard part is how am I going to give that select&highlight action to text component?

How know if right click is on a "text being edited" not/before "text changed" event in winforms?

My question might be simple but I couldn't find specific answer on web.
I have a winforms application with a grid inside, in which I have implemented a context menu to be shown on right click on cells. These cells include text elements that can be edited. When user clicks or double clicks on the cell, the text can be edited and that's what I want. The problem is when the text is in edit mode and user right clicks on it again, 2 context menus are shown on each other. One is my context menu and the other is windows right click on text including options like copy, paste etc.
I wonder if there is any event like "text being edited" or "windows default context menu opened" that can be used for such scenarios? Or what is the proper way of solving this problem, which I guess must be a common one.
In these cases I want to show only the windows right-click menu, not mine.
Perhaps you need the Control.GotFocus event: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.gotfocus%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
You could look for focus, then prevent right clicks in the control until the control has lost focus (Control.LostFocus). If the control gets focus from a right click, then you could open your context menu (I think).

DevExpress DateEdit Force user to use menu popup

I have a WinForms app that uses this control and I would like to prevent the user from typing in a date. We want to make them have to use the popup calendar to make the date selection.
I tried setting ReadOnly of course but that puts the whole control into the read only state.
Our version of DevExpress is: 9.1.9.0
You can accomplish this task using the RepositoryItemButtonEdit.TextEditStyle property.
Assign the DisableTextEditorvalue with this property. In this mode a button editor is displayed in its normal way. However, editing and selecting text is not allowed.
Code snippet:
dateEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;

How to interact with other application forms

I am looking for a way to once I see a form by Name add a button to that form and when the user clicks the added button, pull information from the form. For example, if I see the for title - "Stack Overflow - Wnidows Internet Explorer" I would add a button "MyButton" on the form, and when that button is clicked, I would "pull" the information from the "search" box. It should work on Web or Win forms.
Any help would be greatly appreicated.
I found my answer
You need to get the window handle to the form in question.
To put the button on another form you need to create the button and set its owner to the other window and set the buttons window position.
You can use the same window handle to enumerate the child windows to get the text if its an edit control.

Resources