|
I was refering to recreating the image as a VECTOR image. In other words, drawing a new one so that I was a VECTOR image, then it would scale perfectly.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I think I don't fully understand what do you mean. Are you talking about using a vector graphic (like the ones produced by expression design)? Yes, they scales perfectly, but that's not the problem. My problem is the loss of colordepth in preexistent images. Every image that shows in a wpf app has the "compressed" appearance of a thumbnail, no matter the actual size of the image (actually, it doesn't matter the format either, I've just tried with a bunch of JPG and GIF with the same results as the PNG), while the same image using windows.form controls renders as the original.
PS: maybe is there a class that convert raster images in vector ones and I missed it?
|
|
|
|
|
If you are not scalling or resizing a .jpg, .png, etc at runtime or design time, then the image should display perfectly. I've never heard of anyone with this problem.
To be sure, set the Image control height and width to Auto and the Stretch to None and tell me if the problem is still there.
As soon a you resize or scale an image, WPF has to step in and do it's thing.
Vector: If you only have a few backgrounds you want, then you "can" make then from scratch and use them. If you have many images, then this probably won't work for you.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Yup, I've never heard that before, but as this is a fresh install (I downloaded and installed the iso image of vs2008 from microsoft a couple of days ago) I assume it is not a corruption error.
Im still amazed that some simple test that the one shown in my first screenshot can throw so differents results, but as google shows nobody complaining about colordepth and wpf I'll revise my installation anyway. On monday I will deinstall and reinstall everything again and check.
Cheers.
PS: yes, I'm the previous poster, but codeproject has decided to not accept the password...
|
|
|
|
|
I've set up a virtual machine and installed the vs express and all updates. Now the program shows the image coorectly. Seems that the orginal iso images doesn't install/updates every piece of the runtime.
Anyway, thanks for the interest, and sorry for the noise.
cheers
|
|
|
|
|
WOW! Bummer stuff. Consider reporting this to Microsoft.
I'm glad you got it all sorted out.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I wrote a simple application:
<Button MouseDown="buttonX_MouseDown" ... />
and C# code:
private void buttonX_MouseDown(object sender, MouseButtonEventArgs e)<br />
{<br />
if (e.RightButton == MouseButtonState.Pressed)<br />
{<br />
...<br />
}<br />
else if (e.LeftButton == MouseButtonState.Pressed)<br />
{<br />
...<br />
}<br />
}
However, this event fires ONLY when I press right mouse button. It does not fire (the whole event) when I press left mouse button over this button. Why?
|
|
|
|
|
Because the Button is eating the left mouse button down.
I think if you set up a handler manually for the event in code, there is an property that you can set to tell WPF that you want to receive the click event after is have been marked as HANDLED.
Just look into wiring up routed events that are HANDLED.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
how can i set shadow for a wpf form (winxp)
i want to design a startup form with shadow over desktop
|
|
|
|
|
for just the start up form, you can use a borderless window, then use a bitmap effect on the window root element.
So if you root element was a Grid, you would apply the bitmap effect to the Grid.
There is a good bit of example WPF code out there that explains creating a transparent, borderless (a window without chrome).
modified 27-Feb-21 21:01pm.
|
|
|
|
|
this way is basic and not specified to wpf
is there any new properties that make shadow for controls in wpf?
|
|
|
|
|
Yes.
BitMap effect.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
Look into WPF DataTemplates. You can use a TemplateSelector to select different templates based on some code in the TemplateSelector or you can use a DataTrigger in the DataTemplate to change which icon is displayed.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks Karl. It worked for me. One more question, can we have separate icon for each node? I am asking because currently I am assigning image depending upon the HasItem property of treenode. In future I will like to show different icons for each node. Is it possible?
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#1.1, C# 2.0, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
Yep.
Use one of the two previous methods I gave you and test against the data that is bound to the TreeV Item. Then display the icon you want.
WPF makes things like this very simple for developers. Got to love WPF.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks Karl for reply. Yes it can be done using different properties, for example check the tag value and set the image. Now I am crating a generic user control and I want these images should dynamically get assigned. So, application1 will like some another icon at root level and different icon at child node level, similarly application2 will like to use some different icons. What I will like to do is let the application using my control set the images programmatically. How can we do this?
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#1.1, C# 2.0, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
This a SUPER easy in WPF.
Read up on Styles and ControlTemplates . There are a lot of WPF articles here on Code Project that cover this topic.
This is one of the foundational powers that WPF delivers.
You can simply write one Style, place it in application scope and all Tree controls can use it.
The possibilities are endless.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I`m trying to play a short sound using MediaPlayer class. I`m using the following code snippet:
MediaPlayer mp = new MediaPlayer();
mp.Open(new Uri(@"C:\...\Dom.wav"));
mp.Volume = 1D;
mp.Play();
It goes well, but when I try to play this sound in my form (where I have several endless transformations), it never gets played. I suppose that the reason is that it is to be played on the same thread that UI works. And as the UI works all the time (because of endless transformations), my .wav never gets enough CPU to be played. So I tried to launch it on separate thread. It didn`t help either. The only solution I found is to add a sleep after this:
MediaPlayer mp = new MediaPlayer();
mp.Open(new Uri(@"C:\...\Dom.wav"));
mp.Volume = 1D;
mp.Play();
Thread.Sleep(1500);
But this looks terrible. Could anyone give me another solution?
|
|
|
|
|
If you just want to play sound, look into the managed DirectX classes instead.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Don`t tell me it can`t be done using MediaPlayer class...
|
|
|
|
|
I don't know, but I know that class is slow, and it seems to me like overkill
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Using so enormous technology as DirectX to play 5-second simple sound is even bigger overkill. Thanks for advice however.
|
|
|
|
|
Not really - it's just using built in stuff that is there already.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|