Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ private void GroupTextBox_OnTextChanged(object sender, TextChangedEventArgs e)

SetTextMaxWidth();
SetTextHeight();
ViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
if (GroupTextBox.ActualHeight > 0 && GroupTextBox.ActualWidth > 0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the textbox has custom group name and description already, won't the actual H & W be greater than 0. We don't want to set the HasUnsavedChanges to true in that case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H & W are 0 only at initialization, at which point the group title and description are set (custom or default)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, are the height and width greater than zero only after the text is changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at-least at initialization, when WPF is creating groups.

The group text is bind to AnnotationText, which is set to the stored value when the control is initialized, that action should not trigger HasUnsaved changes, because we are initializing the group for the first time.
I tried capturing this by IsLoaded and IsReady events, but at this point none of them worked, so I needed a way to differentiate between an explicit action by the user to change the text versus group text initialization on workspace load. So I found that H & W are 0 at this point which won't be the case when any user action would trigger it.

{
ViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
}
}


Comment thread
zeusongit marked this conversation as resolved.
Expand Down Expand Up @@ -355,7 +358,10 @@ private void GroupDescriptionTextBox_TextChanged(object sender, TextChangedEvent
if (ViewModel is null || !IsLoaded) return;

SetTextHeight();
ViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
if (GroupDescriptionTextBox.ActualHeight > 0 && GroupDescriptionTextBox.ActualWidth > 0)
{
ViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
}

}

Expand Down
Loading