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: 757876" data-attributes="member: 48495"><p><strong>AW: MPF element: MatrixTransform</strong></p><p></p><p><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> for the hint with the setter, this was the problem why it didn't work.</p><p></p><p>here is the working version:</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); }</p><p> }</p><p></p><p> public override void UpdateTransform()</p><p> {</p><p> base.UpdateTransform();</p><p> CreateMatrix();</p><p> }</p><p></p><p> void CreateMatrix()</p><p> {</p><p> _matrix = SlimDX.Matrix.Identity;</p><p> if (string.IsNullOrEmpty(Matrix))</p><p> return;</p><p></p><p> string[] matrixParts = Matrix.Split(',');</p><p> if (matrixParts.Length != 6) </p><p> return;</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> 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>Would you review and include it?</p></blockquote><p></p>
[QUOTE="morpheus_xx, post: 757876, member: 48495"] [b]AW: MPF element: MatrixTransform[/b] :thx: for the hint with the setter, this was the problem why it didn't work. here is the working version: [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); } } public override void UpdateTransform() { base.UpdateTransform(); CreateMatrix(); } void CreateMatrix() { _matrix = SlimDX.Matrix.Identity; if (string.IsNullOrEmpty(Matrix)) return; string[] matrixParts = Matrix.Split(','); if (matrixParts.Length != 6) return; 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] Would you review and include it? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Submit: Code Patches
MPF element: MatrixTransform
Contact us
RSS
Top
Bottom