|
WPF doesn't use device contexts - doesn't really use HWNDs
on the surface either.
WPF is not GDI!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I was able to get the DC of the window and draw the image in the window loaded event . The thing is the image is not getting retained, its getting redrawn which erases the image again.Any idea like how to overcome this one..
|
|
|
|
|
krishnan.s wrote: Any idea like how to overcome this one..
Yes - Use WPF.
Why use WPF if you're using GDI?
WPF "windows" may be ultimately backed by an HWND, but beyond that everything
is done with a completely different rendering engine.
You should be able to find an equivalent, if not much more robust, way
to do everything in WPF that you are doing with GDI, if you choose to do so.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm using BitmapMetadata.GetQuery() to get metadata from JPEG files just fine with queries like the following, for example, to get the creation date: "/app1/ifd/exif/subifd:{uint=36867}". But when I use the same query string with a .TIFF file, I get nothing back. Every query I make on the TIFF file fails.
I know the TIFF file has the metadata in it I'm seeking because I can see it through the Windows Explorer when I hover over the file name. Here is the code I'm using to read the metadata and the debugger shows me that the BitmapSource I get back from the TIFF file has metadata in it, but the GetQuery() returns null. Should the query string somehow be different for the two formats? Any ideas?
BitmapMetadata metaInfo;
Stream imageStream = null;
imageStream = new FileStream(imageUri.LocalPath, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
string extension = System.IO.Path.GetExtension(imageUri.LocalPath);
BitmapSource bitmapSource = null;
switch (extension.ToLower())
{
case ".jpg":
JpegBitmapDecoder decoderJpg =
new JpegBitmapDecoder(imageStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.Default);
bitmapSource = decoderJpg.Frames[0];
break;
case ".tif":
TiffBitmapDecoder decoderTif =
new TiffBitmapDecoder(imageStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.Default);
bitmapSource = decoderTif.Frames[0];
break;
default:
break;
}
metaInfo = (BitmapMetadata)bitmapSource.Metadata;
if (metaInfo != null)
{
if (metaInfo.ContainsQuery("/app1/ifd/exif/subifd:{uint=36867}"))
return metaInfo.GetQuery("/app1/ifd/exif/subifd:{uint=36867}");
else
return null;
}
else
{
return null;
}
|
|
|
|
|
I'm not sure what the generic queries are for what you're looking for,
but TIFF uses a different format.
Maybe take a look here: Photo Metadata Policy[^]
You can also use TIFF tag values directly if you're familiar with
the format, e.g.
"/ifd/{ushort=256}" Image Width
"/ifd/{ushort=257}" Image Height
"/ifd/{ushort=305}" Software
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I suspected it was something like this! And that's a great link you provided. Thanks for your timely response. Several years ago I succeeded in doing all this using the Small Animals library. He must hide all these differences because the code I had to write was image-format-independent. I just supplied a file path and and got metadata transparent of the various formats. Earlier today I performed a sanity check by testing the same TIFF images that were failing in my WPF code and they worked in that old MFC app. So I'm off and running on this aspect of my program anyhow. I'm still having trouble in my WPF app transferring metadata from a JPEG that I perform an image transformation on (scaling), but I have a link that supposedly accomplishes this. And by the way, I am familiar with the Metadata Query Language (http://msdn.microsoft.com/en-us/library/aa968944(VS.85).aspx[^])
|
|
|
|
|
fjparisIII wrote: I am familiar with the Metadata Query Language (http://msdn.microsoft.com/en-us/library/aa968944(VS.85).aspx[^])
I am not....thank you for the link!!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: fjparisIII wrote:
I am familiar with the Metadata Query Language (http://msdn.microsoft.com/en-us/library/aa968944(VS.85).aspx[^])
I am not....thank you for the link!!
The section, Property Rules, in the document you referenced gives the location of the link I sent you.
Well, I upgraded my program to read TIFF metadata based on the information in your reference. What a mess that was. Image metadata is in a hopeless tangle and everytime some big company tries to bring order to the chaos by introducing a new way of encoding metadata, it just gets messier because you still have to support all the ugly legacy formats in addition to all the slick and elegant new ones. Elegance piled on elegance piled on kludges, and now my program has all that crud in it.
|
|
|
|
|
|
|
I was googling for something else earlier today, and I accidently used this google phrase:
wpf get control in datatemplate
I'm sure you'll get hundreds of hits. Once you get the control, you should be able to manipulate it any way you wish.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
|
|
Since you're using an ItemsControl, there's no notion of
"selected items" so you'll have to track that somehow yourself.
I assume you're doing that somehow already if you know certain items
need their listbox selection changed.
Once you have the ItemsControl item(s) which you need to manipulate, for each item
you can get its template and use FindName() to get at its ListBox (you'll need to give
that template ListBox a name).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Collin Jasnoch wrote: I am not exactly sure what you mean. The Listbox in the template? How can I give it a name? Even if I name it, it is not valid since it is in a DataTemplate.
I was referring to using FindName() to find an element at runtime which was created
through a template (i.e. the "Listbox Inside of a Template"). You'd use x:Name to give
it a name, and find the element with FindName().
If you already have a solution then never mind
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
BTW, I'm still working with your original post where you stated
"I would like a way to remove the selection from specific listboxes."
To do that, you set the listbox's SelectedIndex to -1 (the user can also
do this with Ctrl-Click).
To set the listbox's SelectedIndex to -1, you need the actual listbox object,
which was created via a template, so you use FindName() to get the object at
runtime (since it doesn't exist at design time).
Now you're discussing what you do in response to a listbox's selection changing,
so I'm probably way off topic at this point
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It is simple only. Access the list box items and set the selected index to -1.
e.g.
MyViewModel context = this.DataContext as MyViewModel ;
var results = lstBoxCity.SelectedItems;
bool flag = true;
foreach (RefGeneralValue rval in results)
{
if (rval.RefGeneralValueId == 0)
{
lstBoxCity.SelectedIndex = -1;
flag = false;
break;
}
}
if (flag == true)
{
}
N.B.~ RefGeneralValue is a entity that we are using in our project.
It is as follows (given only for ur reference)
[Serializable]
[DataContract]
public class RefGeneralValue : BaseDomainClass
{
public RefGeneralValue();
[DataMember]
public virtual DateTime? ModifyDate { get; set; }
[DataMember]
public virtual string RefGeneralTypeId { get; set; }
[DataMember]
public virtual string RefGeneralValueCode { get; set; }
[DataMember]
public virtual string RefGeneralValueDescLong { get; set; }
[DataMember]
}
Thanks
Niladri Biswas
|
|
|
|
|
I have used a Barchart in a Client Report Definition (.rdlc) subreport which works properly when shown individually but does not work when integrated with a main report. While showing the Main report, the main report and all its subreports work absolutely fine except the one using BARCHARTS. This barchart subreport comes blank.
Thanks & Regards
Jitesh
|
|
|
|
|
Hi,
I am developing one application in that I stored images from xaml page using generic handler and i am retrieving image from database using generic handler.I have written the database code to retrieve image in generic handler and i am calling that handler page in xaml page.Retrieving the image is working for me now.But my problem is how to retrieving images from DB and bind it to Datagrid in silverlight.And how to call data grid function and where to call that function.I referred the following link to bind images to datagrid but its not working for me and i am not getting how they are calling datagrid function.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=264&AspxAutoDetectCookieSupport=1
Please can anybody help me solve this problem.
Thanks in advance
Pavani
|
|
|
|
|
pavanip wrote: i am not getting how they are calling datagrid function
Calling what datagrid function?
There is an event handler added to the datagrid, and the only access from
code to the datagrid is to the datagrid's Columns property.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In datagrid I used the following attribute to call that function
LoadingRow="dGrid_LoadingRow"
But i am not getting when it will be fired and the code executes.I have written the following code in that event
private void dGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
FrameworkElement ele = dGrid.Columns[4].GetCellContent(e.Row);
string url = "http://localhost:52614/Display.ashx";
Uri imageUri = new Uri(url, UriKind.RelativeOrAbsolute);
(ele as Image).Source = new BitmapImage(imageUri);
}
But its not executing when i debug it line by line. Or can you please tell me tell me how to bind images to datagrid in silverlight.
|
|
|
|