public override Mirror CreateMirror(Cell cell) { var mirror = new EditorMirror { Cell = cell }; GameEditor.SetEditor(mirror, GameEditor.GetEditor(this)); return(mirror); }
private void AddCell(int col, int row, Cell cell) { var mirror = new EditorMirror() { Cell = cell }; GameEditor.SetEditor(mirror, VisualTreeHelper.GetParent(this) as GameEditor); SetColumn(mirror, col); SetRow(mirror, row); bool isCancel = false; mirror.BeginDrag += (sender, e) => { if (e.OldCheckerboard == this) { isCancel = false; AddCell(col, row, mirror.Cell.Clone() as Cell); } }; mirror.PreviewEndDrag += (sender, e) => { if (e.NewCheckerboard == this) { e.Cancel = true; } if (e.Cancel && e.OldCheckerboard == this) { isCancel = true; } }; mirror.EndDrag += (sender, e) => { if (isCancel) { e.OldCheckerboard.Children.Remove(mirror); } }; Children.Add(mirror); }