Skip to content

Instantly share code, notes, and snippets.

@folkertsj
Created February 18, 2013 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save folkertsj/4978637 to your computer and use it in GitHub Desktop.
Save folkertsj/4978637 to your computer and use it in GitHub Desktop.
// Allows us to define our own Dropdown options from code.(UIHint)
[UIHint("BackgroundPlacementMultiple"), Display(Name = "Background Position", Order = 20, Description = "The background placement for the backgrou image of this block")]
public virtual string BackgroundPlacement { get; set; }
public class BackgroundSelectionFactory : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var backgroundOptions = new List<SelectItem>();
backgroundOptions.Add(new SelectItem() { Text = "Top Left", Value = "tl" });
backgroundOptions.Add(new SelectItem() { Text = "Top Center", Value = "tc" });
backgroundOptions.Add(new SelectItem() { Text = "Top Right", Value = "tr" });
backgroundOptions.Add(new SelectItem() { Text = "Center Left", Value = "cl" });
backgroundOptions.Add(new SelectItem() { Text = "Center Center", Value = "cc" });
backgroundOptions.Add(new SelectItem() { Text = "Center Right", Value = "cr" });
backgroundOptions.Add(new SelectItem() { Text = "Bottom Left", Value = "bl" });
backgroundOptions.Add(new SelectItem() { Text = "Bottom Center", Value = "bc" });
backgroundOptions.Add(new SelectItem() { Text = "Bottom Right", Value = "br" });
return backgroundOptions;
}
}
[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "BackgroundPlacementMultiple")]
public class BackgroundMultipleEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
SelectionFactoryType = typeof(BackgroundSelectionFactory);
ClientEditingClass = "epi.cms.contentediting.editors.SelectionEditor";
base.ModifyMetadata(metadata, attributes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment