Guest User

Untitled

a guest
Nov 16th, 2015
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. XAML:
  2. <Path x:Name="Mouth" Stroke="Black" StrokeThickness="3">
  3. <Path.Data>
  4.  
  5. <MultiBinding Converter="{StaticResource MouthConverter}">
  6. <Binding ElementName="HeadYPosSlider" Path="Value" />
  7. <Binding ElementName="MouthHeightSlider" Path="Value" />
  8. <Binding ElementName="MouthWidthSlider" Path="Value" />
  9. <Binding ElementName="myCanvas" Path="Width" />
  10. <Binding ElementName="MouthHappinessSlider" Path="Value" />
  11. </MultiBinding>
  12.  
  13. </Path.Data>
  14. </Path>
  15.  
  16. C#:
  17. public class MouthConverter : IMultiValueConverter
  18. {
  19. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  20. {
  21. PathGeometry pg = new PathGeometry();
  22. pg.Figures = new PathFigureCollection()
  23. {
  24. new PathFigure()
  25. };
  26.  
  27.  
  28. var hyp = values[0];
  29. var mhs = values[1];
  30. var mws = values[2];
  31. var mcw = values[3];
  32. var hap = values[4];
  33.  
  34. double HeadYPos = (double)hyp,
  35. MouthHeight = (double)mhs,
  36. MouthWidth = (double)mws,
  37. CanvasWidth = (double)mcw,
  38. Happiness = (double)hap;
  39.  
  40.  
  41. pg.Figures[0].StartPoint = new Point(((CanvasWidth / 2) - MouthWidth), (HeadYPos + MouthHeight));
  42. ArcSegment point2 = new ArcSegment();
  43. point2.Point = new Point(((CanvasWidth / 2) + MouthWidth), (HeadYPos + MouthHeight));
  44. point2.Size = new Size(Happiness,50);
  45. pg.Figures[0].Segments.Add(point2);
  46.  
  47. return pg;
  48. }
  49.  
  50. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  51. {
  52. throw new NotImplementedException();
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment