void ShowContextMenu() { var items = new List <KryptonContextMenuItemBase>(); Component oneSelectedComponent = ObjectOfWindow as Component; //Editor { var item = new KryptonContextMenuItem(TranslateContextMenu("Editor"), EditorResourcesCache.Edit, delegate(object s, EventArgs e2) { EditorAPI.OpenDocumentWindowForObject(Document, oneSelectedComponent); }); item.Enabled = oneSelectedComponent != null && EditorAPI.IsDocumentObjectSupport(oneSelectedComponent); items.Add(item); } //Settings { var item = new KryptonContextMenuItem(TranslateContextMenu("Settings"), EditorResourcesCache.Settings, delegate(object s, EventArgs e2) { bool canUseAlreadyOpened = !ModifierKeys.HasFlag(Keys.Shift); EditorAPI.ShowObjectSettingsWindow(Document, oneSelectedComponent, canUseAlreadyOpened); }); item.Enabled = oneSelectedComponent != null; items.Add(item); } items.Add(new KryptonContextMenuSeparator()); //New object { EditorContextMenu.AddNewObjectItem(items, CanNewObject(out _), delegate(Metadata.TypeInfo type) { TryNewObject(type); }); } //separator items.Add(new KryptonContextMenuSeparator()); //Cut { var item = new KryptonContextMenuItem(TranslateContextMenu("Cut"), EditorResourcesCache.Cut, delegate(object s, EventArgs e2) { //Cut(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Cut"); item.Enabled = false; // CanCut(); items.Add(item); } //Copy { var item = new KryptonContextMenuItem(TranslateContextMenu("Copy"), EditorResourcesCache.Copy, delegate(object s, EventArgs e2) { Copy(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Copy"); item.Enabled = CanCopy(); items.Add(item); } //Paste { var item = new KryptonContextMenuItem(TranslateContextMenu("Paste"), EditorResourcesCache.Paste, delegate(object s, EventArgs e2) { Paste(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Paste"); item.Enabled = CanPaste(out _); items.Add(item); } //Clone { var item = new KryptonContextMenuItem(TranslateContextMenu("Duplicate"), EditorResourcesCache.Clone, delegate(object s, EventArgs e2) { //TryCloneObjects(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Duplicate"); item.Enabled = false; // CanCloneObjects( out List<Component> dummy ); items.Add(item); } //separator items.Add(new KryptonContextMenuSeparator()); //Delete { var item = new KryptonContextMenuItem(TranslateContextMenu("Delete"), EditorResourcesCache.Delete, delegate(object s, EventArgs e2) { //TryDeleteObjects(); }); item.Enabled = false; // CanDeleteObjects( out List<Component> dummy ); items.Add(item); } //Rename { var item = new KryptonContextMenuItem(TranslateContextMenu("Rename"), null, delegate(object s, EventArgs e2) { EditorUtility.ShowRenameComponentDialog(oneSelectedComponent); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Rename"); //!!!!! item.Enabled = oneSelectedComponent != null; items.Add(item); } EditorContextMenu.AddActionsToMenu(EditorContextMenu.MenuTypeEnum.Document, items); //, this ); EditorContextMenu.Show(items, this); }
private void Editor_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e) { e.Handled = true; var items = new List <KryptonContextMenuItemBase>(); //Find { var item = new KryptonContextMenuItem(TranslateContextMenu("Find and Replace"), null, delegate(object s, EventArgs e2) { SearchReplacePanel?.ShowFindOrReplace(false); }); item.ShortcutKeyDisplayString = EditorActions.ConvertShortcutKeysToString(new Keys[] { Keys.Control | Keys.F }); //item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString( "Find" ); items.Add(item); } //separator items.Add(new KryptonContextMenuSeparator()); //Cut { var item = new KryptonContextMenuItem(TranslateContextMenu("Cut"), EditorResourcesCache.Cut, delegate(object s, EventArgs e2) { editor.Cut(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Cut"); item.Enabled = true; // editor.CanCut(); items.Add(item); } //Copy { var item = new KryptonContextMenuItem(TranslateContextMenu("Copy"), EditorResourcesCache.Copy, delegate(object s, EventArgs e2) { editor.Copy(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Copy"); item.Enabled = true; // CanCopy(); items.Add(item); } //Paste { var item = new KryptonContextMenuItem(TranslateContextMenu("Paste"), EditorResourcesCache.Paste, delegate(object s, EventArgs e2) { editor.Paste(); }); item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Paste"); item.Enabled = true; // CanPaste( out _ ); items.Add(item); } EditorContextMenu.AddActionsToMenu(EditorContextMenu.MenuTypeEnum.General, items); EditorContextMenu.Show(items, this); }