private void btnCut_Click(object sender, RoutedEventArgs e) { int x = DrawArea.TheLayers.ActiveLayerIndex; int n = DrawArea.TheLayers[x].Graphics.SelectionCount; DrawArea.ObjCopyList = new GraphicsList(); for (int i = 0; i < n; i++) { DrawArea.ObjCopyList.Add(DrawArea.TheLayers[x].Graphics[i]); } CommandDelete command = new CommandDelete(DrawArea.TheLayers); if (DrawArea.TheLayers[x].Graphics.DeleteSelection()) { DrawArea.AddCommandToHistory(command); DrawArea.Refresh(); } if (btnCopy.IsEnabled == true) { btnCopy.IsEnabled = false; } if (btnPaste.IsEnabled == false) { btnPaste.IsEnabled = true; } }
/* PHÍM TẮT KEYBOARD */ #region Keyboard Functions // Ấn phím DEL trên bàn phím để xóa một đối tượng đã được chọn private void DrawArea_KeyDown(object sender, KeyEventArgs e) { int al = TheLayers.ActiveLayerIndex; switch (e.KeyCode) { case Keys.Delete: { int x = TheLayers.ActiveLayerIndex; CommandDelete command = new CommandDelete(TheLayers); if (TheLayers[x].Graphics.DeleteSelection()) { AddCommandToHistory(command); Refresh(); } break; } case Keys.ControlKey: _controlKey = true; break; default: break; } }
private void menuDelete_Click(object sender, RoutedEventArgs e) { int x = DrawArea.TheLayers.ActiveLayerIndex; CommandDelete command = new CommandDelete(DrawArea.TheLayers); if (DrawArea.TheLayers[x].Graphics.DeleteSelection()) { DrawArea.AddCommandToHistory(command); DrawArea.Refresh(); } }
/* XỬ LÝ CLICK PHẢI MOUSE */ // Thực hiện xóa được khi click phải mouse chọn Delete private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { int x = TheLayers.ActiveLayerIndex; CommandDelete command = new CommandDelete(TheLayers); if (TheLayers[x].Graphics.DeleteSelection()) { AddCommandToHistory(command); Refresh(); } }