Skip to content

Commit

Permalink
Release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BratchedDev committed Dec 27, 2015
2 parents bf886a5 + 11a9c7c commit e62c58d
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
<rating:RateItemDefinition
BackgroundColor="{Binding FullColor}"
OutlineColor="{Binding FullOutlineColor}"
OutlineThikness="{Binding FullOutlineThikness}"
OutlineThickness="{Binding FullOutlineThickness}"
PathData="{Binding PathData}"/>
</rating:RatingControl.FullItemsDefinition>

<rating:RatingControl.EmptyItemsDefinition>
<rating:RateItemDefinition
BackgroundColor="{Binding EmptyColor}"
OutlineColor="{Binding EmptyOutlineColor}"
OutlineThikness="{Binding EmptyOutlineThikness}"
OutlineThickness="{Binding EmptyOutlineThickness}"
PathData="{Binding PathData}"/>
</rating:RatingControl.EmptyItemsDefinition>
</rating:RatingControl>
</Grid>
<!--<Grid Width="{Binding FullOutlineThikness}"/>-->
<!--<Grid Width="{Binding FullOutlineThickness}"/>-->
<ScrollViewer
Grid.Row="2"
Margin="16,6.167,0,10"
Expand Down Expand Up @@ -241,13 +241,13 @@
VerticalAlignment="Center"
/>

<!--FullOutlineThikness Demo-->
<!--FullOutlineThickness Demo-->
<TextBlock
Grid.Row="8"
Grid.Column="0"
Margin="4"
Style="{ThemeResource BodyTextBlockStyle}"
Text="FullOutlineThikness"
Text="FullOutlineThickness"
VerticalAlignment="Center"
/>
<TextBox
Expand All @@ -256,15 +256,15 @@
Margin="4"
Width="80"
HorizontalAlignment="Left"
Text="{Binding FullOutlineThikness, Mode=TwoWay}" />
Text="{Binding FullOutlineThickness, Mode=TwoWay}" />

<!--EmptyOutlineThikness Demo-->
<!--EmptyOutlineThickness Demo-->
<TextBlock
Grid.Row="9"
Grid.Column="0"
Margin="4"
Style="{ThemeResource BodyTextBlockStyle}"
Text="EmptyOutlineThikness"
Text="EmptyOutlineThickness"
VerticalAlignment="Center"
/>
<TextBox
Expand All @@ -273,7 +273,7 @@
Margin="4"
Width="80"
HorizontalAlignment="Left"
Text="{Binding EmptyOutlineThikness, Mode=TwoWay}" />
Text="{Binding EmptyOutlineThickness, Mode=TwoWay}" />
<!--Path Data Demo-->
<TextBlock
Grid.Row="10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Button
Grid.Row="9"
Margin="8"
Content="MVVM and Value"
Content="Simple Edit"
HorizontalAlignment="Stretch"
Click="Button_Click_4"/>
<TextBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
Value="0"
ItemsCount="5"
Margin="8"
ItemTemplate="Star" >
ItemTemplate="Star"
>

<rating:RatingControl.FullItemsDefinition>
<rating:RateItemDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public RatingControlExampleViewModel()


Nb = 10;
FullOutlineThikness = 5;
EmptyOutlineThikness = 1;
FullOutlineThickness = 5;
EmptyOutlineThickness = 1;
PathData = "M 5.5,0 L 4,4 L 0,4 L 3,7 L 2,11 L 5,9 L 6, 9 L 9,11 L 8,7 L 11,4 L 7,4 L 5.5,0";
Value = 0;
RoundValueSlice = 0.25;
Expand Down Expand Up @@ -164,23 +164,23 @@ public Brush BackgroundColor
}


public double FullOutlineThikness
public double FullOutlineThickness
{
get { return _fullOutlineThikness; }
get { return _fullOutlineThickness; }
set
{
_fullOutlineThikness = value;
RaisePropertyChanged("FullOutlineThikness");
_fullOutlineThickness = value;
RaisePropertyChanged("FullOutlineThickness");
}
}

