New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further fix of screen capture #6893
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dfd1ddf
Further fix of screen capture
Benglin 197c466
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Benglin e692864
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Benglin 2358916
Updated 'GoogleAnalyticsConsent.rtf' with additional contents
Benglin 2b4ddad
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Benglin File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,16 +189,48 @@ internal void SaveWorkspaceAsImage(string path) | |
var initialized = false; | ||
var bounds = new Rect(); | ||
|
||
double minX = 0.0, minY = 0.0; | ||
var dragCanvas = WpfUtilities.ChildOfType<DragCanvas>(this); | ||
var childrenCount = VisualTreeHelper.GetChildrenCount(dragCanvas); | ||
for (int index = 0; index < childrenCount; ++index) | ||
{ | ||
var child = VisualTreeHelper.GetChild(dragCanvas, index); | ||
var firstChild = VisualTreeHelper.GetChild(child, 0); | ||
if ((!(firstChild is NodeView)) && (!(firstChild is NoteView)) && (!(firstChild is AnnotationView))) | ||
continue; | ||
|
||
switch (firstChild.GetType().Name) | ||
{ | ||
case "NodeView": | ||
case "NoteView": | ||
case "AnnotationView": | ||
break; | ||
|
||
// Until we completely removed InfoBubbleView (or fixed its broken | ||
// size calculation), we will not be including it in our size | ||
// calculation here. This means that the info bubble, if any, will | ||
// still go beyond the boundaries of the final PNG file. I would | ||
// prefer not to add this hack here as it introduces multiple issues | ||
// (including NaN for Grid inside the view and the fix would be too | ||
// ugly to type in). Suffice to say that InfoBubbleView is not | ||
// included in the size calculation for screen capture (work-around | ||
// should be obvious). | ||
// | ||
// case "InfoBubbleView": | ||
// child = WpfUtilities.ChildOfType<Grid>(child); | ||
// break; | ||
|
||
// We do not take anything other than those above | ||
// into consideration when the canvas size is measured. | ||
default: | ||
continue; | ||
} | ||
|
||
// Determine the smallest corner of all given visual elements on the | ||
// graph. This smallest top-left corner value will be useful in making | ||
// the offset later on. | ||
// | ||
var childBounds = VisualTreeHelper.GetDescendantBounds(child as Visual); | ||
minX = childBounds.X < minX ? childBounds.X : minX; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I think a |
||
minY = childBounds.Y < minY ? childBounds.Y : minY; | ||
childBounds.X = (double)(child as Visual).GetValue(Canvas.LeftProperty); | ||
childBounds.Y = (double)(child as Visual).GetValue(Canvas.TopProperty); | ||
|
||
|
@@ -221,7 +253,7 @@ internal void SaveWorkspaceAsImage(string path) | |
bounds.Height = 20 + ((((int)Math.Ceiling(bounds.Height)) + 1) & ~0x01); | ||
|
||
var currentTransformGroup = WorkspaceElements.RenderTransform as TransformGroup; | ||
WorkspaceElements.RenderTransform = new TranslateTransform(10.0 - bounds.X, 10.0 - bounds.Y); | ||
WorkspaceElements.RenderTransform = new TranslateTransform(10.0 - bounds.X - minX, 10.0 - bounds.Y - minY); | ||
WorkspaceElements.UpdateLayout(); | ||
|
||
var rtb = new RenderTargetBitmap(((int)bounds.Width), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
break
is ambiguous in this context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it ambiguous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are followed by a
default : continue
statement, butbreak
is forswitch
andcontinue
is forfor
loop. sort of context switch..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fairly standard to me.