@@ -61,6 +61,11 @@ public class Editor : Toplevel
6161 /// </summary>
6262 public static bool Quiet = false ;
6363
64+ /// <summary>
65+ /// Start your message with this if you want it to be visually highlighted as bad.
66+ /// </summary>
67+ public const string Error = "Error" ;
68+
6469 /// <summary>
6570 /// Initializes a new instance of the <see cref="Editor"/> class.
6671 /// </summary>
@@ -293,6 +298,13 @@ protected override void OnDrawComplete(DrawContext? context)
293298 // and have a designable view focused
294299 if ( toDisplay != null )
295300 {
301+ var before = GetCurrentAttribute ( ) ;
302+
303+ if ( toDisplay . StartsWith ( Error ) )
304+ {
305+ SetAttribute ( new Attribute ( Color . Red , Color . Black ) ) ;
306+ }
307+
296308 // write its name in the lower right
297309 int y = this . GetContentSize ( ) . Height - 1 ;
298310 int right = bounds . Width - 1 ;
@@ -303,6 +315,8 @@ protected override void OnDrawComplete(DrawContext? context)
303315 {
304316 this . AddRune ( right - len + i , y , runes [ i ] ) ;
305317 }
318+
319+ SetAttribute ( before ) ;
306320 }
307321 }
308322
@@ -1151,10 +1165,31 @@ private void Delete()
11511165 if ( SelectionManager . Instance . Selected . Any ( ) )
11521166 {
11531167 var cmd = new DeleteViewOperation ( SelectionManager . Instance . Selected . ToArray ( ) ) ;
1168+
1169+
1170+ if ( cmd . IsImpossible && cmd . PreventDeleting . Any ( ) )
1171+ {
1172+ ShowErrorThatViewIsUsedByOthers ( cmd . PreventDeleting ) ;
1173+ return ;
1174+ }
1175+
11541176 OperationManager . Instance . Do ( cmd ) ;
11551177 }
11561178 }
11571179
1180+ private void ShowErrorThatViewIsUsedByOthers ( Design [ ] usedBy )
1181+ {
1182+ if ( usedBy . Length == 1 )
1183+ {
1184+ flashMessage = $ "{ Error } , view referenced by " + usedBy [ 0 ] . FieldName ;
1185+ }
1186+ else
1187+ {
1188+ flashMessage = $ "{ Error } , view referenced by { usedBy . Length } views";
1189+ }
1190+ this . SetNeedsDraw ( ) ;
1191+ }
1192+
11581193 private void DoForSelectedViews ( Func < Design , Operation > operationFunc , bool allowOnRoot = false )
11591194 {
11601195 if ( this . viewBeingEdited == null )
0 commit comments