Skip to content

Instantly share code, notes, and snippets.

@ermshiperete
Last active August 29, 2015 14:06
Show Gist options
  • Save ermshiperete/5e279ec02898d6c19ea9 to your computer and use it in GitHub Desktop.
Save ermshiperete/5e279ec02898d6c19ea9 to your computer and use it in GitHub Desktop.
Xamarin 23168
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{25375166-6DA7-4118-A1E7-F9B3B07A6318}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ButtonWrapBug</RootNamespace>
<AssemblyName>ButtonWrapBug</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ButtonWrapBug", "ButtonWrapBug.csproj", "{25375166-6DA7-4118-A1E7-F9B3B07A6318}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{25375166-6DA7-4118-A1E7-F9B3B07A6318}.Debug|x86.ActiveCfg = Debug|x86
{25375166-6DA7-4118-A1E7-F9B3B07A6318}.Debug|x86.Build.0 = Debug|x86
{25375166-6DA7-4118-A1E7-F9B3B07A6318}.Release|x86.ActiveCfg = Release|x86
{25375166-6DA7-4118-A1E7-F9B3B07A6318}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = ButtonWrapBug.csproj
EndGlobalSection
EndGlobal
// 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