public EnumDropDownControl(HCItemEnumDropDown itemProperty) { InitializeComponent(); this.itemProperty = itemProperty; propertyType = ReferenceUtility.GetUnreferencedType(itemProperty.Property.Type.GetNetType()); if (propertyType.IsEnum) { enumDataType = Enum.GetUnderlyingType(propertyType); isFlag = propertyType.IsDefined(typeof(FlagsAttribute), false); } currentValue = ReferenceUtility.GetUnreferencedValue(itemProperty.GetValues()[0]); propertyItemForUndoSupport = itemProperty.GetItemInHierarchyToRestoreValues(); propertyItemForUndoSupport.SaveValuesToRestore(); listViewEnum.Items.Clear(); listViewEnum.CheckBoxes = isFlag; foreach (var val in Enum.GetValues(propertyType)) { var info = new EnumInfo(val); var displayName = info.DisplayName; var description = info.Description; itemProperty.Owner.PerformOverridePropertyEnumItem(itemProperty, ref displayName, ref description); listViewEnum.Items.Add(new ListViewItem { Text = displayName, ToolTipText = description, Tag = info }); //listViewEnum.Items.Add( new ListViewItem //{ // Text = info.DisplayName, // ToolTipText = info.Description, // Tag = info //} ); } UpdateCheckState(); int itemCount = listViewEnum.Items.Count; var height = itemCount * (Font.Height + DpiHelper.Default.ScaleValue(4)) + 3; var width = ((IHCProperty)itemProperty.CreatedControl).EditorControl.Width; //TODO: bad incapsulation. why this control should know about EditorControl.Width ? Size = new Size(width, Math.Min(dropdownHeight, height)); if (EditorAPI.DarkTheme) { listViewEnum.BackColor = Color.FromArgb(54, 54, 54); listViewEnum.ForeColor = Color.FromArgb(240, 240, 240); } }
private void HierarchicalContainer1_OverridePropertyEnumItem(HierarchicalContainer sender, HCItemEnumDropDown property, ref string displayName, ref string description) { displayName = EditorLocalization.Translate("ContentBrowser.Options", displayName); description = EditorLocalization.Translate("ContentBrowser.Options", description); }
public void PerformOverridePropertyEnumItem(HCItemEnumDropDown property, ref string displayName, ref string description) { OverridePropertyEnumItem?.Invoke(this, property, ref displayName, ref description); }
private void HierarchicalContainer1_OverridePropertyEnumItem(HierarchicalContainer sender, HCItemEnumDropDown property, ref string displayName, ref string description) { displayName = Translate(displayName); description = Translate(description); }