From 203a52ac8ab46e8829e5646ac2300cdb0bb68010 Mon Sep 17 00:00:00 2001 From: abeckus Date: Mon, 9 Jan 2017 16:58:08 -0800 Subject: [PATCH] Updated ATF --- .../Controls/FloatInputControl.cs | 30 +++++++----- .../Controls/IntInputControl.cs | 32 ++++++++----- .../PropertyEditing/BoundedFloatEditor.cs | 48 ++++++++++++++----- .../PropertyEditing/BoundedIntEditor.cs | 47 +++++++++++++----- .../PropertyEditing/BoundedFloatConverter.cs | 16 +++++++ .../PropertyEditing/BoundedIntConverter.cs | 16 +++++++ ATF/wws_atf.component | 2 +- CodeGenDom/CodeGenDom.vs2010.csproj | 2 +- CodeGenDom/CodeGenDom.vs2010.sln | 2 +- 9 files changed, 146 insertions(+), 49 deletions(-) diff --git a/ATF/Framework/Atf.Gui.WinForms/Controls/FloatInputControl.cs b/ATF/Framework/Atf.Gui.WinForms/Controls/FloatInputControl.cs index 0b8db48..6e9144d 100644 --- a/ATF/Framework/Atf.Gui.WinForms/Controls/FloatInputControl.cs +++ b/ATF/Framework/Atf.Gui.WinForms/Controls/FloatInputControl.cs @@ -106,11 +106,7 @@ public float Min get { return m_min; } set { - if (value >= m_max) - throw new ArgumentException("Min"); - m_min = value; - if (m_value < m_min) - Value = m_min; + SetMinMax(value, m_max); this.Invalidate(); } } @@ -122,12 +118,24 @@ public float Max get { return m_max; } set { - if(value <= m_min) - throw new ArgumentException("Max"); - m_max = value; - if (m_value > m_max) - Value = m_max; - this.Invalidate(); + SetMinMax(m_min, value); + } + } + + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(float min, float max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if (m_min != min || m_max != max) + { + m_min = min; + m_max = max; + Value = MathUtil.Clamp(m_value, m_min, m_max); } } diff --git a/ATF/Framework/Atf.Gui.WinForms/Controls/IntInputControl.cs b/ATF/Framework/Atf.Gui.WinForms/Controls/IntInputControl.cs index d1a0e1d..452ab6e 100644 --- a/ATF/Framework/Atf.Gui.WinForms/Controls/IntInputControl.cs +++ b/ATF/Framework/Atf.Gui.WinForms/Controls/IntInputControl.cs @@ -101,12 +101,8 @@ public int Min { get { return m_min; } set - { - if (value >= m_max) - throw new ArgumentException("Min"); - m_min = value; - if (m_value < m_min) - Value = m_min; + { + SetMinMax(value, m_max); this.Invalidate(); } } @@ -118,12 +114,24 @@ public int Max get { return m_max; } set { - if (value <= m_min) - throw new ArgumentException("Max"); - m_max = value; - if (m_value > m_max) - Value = m_max; - this.Invalidate(); + SetMinMax(m_min, value); + } + } + + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(int min, int max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if (m_min != min || m_max != max) + { + m_min = min; + m_max = max; + Value = MathUtil.Clamp(m_value, m_min, m_max); } } diff --git a/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedFloatEditor.cs b/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedFloatEditor.cs index d012423..fcffdc9 100644 --- a/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedFloatEditor.cs +++ b/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedFloatEditor.cs @@ -2,7 +2,8 @@ using System; using System.ComponentModel; -using System.Drawing; +using System.Collections.Generic; +using System.Linq; using System.Drawing.Design; using System.Globalization; using System.Windows.Forms; @@ -20,22 +21,18 @@ public class BoundedFloatEditor : UITypeEditor, IPropertyEditor, IAnnotatedParam /// /// Default constructor public BoundedFloatEditor() + : this(0.0f, 100.0f) { - Min = 0.0f; - Max = 100.0f; + } /// /// Constructs BoundedFloatEditor using the given arguments /// Min value /// Max value - public BoundedFloatEditor(float min = 0, float max = 0) + public BoundedFloatEditor(float min , float max ) { - if (min >= max) - throw new ArgumentOutOfRangeException("min must be less than max"); - Min = min; - Max = max; - + SetMinMax(min, max); } /// @@ -43,7 +40,7 @@ public BoundedFloatEditor(float min = 0, float max = 0) public float Min { get { return m_min; } - set { m_min = value; } + set { SetMinMax(value, m_max); } } /// @@ -51,11 +48,34 @@ public float Min public float Max { get { return m_max; } - set { m_max = value; } + set { SetMinMax(m_min, value); } } - + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(float min, float max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if (m_min != min || m_max != max) + { + m_min = min; + m_max = max; + foreach (var item in m_controlRefList) + { + var ctrl = (BoundedFloatControl)item.Target; + if (ctrl != null) ctrl.SetMinMax(m_min, m_max); + } + m_controlRefList.RemoveAll(item => !item.IsAlive); + } + } + private List m_controlRefList = new List(); + + #region IPropertyEditor Members /// @@ -70,6 +90,10 @@ public virtual Control GetEditingControl(PropertyEditorControlContext context) { var control = new BoundedFloatControl(context, m_min, m_max); SkinService.ApplyActiveSkin(control); + + m_controlRefList.RemoveAll(item => !item.IsAlive); + m_controlRefList.Add(new WeakReference(control)); + return control; } diff --git a/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedIntEditor.cs b/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedIntEditor.cs index 833c3ae..eb44863 100644 --- a/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedIntEditor.cs +++ b/ATF/Framework/Atf.Gui.WinForms/Controls/PropertyEditing/BoundedIntEditor.cs @@ -2,6 +2,8 @@ using System; using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; using System.Drawing; using System.Drawing.Design; using System.Globalization; @@ -19,10 +21,9 @@ public class BoundedIntEditor : UITypeEditor, IPropertyEditor, IAnnotatedParams /// /// Default constructor - public BoundedIntEditor() + public BoundedIntEditor() : this(0,100) { - Min = 0; - Max = 100; + } /// @@ -31,19 +32,15 @@ public BoundedIntEditor() /// Max value public BoundedIntEditor(int min, int max) { - if (min >= max) - throw new ArgumentOutOfRangeException("min must be less than max"); - Min = min; - Max = max; - + SetMinMax(min, max); } - + /// /// Gets or sets the editor's minimum value public int Min { get { return m_min; } - set { m_min = value; } + set { SetMinMax(value, m_max); } } /// @@ -51,9 +48,35 @@ public int Min public int Max { get { return m_max; } - set { m_max = value; } + set { SetMinMax(m_min, value); } } + + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(int min, int max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if (m_min != min || m_max != max) + { + m_min = min; + m_max = max; + foreach (var item in m_controlRefList) + { + var ctrl = (BoundedIntControl)item.Target; + if (ctrl != null) ctrl.SetMinMax(m_min, m_max); + } + m_controlRefList.RemoveAll(item => !item.IsAlive); + } + } + private List m_controlRefList = new List(); + + + #region IPropertyEditor Members @@ -69,6 +92,8 @@ public virtual Control GetEditingControl(PropertyEditorControlContext context) { var control = new BoundedIntControl(context, m_min, m_max); SkinService.ApplyActiveSkin(control); + m_controlRefList.RemoveAll(item => !item.IsAlive); + m_controlRefList.Add(new WeakReference(control)); return control; } diff --git a/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedFloatConverter.cs b/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedFloatConverter.cs index f58b2f4..67f9ae7 100644 --- a/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedFloatConverter.cs +++ b/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedFloatConverter.cs @@ -39,6 +39,22 @@ public void Initialize(string[] parameters) #endregion + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(float min, float max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if ((m_min.HasValue && m_min.Value != min) || (m_max.HasValue && m_max.Value != max)) + { + m_min = min; + m_max = max; + } + } + /// /// Converts the given object to the type of this converter, using the specified context and culture information /// An System.ComponentModel.ITypeDescriptorContext that provides a format context diff --git a/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedIntConverter.cs b/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedIntConverter.cs index 8ba4766..7f429ff 100644 --- a/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedIntConverter.cs +++ b/ATF/Framework/Atf.Gui/Controls/PropertyEditing/BoundedIntConverter.cs @@ -39,6 +39,22 @@ public void Initialize( string[] parameters ) #endregion + /// + /// Sets min and max + /// + /// min value + /// max value + public void SetMinMax(int min, int max) + { + if (min >= max) + throw new ArgumentOutOfRangeException("min must be less than max"); + if ((m_min.HasValue && m_min.Value != min) || (m_max.HasValue && m_max.Value != max)) + { + m_min = min; + m_max = max; + } + } + /// /// Converts the given object to the type of this converter, using the specified context and culture information /// An System.ComponentModel.ITypeDescriptorContext that provides a format context diff --git a/ATF/wws_atf.component b/ATF/wws_atf.component index 1ce8979..49bcda1 100644 --- a/ATF/wws_atf.component +++ b/ATF/wws_atf.component @@ -5,7 +5,7 @@ xsi:schemaLocation="http://www.ship.scea.com/wws_sdk/component/v1 http://www.ship.scea.com/wws_sdk/component/v1.xsd"> Authoring Tools Framework - 3.10.9.0 + 3.10.10.0 abeckus PC Component diff --git a/CodeGenDom/CodeGenDom.vs2010.csproj b/CodeGenDom/CodeGenDom.vs2010.csproj index 79c7f38..afb6961 100644 --- a/CodeGenDom/CodeGenDom.vs2010.csproj +++ b/CodeGenDom/CodeGenDom.vs2010.csproj @@ -95,7 +95,7 @@ - + {9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F} Atf.Core.vs2010 diff --git a/CodeGenDom/CodeGenDom.vs2010.sln b/CodeGenDom/CodeGenDom.vs2010.sln index abcc361..e43e8d4 100644 --- a/CodeGenDom/CodeGenDom.vs2010.sln +++ b/CodeGenDom/CodeGenDom.vs2010.sln @@ -6,7 +6,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeGenDom.vs2010", "CodeGe {9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F} = {9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atf.Core.vs2010", "..\ATF\Framework\Atf.Core\Atf.Core.vs2010.csproj", "{9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atf.Core.vs2010", "..\..\wws_atf\Framework\Atf.Core\Atf.Core.vs2010.csproj", "{9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution