public SelectableTextBlock() { this.Cursor = Cursors.IBeam; Focusable = true; var contextMenu = new ContextMenu(); ContextMenu = contextMenu; copyMenu = new MenuItem(); copyMenu.Header = "复制"; copyMenu.InputGestureText = "Ctrl + C"; copyMenu.Click += (ss, ee) => { Copy(); }; contextMenu.Items.Add(copyMenu); selectAllMenu = new MenuItem(); selectAllMenu.Header = "全选"; selectAllMenu.InputGestureText = "Ctrl + A"; selectAllMenu.Click += (ss, ee) => { SelectAll(); }; contextMenu.Items.Add(selectAllMenu); fowardMenu = new MenuItem(); fowardMenu.Header = "转发"; fowardMenu.Click += (ss, ee) => { FowardEvent?.Invoke(this); }; #if !CUSTOMSERVER contextMenu.Items.Add(fowardMenu); #endif var deleteItem = new MenuItem(); deleteItem.Header = "删除"; deleteItem.Click += (ss, ee) => { Deleted?.Invoke(this); }; contextMenu.Items.Add(deleteItem); withDrawMenu = new MenuItem(); withDrawMenu.Header = "撤回"; withDrawMenu.Click += (ss, ee) => { WithDraw?.Invoke(this); }; ContextMenuOpening += contextMenu_ContextMenuOpening; this.LineHeight = 30; }
private void Button_WithDraw_Click(object sender, EventArgs e) { WithDraw?.Invoke(this, EventArgs.Empty); }