I copied some code from here to make an extension compatible with Visual Studio 2019 to replace the built-in outlining because it does not collapse the curly braces in catch & finally block.
Now the extension works fine as the picture shows below.
But there is only one thing I'm not satisfied with. When I move the mouse to the collapsed part, it just shows plain text tooltip without any color or format.
I would like to make the tooltip look like the built-in one. But I don't know where to start.
I did some research about this. I may need to change the hoverText in this code.
return new TagSpan<IOutliningRegionTag>(span, new OutliningRegionTag(false, false, GetCollapsedText(), hoverText));
I think it might involve with Classification, ITooltipService or something else.
I'm new to this, could anyone give me some advice? Some demo code or document would be great help. Thanks.
Code is here: CSharpOutline2019
After a night long research, I finally found a solution and achieved my goal.
In case anyone would be interested with this question, I'll try to exlpain how it works, giving a general idea.
Import IProjectionBufferFactoryService to create the hover TextBuffer
Import ITextEditorFactoryService to create a IWpfTextView to show the hover content
Replace the parameter hoverText with IWpfTextView in the code I mentioned above
return new TagSpan<IOutliningRegionTag>(span, new OutliningRegionTag(false, false, GetCollapsedText(), hoverText));
That's pretty much it. And I found the solution here.
The extension works great, the tooltip looks just the same as the default one.
The complete code will be uploaded to CSharpOutline2019 soon.
Related
What the title says.
I don't mind them being in the "Error List" because they're only marked as "Messages" so they can easily be filtered, but I'd like to hide the dots in the code.
To turn off the "Based on recent edits" stuff, go to turn off IntelliCode suggestions.
Per the docs:
If you wish to turn it off, choose Tools > Options, IntelliCode General tab, and then switch C# suggestions to Disabled
This will turn off "Based on Recent edits" while still leaving on the other stuff like code styles/autocomplete/etc.
How to hide Intellisense “based on recent edits” suggestions?
If you want to hide such suggestion in Intellisense(show as a dot), you should add this below on the top of every cs file:
#pragma warning disable xxx(suggestion ID)
Or use #pragma warning disable to disable every suggestion.
For an example, I have make a similar sample:
================================================================
And usually to remove that Intellisense Suggestion, you should enter Tools-->Options-->Text Editor-->C#-->Code Style and then find such suggestion message and change its Severity from Suggestion to Refactoring Only. With this, you could remove such Suggestion on Code Editor.
Since I did not know your specific suggestion message(based on recent edits) and the ID and also not sure whether such suggestion are in the Code Style menu, so I suggest you could try my first solution.
Note that: So far, no matter which way you suppress the suggestion, removing dot in the Code Editor will also remove the message in the Error List. They are unified, you cannot suppress the IntelliSense in the Code Editor and save the message in the Error List.
Besides, if you still want this,you could suggest a feature on our User Voice Forum.
I have a WinForms app that I am currently implementing a translation engine in. What I have so far is a bunch of text documents that follow the syntax like:
messages.manualupdate="There is a manual update available for ProgName.\n\nDo you want to update to version {0}.{1}.{2}{3}?"
messages.errorcopy="Clicking OK will copy the error so you can paste it elsewhere!"
messages.error="Error"
messages.notsupported.title="Unsupported client"
messages.notsupported.message="This version is no long supported. Please wait for an update."
I have lots of these for different languages, for example:
messages.manualupdate="é disponibile un'aggiornamento manuale del programma ProgName.\n\nVuoi aggiornare alla versione {0}.{1}.{2}{3}?"
messages.errorcopy="Cliccando OK eseguirete una copia degli errori visualizzati"
messages.error="Error"
messages.notsupported.title="Client non supportato"
messages.notsupported.message="Questa versione non è utilizzabile al momento. attendi il prossimo aggiornamento!"
I then parse this into a DynamicObject which I can access like language.messages.notsupported.error. What I would like to know is if I can somehow link all the controls on the form to use variables from the dynamic object on creation. For instance I have a button on my form that I want to have the text "Error" in. Before the form shows, I set the language variable to the users chosen language, and then when the form shows it simply loads the text from language. Is there a way to do this in the designer rather than having to write a method that is called in the Forms constructor as it seems to me like a little bit of a waste to set all the button text to a value and then change them all when the form loads. I'm looking for a sort of binding, but to the controls Text parameter.
Anyone have any ideas?
MSDN has a walkthrough on string localization that might be of use to you link
Honestly, the approach you are trying to avoid looks best to me. I will suggest you to create a property for the control where you are trying to set the Text. In Set attribute, check for the language selected and get the appropriate text for you.
public string Error
{
set { _errorLabel.Text = value; }
}
private void SetText()
{
if(EnglishSelected)
Error = "English";
}
Regarding waste of time, well, I will just suggest not to set anything in designer and directly set the property in Load form. But I would like to add one more point here that any of the approach will not hit your application speed. First its about making your application expandable and maintainable and then about making it fast. Setting logical things in designer is always a bad practice. If your application is not tiny/small then I will suggest you to follow some design patterns like MVP and move all this logical things in Presenter. Not trying to preach but just suggesting.
And yes, in our company one of team is working in localization part of the application. Using resource may be a better way of doing this.
Hope it helps.
how can i get the effect that when u point over a link an information is shown in a box which tells u what that link does.
its like when you hover over a link a box explains its action.
Can some1 help me out with a neat sample.
do i need to use the ajax - hovermenuextender for this??
Thanks
It depends on how fancy you want to be. I personally have found jQuery (AKA JavaScript) to answer the call here. qTip is a jQuery library that has some amazing pop-up "bubble" effects. Head over to their website and check out the various things you can do.
If you head to the qTip documentation (particularly this page), you can see how easy it is to replace "normal" link pop-ups with a much better looking tool tip. Code example shown below:
$('a[title]').qtip({ style: { name: 'cream', tip: true } })
Since you are using ASP.NET you could use ASPNET ToolTip; hover over the bulleted items in the link to see examples.
I would like to know how can I get highlighted text from any window for example: (excel, ie, firefox,…).
please note that the following message not work in the above application
WM_GETTEXT,WM_COPY,EM_GETSELTEXT.
I have also tried control C (copy) and get selected text from clipboard but it is not a good idea.
Language used: C#
I haven't tried it myself, but the Microsoft UI Automation API should have the functionality that you need.
The UI Automation API is what you would use if you were building a screen reader to assist blind people. So it should definitely be able to access the selected text in an arbitrary application.
A good place to start would be with the "Text Pattern Overview" at http://msdn.microsoft.com/en-us/library/ms745158.aspx
Also keep your eye on question 517694. I think you'll find that answers to that question will solve your problem.
No answers huh? Well, I know you can get it from Excel, Word etc using interop. Look into that. It might give you som ideas on how to proceed with ie and ff. But basically the recieving application must have some sort of fascility for letting you do this and I don't think there's any general way which works all the time.
There is no general purpose answer to this question. Each window class will have a different solution.
For instance, if the hilighted text is in an edit window, then you can use EM_GETSEL to get the range of the selection, then WM_GETTEXT to get the text (and then throw the unselected part a way) or EM_LINEFROMCHAR to turn that range into line indexes, and then EM_GETLINE to get the selected text one line at a time.
But this won't work for any other window class.
No need to write this in C# from scratch. What's wrong with using the clipboard? This script ensures that it restores what was on the clipboard when it has finished.
Autohotkey makes this much simpler.
; Hotkey: Ctrl Shift t
^!t::
; Remember what was in the clipboard
clipboardPrev = %clipboard%
; Clear the clipboard
clipboard:=
Sleep,200
; Send a Ctrl C to copy the current selection
SendInput, {Ctrl down}c{Ctrl up}
Sleep,200
; Get the current selection from the clipboard
selectedText=%Clipboard%
if SelectedText =
{
; If the first attempt didn't get any test, try again
Sleep,200
; Send a Ctrl C to copy the current selection
SendInput, {Ctrl down}c{Ctrl up}
; Get the current selection from the clipboard
selectedText=%Clipboard%
}
; Restore the clipboard
clipboard=%clipboardPrev%
MsgBox, %selectedText%
return
Im new into that asp.net thing, but here goes.
I got at ImageButton, and when its clicked i want the image displayed in another window. If I can avoid using ajax i would like to do that.
If possible would like to make the window modal, but still avoid ajax, since Im not ready to mix more technolgies yet.
The existing answers with JavaScript are fine, but just to suggest an alternative - could you use a HyperLink (with an ImageUrl set so you still get an image) and set its Target property instead?
IMHO the best practice to show a picture is in the same page on the top of the content. I personally use Lightbox. You can find the documentation on their page, so it should be easy for you to integrate their JavaScript code.
Somewhat like this:
<asp:ImageButton ID="imbJoin" CssClass="btn-find" AlternateText="Find" ToolTip="Find" runat="server" ImageUrl="~/library/btn-find.gif" onClick="javascript:popUp("ServicesLocator.aspx")" />
Resource: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22832169.html
Using the ImageButton you need to use a JavaScript to open it in a new window. You can also look into the OnClientClick-event
You can use the ImageButton's OnClientClick property:
<asp:ImageButton ... OnClientClick="javascript:window.open('url_to_image');" >
But this popup window will not be modal.
The following javascript will do what you're looking for:
window.open('page.html','WindowTitle','width=400,height=200')
It might be worth pointing to a two relevant entries in the excellent EFNet's #javascript FAQ:
Correct Use of Popups - yay accessibility!
How do I make a popup window the same size as my image?
How do I create a custom 'OK' dialog or something similar? - modal windows are not that useful and something like the suggested Lightbox or similar scripts would be better "modal" options
Correct Use of Links - this one being only partly on-topic but the previous answers use of the "javascript:" pseudo protocol made it necessary: it is never required nor useful in a web page that should work across browsers. After all, JavaScript is the default (and only) scripting language.
Thank you for all the answers! I ended up using lightbox
I found this example
http://neutrongenious.wordpress.com/2007/09/08/lightbox-for-asp-net-2-0/
And it works perfectly