home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Submit: Code Patches
MPF element: MatrixTransform
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="morpheus_xx" data-source="post: 757749" data-attributes="member: 48495"><p>While I was experimenting with converted svg->xaml graphics I noticed some missing MPF elements.</p><p></p><p>One of this is "MatrixTransform".</p><p>[CODE]</p><p> <RadialGradientBrush.Transform></p><p> <!--radialGradient--></p><p> <MatrixTransform Matrix="1, 0, 0, 0.916055, -70.7146, 48.8309"/></p><p> </RadialGradientBrush.Transform></p><p>[/CODE]</p><p></p><p>Here my first try to implement this feature, based on other existing transforms:</p><p>[CODE]#region Copyright (C) 2007-2011 Team MediaPortal</p><p></p><p>/*</p><p> Copyright (C) 2007-2011 Team MediaPortal</p><p> https://www.team-mediaportal.com</p><p></p><p> This file is part of MediaPortal 2</p><p></p><p> MediaPortal 2 is free software: you can redistribute it and/or modify</p><p> it under the terms of the GNU General Public License as published by</p><p> the Free Software Foundation, either version 3 of the License, or</p><p> (at your option) any later version.</p><p></p><p> MediaPortal 2 is distributed in the hope that it will be useful,</p><p> but WITHOUT ANY WARRANTY; without even the implied warranty of</p><p> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</p><p> GNU General Public License for more details.</p><p></p><p> You should have received a copy of the GNU General Public License</p><p> along with MediaPortal 2. If not, see <http://www.gnu.org/licenses/>.</p><p>*/</p><p></p><p>#endregion</p><p></p><p>using System.Globalization;</p><p>using MediaPortal.Core.General;</p><p>using MediaPortal.Utilities.DeepCopy;</p><p></p><p>namespace MediaPortal.UI.SkinEngine.Controls.Transforms</p><p>{</p><p> public class MatrixTransform : Transform</p><p> {</p><p> #region Protected fields</p><p></p><p> protected AbstractProperty _matrixStringProperty;</p><p></p><p> #endregion</p><p></p><p> #region Ctor</p><p></p><p> public MatrixTransform()</p><p> {</p><p> Init();</p><p> Attach();</p><p> }</p><p></p><p> public override void Dispose()</p><p> {</p><p> base.Dispose();</p><p> Detach();</p><p> }</p><p></p><p> void Init()</p><p> {</p><p> _matrixStringProperty = new SProperty(typeof(string), string.Empty);</p><p> }</p><p></p><p> void Attach()</p><p> {</p><p> _matrixStringProperty.Attach(OnPropertyChanged);</p><p> }</p><p></p><p> void Detach()</p><p> {</p><p> _matrixStringProperty.Detach(OnPropertyChanged);</p><p> }</p><p></p><p> public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager)</p><p> {</p><p> Detach();</p><p> base.DeepCopy(source, copyManager);</p><p> MatrixTransform t = (MatrixTransform) source;</p><p> Matrix = t.Matrix;</p><p> Attach();</p><p> }</p><p></p><p> #endregion</p><p></p><p> public AbstractProperty MatrixProperty</p><p> {</p><p> get { return _matrixStringProperty; }</p><p> }</p><p></p><p> public string Matrix</p><p> {</p><p> get { return (string) _matrixStringProperty.GetValue(); }</p><p> set { _matrixStringProperty.SetValue(value); CreateMatrix(); }</p><p> }</p><p></p><p> void CreateMatrix()</p><p> {</p><p> _matrix = SlimDX.Matrix.Identity;</p><p> string[] matrixParts = Matrix.Split(',');</p><p> if (matrixParts.Length == 6)</p><p> {</p><p> ParseToFloat(ref _matrix.M11, matrixParts[0]);</p><p> ParseToFloat(ref _matrix.M12, matrixParts[1]);</p><p> ParseToFloat(ref _matrix.M21, matrixParts[2]);</p><p> ParseToFloat(ref _matrix.M22, matrixParts[3]);</p><p> ParseToFloat(ref _matrix.M41, matrixParts[4]);</p><p> ParseToFloat(ref _matrix.M42, matrixParts[5]);</p><p> _needUpdate = false;</p><p> }</p><p> }</p><p></p><p> static void ParseToFloat(ref float target, string value)</p><p> {</p><p> target = float.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p>Then it's registered in Registration.cs:</p><p>[CODE]</p><p> _objectClassRegistrations.Add("MatrixTransform", typeof(SkinEngine.Controls.Transforms.MatrixTransform));</p><p>[/CODE]</p><p></p><p>Is this the right way to handle this? Dp I have to use "String" for "Matrix" element?</p><p></p><p>The object gets created, but "Matrix" is not set during my tests.</p><p></p><p>Morpheus</p></blockquote><p></p>
[QUOTE="morpheus_xx, post: 757749, member: 48495"] While I was experimenting with converted svg->xaml graphics I noticed some missing MPF elements. One of this is "MatrixTransform". [CODE] <RadialGradientBrush.Transform> <!--radialGradient--> <MatrixTransform Matrix="1, 0, 0, 0.916055, -70.7146, 48.8309"/> </RadialGradientBrush.Transform> [/CODE] Here my first try to implement this feature, based on other existing transforms: [CODE]#region Copyright (C) 2007-2011 Team MediaPortal /* Copyright (C) 2007-2011 Team MediaPortal https://www.team-mediaportal.com This file is part of MediaPortal 2 MediaPortal 2 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. MediaPortal 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with MediaPortal 2. If not, see <http://www.gnu.org/licenses/>. */ #endregion using System.Globalization; using MediaPortal.Core.General; using MediaPortal.Utilities.DeepCopy; namespace MediaPortal.UI.SkinEngine.Controls.Transforms { public class MatrixTransform : Transform { #region Protected fields protected AbstractProperty _matrixStringProperty; #endregion #region Ctor public MatrixTransform() { Init(); Attach(); } public override void Dispose() { base.Dispose(); Detach(); } void Init() { _matrixStringProperty = new SProperty(typeof(string), string.Empty); } void Attach() { _matrixStringProperty.Attach(OnPropertyChanged); } void Detach() { _matrixStringProperty.Detach(OnPropertyChanged); } public override void DeepCopy(IDeepCopyable source, ICopyManager copyManager) { Detach(); base.DeepCopy(source, copyManager); MatrixTransform t = (MatrixTransform) source; Matrix = t.Matrix; Attach(); } #endregion public AbstractProperty MatrixProperty { get { return _matrixStringProperty; } } public string Matrix { get { return (string) _matrixStringProperty.GetValue(); } set { _matrixStringProperty.SetValue(value); CreateMatrix(); } } void CreateMatrix() { _matrix = SlimDX.Matrix.Identity; string[] matrixParts = Matrix.Split(','); if (matrixParts.Length == 6) { ParseToFloat(ref _matrix.M11, matrixParts[0]); ParseToFloat(ref _matrix.M12, matrixParts[1]); ParseToFloat(ref _matrix.M21, matrixParts[2]); ParseToFloat(ref _matrix.M22, matrixParts[3]); ParseToFloat(ref _matrix.M41, matrixParts[4]); ParseToFloat(ref _matrix.M42, matrixParts[5]); _needUpdate = false; } } static void ParseToFloat(ref float target, string value) { target = float.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture); } } } [/CODE] Then it's registered in Registration.cs: [CODE] _objectClassRegistrations.Add("MatrixTransform", typeof(SkinEngine.Controls.Transforms.MatrixTransform)); [/CODE] Is this the right way to handle this? Dp I have to use "String" for "Matrix" element? The object gets created, but "Matrix" is not set during my tests. Morpheus [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Submit: Code Patches
MPF element: MatrixTransform
Contact us
RSS
Top
Bottom