public MainForm() { InitializeComponent(); _activeRadialMenu = this.c1RmC1; chkShowOnMouseDown.Checked = true; chkShowExpanded.Checked = true; chkAutoHide.Checked = _activeRadialMenu.AutoHide; chkAnimateMenu.Checked = _activeRadialMenu.UseAnimation; }
private void UpdateContextMenu() { if (_skipMenuUpdate) { _skipMenuUpdate = false; return; } bool isTable = rtb.Selection.Cells.Count<C1TableCell>() > 0 && string.IsNullOrEmpty(rtb.Selection.Text); if (isTable) { if (currentC1RadialMenu != tableMenu) { // the table is selected, show table menu currentC1RadialMenu = tableMenu; tableMenu.Visibility = Visibility.Visible; contextMenu.Visibility = Visibility.Collapsed; contextMenu.Hide(); } } else { if (currentC1RadialMenu != contextMenu) { // hide table menu, show common one currentC1RadialMenu = contextMenu; contextMenu.Visibility = Visibility.Visible; tableMenu.Visibility = Visibility.Collapsed; tableMenu.Hide(); } } // update Paste try { tableMenuPaste.IsEnabled = menuPaste.IsEnabled = (System.Windows.Clipboard.GetDataObject().GetFormats().Length > 0); } catch { // it's possible that Clipboard access is denied. Don't fail application in such case } DocumentHistory_HistoryChanged(null, null); if (LastLocation.X > 0) { C1RadialMenu menu = currentC1RadialMenu; if (menu != null) { // count menu Offset, so that it doesn't overlap current selection in the RichTextBox // offset to right Point offset = new Point(150, 0); if (LastLocation.X > this.ActualWidth - 300) { // if menu is close to the right side of the screen, it will be automatically moved so that // all menu is visible on the screen. In such case it will overlap current pointer position. // So, use additional offset to top or bottom offset.Y = LastLocation.Y > this.ActualHeight - 300 ? -150 : 150; } menu.Offset = offset; // show menu in collapsed state, with some offset to the right, so that it doesn't overlap current selection menu.Show(rtb, LastLocation, false); } } }
private void UpdateContextMenu() { if (_skipMenuUpdate) { _skipMenuUpdate = false; return; } bool isTable = rtb.Selection.Cells.Count <C1TableCell>() > 0 && string.IsNullOrEmpty(rtb.Selection.Text); if (isTable) { if (currentC1RadialMenu != tableMenu) { // the table is selected, show table menu currentC1RadialMenu = tableMenu; tableMenu.Visibility = Visibility.Visible; contextMenu.Visibility = Visibility.Collapsed; contextMenu.Hide(); } } else { if (currentC1RadialMenu != contextMenu) { // hide table menu, show common one currentC1RadialMenu = contextMenu; contextMenu.Visibility = Visibility.Visible; tableMenu.Visibility = Visibility.Collapsed; tableMenu.Hide(); } } // update Paste try { tableMenuPaste.IsEnabled = menuPaste.IsEnabled = (System.Windows.Clipboard.GetDataObject().GetFormats().Length > 0); } catch { // it's possible that Clipboard access is denied. Don't fail application in such case } DocumentHistory_HistoryChanged(null, null); if (LastLocation.X > 0) { C1RadialMenu menu = currentC1RadialMenu; if (menu != null) { // count menu Offset, so that it doesn't overlap current selection in the RichTextBox // offset to right Point offset = new Point(150, 0); if (LastLocation.X > this.ActualWidth - 300) { // if menu is close to the right side of the screen, it will be automatically moved so that // all menu is visible on the screen. In such case it will overlap current pointer position. // So, use additional offset to top or bottom offset.Y = LastLocation.Y > this.ActualHeight - 300 ? -150 : 150; } menu.Offset = offset; // show menu in collapsed state, with some offset to the right, so that it doesn't overlap current selection menu.Show(rtb, LastLocation, false); } } }