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); } }
void PackagingInit() { packagingNeedInit = false; //files string[] files; try { files = VirtualDirectory.GetFiles("", "*.product", SearchOption.AllDirectories); } catch { files = new string[0]; } var items = new List <ContentBrowser.Item>(); kryptonLabelInstallPlatformTools.Visible = false; foreach (var virtualPath in files) { string fileName = Path.GetFileName(virtualPath); var alreadyAddedImages = new ESet <string>(); var packageComponent = ResourceManager.LoadResource <Component_Product>(virtualPath); if (packageComponent != null) { string imageKey = packageComponent.Platform.ToString(); bool imageExists = false; if (!alreadyAddedImages.Contains(imageKey)) { var image16 = Properties.Resources.ResourceManager.GetObject(imageKey + "_16", Properties.Resources.Culture) as Image; var image32 = Properties.Resources.ResourceManager.GetObject(imageKey + "_32", Properties.Resources.Culture) as Image; if (image16 != null) { contentBrowserPackage.AddImageKey(imageKey, image16, image32); alreadyAddedImages.Add(imageKey); imageExists = true; } } string packageName = packageComponent.ProductName.Value; if (string.IsNullOrEmpty(packageName)) { packageName = "\'No name\'"; } var text = string.Format("{0} - {1} - {2}", packageName, packageComponent.Platform, virtualPath); var item = new ContentBrowserItem_Virtual(contentBrowserPackage, null, text); item.Tag = packageComponent; if (imageExists) { item.imageKey = imageKey; } if (!IsPlatformInstalled(packageComponent.Platform)) { item.ShowDisabled = true; kryptonLabelInstallPlatformTools.Visible = true; } items.Add(item); } } CollectionUtility.MergeSort(items, delegate(ContentBrowser.Item item1, ContentBrowser.Item item2) { var c1 = (Component_Product)item1.Tag; var c2 = (Component_Product)item2.Tag; var order1 = c1.SortOrderInEditor.Value; var order2 = c2.SortOrderInEditor.Value; if (order1 < order2) { return(-1); } if (order1 > order2) { return(1); } return(string.Compare(c1.Name, c2.Name)); }); contentBrowserPackage.SetData(items, false); if (items.Count != 0) { contentBrowserPackage.SelectItems(new ContentBrowser.Item[] { items[0] }); } }