This commit is contained in:
parent
f4c2ad79f2
commit
34863a9984
8 changed files with 207 additions and 333 deletions
|
@ -3,6 +3,8 @@ using System.IO;
|
|||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Linq;
|
||||
using Myra.Graphics2D.UI;
|
||||
using Myra.Graphics2D.Brushes;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
|
@ -30,6 +32,35 @@ namespace Sledgemapper
|
|||
{
|
||||
return new Point(System.Math.Abs(point.X), System.Math.Abs(point.Y));
|
||||
}
|
||||
|
||||
public static (Window Window, C Content) GetParentContentInWindow<C>(this Widget widget) where C : Widget
|
||||
{
|
||||
Container container = widget.Parent;
|
||||
while (!(container is Window))
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as C;
|
||||
return (localWindow, localContent);
|
||||
}
|
||||
|
||||
public static bool ValidateTextbox(this TextBox textBox)
|
||||
{
|
||||
var valid = !string.IsNullOrWhiteSpace(textBox.Text);
|
||||
if (!valid)
|
||||
{
|
||||
textBox.Background = new SolidBrush(Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox.Background = new SolidBrush(new Color(51, 51, 51)); ;
|
||||
}
|
||||
return valid;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue