Search This Blog

Thursday, December 15, 2011

Silverlight two lines in a button; Silverlight two polylines in a button; Silverlight draw shapes inside a button

To draw shapes inside a button use Polyline. You use Fill property to set filled shapes color and Stroke to set line’s color. StrokeThickness sets line’s thickness. Points are just X,Y coordinates.

<Button>
    <Grid>
        <Polyline Stroke="Red" StrokeThickness="2" Points="0,0 8,8" />
        <Polyline Stroke="Red" StrokeThickness="2" Points="0,8 8,0" />
    </Grid>
</Button>

image

Wednesday, December 7, 2011

Notepad++ XML Tools Pretty print Errors detected in content

If you’ve installed XML Tools for Notepad++ and after pressing ctrl+shift+alt+B (pretty format XML with line breaks) you get an error:

“Error in content. […..]”

Look for ANY non-UTF-8 characters in your XML. That could be the case.

Sunday, December 4, 2011

how to install coffee-bytes plugin in eclipse; Eclipse folding plugin; manual folding plugin

I had trouble finding a good folding plugin for eclipse Indigo. The installation details are inserted below. In short: download the archive, extract plugins and features folders to the appropriate plugins and features folders in eclipse.

USAGE:

in User Defined Regions tab use e.g.:

Start identifier: region    End identifier: endregion

In code:

//region SomeName
your code
//endregion SomeName

 

Installation instructions:

  1. Install plugin
    1. Unpack the downloaded file eclipse-folding-plugin.tar.gz
    2. Copy the contents of the:
      1. features folder => eclipse features folder
      2. plugins folder => eclipse plugins folder
  2. Configure plugin in Eclipse:
    1. Select "Windows->Preferences"
    2. Select "Java->Editor->Folding"
    3. Check the "Enable folding" option
    4. Select "Coffee Bytes Java Folding" in the "Select folding to use:" option
    5. Check "User Defined Regions" in the "General Fold Setting:" option

Thursday, December 1, 2011

Silverlight DoubleAnimation rotate 180 degrees; Silverlight animation rotate image from style; Rotate ToggleButton image

This example shows how to make a ToggleButton with an image that rotates according to toggle button’s state.

1. Add a ToggleButton to your view and set its style. (You can download a standard toggle button’s style from microsoft’s sites)

2. Edit the Style:

<vsm:VisualStateManager.VisualStateGroups>
    <vsm:VisualStateGroup x:Name="CheckStates">
        <vsm:VisualState x:Name="Checked">
            <Storyboard>
                <DoubleAnimation Duration="0:0:0.25" Storyboard.TargetName="myToggleButtonRotateTransform" Storyboard.TargetProperty="Angle" To="0"></DoubleAnimation>
            </Storyboard>
        </vsm:VisualState>
    </vsm:VisualStateGroup x:Name="CheckStates">
</vsm:VisualStateManager.VisualStateGroups>

<ContentPresenter RenderTransformOrigin="0.5,0.5"
        x:Name="contentPresenter"
        [.... SOME OTHER STANDARD PROPERTIES ...] >
    <ContentPresenter.RenderTransform>
        <RotateTransform x:Name="myToggleButtonRotateTransform" Angle="0" />
    </ContentPresenter.RenderTransform>
</ContentPresenter>

 

Full style source here.

Silverlight xaml style add image

I will cover adding images with the example of ToggleButton. To add an image to a Silverlight style just do the following:

<ToggleButton>
    <Image Source="/Some.Company.Namespace.ModuleName;component/Styles/Images/image.png" Width="10" Height="10" />
</ToggleButton>

Where Some.Company.Namespace.ModuleName is the assembly name (project properties->Assembly name). This is followed by ‘component’ which denotes project folder. Then we have folder path and image file name.

So the path is:

AssemblyName;component/PathToTheImage

Tuesday, November 29, 2011

Replace/change headlights’ light bulb in Opel Corsa C 2006 1.3 CDTI

Changing the light bulb in Opel Corsa’s C can be a little tricky especially when YOU CAN’T really see what’s inside the headlight as there is so little space inside. I decided to take this picture to make our lives a little easier.
Instructions:
1. Hang the wire on the headlight’s bottom’s hook
2. Line-up the wire with the bulb's cavities
3. Pressing the wire to the bulb’s cavities widen the upper part and THEN push it toward the bulb. After pushing the wire start squeezing it together.


C# DependencyProperty assign List or Array; C# convert List to DependencyObject

Actually if you’re trying to set a List<object> to a dependency property you don’t need to do any of these things. Just make your base class inherit from DependencyObject and use SetValue() method.

public class YourClass : DependencyObject
{
    public static DependencyProperty SCProperty = DependencyProperty.RegisterAttached("SC", typeof(List<SD>), typeof(DataGrid), new PropertyMetadata(SCChanged));
                                                                   
    public static void SetSortedColumns(DependencyObject dp, object value)
    {
        dp.SetValue(SCProperty, value);
    }

    public static object GetSortedColumns(DependencyObject dp)
    {
        return dp.GetValue(SCProperty);
    }

    private static void SCChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { }
   
   
    //REST OF YOUR CODE
    [.....]
    //REST OF YOUR CODE
   
    private void SomeMethod()
    {
        SetValue(SCProperty, newValue_List);
    }
}