WiP: Adding design time support for MPF-XAML (1 Viewer)

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    Up to now, if you open the MP2 skin files (screens, styles) inside a design tool (VisualStudio, Blend), the used elements are not known. This leads to underlining the control names and the lack of autocomplete (intellisense) feature.

    Fortunately I found an solution for this issue: http://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx.

    It is possible to make own class implementations known to the xaml world! MPF already uses an own namespace, but the control types etc. are not yet published correctly.

    First step is to map CLR namespace to our MPF XAML-namespace:
    Code:
    // Register CLR namespaces for XAML
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.ScreenManagement")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Commands")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Animations")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Panels")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Transforms")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Brushes")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Brushes.Animation")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Visuals")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Visuals.Styles")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Visuals.Templates")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.Controls.Visuals.Triggers")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.MpfElements.Resources")]
    [assembly: XmlnsDefinition("www.team-mediaportal.com/2008/mpf/directx", "MediaPortal.UI.SkinEngine.MarkupExtensions")]
    This makes already all attributes visible to VS:
    xaml_namespace.png


    Next is to declare some properties as default for adding content via XAML:
    Code:
      /// <summary>
      /// Screen class respresenting a logical screen represented by a particular skin.
      /// </summary>
      [ContentProperty("Root")]
      public class Screen : UIElement, INameScope, IAddChild<FrameworkElement>, IUnmodifiableResource
      {
        #region Consts

    I currently add more attributes to MPF classes, so that in the end we will have (nearly complete?) designer support for MPF!!! Yeah, finally!

    This is useful for both @Developers and @Designers
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #2
    First changes are commited here: https://github.com/MediaPortal/MediaPortal-2/commit/5c1f41da3ebc053347da1f1b3f194037f6e48232

    The auto complete is working with our own MPF object (y):
    xaml_autocomplete.png


    Then we can also use "goto to definition" (F12) on any element to jump into code:
    xaml_goto_code.png


    Leads us to our source code file:
    xaml_code.png


    Open issues:
    1. MarkupExtensions are not fully working, as they don't derive from System.Windows.MarkupExtension. You get a blue underline warning that it is used like a extension, but is not derived from it. This cannot be fixed easily
    2. ResourceWrapper is using "object" as generic type. This is useful, but now XAML is checking types strictly: like "object" defined versus "Brush" expected. Not fixable for now
    3. MPF-Converters are not known to XAML, it expects WPF-converters that use a different interface. Not fixable for now.
    Any way, I'm really happy about the current improvements, it makes working with MPF-XAML much easier!
     

    Valk

    Portal Pro
    February 25, 2006
    302
    108
    Home Country
    Australia Australia
    If we manage to fix the outstanding issues will that mean we can possible get the preview working in VS (even in a basic form without directX rendering)?
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #4
    Well, that would be what I'm dreaming of. But I'm afraid that it won't work that way.
    But I keep trying to make things easier :)
     

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,989
    3,712
    Stuttgart
    Home Country
    Germany Germany
    I have some experiences in writing a custom editor for Visual Studio. We could host our MP2 rendering engine in that :) But we would need a way for the rendering engine to quickly reload when the user changes something in the xml.
     

    morpheus_xx

    Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    • Thread starter
    • Moderator
    • #8
    Here are two more screenshots of before/after:
    xaml_after.png xaml_before.png

    There are few problems with properties that are using SharpDX structs (like Vector2). I get an error "property member not accessible". Not sure if it is because that they are structs (value type), or that they come from SharpDX assembly? Maybe I find something later...
     

    FreakyJ

    Retired Team Member
  • Premium Supporter
  • July 25, 2010
    4,024
    1,420
    Home Country
    Germany Germany
    @offbyone
    having the design functionality would be aweasome!
    So people could do easy modifications without looking to much at the code (y)
     

    Users who are viewing this thread

    Top Bottom