Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XAML:
- <Path x:Name="Mouth" Stroke="Black" StrokeThickness="3">
- <Path.Data>
- <MultiBinding Converter="{StaticResource MouthConverter}">
- <Binding ElementName="HeadYPosSlider" Path="Value" />
- <Binding ElementName="MouthHeightSlider" Path="Value" />
- <Binding ElementName="MouthWidthSlider" Path="Value" />
- <Binding ElementName="myCanvas" Path="Width" />
- <Binding ElementName="MouthHappinessSlider" Path="Value" />
- </MultiBinding>
- </Path.Data>
- </Path>
- C#:
- public class MouthConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- PathGeometry pg = new PathGeometry();
- pg.Figures = new PathFigureCollection()
- {
- new PathFigure()
- };
- var hyp = values[0];
- var mhs = values[1];
- var mws = values[2];
- var mcw = values[3];
- var hap = values[4];
- double HeadYPos = (double)hyp,
- MouthHeight = (double)mhs,
- MouthWidth = (double)mws,
- CanvasWidth = (double)mcw,
- Happiness = (double)hap;
- pg.Figures[0].StartPoint = new Point(((CanvasWidth / 2) - MouthWidth), (HeadYPos + MouthHeight));
- ArcSegment point2 = new ArcSegment();
- point2.Point = new Point(((CanvasWidth / 2) + MouthWidth), (HeadYPos + MouthHeight));
- point2.Size = new Size(Happiness,50);
- pg.Figures[0].Segments.Add(point2);
- return pg;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment