How to Embedd notepad++ in my windows form? - c#

Embed notepad++ in my windows form. Through which i want to control notepad++ with my own function.
I am using split container.
In panel1--i have a button.
In panel2--notepad++ appear when the form loading.
notepad++ appear on the panel2.
what i am expect is, i use one button in my form.
whenever i click that button, replacing will occur in notepad++ for a single word.
ex, text in notepad++ is,
"This is a file testing for replacing a word in notepad++ through Windows form."
i want to replace a word "This" to "It".
can anyone help me?
Expected Output appear in notepad++ is,
"It is a file testing for replacing a word in notepad++ through Windows form."
So far i did,

What you want to do can be achieved differently. Embedding Notepad++ is a wrong idea. It is an independent executable that is not intended to be the "plugin of something"... but is is a great plugin holder itself.
Check the Notepad++ documentation to create your own plugin,
which will probably be easier and more reliable.
If you want to stick with C#, use a dedicated Control to highlight
some synthax (if it is what you're trying to do), like Scintilla.NET.

Related

Display PDF preview in WPF and search for a phrase

I need to display PDF preview in WPF control, programmatically search for text in it, highlight found text and be able to copy text. Sounds simple, but I am struggling with different approaches for a week already.
Here what I have considered:
Find PDF controls for WPF
Most of them just render PDF as images or cost too much. Royalty or subscription fee is not an option.
The only suitable control that I found is:
http://www.syncfusion.com/products/wpf/pdf-viewer
I was even able to do searches programmatically with reflection hacks, but it renders text too blurry (Syncfusion promise to fix this soon) and load pages with a noticeable lag during scrolling.
Using AcroPDFlib as an ActiveX component
I was not able to make it work with the latest Adobe reader on Windows 10 64-bit. But I don't see methods for search anyway, so I dropped this. Also, it seems that it is not free for commercial use:
AcroPDFlib, AxAcroPDFLib commercial use
Load PDF in WebBrowser control
It works and even allow searches, but it can search only for single words which make this search useless. If I search for "big apple" it highlights all big and apple and also open this search panel that cover the document.
Send CTRL+F and text to the browser control to trigger search
I have tried to use this library
http://inputsimulator.codeplex.com/
But PDF in browser control seems to ignore keystrokes from there or maybe I am doing something wrong. Still considering this option.
Use pdf.js in browser control
IE7-based control from WPF won't support that, so I need another browser control. And it seems that I also need to start nodejs to make it work. Seems like a too much overhead for this task. And also it is not clear does PDF.js supports search for a phrase or not.
But I am still not discarding this option. Does anyone were able to make it work inside WPF?
Any suggestions?

How can I save a multiple screenshots using hook in C#, directly to a word file?

Before I start, I am totally new to C# and most of my programming knowledge come from searching what i need on Google. :P I am good at copy paste but have basic programming skills.
I am working on an windows screenshot application to capture screens using Print Scrn key (by Hook in C#). So this application minimizes on start and user would be able to capture screens by just clicking on Print Scrn key.
I problem is I want the application to be able to save these screen caps in a word file in the background and when the user Hits "End" key the Word file Save Dialog should be displayed (This way user can save the word file by giving a name).
I know this is kind of tricky, but currently we do all these manually which eats up lot of our time. Open Word-> Take Screenshot - > Navigate to Word -> Paste - > Navigate to Window -> Take Screenshot - > Navigate to word again -> Paste .....
I wanted your help to make is let pain... Simple take screen caps-> keep doing it until done -> Click End to Save document.
I have found a portion of code to use Hook from stack overflow, all I need is a way to open an handle word file in the background.
Also I am able to generate pdf file using a third party .dll --which generates document with watermark :( So I thought I should use Word.
Your help would be much appreciated! Cheers! :)
I've actually made an application very similar to this and this is what I think personally: don't try to hook into keyboard shortcuts. What I did was created a system tray icon that if you middle click on will start the capture process.
Sending to Word as an in between staging step to get to PDF is weird. With iTextSharp library you can, with relative ease, add images to a PDF. And there is actually quite a few examples of doing so.
An existing model of an application to look at would be the Snipping Tool in Windows. It's not hard to screen capture the entire screen with .NET and place it on a form that you overlay across the entire screen. You can then allow them with their cursor to select a portion of the form.

VS2010 highlight references only on doubleclick

Is it possible to make C# code editor in VS2010 only highlight word references when a word is doubleclicked, like e.g. MetalScroll, not always whenever the cursor is on a word?
Maybe there are some extensions that could do it? Is it even possible to affect this area of VS with an extension?
http://blogs.msdn.com/b/zainnab/archive/2010/04/14/the-best-of-visual-studio-2010-how-to-use-reference-highlighting.aspx
You could maybe use the information here to write a macro to enable/disable highlighting on demand (though it won't work on a double click)

How do I add HTML links in C# TextBox?

How can I put a link in a C# TextBox? I have tried to put HTML tags in the box but instead of showing a link it shows the entire HTML tag. Can this be done with a TextBox?
Use the RichTextBox, no need to build your own, it cames with VS
I would try using an editable div and making it look like a text box. This would allow you to get user input and use links.
To make this easier, try JEditable.
If that is in windows forms and you really can't use the richtextbox, you can create a control with a linklabel inside of textbox.
http://www.codeproject.com/KB/miscctrl/LinkTextBox.aspx
I would think about this a little bit. If you allow executable code in an editable control, the user, the user can execute ANY code. This is generally a bad idea.
The behavior of the C# control is intentional to prevent the exact behavior that you are trying to create. A little creativity (such as parsing out links from the text box and creating a list of links next or below the text box) will provide a much safer application.
To my knowledge not with the standard textbox. You'd have to create your own. One option it the Telerik controls, they're a little pricey for individual development, but very robust and configurable.
For windows application, we can use a webbrowser control. However, for web applications Freetextbox will do the job.This is freely available dll.

Replacement for yes/no/cancel MessageBox (C#)

I am looking for a decent replacement for the standard windows YES/NO or YES/NO/CANCEL MessageBox.
I have often seen these standard dialogs misused in ways such as: "To save in plain text answer YES, or to save in html answer NO". Obviously, the text should read "Save As: and the "buttons should be labeled "Text" and "HTML". It is not a yes/no question that is being asked, and although it could be phrased that way, it would not be easy to read and understand.
Microsoft gives no way to change the text on the buttons. There is no fast/simple way to build a replacement from scratch... as evidenced by the number of applications using the awkward style mentioned above.
Is there any free C# replacement dialog or MessageBox out there that lets you at least:
- specify the number of buttons
- specify the text to appear on each button
- specify the default button
I have looked and have been unable to find one.
(I would build one myself, but I am not familiar enough with all the behaviors that a fully functional control should have, since I only need/use/know a small subset. Two examples I don't use: themes and internationalization. I need something that my coworkers will also want to use.)
Check out Dissecting the MessageBox on CodeProject. The project is a bit dated, but it's pretty much exactly what you're looking for and it shouldn't take much to update it.
Depending on your target platform, a task dialog may be a good way of doing this. There is a .NET wrapper for task dialogs in the Windows API Code Pack. However these are provided only in Windows Vista and above, not in XP or 2003.
Frankly, it is not that difficult to create such a Messagebox yourself, we have such a thing working in the current app we are developing.
What you need is a FlowLayout for the buttons that will auto-align any buttons you create. Our API then has something like (params Tuple<string,DialogResult>[] buttons)
Tuple is a helper class that contains two values. The string is the Text of the button, the Dialogresult is the one our messagebox returns when the button with said text is clicked.
I agree with Frank. It wouldn't be too difficult to create your own generic form that handles this for you. Without getting into code, the form should do the following
1) Have a property to set the message you want to show to the user.
2) Have a method for adding buttons, with 2 arguments, one for the button text, and one for the dialog result
3) When the form is displayed, it should be in modal dialog mode so that the rest of the application is inactive while until one of the options is clicked.
So, to create a Save As/Don't Save/Cancel, you would add 3 buttons in step 2, all with the appropriate button text and dialog result.
Using Flow layout, you should be able to get it to display properly regardless of the size of the message, or the number of buttons.

Categories