Skip to content
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

PrintHelper + Code printing #485

Merged
merged 11 commits into from
Oct 26, 2016
Merged

PrintHelper + Code printing #485

merged 11 commits into from
Oct 26, 2016

Conversation

deltakosh
Copy link
Contributor

@deltakosh deltakosh commented Oct 17, 2016

PrintHelper allows developer to print a XAML control per page (no page break).
You can easily create any kind of xaml (like textboxes, rich text or even images) and send them to the printer with a few lines of code:

var printHelper = new PrintHelper(Container);
printHelper.AddFrameworkElementToPrint(PrintableContent);

printHelper.OnPrintFailed += PrintHelper_OnPrintFailed;
printHelper.OnPrintSucceeded += PrintHelper_OnPrintSucceeded;

await printHelper.ShowPrintUIAsync("UWP Community Toolkit Sample App");

This PR also includes a Print button to print code samples (Fixes #450)

Documentation will come in another PR

@dnfclas
Copy link

dnfclas commented Oct 17, 2016

Hi @deltakosh, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

deltakosh added a commit that referenced this pull request Oct 17, 2016
jasonshortphd added a commit that referenced this pull request Oct 17, 2016
Add documentation for PrintHelper (#485)
Conflicts:
	docs/helpers/PrintHelper.md
@IbraheemOsama
Copy link
Member

LGTM but there are conflicts @deltakosh
I was wondering if there is a cloning method we can call on PrintableContent so we don't have to remove it from root grid and readd it after printing succeeded.
(I didn't find my self but maybe serialization and deserialization would cause a loop because of parent child relation)

@deltakosh
Copy link
Contributor Author

Unfortunately there is XamlReader in UWP :(

@deltakosh
Copy link
Contributor Author

Should be good now

@IbraheemOsama
Copy link
Member

@deltakosh sorry but we still having conflicts here :)

@deltakosh
Copy link
Contributor Author

lol everytime I merge other PR I add more conflicts here :)

@deltakosh
Copy link
Contributor Author

@IbraheemOsama should be good now

// Set-up "printable area" on the "paper"
var stateBag = new PrintHelperStateBag();
stateBag.Capture(element);
_stateBags.Add(element, stateBag);
Copy link
Contributor

Choose a reason for hiding this comment

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

when changing the page orientation from portrait to landscape, the preview hangs and in debug mode we get this error

An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: An item with the same key has already been added. Key: Windows.UI.Xaml.Controls.StackPanel

@deltakosh
Copy link
Contributor Author

fixed! Thanks @hermitdave

@hermitdave
Copy link
Contributor

LGTM

@hermitdave hermitdave merged commit cbf9591 into dev Oct 26, 2016
@ScottIsAFool ScottIsAFool deleted the print branch October 26, 2016 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants