Skip to content

Commit

Permalink
TextBox - added horizontal alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel grahame committed Jul 20, 2018
1 parent 9218d26 commit 1c65d77
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 9 deletions.
1 change: 1 addition & 0 deletions ClassicFormsShared/ClassicFormsShared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\Button.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\ButtonBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\CheckBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\HorizontalAlignment.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\ClientUtils.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\ComboBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows\Forms\ContainerControl.cs" />
Expand Down
2 changes: 2 additions & 0 deletions ClassicFormsShared/HTML/HTMLStyleCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private string Get(string name)
public string lineHeight { get => Get(nameof(lineHeight)); set => Set(nameof(lineHeight), value); }
public string color { get => Get(nameof(color)); set => Set(nameof(color), value); }
public string transform { get => Get(nameof(transform)); set => Set(nameof(transform), value); }

public string textAlign { get => Get(nameof(textAlign)); set => Set(nameof(textAlign), value); }
}
}
#endif
8 changes: 4 additions & 4 deletions ClassicFormsShared/Windows/Forms/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,10 +944,10 @@ public Form() : base()
var dummyControl = new Control(formBase, false);
formBase.style.overflow = "hidden";
formBase.style.position = "absolute";
formBase.style.left = "1px";
formBase.style.top = "1px";
formBase.style.width = "calc(100% - 2px)";
formBase.style.height = "calc(100% - 2px)";
formBase.style.left = "0";
formBase.style.top = "0";
formBase.style.width = "100%";
formBase.style.height = "100%";
formBase.style.cursor = "default";
formBase.style.outline = "none";

Expand Down
26 changes: 26 additions & 0 deletions ClassicFormsShared/Windows/Forms/HorizontalAlignment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace System.Windows.Forms
{
//
// Summary:
// Specifies how an object or text in a control is horizontally aligned relative
// to an element of the control.
public enum HorizontalAlignment
{
//
// Summary:
// The object or text is aligned on the left of the control element.
Left = 0,
//
// Summary:
// The object or text is aligned on the right of the control element.
Right = 1,
//
// Summary:
// The object or text is aligned in the center of the control element.
Center = 2
}
}
16 changes: 16 additions & 0 deletions ClassicFormsShared/Windows/Forms/TextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ public class TextBox : Control
{
public bool Multiline { get; set; }

private HorizontalAlignment _textAlign = HorizontalAlignment.Left;
public HorizontalAlignment TextAlign { get
{
return _textAlign;
}
set
{
if(_textAlign != value)
{
_textAlign = value;
Element.style.textAlign = _textAlign.ToString("G").ToLower();

}
}
}

protected override string GetDefaultTag()
{
var currentTag = Tag as string;
Expand Down
35 changes: 31 additions & 4 deletions TestBridge/bin/Debug/bridge/ClassicForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5057,6 +5057,17 @@ Bridge.assembly("ClassicForms", function ($asm, globals) {
}
});

Bridge.define("System.Windows.Forms.HorizontalAlignment", {
$kind: "enum",
statics: {
fields: {
Left: 0,
Right: 1,
Center: 2
}
}
});

Bridge.define("System.Windows.Forms.IWin32Window", {
$kind: "interface"
});
Expand Down Expand Up @@ -12566,13 +12577,26 @@ Bridge.assembly("ClassicForms", function ($asm, globals) {
inherits: [System.Windows.Forms.Control],
fields: {
Multiline: false,
_textAlign: 0,
prevString: null,
_useSystemPasswordChar: false
},
events: {
TextChanged: null
},
props: {
TextAlign: {
get: function () {
return this._textAlign;
},
set: function (value) {
if (this._textAlign !== value) {
this._textAlign = value;
this.Element.style.textAlign = System.Enum.format(System.Windows.Forms.HorizontalAlignment, this._textAlign, "G").toLowerCase();

}
}
},
Text: {
get: function () {
return this.Element.value;
Expand Down Expand Up @@ -12600,6 +12624,9 @@ Bridge.assembly("ClassicForms", function ($asm, globals) {
}
},
ctors: {
init: function () {
this._textAlign = System.Windows.Forms.HorizontalAlignment.Left;
},
ctor: function () {
var $t;
this.$initialize();
Expand Down Expand Up @@ -13253,10 +13280,10 @@ Bridge.assembly("ClassicForms", function ($asm, globals) {
var dummyControl = new System.Windows.Forms.Control(formBase, false);
formBase.style.overflow = "hidden";
formBase.style.position = "absolute";
formBase.style.left = "1px";
formBase.style.top = "1px";
formBase.style.width = "calc(100% - 2px)";
formBase.style.height = "calc(100% - 2px)";
formBase.style.left = "0";
formBase.style.top = "0";
formBase.style.width = "100%";
formBase.style.height = "100%";
formBase.style.cursor = "default";
formBase.style.outline = "none";

Expand Down
3 changes: 2 additions & 1 deletion TestBridge/bin/Debug/bridge/ClassicForms.meta.js

Large diffs are not rendered by default.

0 comments on commit 1c65d77

Please sign in to comment.