I'm currently using a semi-transparent WPF form with no border as a camera style device in a program of mine. However, when I access the position (top, left) and dimension (height, width) properties of the form, it would appear they are wrong.
The top property reported to be roughly 26 pixels higher than it actually is in relation to the desktop. IE if I put the forms top and left at (0,0) the properties will report (0, -26).
The height is also incorrect, reporting about 50-60 pixels shorter than it actually is.
Has anybody experienced this problem in the past and have a solution?
Regards,
Andy Hunt
if I understand correctly, this is no problem at all but the expected behavior.
WPF uses DPI-independent virtual units for measuring size and position, not actual pixels.
There are many sources like this explaining this.
If I understood the question wrong (its late and I am tired ;) could you provide a code sample illustrating the issue?
Andrej
Related
I want to create a plot that dynamically displays active elements as rectangles. I have achieved a first version that is actually ok using OxyPlot.Annotations.RectangleAnnotation which I add to myPlotModel.Annotations, you can see it in the image hereafter:
Example of wanted display
The thing is that after a while, the amount of drawn rectangles make the update not smooth as I update the shown timewindow (which is set to 15 seconds). I have already set a maximum of drawn elements that suffice to cover the displayed window (i.e. the rectangles get removed as they are too far in the past), but the rendering is still jerky. I draw the rectangles by allocating them to an equal fraction of the Y-axis, that is the third one from the top gets:
rowNumber= 3.0
minimumY = maximalY - maximalY / totalElements * rowNumber
maximumY = maximalY - maximalY / totalElements * (rowNumber + 1.0)
And the Y-axis is hidden.
My question:
Is there a smarter way of creating such a display that would be less computationally heavy, and therefore allow a smoother update? I do not have to stick to OxyPlot, it is simply the easiest way that I found to obtain what I wanted.
Thanks for your answers!
Technically, the answer to your question is "Yes".
There are a number of ways to do this.
You could have a vertical itemscontrol that had an itemscontrol in it's template. That could have a canvas as it's itemspresenter and you could bind canvas.top and canvas.left to properties in it's content. Template each into a rectangle and bind height and width.
And of course do something about the scale on the bottom and the column of activity labels or whatever you want to call them there.
Unless you're using an absolutely ancient machine, that'd just fly.
It's quite a lot of work but it would probably be quicker to write that than to search through a load of alternative packages and decide which was optimal.
So this may be a bit vague, but I'm having some issues. Basically, I am drawing my little ninja sprite (16x16px) and on 2 frames of his animation, he loses pixels on his headband. I have looked everywhere in an attempt to find an answer, but to no avail.
Original Sprite Sheet (Bugged frames are 4th row, 3rd and 4th frames):
After a little more investigation, it seems that the bugged pixels are due to the width of the sprite sheet. It almost seems random what pixels get messed up depending on the width. However, with a constant width, the messed up pixels are constant regardless of creating a new build or using an old one.
As you can see, the back of his headband is missing pixels. While it may not be game changing, it is very annoying and if anyone knows of a fix, that'd be great! Thanks guys!
My guess is that those pixels are magenta (255,0,255) which is automatically keyed out of the image as transparent by the SpriteTextureProcessor. If that is the case, change the pixels to be a slightly different color (255,1,255) or use the TextureProcessor for the content. You can do this in the properties window of the image file in your content project.
So a workaround I found is actually changing the size of the rectangle used to display the image. It was set to 100, setting it to 99 works and there is barely any visual difference.
I want to make a vertical meter for values between 2 ranges.
so what i tried so far, was to make a frame, and under it put a mask, and under that a rectangle.
with the idea, of lowering/increasing the rectangle Y position to make it seems to move.
rect.position = new Vector3(rect.position.x, (rect.position.y - rect.sizeDelta.y));
so i did that, to first lower by it's height, so the bar will seem empty.
but it doesn't work right, the position depends on the screen size, and the rect Y end up way lower then exactly his height.
so, tl;dr, i want a bar that i can give a value between 0-100 and it will fill it according to that.
and i might have gone wrong about it.
so, any suggestions would be appreciated.
edit:
Add picture to show what i want the bar to look like:
Well i feel kinda dumb
I didn't realize how customizable the Slider control is.
I removed it's handle, unchecked interactble and removed it's background, and now i can give it a value between 0-100 and it works exactly as i wanted.
thanks Mathias Siig Nørregaard for referencing me to the video link that opened my eyes.
I have a treeview that contains icons. The icons are ugly. and by ugly i mean low quality. and by low quality i mean something i would expect to see from a dos program
i would hope there would be a way to improve the image quality of the icons, but after looking around on microsoft's development site, I have yet to find a solution.
to be honest, at this point i don't even know what to look for. 'image quality' is very too broad of a phrase to search for (i've gotten very random results from google searches).
i am using an ImageList to store these icons in the TreeView. there really isnt much code to show that would be of use here - at least i dont think so.
sorry for the boring question.
Is this what you're looking for?
http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.colordepth.aspx
The default value is set to 8-bit, so changing this property of your list will probably help. Essentially, just add the following line to your code:
imagelist.ColorDepth = ColorDepth.Depth32Bit;
It can be improved. What you need to do is to open it in photoshop or gimp and resample it at 3 times it size. Then resample it at 600 dpi and resize it down to 8 x 10.
Notice, that I specified to resize and not down size. You click on the pic and the corners have a handle for you to click on and size it down to the appropraite size. This way, the pixels are closer together.
Then, you use a very soft blur, I mean really soft. The secret is when it is printed. We print at 600 to 1200 dpi which is what will enhance the picture and that is what a printer has to keep in mind. When you print on glossy paper at 600 dpi, the pic comes out really nice and sharp.
Not sure if anyone else has seen this, but I am rendering a custom control that has zoom functionality. Lets say for simplicity sake that I am just drawing one rectangle with border width = 1 in the viewable area of the control. When I alter the zoom (graphics.ScaleTransform()) the rectangle's borders take on different sizes (sometimes the same, mostly different). This makes my control look ugly when the user zooms in or out. I'm sure it's something really simple but i'm struggling to fix it. Any help appreciated!
thanks,
Thornza
Yes, the pen width gets scaled as well. Create a pen with a Width = 0. That will always be one pixel wide, regardless of the ScaleTransform.