fasdfsa commited on
Commit
631cd41
·
1 Parent(s): e023998

删选框同时删文本

Browse files
Files changed (1) hide show
  1. src/WpfEditor/MainWindow.xaml.cs +29 -0
src/WpfEditor/MainWindow.xaml.cs CHANGED
@@ -314,7 +314,36 @@ namespace WpfEditor
314
  deleteMenuItem.Click += (s, e) =>
315
  {
316
  var rect = (RectangleItem)((MenuItem)s).Tag;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  ViewModel.RemoveRectangle(rect);
 
 
 
 
 
 
 
318
  };
319
 
320
  contextMenu.Items.Add(deleteMenuItem);
 
314
  deleteMenuItem.Click += (s, e) =>
315
  {
316
  var rect = (RectangleItem)((MenuItem)s).Tag;
317
+
318
+ // 先删除选框下的文字
319
+ int idx = -1;
320
+ foreach (var (line, index) in Editor._lines.Select((line, index) => (line, index) ))
321
+ {
322
+ if (line.selected_rectange == null || !line.selected_rectange.HasValues)
323
+ {
324
+ continue;
325
+ }
326
+ int Id = line.selected_rectange["Id"].Value<int>();
327
+ if (rect.Id == Id)
328
+ {
329
+ idx = index;
330
+ break;
331
+ }
332
+ }
333
+ if (idx != -1)
334
+ {
335
+ Editor._lines.RemoveAt(idx);
336
+ }
337
+
338
+ // 删除选框
339
  ViewModel.RemoveRectangle(rect);
340
+
341
+ Editor.ClearSelection();
342
+ _textChanged = true;
343
+ Editor.InvalidateVisual();
344
+ // 触发文本改变事件
345
+ Editor.OnTextChanged();
346
+
347
  };
348
 
349
  contextMenu.Items.Add(deleteMenuItem);