Skip to content

Instantly share code, notes, and snippets.

@codeimpossible
Forked from edgesmash/elseall.cs
Last active August 29, 2015 13:56
Show Gist options
  • Save codeimpossible/9336568 to your computer and use it in GitHub Desktop.
Save codeimpossible/9336568 to your computer and use it in GitHub Desktop.
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