private IUIControl CreateGroup(IDictionary map) { string title = map["title"] as string; IList <object> contents = map["contents"] as IList <object>; List <object> controls = new List <object>(); foreach (object obj in contents) { IUIControl control = null; if (obj is IDictionary) { control = CreateGroup(obj as IDictionary); } else if (obj is string) { control = CreateControl(obj as string); } controls.Add(control); } IDictionary <string, object> newMap = new Dictionary <string, object>(map as IDictionary <string, object>); newMap.Remove("title"); newMap.Remove("contents"); newMap.Add("id", title); newMap.Add("Description", title); newMap.Add("controls", controls); return(OmegaFactory.CreateControl("Group", newMap)); }
/// <summary> /// Initializes the ControlList with the value of "controls" parameter in the Input. /// </summary> /// <param name="input"></param> public override void SetInput(IUIInput input) { base.SetInput(input); if (Input.HasParameter("controls")) { ControlList = new List <object>(); IList <object> list = Input.GetInput("controls") as IList <object>; foreach (object control in list) { if (control is IDictionary) { ControlList.Add(OmegaFactory.CreateControl(control as IDictionary <string, object>)); } else if (control is IUIControl) { ControlList.Add(control); } else { throw new Exception(control + "is not a control"); } } } }
private IUIControl CreateControl(string id) { IUIControl control = null; if (itemList.Contains(id)) { Dictionary <string, object> item = itemList[id] as Dictionary <string, object>; control = OmegaFactory.CreateControl(id, item); } else { control = OmegaFactory.CreateControl(id); } ControlMap.Add(id, control); return(control); }
/// <summary> /// It registers the controls to the unity container instance /// </summary> /// <param name="container"></param> public static void RegisterUIControls(IUnityContainer container) { OmegaFactory.InitializeOmegaFactory(container); container.RegisterType <IUIControl, StringControl>("String"); container.RegisterType <IUIControl, IntControl>("Int"); container.RegisterType <IUIControl, FloatControl>("Float"); container.RegisterType <IUIControl, DoubleControl>("Double"); container.RegisterType <IUIControl, RadioCardUIControl>("RadioCard"); container.RegisterType <IUIControl, BooleanControl>("Boolean"); container.RegisterType <IUIControl, XamSliderControl>("XamSlider"); container.RegisterType <IUIControl, RangeSliderControl>("RangeSlider"); container.RegisterType <IUIControl, ListControl>("List"); container.RegisterType <IUIControl, ComboBoxControl>("CheckBoxCombo"); container.RegisterType <IUIControl, FileChooserControl>("FileControl"); container.RegisterType <IUIControl, GroupControl>("Group"); container.RegisterType <IUIControl, TabOmegaControl>("Tab"); }
protected Panel CreateContentPane(IList ui) { List <object> controls = new List <object>(); IDictionary map = null; foreach (object obj in ui) { map = obj as IDictionary; map.Add("showBorder", false); controls.Add(CreateGroup(map)); } Dictionary <string, object> parameters = new Dictionary <string, object> { { "id", "properties" }, { "Description", "Properties" }, { "controls", controls } }; IUIControl omega = null; if (controls.Count == 1) { parameters["Description"] = map.Contains("title") ? map["title"] : "Properties"; omega = OmegaFactory.CreateControl("Group", parameters); } else { omega = OmegaFactory.CreateControl("Tab", parameters); } TabbedComponent = omega; Grid panel = new Grid(); panel.Children.Add(omega.GetUIElement()); return(panel); }