Reputation: 3009
I have a template image that ships with my application and I want the user to be able to open it, edit it and save it locally as a new image. I already have the opening part working as outlined here Open an image with the Windows default editor in C#
What I really need to do is open it not allowing save, just Save As. I also would like to specify the target folder. Does anyone know if you can do this with verbage?
Thanks.
Upvotes: 0
Views: 1241
Reputation: 5262
No Control
You won't have that kind of control over the app that opens unless the app allows for that kind of control through environment variables or command arguments or some other way of setting options. When you launch another app, you are at it's mercy for how it handles files. If you want more control, then you'll have to use an image editor control that can fit inside your app.
Embedded Image Editor
Image editing is a complex task. Filters that alter the image geometrically or by using shaders is available in existing libraries. But if you want more complex effects like framing, adding text, etc., you'll need a professional image editing library. The big-name image editors don't offer their product as a library, but you can find for-sale solutions on the market. If you want something that allows for more composite effects, you may want to image-scrape the results of overlaying WPF elements on an existing image.
Template Image as Resource
An alternative would be to have the template be a resource in your application or dlls that you deliver, that they can't save over. You'd pull the resource out, write it out as a file, then open that file in the default editor. Then they could save, save as, etc, without the risk of overwriting your original template. But you'll still not have control over where they save. You also won't know what they even did. Whether they closed without saving, saved to a certain location, saved over the file, will all be unknown to you. You could monitor folder locations, but you won't get data back unless the app offers that information.
Restricting Save Location
Now, once you have that settled, target folder is a big issue. The file dialog doesn't have a direct way to limit to a file location. So you'll need to either not use the file dialog or hook into it's file-ok event.
file-ok event gives you the opportunity to cancel the save/load and leave the dialog open, but I think you're better off creating your own dialog if you intend to keep the file restricted to a single folder.
Upvotes: 1
Reputation: 15875
Verbs have to do with the file type, not the save dialog. What would you do if the user chose to "Save As" your original file?
I think that you will need to pull an editor into your application and control the save dialog from there.
Or you could try keeping a back up copy of the file, if the original gets changed work through a system to replace the file.
Upvotes: 0