void UpdateActions() { var settings = GetSettings(); if (settings == null) { return; } var control = (HCItemProjectShortcutsForm)CreatedControlInsidePropertyItemControl; foreach (var item in control.contentBrowserAll.GetAllItems()) { var action = item.Tag as EditorAction; if (action != null) { var text = action.Name; var actionItem = settings.GetActionItem(action.Name); if (actionItem != null) { var keysString = EditorActions.ConvertShortcutKeysToString(actionItem.ToArray()); if (keysString != "") { text += " (" + keysString + ")"; } } ((ContentBrowserItem_Virtual)item).SetText(text); } } }
// void AddActionToQAT(EditorAction action) { var button = new KryptonRibbonQATButton(); //action.createdQATButton = button; button.Enabled = false; button.Image = EditorAPI.GetImageForDispalyScale(action.GetImageSmall(), action.GetImageBig()); //!!!! //button.ShortcutKeys = action.shortcutKeys; button.Tag = action; //button.Tag = action.name; //!!!! button.Text = action.Name; //set tool tip var toolTip = EditorLocalization.Translate("EditorAction.Name", action.Name); if (action.Description != "") { toolTip += "\n" + EditorLocalization.Translate("EditorAction.Description", action.Description); } var keysString = EditorActions.ConvertShortcutKeysToString(action.ShortcutKeys); if (keysString != "") { toolTip += " (" + keysString + ")"; } button.ToolTipBody = toolTip; if (action.ActionType == EditorAction.ActionTypeEnum.DropDown) { button.IsDropDownButton = true; button.KryptonContextMenu = action.DropDownContextMenu; } kryptonRibbon.QATButtons.Add(button); button.Click += QATButton_Click; }
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); }
public override void ControlInsidePropertyItemControlWasCreated() { base.ControlInsidePropertyItemControlWasCreated(); var settings = GetSettings(); if (settings == null) { return; } var control = (HCItemProjectShortcutsForm)CreatedControlInsidePropertyItemControl; control.contentBrowserAll.ItemAfterSelect += ContentBrowserAll_ItemAfterSelect; control.kryptonButtonReset.Click += KryptonButtonReset_Click; //init all actions { var items = new List <ContentBrowser.Item>(); var actions = new List <EditorAction>(EditorActions.Actions); CollectionUtility.InsertionSort(actions, delegate(EditorAction a, EditorAction b) { return(string.Compare(a.Name, b.Name)); }); Dictionary <Image, string> images = new Dictionary <Image, string>(); int imageCounter = 0; foreach (var action in actions) { var text = action.Name; var actionItem = settings.GetActionItem(action.Name); if (actionItem != null) { var keysString = EditorActions.ConvertShortcutKeysToString(actionItem.ToArray()); if (keysString != "") { text += " (" + keysString + ")"; } } //var text = action.Name; //var keysString = EditorActions.ConvertShortcutKeysToString( action.ShortcutKeys ); //if( keysString != "" ) // text += " (" + keysString + ")"; var item = new ContentBrowserItem_Virtual(control.contentBrowserAll, null, text); item.Tag = action; item.Description = action.Description; var smallImage = action.GetImageSmall(); if (smallImage != null) { if (!images.TryGetValue(smallImage, out var id)) { id = "Name_" + imageCounter.ToString(); images[smallImage] = id; control.contentBrowserAll.AddImageKey(id, smallImage, action.GetImageBig()); imageCounter++; } item.imageKey = id; } items.Add(item); } control.contentBrowserAll.SetData(items, false); } }