Disable PowerPoint features using C# - c#

My scenario:
I have a requirement in my project(C#).I need to give the user only reading capability for my powerpoint presentation opened thru my application.All other featues like cut,copy,paste,save,saveas,print,right click context menus should be disabled.How can i achieve this in powerpoint programatically using c#? can anyone extend their help?

Can you publish the ppt as pps and use that file instead?

Just export each slide as a JPG or PNG and display those: Slide.Export. This would be for static slide views. If you want to retain animations, transitions, video/audio and navigation features for your PPT/PPTX, a PowerPoint-to-Flash converter is a better way to do this. iSpring makes a free version of their converter: www.ispringfree.com.

You should use the Powerpoint COM component, kind of like whats described here...
Using C# to display powerpoint
I have only used Word and Excel ones, and i must say they are extremely easy to use.
Or is you MUST make it completely read-only, id suggest writing your own ODF parser, or investigating in the ODF COM component, maybe that could work as well :)

One solution could be to use something like Aspose.Slides to render the Slides to TIFF or PDF and then display those inside your application.

If you have a low number of powerpoint presentations, you can look into Information Rights Management or use the Permissions Object. (Disclaimer:I have not used this)

Assuming that you're using Powerpoint Automation. Get hold of the PowerPoint.Application object and then loop through the CommandBars property and for each command bar, set Visible to false.
This should remove the command bars at least. And there might be other properties on the Application object that lets you disable context menus, but I've never really used powerpoint, so I'm not sure which ones.
I don't think that there's any good way of disabling printing etc altogether though. However, this MS KB article discusses a hacky way of dismissing any dialogs automatically, so assuming that the print/save etc would always bring up a dialog (which I'm not sure off) you might be able to use something from there: How To Dismiss a Dialog Box Displayed by an Office Application with Visual Basic
It's all VB code in that article, but the ideas will be similar.

Related

Is it possible to read data from Pane control type?

I've started using FlaUI for Automating my thick client .net application. The application is Windows Form based. The start was good and Login Form was identified and I could Login, but after that came the dead end and I found that almost everything in the application is developed as Pane control type.
So, there is grid, table etc. but they all just appear as Pane type when I see the object hierarchy using Inspect.exe or FLAUInspect tools. And nothing really appears in thier property, so it seems that nothing could be read. But before giving up I just wanted to check with experienced audience on this forum if there is really any way to get the data from Pane objects.
Please suggest if there is any way, even that means using other libraries like UIAutomation, TestStack.White, etc.
UPDATE: I now understand little more about this. So, the objects that are there in the pane are developed in syncfusion and devexpress. Is it possible to identify objects developed in syncfusion and devexpress using FlaUI or UIAutomation or TestStack.White, etc ?
I don't know if you have already tried the following steps. Have you add automationId's to your objects in xaml code with:
AutomationProperties.AutomationId="AnyID"
In the testcode, first initialize the main window of the application.
MainWindow = fApplication.GetMainWindow(fAutomation, null)?.AsWindow()
After that you can find your objects by the automationId's, like:
MainWindow .FindFirstDescendant(cf => cf.ByAutomationId(AnyID))
I did it this way, and don't have to know the hierarchy of my application. Maybe this will work?
Most UI Frameworks nowadays fully support UI Automation. So first make sure that you have a recent version of your framework (syncfusion, devexpress). In addition, some frameworks provide settings to enable UI Automation. Like for devexpress, you need to set
ClearAutomationEventsHelper.IsEnabled = false;
at the start of your application to test so it exposes way more things (like tabs) to FlaUI.

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?

Looking for an Elegant "Dont Show Me This Dialog Again" Dialog in C#

I've been looking for a dialog with a checkbox "Don's show me this dialog again" in C#.
I googled and search a lot, but I just could not find an elegant solution.
The dialog should work as similar as the native MessageBox.Show, but with a new property value (bool value) return to the caller.
Thanks.
Vista and Windows 7 applications can use the new TaskDialog features which extend the standard MessageBoxes to support a checkbox at the bottom (along with all sorts of other goodies such as Command Links, custom button text, footers etc).
Unfortunately from C# you need to do some interop to access this. If you just want the advanced TaskDialogs to target Vista/Windows 7, use the WindowsAPICodePack from http://code.msdn.microsoft.com/WindowsAPICodePack which can handle the interop complexity for you.
If you need to support XP, there is an excellent wrapper that supports the native TaskDialogs on Vista/7 with a WinForms fallback for XP here:
http://www.codeproject.com/KB/vista/Vista_TaskDialog_Wrapper.aspx
Why don't you create your own. It is a very simple one. Just derive from System.Windows.Forms.Form class and mimic it like the one you want.
I don't feel there will be a readymade solution as such. For implementing "Do not show me again", you need to persist the information outside the dailog and also create a user profile.
If your infrastructure of persisting the user profile is there, you can simple create a class similar to the messagebox class. You can not derive from messagebox however.

How do I browse the local directory's files without using OpenFileDialog? (C#)

I want to build something where the user to browse the local files on the application I am providing, the screen is actually identical to OpenFileDialog, but I do not want that to be a dialog but a control on my form.
I tried to use a Web Browser control, it works, but I have to write a bunch of navigation code in order for that to work, and another problem is if the user selected any files on that screen, I am not sure how to capture the results.
So is there another way to do that? Or maybe override some of the OpenFileDialog control to make it not only showing as a dialog but a normal control.
Thanks
Maybe something like this is what you are looking for:
It uses the tree view.
http://www.codeproject.com/KB/cs/TreeViewFileExplorer.aspx
It's better to use the openfiledialog and attempt to ownerdraw that (which I think you can enable).
Use controls from Shell MegaPack - they can be put on your own forms, and provide lots of customization and flexibility.
DISCLAIMER: I work for LogicNP Software, the developer of Shell MegaPack.

WYSIWYG Control for Winform

I am looking for a free WYSIWYG editor control to be used in a Winform application. The applications primary language is VB but using C# is also an option. To clarify I need a rich text editor control that has a formatting bar. I have looked all over the web and the only options I can find are expensive control packages that have more than I need. I am not adverse to creating my own version of this control, it would just be nice to find a free and open alternative.
In this scenario, starting with CodeProject articles seems the easiest:
http://www.codeproject.com/KB/edit/editor_in_windows_forms.aspx -- Not my first recommendation, but perhaps of use if you want HTML.
http://www.codeproject.com/KB/edit/TextRulerControl.aspx?fid=968441&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=2438044
http://www.codeproject.com/KB/cs/eRichTextBox.aspx
Actually it's very easy to write your own based on the RichTextBox control.
I would go that way for sure. Your biggest problem will be the icons for the edit bar.
Check this one for starter.

Categories