WPF / C# Display of Acrobat Toolbar - c#

I'm creating a WPF application that has viewing of PFDs built into it. I use WindowsFormsHost method to view the PDF:
<WindowsFormsHost x:Name="PDFViwer"/>
var pdfViwer = new AdobePDFViewer(#"E:\temp\test\testFile1C.pdf");
this.PDFViwer.Child = pdfViwer;
I've noticed that when I view some files (such as electronic version of books), the Acrobat Toolbar will display automatically, such as this:
However, some other files that are.. let's say created from a Word Document or sent to print to PDF, will display the document in Read Mode, which brings up a menu bar at the bottom if you hover towards that area, such as this:
I like the second better than the first; however, due to the fact that some users might not know that hovering towards the bottom will display those options, I want to be able to force those options to display.
If I click the Acrobat symbol on the popup menu that has a caption of Show Acrobat Toolbar, it'll go into the mode where the Toolbar will display at the top... but once again, the user has to know of the popup menu existence in the Read Mode.
Is there a way to force the Toolbar to display by default or a way to make a custom button force mode switch?
Adobe doesn't have the greatest developer documentation in the world... why can't everyone be like Oracle. They'll provide a list of methods, but don't provide a clear list of possible parameters or a very clear description of those methods.. So I've been playing with this.axAcroPDF1 methods and one of them does something halfway to what I'm trying to accomplish: this.axAcroPDF1.setShowToolBar(true). However, what that does is displays the Adobe Reader Toolbar at the top of the document while still in Read Mode. So, I have a toolbar on top and the dynamic toolbar on bottom, which is a bit messy in my opinion. I can't figure out how to switch modes... there are more methods, but I can't find the list of available enumeration parameters for them.
I don't believe how ridiculously hard it is to find information on Adobe products if you're a developer... I guess I was spoiled by Oracle's incredible documentation of Java. Anyways, I've even read through this "lovely" document, and I still can't figure it out: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/iac_api_reference.pdf

Try to customize current view as described in link

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 to tail text from a specific control from an external program?

I have tried inspecting this window using Inspect.exe provided on Windows' 8.1 Software Development Kit Testing Tools. I couldn't seem to identify the control handle for this huge rich textbox like control. I could however get the control handle of the edit box below the textbox. I was hoping I could talk directly to the control and use a library such as WindowScrape to get the text.
I believe the external program is created in VC++ . If that helps.
This is the window. I am trying to get text from that is boxed in red color. This is a chat window , messages come in every 5 to 10 seconds. This box scrolls automatically. I want to tail through the text and get the latest message.
Is there any other way to accomplish this?
Tesseract maybe, but I do not know where to start to monitor a specific position relative to the window. So that when I move the window it will still be able to monitor that window.
Can you provide a screenshot of Inspect results showing both the tree and details panes while selecting the chat box?

WPF C# UI : New Window or Tab?

Our WPF application in the current design opens new windows for list screen.We don't have restrictions on the number of windows you open etc.We are using a ribbon control and well it has tab support.Which is better a new window or a tab? (With windows 7 having a better group of window management etc) Should I go in for tab or leave it as window. I can't make the detail screen tab since well the user click of a item in the grid to select and edit.Any valid suggestions? Thanks in advance.
Tabs in a Ribbon shouldn't change the view. The Ribbon is an enhanced toolbar, not a view changer.
If your using the MS Ribbon via OfficeUI, then there is a stipulation in the design guidelines that the view should never change the appearance of the ribbon (apart from loading context tabs) and that they ribbon should never wholesale change the view.
In regards to your question, do you mean that you have list/grid and you want a view to be able to change the data in the row. Eg. they double click a row, a view appears that gives them the ability to edit that row?
The right way is to ask your users what they like more. If you can't ask users, ask yourself - what you find more convenient - to open\close windows or switch between tabs. I wouldn't rely on win7 task bar as it's grouping behavior can be disabled or users may use another OS. Also I would suggest to check Microsoft guidelines for using ribbon.
Do you need to see more than one pane's content at once? Windows allow this, but tabs do not.
Tabs make management of the various windows easier at the expense of some flexibility.
Are your users likely to be running on multiple windows?
It is really hard to give a confident answer to you on this one without knowing more about your application and your user's requirements.
Windows 7 displays multiple previews on grouped windows of the application, however in case of tab, like IE, you will have to write quite a good custom code to show your tabs in preview of Windows 7 taskbar, which in case of Multiple Windows, it will be done automatically.
Not only that, Windows 7 also lets you put seven toolbar buttons on the preview windows, very few people knows about it because no application currently does it.
For tabs you will need to do extra programming to support multi window preview.
So its better to stay with multi window solution for now.
However in case of IE, if you try to use Windows 7 taskbar, the tabs dont align themselves in correct order of what is displayed in preview, it could be bug, but yes there might be certain limitations because when user chooses the tab to preview you will not be able to show them preview unless you make it active and thats why its little bad.
I recommend playing with Mozilla Firefox and Google Chrome if you want to see tabs at their finest.
Notice that tabs can be teared out into a separate window and windows can be docked as tabs.

Non intrusive 'live' help system

I'm searching a C# component or code snipped that does something like that:
I want to inform new users about the most important program functions if he opens a new window for example.
It should be a box showing text (formated if possible) that is of course not modal and has some mechanism to 'go out of the way' if the user enters the textbox area. So that he can access what's underneath it. Alternativly the window could also stick to the border of the window, but there needs to be a way that this also works if the window is maximized.
So I want to present him with a short introduction of what he can do in every corner of my app most painlessly.
Thank you!
I use a "bar" at the top of every window to display some information about the current window/dialog.
Use tooltips. They can be programmatically controlled, and you can have them appear at will. You'll need to add the functionality to your app to keep track of what tooltips have been shown to the user already.
You can add a "balloon" style by setting the IsBalloon property to true.
You can also replace them with smaller descriptions for when the user wants to hover over the control and have them displayed again.
I'm already using tooltips heavily. However, they aren't very practical when displaying bigger amounts of data and they are bound to specific user actions.
Have you considered having a contextual menu for each form / page which contains links to Adobe Captivate style presentations for each available task? That way the user can investigate an example of how to achieve a task relating to what they are trying to achieve from within the application / site.
This approach would require a good deal of maintenance and management if your code changes regularly but coordinating it with a training department can provide rich help features in your application.
See http://www.adobe.com/products/captivate/ for more information.

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