-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle git errors more gracefully in the same way base s&box does
- Loading branch information
Showing
2 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Tools; | ||
|
||
public class PopupWindow : BaseWindow | ||
{ | ||
Label Label; | ||
|
||
public PopupWindow( string title, string text, string buttonTxt = "OK", IDictionary<string, Action> extraButtons = null ) | ||
{ | ||
//FixedWidth = 500; | ||
//FixedHeight = 150; | ||
|
||
SetWindowIcon( "info" ); | ||
|
||
WindowTitle = title; | ||
|
||
AdjustSize(); | ||
|
||
SetModal( true, true ); | ||
|
||
SetLayout( LayoutMode.TopToBottom ); | ||
Layout.Margin = 24; | ||
Layout.Spacing = 24; | ||
|
||
Label = new Label( this ); | ||
Label.Text = text; | ||
Layout.Add( Label ); | ||
|
||
var okButton = new Button( this ); | ||
okButton.Text = buttonTxt; | ||
okButton.MinimumWidth = 64; | ||
okButton.MouseLeftPress += () => this.Destroy(); | ||
okButton.AdjustSize(); | ||
|
||
var buttonLayout = Layout.Row( true ); | ||
buttonLayout.Spacing = 5; | ||
Layout.Add( buttonLayout ); | ||
buttonLayout.Add( okButton ); | ||
|
||
if ( extraButtons != null ) | ||
{ | ||
foreach ( var KVs in extraButtons ) | ||
{ | ||
var customBtn = new Button( this ); | ||
customBtn.Text = KVs.Key; | ||
customBtn.MinimumWidth = 64; | ||
customBtn.MouseLeftPress += KVs.Value; | ||
customBtn.MouseLeftPress += () => this.Destroy(); | ||
customBtn.AdjustSize(); | ||
|
||
buttonLayout.Add( customBtn ); | ||
} | ||
} | ||
|
||
buttonLayout.AddStretchCell(); | ||
} | ||
|
||
protected override void OnPaint() | ||
{ | ||
base.OnPaint(); | ||
|
||
Paint.ClearPen(); | ||
Paint.SetBrush( Theme.WidgetBackground ); | ||
Paint.DrawRect( LocalRect, 0.0f ); | ||
} | ||
} |
This file contains 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