XAML & MPF: PowerButton (1 Viewer)

chefkoch

Retired Team Member
  • Premium Supporter
  • October 5, 2004
    3,129
    1,634
    Dresden / Munich / Maastricht
    Home Country
    Germany Germany
    I tried to create a power button in xaml.

    I used http://en.wikipedia.org/wiki/File:IEC5009_Standby_Symbol.svg as a base:
    177px-IEC5009_Standby_Symbol.svg.png


    With inkscape I was able to convert the svg to xaml:
    SVG
    XML:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In  -->
    <!DOCTYPE svg [
    	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
    ]>
    <svg version="1.2" baseProfile="tiny"
    	xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
    	x="0px" y="0px" width="177px" height="202px" viewBox="-0.8 -0.5 177 202" xml:space="preserve">
    <defs>
    </defs>
    <path fill="none" stroke="#000000" stroke-width="30" stroke-linecap="round" d="M33.7,64.3C22.1,77.2,15,94.3,15,113
    	c0,40.1,32.5,72.7,72.7,72.7c40.1,0,72.7-32.5,72.7-72.7c0-18.7-7.1-35.8-18.7-48.7"/>
    <line fill="none" stroke="#000000" stroke-width="30" stroke-linecap="round" x1="87.8" y1="15" x2="87.8" y2="113"/>
    </svg>

    XAML
    XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
      <Canvas Name="svg2997" Width="177" Height="202" Canvas.Left="0" Canvas.Top="0">
    	<Canvas.RenderTransform>
    	  <TranslateTransform X="0,8" Y="0,5"/>
    	</Canvas.RenderTransform>
    	<Canvas.Resources/>
    	<!--Unknown tag: metadata-->
    	<!--Unknown tag: sodipodi:namedview-->
    	<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3001" StrokeThickness="30" Stroke="#FF000000" StrokeStartLineCap="Round" StrokeEndLineCap="Round">
    	  <Path.Data>
    		<PathGeometry Figures="M33.7 64.3C22.1 77.2 15 94.3 15 113  c0 40.1 32.5 72.7 72.7 72.7c40.1 0 72.7-32.5 72.7-72.7c0-18.7-7.1-35.8-18.7-48.7" FillRule="NonZero"/>
    	  </Path.Data>
    	</Path>
    	<Line xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" X1="87.8" Y1="15" X2="87.8" Y2="113" Name="line3003" StrokeThickness="30" Stroke="#FF000000" StrokeStartLineCap="Round" StrokeEndLineCap="Round"/>
      </Canvas>
    </Viewbox>


    First try: https://github.com/chefkoch/MediaPortal-2/commit/a37d0f906d5003fb6e0e61aa86807f4549e6210e
    Result:
    Code:
    [2013-05-28 03:15:11,651] [14185  ] [AMQ 'ScreenManager'] [ERROR] - Unhandled exception in message handler of async message queue 'ScreenManager' when handling a message of type 'ShowScreen'
    MediaPortal.UI.SkinEngine.Xaml.Exceptions.ConvertException: Could not convert object '72.7-32.5' to type 'Single'
      bei MediaPortal.UI.SkinEngine.Xaml.TypeConverter.Convert(Object value, Type targetType)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.Shapes.Path.ParsePath()
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.Shapes.Path.CalculateTransformedPath(RectangleF baseRect)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.Shapes.Path.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.Grid.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.Control.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.Grid.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.Control.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.DockPanel.CalculateDesiredSize(IEnumerator`1 currentVisibleChildEnumerator, SizeF currentAvailableSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.DockPanel.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.Grid.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.DockPanel.CalculateDesiredSize(IEnumerator`1 currentVisibleChildEnumerator, SizeF currentAvailableSize)
      bei MediaPortal.UI.SkinEngine.Controls.Panels.DockPanel.CalculateInnerDesiredSize(SizeF totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.Measure(SizeF& totalSize)
      bei MediaPortal.UI.SkinEngine.Controls.Visuals.FrameworkElement.UpdateLayoutRoot(SizeF skinSize)
      bei MediaPortal.UI.SkinEngine.ScreenManagement.Screen.Prepare()
      bei MediaPortal.UI.SkinEngine.ScreenManagement.ScreenManager.DoExchangeScreen_NoLock(Screen screen)
      bei MediaPortal.UI.SkinEngine.ScreenManagement.ScreenManager.DoShowScreen_NoLock(Screen screen, Boolean closeDialogs)
      bei MediaPortal.UI.SkinEngine.ScreenManagement.ScreenManager.OnMessageReceived(AsynchronousMessageQueue queue, SystemMessage message)
      bei MediaPortal.Common.Messaging.AsynchronousMessageQueue.DoWork()
    In Blend the path (half power button) was rendered fine:
    20130528_031830.png

    Second try: https://github.com/chefkoch/MediaPortal-2/commit/1c18fc00e94f5843d9f2d243b05506fa94fc883f
    MP2 was loaded nicely, but the (half) power button looks like this:
    20130528_032057.png


    Even enabling anti-aliasing did not changed anything.



    EDIT: Now I realized I may should have kept the commas within the data attribute. Too late for now.
    If anybody else would like to continue this experiment feel free :)
     
    Last edited:

    sa_ddam213

    Retired Team Member
  • Premium Supporter
  • March 3, 2009
    312
    281
    Canterbury
    Home Country
    New Zealand New Zealand
    Not sure if its related or not but the TranslateTransform values will not parse at my end because of using ',' instead of '.'
    <TranslateTransform X="0,8" Y="0,5"/> <!-- parse error ->
    <TranslateTransform X="0.8" Y="0.5"/>

    But perhaps this is just a localization thing between German and English cultures

    Capture.PNG
     

    Users who are viewing this thread

    Top Bottom