Here is my scenario:
I have a Gridview that shows data retrieved from a network service. The number of data may be quite large. So, the VirtualizingStackPanel is used to display the content. Some of those data may require retrival of images when they are rendered(lazy loading)
My (very limited) understanding is that the VirtualStackPanel will automatically request data as the grid requiring that data is being rendered. If the element that needs to be rendered is of image type, I send a placeholder image and submit an async network call to retrieve that image.
But, I notice that the calls to render all the element is being received and consequently a deluge of network calls to retrieve images are sent (esp if most of the items are of image type).
Question: Is there something I should be configuring in code (XAML or C#) for the VirtualizingStackPanel or should go the route of detecting if the item is really being displayed and then issue network call?
Here is my XAML.
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Grouped Items"
Grid.RowSpan="3"
Padding="116,137,40,46"
ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
VirtualizingStackPanel.VirtualizationMode="Standard"
ItemTemplateSelector="{StaticResource CellStyleSelector}"
ItemClick="ItemView_ItemClick"
IsItemClickEnabled="True"
SelectionMode="None"
IsSwipeEnabled="false">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
Here is the Item's Property which is bound to the Image in XAML
private ImageSource _image = null;
private String _imagePath = null;
public ImageSource ThumbImage
{
get
{
// Check if the image is already cached
if (this._image == null)
{
// Setup a placehoder image
this._imagePath = "Assets/metro_photo_55#2x.png";
this._image = new BitmapImage(new Uri(Defs.BaseUri, this._imagePath));
// Async call to download thumb image from server
this.getThumb();
}
return this._image;
}
private set
{
this.SetProperty(ref this._image, value);
}
}
Here is the async call to download the thumb
private async void getThumb()
{
// Get image and store
Network network = new Network();
// Since this is a bound property. this action updates the UI
this.ThumbImage = await network.getImage(this._rawData[Defs.PATH_KEY], true);
Debug.WriteLine(this._rawData[Defs.PATH_KEY] + " - Thumb retrieved!");
}
Related
I'm having some difficulty getting some data to be shown the first time a page is loaded on an ionic app.
What I want to happen is for a user to click a link of the menu, the page to load and data to instantly be displayed. But whats happening is nothing is shown the first time the page is loaded, but if you re-click the link from menu data will be displayed.
My code is -
export class ViewSessions {
lastScans = [];
ionViewWillEnter(){
this.barcodeTracker.lastScans = this.barcodeTracker.getScans();
}
constructor(private barcodeScanner: BarcodeScanner, private
nativeStorage: NativeStorage, private barcodeTracker: BarcodeTracker,
private storage: Storage) {
this.lastScans = this.barcodeTracker.getScans();
}
}
I think what is happening is the array is only being created the first time the page is loaded. Then populated the second time its loaded. So I tried to create the array on the home-page which is loaded with the app, then adding data to this array when this page is loaded and showing the array from home-page in the html, but this was unsuccessful.
Edit -
This is the getScans function that is being called -
public getScans(){
console.log(this.data);
return this.data;
}
I have an aspx page that inherits the IHttpHandler class.
On page load I issued a call to an Impersonation class in which it renders the content under a different username than that currently logged in. But the problem is when impersonated I call a function back on the code behind in the aspx page that needs to access a div tag in order to insert content to it via an object tag and it doesn't find the tag anymore. Any clue as to why? Or to how am I able to build tags from the code behind in such a situation?
The impersonation function I used is based off of : https://www.codeproject.com/Articles/107940/Back-to-Basic-ASP-NET-Runtime-Impersonation.aspx
And this is the function that is called when impersonated within my aspx page:
public void FUNCTION() //This is called from the impersonation function above
{
report = Session[Document];
string url = "http://localhost/PATH" + report.toString();
HtmlGenericControl objReport = new HtmlGenericControl();
objReport.TagName = "object";
objReport.Attributes.Add("data", url);
Control cntrl = Page.FindControl("objReportFrame");
if (cntrl != null)
cntrl.Controls.Add(objReport);
}
I have an mx:application using the Flex 4.6.0 SDK and I’m having some issues with the FlexPrintJob in Chrome only. The FlexPrintJob worked fine in chrome, up until maybe a couple weeks ago (I made no changes to the code) and now I’ve started experiencing “Shockwave Crashes”.
While printing I’m using:
first title page template
middle section template to handle a DataGrid. This is using the PrintDataGrid and loops through the dataProvider to see if the data will fit on one page, if not it will create another.
Terms and conditions last page template
Problem: I’ve narrowed it down to this, I’m getting the Shockwave Crash error in chrome when the data (for the middle section) exceeds one page and tries to create another. This just started happening, I’m guessing with a chrome update…Sorry if I left something out and my description is lacking detail. I can add more clarification if needed.
Any ideas what’s going on?
Thanks!
--moe
public function doPrint(): void {
// Create a FlexPrintJob instance.
var printJob: FlexPrintJob = new FlexPrintJob();
// Start the print job.
if (printJob.start()) {
// Create a FormPrintView control as a child of the application.
var thePrintView: FormPrintView = new FormPrintView();
addElement(thePrintView);
// Set the print view properties.
thePrintView.width = printJob.pageWidth;
thePrintView.height = printJob.pageHeight;
thePrintView.horizontalAlign = "center";
// Set the data provider of the FormPrintView component's DataGrid to be the data provider of the displayed DataGrid.
thePrintView.summaryGrid.dataProvider = summaryGrid.dataProvider;
// Create a single-page image.
thePrintView.showPage("single");
// If the print image's DataGrid can hold all the data provider's rows, add the page to the print job.
if (!thePrintView.summaryGrid.validNextPage) {
printJob.printAsBitmap = false;
printJob.addObject(UIComponent(mainPagePrint), FlexPrintJobScaleType.MATCH_WIDTH);
printJob.addObject(thePrintView);
printJob.addObject(UIComponent(terms), FlexPrintJobScaleType.MATCH_WIDTH);
}
// Otherwise, the job requires multiple pages.
else {
// Create the first page and add it to the print job.
thePrintView.showPage("first");
printJob.printAsBitmap = false;
printJob.addObject(UIComponent(mainPagePrint), FlexPrintJobScaleType.MATCH_WIDTH);
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
// Loop through the following code until all pages are queued.
while (true) {
// Move the next page of data to the top of the PrintDataGrid.
thePrintView.summaryGrid.nextPage();
printJob.printAsBitmap = false;
// Try creating a last page.
thePrintView.showPage("last");
// If the page holds the remaining data, or if the last page was completely filled by the last grid data, queue it for printing.
// Test if there is data for another PrintDataGrid page.
if (!thePrintView.summaryGrid.validNextPage) {
// This is the last page; queue it and exit the print loop.
printJob.addObject(thePrintView);
printJob.addObject(UIComponent(terms), FlexPrintJobScaleType.MATCH_WIDTH);
break;
} else // This is not the last page. Queue a middle page.
{
thePrintView.showPage("middle");
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
}
}
}
// All pages are queued; remove the FormPrintView control to free memory.
removeElement(thePrintView);
}
// Send the job to the printer.
printJob.send();
}
I ended up taking things apart one-by-one and figured out what it was - the issue was is the FormPrintView. I had some unneeded properties in my PrintDataGrid that I think were originally copied from my main datagrid in my application.
I'm not sure why it was working before and just starting acting crashing now, but either way I shouldn't have had some of those properties there in the first place.
thanks!
--moe
<mx:PrintDataGrid id="summaryGrid" width="100%" height="100%" sizeToPage="true"
alternatingItemColors="[#f7f7f7, #ffffff]" alpha="0.8"
borderStyle="solid" borderThickness="1" color="#646262"
creationComplete="summaryGrid_creationCompleteHandler(event)" fontSize="9"
headerColors="[#ffffff, #e8e8e8]" headerHeight="25" paddingTop="5"
rowHeight="55" textAlign="center" wordWrap="true" paddingRight="-1" >
I've started using LibTiff.NET for writing tiff IPTC tags lately and discovered strange behavior on some files that i have here. I'm using sample code that ships with LibTiff.NET binaries, and it works fine with most of the images, but some files are having image data corruption after these lines:
class Program
{
private const TiffTag TIFFTAG_GDAL_METADATA = (TiffTag)42112;
private static Tiff.TiffExtendProc m_parentExtender;
public static void TagExtender(Tiff tif)
{
TiffFieldInfo[] tiffFieldInfo =
{
new TiffFieldInfo(TIFFTAG_GDAL_METADATA, -1, -1, TiffType.ASCII,
FieldBit.Custom, true, false, "GDALMetadata"),
};
tif.MergeFieldInfo(tiffFieldInfo, tiffFieldInfo.Length);
if (m_parentExtender != null)
m_parentExtender(tif);
}
public static void Main(string[] args)
{
// Register the extender callback
// It's a good idea to keep track of the previous tag extender (if any) so that we can call it
// from our extender allowing a chain of customizations to take effect.
m_parentExtender = Tiff.SetTagExtender(TagExtender);
string destFile = #"d:\00000641(tiffed).tif";
File.Copy(#"d:\00000641.tif", destFile);
//Console.WriteLine("Hello World!");
// TODO: Implement Functionality Here
using (Tiff image = Tiff.Open(destFile, "a"))
{
// we should rewind to first directory (first image) because of append mode
image.SetDirectory(0);
// set the custom tag
string value = "<GDALMetadata>\n<Item name=\"IMG_GUID\">" +
"817C0168-0688-45CD-B799-CF8C4DE9AB2B</Item>\n<Item" +
" name=\"LAYER_TYPE\" sample=\"0\">athematic</Item>\n</GDALMetadata>";
image.SetField(TIFFTAG_GDAL_METADATA, value);
// rewrites directory saving new tag
image.CheckpointDirectory();
}
// restore previous tag extender
Tiff.SetTagExtender(m_parentExtender);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
After opening i see mostly blank white image or multiple black and white lines instead of text that have been written there (i don't need to read\write tags to produce this behavior). I noticed this happens when image already has a custom tag (console window alerts about it) or one of tags have got 'bad value' (console window in this case says 'vsetfield:%pathToTiffFile%: bad value 0 for "%TagName%" tag').
Original image: http://dl.dropbox.com/u/1476402/00000641.tif
Image after LibTiff.NET: http://dl.dropbox.com/u/1476402/00000641%28tiffed%29.tif
I would be grateful for any help provided.
You probably should not use CheckpointDirectory method for files opened in append mode. Try using RewriteDirectory method instead.
It will rewrite the directory, but instead of place it at it's old
location (as WriteDirectory() would) it will place them at the end of
the file, correcting the pointer from the preceeding directory or file
header to point to it's new location. This is particularly important
in cases where the size of the directory and pointed to data has
grown, so it won’t fit in the space available at the old location.
Note that this will result in the loss of the previously used
directory space.
I wanted to save the google map into an image from a webpage.
while i was searching for that i got this program.
http://www.codres.de/downloads/gms.exe[^]
besides other alternatives like print screen i wanted to use a program or map api which can save a specified dimension of google map instead of the screen.
i have used browser component in c# for http access and for displaying certain webpages.
I want to know whether there are options to capture the browser screen to image using any c# functionality or even the browser component would have given such options. just a guess.
i would like to have answers, suggestions on how to capture the map with custom dimension and zoom size to an image.
I used this to get captcha Image from the current page, so you can use similar code just amend the imageID to point to the google map image and use this solution for zooming.
public string newsavefunction(WebBrowser webBrowser1)
{
IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.DomDocument;
IHTMLControlRange imgRange = (IHTMLControlRange)((HTMLBody)doc.body).createControlRange();
string imagename = string.Empty;
try
{
foreach (IHTMLImgElement img in doc.images)
{
imgRange.add((IHTMLControlElement)img);
imgRange.execCommand("Copy", false, null);
using (Bitmap bmp = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap))
{
bmp.Save(#"F:\captchaimages\captchapic.jpg");
}
imagename = img.nameProp;
break;
}
}
catch (System.Exception exp)
{ }
return imagename;
}