Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3853 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
18 changed files with 97 additions and 317 deletions
@ -1,27 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlAutoScaleModeProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlAutoScaleModeProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is AutoScaleMode) { |
|
||||||
return (AutoScaleMode)propertyValue == AutoScaleMode.Inherit; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Represents the AutoValidate property for a Form or ContainerControl.
|
|
||||||
/// </summary>
|
|
||||||
public class PythonControlAutoValidateProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlAutoValidateProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is AutoValidate) { |
|
||||||
return (AutoValidate)propertyValue == AutoValidate.EnablePreventFocusChange; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,26 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlBooleanProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
bool defaultValue; |
|
||||||
|
|
||||||
public PythonControlBooleanProperty(bool defaultValue) |
|
||||||
{ |
|
||||||
this.defaultValue = defaultValue; |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
return (bool)propertyValue == defaultValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,28 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlCursorProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlCursorProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
Cursor cursor = propertyValue as Cursor; |
|
||||||
if (cursor != null) { |
|
||||||
return cursor == Cursors.Default; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlImeModeProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlImeModeProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is ImeMode) { |
|
||||||
return (ImeMode)propertyValue == ImeMode.NoControl; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Drawing; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlPointProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
Point defaultPoint; |
|
||||||
|
|
||||||
public PythonControlPointProperty(int x, int y) |
|
||||||
{ |
|
||||||
defaultPoint = new Point(x, y); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is Point) { |
|
||||||
return (Point)propertyValue == defaultPoint; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Represents a property on a control or form.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns true if the property value matches the default for this control's property.
|
|
||||||
/// </summary>
|
|
||||||
public virtual bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlRightToLeftProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlRightToLeftProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is RightToLeft) { |
|
||||||
return (RightToLeft)propertyValue == RightToLeft.No; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Drawing; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
public class PythonControlSizeProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
Size defaultSize; |
|
||||||
|
|
||||||
public PythonControlSizeProperty(int width, int height) |
|
||||||
{ |
|
||||||
defaultSize = new Size(width, height); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
if (propertyValue is Size) { |
|
||||||
return (Size)propertyValue == defaultSize; |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
|
|
||||||
namespace ICSharpCode.PythonBinding |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Represents a Control's Text Property.
|
|
||||||
/// </summary>
|
|
||||||
public class PythonControlTextProperty : PythonControlProperty |
|
||||||
{ |
|
||||||
public PythonControlTextProperty() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns true if the Text property's value is an empty string.
|
|
||||||
/// </summary>
|
|
||||||
public override bool IsDefaultValue(object propertyValue) |
|
||||||
{ |
|
||||||
return (string)propertyValue == String.Empty; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using NUnit.Framework; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Designer |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class GenerateFormPaddingTestFixture |
||||||
|
{ |
||||||
|
string generatedPythonCode; |
||||||
|
|
||||||
|
[TestFixtureSetUp] |
||||||
|
public void SetUpFixture() |
||||||
|
{ |
||||||
|
using (Form form = new Form()) { |
||||||
|
form.Name = "MainForm"; |
||||||
|
form.ClientSize = new Size(284, 264); |
||||||
|
form.Padding = new Padding(10, 20, 15, 18); |
||||||
|
|
||||||
|
string indentString = " "; |
||||||
|
PythonForm pythonForm = new PythonForm(indentString); |
||||||
|
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GeneratedCode() |
||||||
|
{ |
||||||
|
string expectedCode = "def InitializeComponent(self):\r\n" + |
||||||
|
" self.SuspendLayout()\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" # MainForm\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" + |
||||||
|
" self.Name = \"MainForm\"\r\n" + |
||||||
|
" self.Visible = False\r\n" + |
||||||
|
" self.Padding = System.Windows.Forms.Padding(10, 20, 15, 18)\r\n" + |
||||||
|
" self.ResumeLayout(False)\r\n" + |
||||||
|
" self.PerformLayout()\r\n"; |
||||||
|
|
||||||
|
Assert.AreEqual(expectedCode, generatedPythonCode); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue