I am working with expression blend and c# to create a silverlight site. I would like to create a map of the world which has many regions. on clicking on the region the colour changes. I have already created the regions.
Does anyone know how to do that?
Thanks
Since you have the regions created already, when you get the click event you need to change the colour of the region. Normally this would be the background property of the control, though it can depend on what control you used to represent a region?
Edit in response to comment
Since you're using rectangle and other shapes Fill is the property you will be changing.
Related
I need to include a colorpicker in a form in a powerpoint custom task pane. I want to be able to show a colorslider which shows the gradient going from 0 to highest saturation of a given color, with a draggable control to select the saturation from the slider (like the one in the ColorDialog form). Is there an existing implementation in the api/easily available alternative?
Check the below links
http://msdn.microsoft.com/en-us/library/ms996423.aspx
http://msdn.microsoft.com/en-us/library/ms996423.aspx#colorpicker_topic3
You can try to create color slider with the help of above links.
http://msdn.microsoft.com/en-us/library/ms996423.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.colordialog(v=vs.110).aspx
Also codeplex has probably hundreds of similar controls
I have one green checkmark (an image control). I have to verify that the checkmark is green. I am not able to get the color. Can you help me?
Coded UI is about checking the functionality of an application. It is not so good at checking the aesthetics (ie colour, size or fonts).
Rather than check the colour can you check some other feature of the UI control for the image? If the green image is not shown then what is shown instead? Try using the crosshairs tool to inspect the green image and also to inspect any other images shown in the same place. Hope to find some properties to distinguish the green image from the others.
You could request the developers to add some distinguishing features. If they do not want to then ask them how a screen reading program for sight impaired people would be able to tell the difference between the images.
For checking colours of UI controls you could capture and image of the controls and then examine the colours used in the image. To get the image use code based on
Image img = this.UIMap.UIYourApplicationsWindow.UISubWindow.UISubSub.CaptureImage();
When testing an application with a page save message, we had an error message that was always there, but was either colored red or not to make it visible or not. I found that the filter property controldefinition had reference to the color of the control. Could you look to see if the color is mention in any of the properties? If not AdrianHHH's answer is your best bet with coded ui.
Sikuli could compare the image if you want to run a little sikuli script from your coded ui test.
I have a C# WPF application where I have several possible images, some having irregular shapes within the image. I would like to generate different events when clicking on the different shapes within the image.
For example: If the image was of the front of the house, I would genereate different events when clicking on the doorknob, the door, the windows, the roof, etc.
The image has to be resizable.
I can do it manually with a grid and shapes, but it seems like there should be a more elegant way.
I thought I saw a technique where you could make a "shadow" image that was like the original, but with each clickable region filled in a different color. (A "color map" of the clickable regions.) Then the click handler could access the color of the shadow image and raise the appropriate event. However, I couldn't figure out how to hide the shadow image "under" the display image and still have the click event handler pick up the color.
I'm sure there's a good way to handle this, I just don't normally work with images so I'm completely ignorant of it.
Thanks.
How about having the nice image higher in the Z-order than the "shadow image" and setting topImage.IsHitTestVisible = false;
This would cause clicks to bypass the top, visible image and go straight to the underlying shadow image click handler.
Another technique I have used in production code is to derive a new class from Image and override HitTestCore and test the pixel value myself and if it's a certain color or opacity, I return a different object. This way I control all the action.
I'm using the DatePicker control from the WP7 SL toolkit. It navigates to DatePickerPage.xaml, which has the scrollers for date picking. I want to keep all the functionality, but change the colors. I'm messing around with DatePickerPage.xaml and updating colors to fit my needs.
I've been able to update the text colors on the scrollers and header, but I can't figure out how to update the background color on the selected item in each or the square outline while the scroller is active. Based on tests I have done with changing the background color of the DatePickerPage.xaml, it appears that the selected item and square outlines are an opaque version of the background color. Unfortunately, this wont work for me, since I want the background to the be white and the outlines aren't visible. Is there a way to explicitly set those colors?
If you get the control into Blend and right click on it and select Edit Tempate --> Edit a Copy, you'll get the template for the control so that you can edit it.
What you'll be looking for is the resources keys that are used for the background, foreground, etc. You can replace them with your own resources, or hardcode them, or the best option is to override the resource.
Additional Advice
Be careful though, don't forget that a user can have either a dark or light background to the phone, so unless your app is taking control of the background color of the whole page, you need to consider what might happen when picking colors
I can draw a 3D border using ControlPaint.DrawBorder3D, but I get the 'Windows Classic' 3D border. I want to draw the current theme's 3D border - in the default XP theme, this is a 1px blue or gray border. How do I draw that, and how do I get its widths?
Sounds like you might need to look at System.Windows.Forms.VisualStyles.VisualStyleRenderer:
The System.Windows.Forms.VisualStyles
namespace exposes VisualStyleElement
objects that represent all of the
controls and user interface (UI)
elements that are supported by visual
styles. To draw or get information
about a particular element, you must
set a VisualStyleRenderer to the
element you are interested in.
To draw an element, use the
DrawBackground method. The
VisualStyleRenderer class also
includes methods, such as GetColor and
GetEnumValue, that provide information
about how an element is defined by the
current visual style.
There's a code sample on that page as well.
You will have to draw the border yourself, but you can get the color from VisualStyleElement.Window.Caption.Active and the size should be the size of the window frame (I believe), which is VisualStyleElement.Window.FrameBottom.Active. If you explore the VisualStyleElement.Window, you should be able to determine which window element has the information you need to draw your border.
Pre .NET Framework 2.0 Answer
I'm assuming that you are drawing your own, special control and you want to use elements of the currently active theme to draw it so it better fits with standard XP controls. You're NOT trying to, for example, enable theming on a standard Button control. Correct?
It's actually somewhat complicated. Your main focus should be UxTheme.dll. This houses everything you need for drawing themed controls. Here is a nice C# wrapper around this dll to make your life easier. There are others so if this isn't exactly what you wanted, I hope I've pointed you in the right direction.