How to interpolate between colors for a polygon in Bing Maps - wpf

I have a WPF application with the Bing Maps API. What I have is a polygon rendering on many countries as well as real time statistics being display. I'm using this to keep track of where my server traffic is mainly coming from. The project is coming along nicely, but I hit a small roadblock. What I have are polygons that go from green to red and vice versa if there is a change in the statistics. If someone logs off then it would go into the green, if someone logged on it would go into the red. What I'd like to do is given a set number of users, let's say 20, I can gradually change the colors over a period of a second.
An example is 0 would be green and 20 would be red. So 10 would be yellow. With this, is there a way to gradually change colors?
Thanks in advance

There might be a fancy way of doing what you are looking for in xaml, but I imagine it would be a lot easier to to just have the color of the polygon bound to a property in your viewmodel/code-behind and then update the color whenever necessary.
For color interpolation, there is another SO question on it here.

Related

How to go about changing the tint color of an image?

Sorry for the vague title, I have no idea how to really ask this question to be honest so I'll describe what I'm trying to do
I'm attempting to make an app where users can change the colors of different parts of a car. They can change the door for instance to a green as shown, or any other color they wish. They would then be able to change the color of the hood, or the roof, etc.
I've thought about having seperate images for each component and then lining them up to match. However this seems practically impossible when it comes to different screen sizes and scales. I also thought about making a blanket white image, and then creating views over the top with the selected color.
Does anyone have any ideas how I could possibly approach this?
Thankyou
I dont know about the performance of this. But, how about, an overlay of the different parts of the car, but using the same size of the whole car. For example, you have the image of the whole car, and erase all but the door. In other image, you erase all but the hood. If you lay one image above another, it will make the whole car, and the size of the screen will not affect you, because all the images will have the same size.
Then you can use the tint style to change the color of each layer.

How to add a progress bar showing the level of a person

I've looked everywhere for a tutorial for this but had no luck.
What I'm trying to do is that lets say if a person has 10/100 XP I want it to show like a image progress bar.
You can make a bar for every one XP. You show them based on what they have. There aren't implemented features for progress bars.
Ill answer my 3 year old question as this post still receives views.
I'd advise using node-canvas as it's the best way to generate a buffered image to send.
Create a canvas (follow the tutorial via the README.md)
Set the width to something of your choice (ex. 500px)
Set the height to something of your choice (ex. 20px)
Calculate the percentage of the XP (ex. 10/100 would be .1 or 10%)
Fill the canvas with a height of the canvas, along with a width of the percentage (in decimal) multiplied by the width of your canvas.
Color the canvas that you filled to your choice (Should be prior to filling)
Enjoy your image generated progress bar!

Changing color of an image - at runtime

Im going to make a new application for a car dealership. They basically want a WPF/silverlight application where one can slect a car (model) and then via a color palette choose the color of the car (from predefined colors). They also need to be able to different kind of rims, headlights and interior.
what is the best/easiest approach for this. Been thinking on having all the different images and then just swap them out when the selection changes. This, however has the potentional problem of all images with all combinations does not exist (eg. a red VW, metallic rims, white leather interior) etc.
Is there any other approach to this? replacing colors? Having a basic model and then copying the "body" of the car on top, copy rims on top etc. and then just having to enable/disable a particular "layer" of the images?
I would do this by using different layers: the basic model with the car's color as translucent part, on top of this pictures with the different add-ons, the background color is the car's color. The trick is to fit everything together that it looks good.
Depending on the color (maybe you want to have shadows or chrome effects), you could have one model's picture for each color, and then add the add-ons and the interior on top of this.

MultiScaleImage Zoom Particular Areas

I am trying to create a Deep Zoom based multiscale image that essentially has 2 views. Initially it will display a large map of the world. When the user click the USA the image should then zoom into the USA. Clicking an external button should zoom the image back out. Thats it. I don't want panning or additional zooming.
What I don't understand is how to define a "hit area" around the USA that zooms it in. Can anyone provided links to resources that explain how to do this... I never seem to find exactly what I am after?
Thanks in advance.
I can't remember the code exactly.
But if you generate a project with the source code in Deepzoom composer and then take a look at the source code.
Right down the bottom of the the Deepzoom code is a function for zooming into a LogicalPoint.
Convert the top left point of the image you are zooming into a logical point. Set this as your ViewportOrigin as this will put it in the top left.
http://blogs.msdn.com/jaimer/archive/2008/06/23/working-with-collections-in-deep-zoom.aspx This post here explains the ViewportOrigin quite well. Just remember that everything is related to the Width.
You will also need to set the the ViewportWidth.
When the ViewportWidth = 1 the whole image is displayed so it will be a fraction of the total width of the image. (USA width / WorldMap Width)
Hope this makes sense.

WPF Custom Draw Multiple Progress Bar

In processing a group of items, I wanted to display a unified image of the status of the group, so I essentially made a Grid of a number of progressbars with transparent backgrounds and various colored foregrounds all at the same cell.
I'm running into some transparency artifacts (purple bar is actually purple under the green, and sometimes it draws over the top, etc) and it just seems a bit wasteful. So, I decided to make my own, but now I've got a bit of paralysis on how to do it. Do I use the DrawingContext in FrameworkElement's OnRender, or is there something simpler? Is there a set of general rules when it comes to making your own control?
I pondered switching to a pie chart since those are easy to come by, but its high time I did something not off-the-shelf.
Thanks!
I'm not quite sure how you intend the progressbar to combine different progresses, but if say the furthest along progress is at the bottom of the z-index and the least along progress is at the top, then I'd do something on the lines of this:
1) I would probably create a user control for this new progresbar.
2) It would have a property called NumberOfProgresses, that is tied with an array containing status of said progresses.
3) Each progress would be represented by a Border item (or perhaps something more suitable up the visual tree), because it's a simple wpf control with a background property. The background property would be set to nice a looking progress style and the progress color can be bound in the style to say the border's borderbrush property. Making it easy to set the color of the progress.
4) The user control would have a method UpdateProgress which takes the percentage value and the index of the progress in the array as parameters.
5) As progresses are updated you can either, just calculate the appropriate width (user control actual width * percentage) for the border and play around with the Z index to get it displayed at the top/bottom, or stack the borders horizontaly, set the least along progress as first, then for the rest of the progresses you'd have to substract previous progresses lengths to get the same effect.
This way there would be no transparency induced artifacts and no OnRender()...
Mind you, in WPF there should be no reason to mess with OnRender this and OnRender that, like it was required in WinForms with OnPaint.
Just set up the elements via code to get the look you want, and let WPF do it's rendering ;)
I can imagine one problem with this user control though. You'd have to provide feedback to the user as to which color belongs to which progress. But that would probably take you back to square one, meaning it's better/simpler to just display multiple progressbars.

Resources