Last active
August 29, 2015 14:06
-
-
Save ermshiperete/5e279ec02898d6c19ea9 to your computer and use it in GitHub Desktop.
Xamarin 23168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/ | |
obj/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2014 Eberhard Beilharz | |
// This software is licensed under the MIT license (http://opensource.org/licenses/MIT) | |
using System; | |
using System.Windows.Forms; | |
using System.Drawing; | |
namespace ButtonWrapBug | |
{ | |
class MainClass | |
{ | |
private static Form f; | |
private static TextBox textbox; | |
private static int top = 30; | |
public static void Main(string[] args) | |
{ | |
f = new Form(); | |
textbox = new TextBox(); | |
textbox.Location = new System.Drawing.Point(10, 10); | |
textbox.TextChanged += HandleTextChanged; | |
textbox.Text = "Button text is w"; | |
f.Controls.Add(textbox); | |
AddButton(f, TextImageRelation.ImageAboveText, false, false); | |
AddButton(f, TextImageRelation.ImageAboveText, true, false); | |
AddButton(f, TextImageRelation.ImageAboveText, false, true); | |
AddButton(f, TextImageRelation.ImageAboveText, true, true); | |
AddButton(f, TextImageRelation.Overlay, false, false); | |
AddButton(f, TextImageRelation.Overlay, true, false); | |
AddButton(f, TextImageRelation.Overlay, false, true); | |
AddButton(f, TextImageRelation.Overlay, true, true); | |
HandleTextChanged(textbox, EventArgs.Empty); | |
Application.Run(f); | |
} | |
static Button AddButton(Form f, TextImageRelation relation, bool autoEllipsis, bool autoSize) | |
{ | |
var label = new Label(); | |
label.Location = new Point(10, top); | |
label.Text = string.Format("{0}, Ellipsis: {1}, AutoSize: {2}", relation, autoEllipsis, autoSize); | |
label.AutoSize = true; | |
f.Controls.Add(label); | |
var button = new Button(); | |
button.TextImageRelation = relation; | |
button.AutoEllipsis = autoEllipsis; | |
button.AutoSize = autoSize; | |
button.Location = new System.Drawing.Point(10, top + 10); | |
button.Size = new System.Drawing.Size(90, 50); | |
top += 70; | |
f.Controls.Add(button); | |
return button; | |
} | |
static void HandleTextChanged(object sender, EventArgs e) | |
{ | |
foreach (var ctrl in f.Controls) | |
{ | |
Button b = ctrl as Button; | |
if (b != null) | |
{ | |
b.Text = textbox.Text; | |
b.Invalidate(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment