Click here to Skip to main content
15,915,172 members
Home / Discussions / C#
   

C#

 
GeneralRe: Save and Save as Pin
squerley2-Dec-10 11:39
squerley2-Dec-10 11:39 
GeneralRe: Save and Save as Pin
Pete O'Hanlon2-Dec-10 11:55
mvePete O'Hanlon2-Dec-10 11:55 
GeneralRe: Save and Save as Pin
Dalek Dave2-Dec-10 12:26
professionalDalek Dave2-Dec-10 12:26 
AnswerRe: Save and Save as Pin
GenJerDan2-Dec-10 11:29
GenJerDan2-Dec-10 11:29 
GeneralRe: Save and Save as Pin
squerley2-Dec-10 12:15
squerley2-Dec-10 12:15 
GeneralRe: Save and Save as Pin
GenJerDan2-Dec-10 17:22
GenJerDan2-Dec-10 17:22 
GeneralRe: Save and Save as Pin
Dalek Dave2-Dec-10 12:27
professionalDalek Dave2-Dec-10 12:27 
AnswerRe: Save and Save as Pin
Luc Pattyn2-Dec-10 12:10
sitebuilderLuc Pattyn2-Dec-10 12:10 
you need both:
- a string holding the file path
- a boolean "dirty" flag

the path is set when you open an existing document or save the document; and it gets nulled at start, and when the user "clears" the document (no content => no path).

the dirty flag gets cleared any time you set the path (to null or to an actual path); and set on any change you make in the document (yes, that is in many many places in the code of a typical editor).

then, when you want to exit the app, the dirty flag tells you to ask the user: "shouldn't I save your current document first?"; same if your app can only handle one document at the time, and the user is about to open one while still holding dirty data.

And whenever the user saves without "SaveAs" (i.e. by performing "Save" or answering "yes" to "shouldn't I save ...", the path variable tells you whether you should ask for a path (if null) or use what you have already; a save through "SaveAs" always must ask for a path (and the answer gets stored in the string variable, unless cancelled).

Optionally, you could disable the "Save" menu item as long as path is null, forcing the user to use SaveAs.

Optionally again, you could have shortcut keys, and CTRL/S should do what "Save" does, i.e. ask for a path if and only if path is null. And to be top-notch, CTRL/S should even work when "Save" is disabled, i.e. when you don't have a path.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at them.


AnswerRe: Save and Save as Pin
_Erik_3-Dec-10 3:22
_Erik_3-Dec-10 3:22 
GeneralRe: Save and Save as Pin
squerley3-Dec-10 8:59
squerley3-Dec-10 8:59 
GeneralRe: Save and Save as Pin
squerley4-Dec-10 16:08
squerley4-Dec-10 16:08 
GeneralRe: Save and Save as Pin
_Erik_6-Dec-10 23:35
_Erik_6-Dec-10 23:35 
GeneralRe: Save and Save as Pin
squerley10-Dec-10 15:46
squerley10-Dec-10 15:46 
QuestionHow to delete word field code from C# Pin
Andraw Tang2-Dec-10 8:45
Andraw Tang2-Dec-10 8:45 
QuestionXPathNavigator iterate and write Pin
Mark F.2-Dec-10 5:38
Mark F.2-Dec-10 5:38 
AnswerRe: XPathNavigator iterate and write Pin
cechode2-Dec-10 13:15
cechode2-Dec-10 13:15 
GeneralRe: XPathNavigator iterate and write [modified] Pin
Mark F.3-Dec-10 9:00
Mark F.3-Dec-10 9:00 
AnswerRe: XPathNavigator iterate and write Pin
cechode3-Dec-10 9:34
cechode3-Dec-10 9:34 
QuestionAvoid Peer 2 Peer acces Pin
utunity2-Dec-10 5:08
utunity2-Dec-10 5:08 
AnswerRe: Avoid Peer 2 Peer acces Pin
musefan2-Dec-10 5:36
musefan2-Dec-10 5:36 
GeneralRe: Avoid Peer 2 Peer acces Pin
utunity2-Dec-10 5:45
utunity2-Dec-10 5:45 
GeneralRe: Avoid Peer 2 Peer acces Pin
musefan2-Dec-10 5:51
musefan2-Dec-10 5:51 
GeneralRe: Avoid Peer 2 Peer acces Pin
Luc Pattyn2-Dec-10 7:48
sitebuilderLuc Pattyn2-Dec-10 7:48 
GeneralRe: Avoid Peer 2 Peer acces Pin
fjdiewornncalwe3-Dec-10 1:15
professionalfjdiewornncalwe3-Dec-10 1:15 
AnswerRe: Avoid Peer 2 Peer acces Pin
T M Gray2-Dec-10 11:08
T M Gray2-Dec-10 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.