Sunday, 15 March 2015

c# - Windows Store Apps async xaml rendering -



c# - Windows Store Apps async xaml rendering -

i'm trying load vector image in zoomable scrollviewer, works great on laptop, slow on tablet when zooming/unzooming. ui frozen during image rendering.

my image converted svg xaml file inkscape. (~2,37 mb)

c#

public mainpage() { this.initializecomponent(); this.loaded += mainpage_loaded; } async void mainpage_loaded(object sender, routedeventargs e) { string filecontent; storagefile file = await storagefile.getfilefromapplicationuriasync(new uri(@"ms-appx:///images/plan.xaml")); using (streamreader sread = new streamreader(await file.openstreamforreadasync())) filecontent = await sread.readtoendasync(); var xamlread = xamlreader.load(filecontent) canvas; imgmaingrid.height = xamlread.height; imgmaingrid.width = xamlread.width; imgmaingrid.children.add(xamlread); }

xaml

<scrollviewer grid.row="1" x:name="scrl" zoommode="enabled" horizontalscrollmode="enabled" verticalscrollmode="enabled" horizontalscrollbarvisibility="hidden" verticalscrollbarvisibility="hidden" minzoomfactor="1"> <grid x:name="imgmaingrid" horizontalalignment="stretch" verticalalignment="stretch"/> </scrollviewer>

how can render canvas in background ? (without blocking ui). if it's not possible, how can handle rendering add together progressbar while rendering ?

this not real reply question, temporary solution.

first open svg file inkscape , enlarge big resolution (i tried 3500*4000), , export xaml. (this method enlarge image keeping little file size).

on c# code add together xamlread.cachemode = new bitmapcache(); , render image vector bitmap exported size.

in end 's working big png/jpeg image smaller file size. other interests of utilize vector images lost. result fair.

c# xaml windows-store-apps

No comments:

Post a Comment