Skip to content

Commit

Permalink
Updated ATF
Browse files Browse the repository at this point in the history
  • Loading branch information
abeckus committed Jan 10, 2017
1 parent d5a2af9 commit 203a52a
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 49 deletions.
30 changes: 19 additions & 11 deletions ATF/Framework/Atf.Gui.WinForms/Controls/FloatInputControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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);
}
}

/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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);
}
}

Expand Down
32 changes: 20 additions & 12 deletions ATF/Framework/Atf.Gui.WinForms/Controls/IntInputControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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);
}
}

/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,42 +21,61 @@ public class BoundedFloatEditor : UITypeEditor, IPropertyEditor, IAnnotatedParam
/// <summary>
/// Default constructor</summary>
public BoundedFloatEditor()
: this(0.0f, 100.0f)
{
Min = 0.0f;
Max = 100.0f;

}

/// <summary>
/// Constructs BoundedFloatEditor using the given arguments</summary>
/// <param name="min">Min value</param>
/// <param name="max">Max value</param>
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);
}

/// <summary>
/// Gets or sets the editor's minimum value</summary>
public float Min
{
get { return m_min; }
set { m_min = value; }
set { SetMinMax(value, m_max); }
}

/// <summary>
/// Gets or sets the editor's maximum value</summary>
public float Max
{
get { return m_max; }
set { m_max = value; }
set { SetMinMax(m_min, value); }
}



/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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<WeakReference> m_controlRefList = new List<WeakReference>();


#region IPropertyEditor Members

/// <summary>
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,10 +21,9 @@ public class BoundedIntEditor : UITypeEditor, IPropertyEditor, IAnnotatedParams

/// <summary>
/// Default constructor</summary>
public BoundedIntEditor()
public BoundedIntEditor() : this(0,100)
{
Min = 0;
Max = 100;

}

/// <summary>
Expand All @@ -31,29 +32,51 @@ public BoundedIntEditor()
/// <param name="max">Max value</param>
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);
}

/// <summary>
/// Gets or sets the editor's minimum value</summary>
public int Min
{
get { return m_min; }
set { m_min = value; }
set { SetMinMax(value, m_max); }
}

/// <summary>
/// Gets or sets the editor's maximum value</summary>
public int Max
{
get { return m_max; }
set { m_max = value; }
set { SetMinMax(m_min, value); }
}


/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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<WeakReference> m_controlRefList = new List<WeakReference>();




#region IPropertyEditor Members

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ public void Initialize(string[] parameters)

#endregion

/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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;
}
}

/// <summary>
/// Converts the given object to the type of this converter, using the specified context and culture information</summary>
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext that provides a format context</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ public void Initialize( string[] parameters )

#endregion

/// <summary>
/// Sets min and max
/// </summary>
/// <param name="min">min value</param>
/// <param name="max">max value</param>
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;
}
}

/// <summary>
/// Converts the given object to the type of this converter, using the specified context and culture information</summary>
/// <param name="context">An System.ComponentModel.ITypeDescriptorContext that provides a format context</param>
Expand Down
2 changes: 1 addition & 1 deletion ATF/wws_atf.component
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<readablename>Authoring Tools Framework</readablename>
<version>3.10.9.0</version>
<version>3.10.10.0</version>
<owner>abeckus</owner>
<platforms>PC</platforms>
<category>Component</category>
Expand Down
2 changes: 1 addition & 1 deletion CodeGenDom/CodeGenDom.vs2010.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ATF\Framework\Atf.Core\Atf.Core.vs2010.csproj">
<ProjectReference Include="..\..\wws_atf\Framework\Atf.Core\Atf.Core.vs2010.csproj">
<Project>{9D1835B6-D1C2-44BA-BAE1-05C6EC442D2F}</Project>
<Name>Atf.Core.vs2010</Name>
</ProjectReference>
Expand Down
2 changes: 1 addition & 1 deletion CodeGenDom/CodeGenDom.vs2010.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 203a52a

Please sign in to comment.