-
-
Save codeimpossible/9336568 to your computer and use it in GitHub Desktop.
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
public override void RenderContent(DataContext dataContext) | |
{ | |
// Note: Given the framework/tech, I don't have full control over all of this. Maybe I should refactor? | |
var dataItem = GetDataItem(dataContext); | |
// If we're right-aligned, either set a new data item or don't do anything | |
if (IsRightAligned) | |
{ | |
var rightAlignedDataItem = GetRightAlignedDataItem(dataContext, currentItemDetails, mediaList); | |
if (rightAlignedDataItem != null) | |
{ | |
dataItem = rightAlignedDataItem; | |
} | |
} | |
// Do stuff to the dataItem | |
} | |
protected Item GetRightAlignedDataItem(PrintContext printContext, MediaItemLayoutDetails currentItemDetails, Item dataItem) | |
{ | |
Item rightAlignedItem = null; | |
if ( !dataItem.IsFullWidth && !dataItem.IsRightAligned && dataItem != mediaList.Last() ) | |
{ | |
var nextItemDetails = mediaList[ mediaList.IndexOf(dataItem) + 1 ]; | |
// if the next item is right-aligned and not full-width, then we should render it | |
if ( nextItemDetails.IsRightAligned && !nextItemDetails.IsFullWidth ) | |
{ | |
rightAlignedItem = GetNewDataItem(dataContext); | |
} | |
} | |
return rightAlignedItem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment