HasChanges property

Apr 15, 2009 at 2:23 PM
Could you please add a boolean HasChanges (or similar) property to DocumentContent so we can prompt to save them when the document is closing?
Apr 15, 2009 at 2:41 PM

You can inherit your own class from DocumentContent and implement such a field:

Public class MyDocumentContent:AvalonDock.DocumentContent

{

                Private bool hasChanges = false;

                Public bool HasChanges

{

                get

                {

return hasChanges;

                               }

set

                {

hasChanges = value;

                               }

}

Protected overrive void FormClosing(...)

{

If(HasChanges)

{

//Prompt something…

//If User doesn’t want to close set e.Cancel = true

}

}

}

Maybe this helps.

TopperDEL

Von: notifications@codeplex.com [mailto:notifications@codeplex.com]
Gesendet: Mittwoch, 15. April 2009 15:23
An: timparth@web.de
Betreff: HasChanges property [AvalonDock:53359]

From: Overlord123

Could you please add a boolean HasChanges (or similar) property to DocumentContent so we can prompt to save them when the document is closing?

Read the full discussion online.

To add a post to this discussion, reply to this email (AvalonDock@discussions.codeplex.com)

To start a new discussion for this project, email AvalonDock@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 15, 2009 at 2:42 PM

To correct myself:

Use:

Protected override OnClosing(System.ComponentModel.CancelEventArgs e)

Von: notifications@codeplex.com [mailto:notifications@codeplex.com]
Gesendet: Mittwoch, 15. April 2009 15:23
An: timparth@web.de
Betreff: HasChanges property [AvalonDock:53359]

From: Overlord123

Could you please add a boolean HasChanges (or similar) property to DocumentContent so we can prompt to save them when the document is closing?

Read the full discussion online.

To add a post to this discussion, reply to this email (AvalonDock@discussions.codeplex.com)

To start a new discussion for this project, email AvalonDock@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Apr 15, 2009 at 5:04 PM
Edited Apr 15, 2009 at 5:08 PM

I'm already doing this, unfortunately the following code won't work that way:

LocalizationContent[] changedDocs = dockingManager.Documents.Where(o => o.HasChanges);

neither does:

LocalizationContent[] changedDocs = dockingManager.Documents.Where<LocalizationContent>(o => o.HasChanges);

LocalizationContent is my inherited DocumentContent.

Moreover I have multiple derived DocumentContent classes, which adds to the amount of work involved if there's not such a property.

Apr 16, 2009 at 10:13 AM

This is LINQ, right? I don’t know LINQ very much. Maybe you can check something like:

List<LocalizationContent> AllLocContents = new List<LocalizationContent>();

Foreach(AvalonDock.DocumentContent doc in dockingManager.Documents)

{

                If(doc is LocalizationContent)

{

                AllLocContents.Add((LocalizationContent)doc);

}

}

This works principle works in my program.

TopperDEL

Apr 17, 2009 at 10:34 AM

I'm currently doing it like this, but it is inconvenient:

var changedDocs = new List<DocumentContent>();
foreach (var doc in dockingManager.Documents)
{

if (doc is LocalizationContent)
{
var locContent = doc as LocalizationContent;
if (locContent.HasChanges)
{
changedDocs.Add(doc);
}

}

// Repeat for every derived content

}

Apr 21, 2009 at 9:37 AM
Hi, this seems to work fine:

 

IEnumerable<DemoDocument> docs = _dockingManager.Documents.Cast<DemoDocument>().Where<DemoDocument>(d => d.IsChanged);

 

please ensure that linq extensions namespace System.Linq is included,
ado