public double EmptyOutlineThikness
public double EmptyOutlineThickness
{
get { return _emptyOutlineThikness; }
get { return _emptyOutlineThickness; }
set
{
_emptyOutlineThikness = value;
RaisePropertyChanged("EmptyOutlineThikness");
_emptyOutlineThickness = value;
RaisePropertyChanged("EmptyOutlineThickness");
}
}

Expand Down Expand Up @@ -235,8 +235,8 @@ public double RoundValueSlice
private SolidColorBrush _emptyOutlineColor;
private SolidColorBrush _emptyColor;

private double _emptyOutlineThikness;
private double _fullOutlineThikness;
private double _emptyOutlineThickness;
private double _fullOutlineThickness;
private string _pathData;
private Brush _backgroundColor;
private Thickness _padding;
Expand Down
196 changes: 196 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# Bratched.Tools.RatingControl

![](http://dev.bratched.com/fr/wp-content/uploads/sites/2/2015/03/RateControlIcon_100x100.png)

a complete xaml rating control

More informations in
* [http://dev.bratched.com/fr](http://dev.bratched.com/fr)
* [http://www.bratched.com](http://www.bratched.com)


## Introduction ##

The Bratched Rating Control is used to show or Edit rate information.

This solution include :

* Common RatingControl source code
* Project to build Rating control in Universal App, WP8.1, WP8.0, WP7.0
* Demo source in Universal App, WP8.1, WP8.0, WP7.0

Compatible with:

* Windows Phone 7.1
* Windows Phone 8
* Windows Phone 8.1
* Windows 8.1 (WINRT App)
* Windows 10 (Universal App)


## How to use it ? ##

###Nuget
There is a [nuget package](https://www.nuget.org/packages/BratchedTools.RatingControl/) to easily add RatingControl in your project.

![](http://dev.bratched.com/fr/wp-content/uploads/sites/2/2015/03/NugetRatingControl.png)

In your solution, choose manage nuget package and install Bratched Rating Control.

###Into the XAML Header Page of your project
Into the Page header add :

####Windows Phone 7
xmlns:rating="clr-namespace:Bratched.Tools.RatingControl.Controls;assembly=Bratched.Tools.RatingControl_wp71"

####Windows Phone 8.0

xmlns:rating="clr-namespace:Bratched.Tools.RatingControl.Controls;assembly=Bratched.Tools.RatingControl_wp80"

####Windows Phone 8.1

xmlns:rating="clr-namespace:Bratched.Tools.RatingControl.Controls;assembly=Bratched.Tools.RatingControl_wp81"

####Universal Apps, Windows 8/10 and Windows Phone/Mobile 8.1/10 XAML app

xmlns:rating="clr-namespace:Bratched.Tools.RatingControl"

###Into the XAML Page

Add the rate control with this code

<rating:RatingControl ItemsCount="5" Value="2.5" />

![](http://dev.bratched.com/fr/wp-content/uploads/sites/2/2015/03/VisualStudioRatingControl.png)

##Main Properties of the RatingControl

###ItemsCount
To change the number of rate items

###Value
The value of the rate

###IsEditable
* False : Not Editable
* True : User can change the value with click or tap

###ItemsSpacing
Space between each items in percent.
Each items has a theoretical width of 100 units. To have the same space that an item you need to have 100 in this value.

###ItemTemplate
Choose predefined forms to change star rate to other pattern like :

* Heart
* Like
* Smiley
* Trophy
* Star

note: You can also define your own pattern
*(see in advanced properties)*

###RoundValueSlice

Round the Editing value.

**example 1 : RoundValueSlice = 0.5**
will accept only values like 0.5, 1, 1.5, 2, 2.5, ...

**example 2 : RoundValueSlice = 0.25**
will accept only values like 0.25, 0.5, 0.75, 1, 1.25, 1.5, ...

if RoundValueSlice == 0,all the values are accepted.

## Advanced Properties of the RatingControl
### Principe
You can personalize aspect of ratingcontrols with 2 lists of properties :

* EmptyItemsDefinition
* FullItemsDefinition

To change background color of the empty rate items you can use this syntax (Change the background color of the default yellow star in Red):

<rating:RatingControl ItemsCount="5" Value="1" >
<rating:RatingControl.EmptyItemsDefinition>
<rating:RateItemDefinition BackgroundColor="Red"/>
</rating:RatingControl.EmptyItemsDefinition>
</rating:RatingControl>

To Change the background color of the full rate items you can use this syntax.

<rating:RatingControl ItemsCount="5" Value="1" >
<rating:RatingControl.FullItemsDefinition>
<rating:RateItemDefinition BackgroundColor="Red"/>
</rating:RatingControl.FullItemsDefinition>
</rating:RatingControl>

Of course you can combine empty and full items but you can also define cyclic schemes like this.

*(first empty items are in green, last are in yellow and all the selected items are red)*

<rating:RatingControl ItemsCount="5" Value="1" >
<rating:RatingControl.EmptyItemsDefinition>
<rating:RateItemDefinition BackgroundColor="Green"/>
<rating:RateItemDefinition BackgroundColor="Yellow"/>
</rating:RatingControl.EmptyItemsDefinition>
<rating:RatingControl.FullItemsDefinition>
<rating:RateItemDefinition BackgroundColor="Red"/>
</rating:RatingControl.FullItemsDefinition>
</rating:RatingControl>

### RateItemsDefinition properties

#### BackgroundColor
The color of the item

#### OutlineColor
The color of the outline of the figure

#### OutlineThickness
The depth of the outline of the figure

#### PathData
The geometry Path Data of the figure in a string.
See [https://msdn.microsoft.com/fr-fr/library/ms752293(v=vs.110).aspx](https://msdn.microsoft.com/fr-fr/library/ms752293(v=vs.110).aspx)

Example with all the properties

<rating:RatingControl ItemsCount="8" Value="2">
<rating:RatingControl.EmptyItemsDefinition>
<rating:RateItemDefinition
BackgroundColor="Cyan"
OutlineColor="Blue"
OutlineThickness="4"
PathData="M 0,0 A 15,5 180 1 1 200,0 L 200,100 L 300,100
L 300,200 A 15,5 180 1 1 100,200 L 100,100 L 0,100 Z"/>
</rating:RatingControl.EmptyItemsDefinition>
<rating:RatingControl.FullItemsDefinition>
<rating:RateItemDefinition
BackgroundColor="Blue"
OutlineColor="Red"
OutlineThickness="8"
PathData="M 0,0 A 15,5 180 1 1 200,0 L 200,100 L 300,100
L 300,200 A 15,5 180 1 1 100,200 L 100,100 L 0,100 Z"/>
</rating:RatingControl.FullItemsDefinition>
</rating:RatingControl>

![](http://dev.bratched.com/fr/wp-content/uploads/sites/2/2015/03/VisualStudioRatingControl2.png)

##Version history

* v1.1
* #Issue 4 : bad pointer moving in Windows 8.1/10 App
* AllowHover Option (thanks mitchcapper)
* debug lines in a const value (thanks mitchcapper)
* OutlineThickness is corrected (OutlineThikness besfore, sorry for this breaking compatibility)


* v1.0

* First public release of the current implementation.




2 changes: 1 addition & 1 deletion Src/Bratched.Tools/RatingControl/IRateItemDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IRateItemDefinition
{
SolidColorBrush BackgroundColor { get; set; }
SolidColorBrush OutlineColor { get; set; }
object OutlineThikness { get; set; }
object OutlineThickness { get; set; }
object PathData { get; set; }
}
}
Loading

0 comments on commit e62c58d

Please sign in to comment.