private void ProcessWidgets_Recrusive(List <UEditorWidgetBase> CurrentContainer) { List <UEditorWidgetBase> __nestedWidgets = new List <UEditorWidgetBase>(); foreach (var item in CurrentContainer) { UEditorWidgetBase __castWidget = (UEditorWidgetBase)item; UWidgetCodeGen __cGen = new UWidgetCodeGen(__castWidget); _widgetDeclarations.Add(__cGen.WidgetDeclaration); _widgetPropertySetters.Add("\t//Property setters for ->" + item.Name); foreach (var setter in __cGen.PropertySetters) { _widgetPropertySetters.Add("\t" + setter); } _widgetPropertySetters.Add("\t" + __cGen.WidgetParent); _widgetPropertySetters.Add(""); _widgetPropertySetters.Add(""); if (item.GetType().IsSubclassOf(typeof(UEditorPanelBase))) { UEditorPanelBase __castPanel = (UEditorPanelBase)item; __nestedWidgets.AddRange(__castPanel.Children.Cast <UEditorWidgetBase>().ToList()); } } if (__nestedWidgets.Count > 0) { ProcessWidgets_Recrusive(__nestedWidgets); } }
void __newFoldout_OnClick(IUEditorWidgetClickable sender, System.EventArgs e) { if (this._controlKeyPressed) { UEditorWidgetBase __castSender = (UEditorWidgetBase)sender; //TODO: if the current object is the root form bail out!!!!! //Is the selected widget a container if (__castSender.BoundObject.GetType().IsSubclassOf(typeof(UEditorPanelBase)) || __castSender.BoundObject.GetType().IsSubclassOf(typeof(UEditorPanelBase))) { IWidgetContainer __newParent = (IWidgetContainer)__castSender.BoundObject; UEditorWidgetBase __widgetToMove = (UEditorWidgetBase)this.SelectedFoldout.BoundObject; IWidgetContainer __oldParent = ((UEditorWidgetBase)this.SelectedFoldout.BoundObject).parent; __oldParent.RemoveChild(__widgetToMove); __newParent.AddChild(__widgetToMove); } } //Update the selected foldout //TODO: Consider wrapping some type saftey around this this.SelectedFoldout = (UEditorWidgetFoldout)sender; }
private void AddNewWidget(UEditorWidgetBase newControl) { //TODO: This functionality is already getting achieved by the onContainerChange() call, work out how to decom this //and still keep the select widget working. //Create a new hierarchy widget UEditorWidgetFoldout __newHierarchyWidget = UWidget.Create <UEditorWidgetFoldout>(); __newHierarchyWidget.BindTo(newControl, "Name"); __newHierarchyWidget.ObjectID = newControl.ObjectID; __newHierarchyWidget.LayoutMode = ePositioningLayout.Layout; //__newHierarchyWidget.OnClick += __newFoldout_OnClick; if (newControl.GetType().IsSubclassOf(typeof(UEditorPanelBase)) == false) { __newHierarchyWidget.BaseStyle = "label"; } Canvas.CurrentContainer.AddChild(newControl); UEditorWidgetFoldout __containerInHierarchy = (UEditorWidgetFoldout)UWidget.FindWidgetById(this.HierarchyContainer, Canvas.CurrentContainer.ObjectID); __newHierarchyWidget.IndentLevel = __containerInHierarchy.IndentLevel + 1; //Select the new control this.__newFoldout_OnClick(__newHierarchyWidget, new System.EventArgs()); }
public void RemoveChild(UEditorWidgetBase removeChild, bool bSilent = false) { this._children.Remove(removeChild); if (bSilent == false) { this.Raise_onContainerChange(); } }
public virtual void AddChild(UEditorWidgetBase addChild, bool bSilent = false) { addChild.parent = this; this._children.Add(addChild); if (bSilent == false) { this.Raise_onContainerChange(); } }
//Constructor public UWidgetCodeGen(UEditorWidgetBase Widget, bool PharseOnConstruct = true) { _widget = Widget; if (PharseOnConstruct) { this.PharseWidget(); } }
void Hierarchy_onContainerChange(IWidgetContainer sender) { //Find the widget in the hierarchy UEditorWidgetBase __hierarchyContainer = UWidget.FindWidgetById(this.HierarchyContainer, sender.ObjectID); if (__hierarchyContainer != null) { BuildHericRecursive((UEditorWidgetFoldout)__hierarchyContainer, sender.Children); } }
void _listMenuOptions_onItemRemoved(UEditorWidgetBase sender, int indexRemoved) { //Remove the actual panel UEditorPanelTab_TabPanelItem __itemToRemove = this.TabPanelData[indexRemoved]; TabAreaPanel.RemoveChild(__itemToRemove.Panel); //Remove the associated panelData item this._tabPanelData.RemoveAt(indexRemoved); //Remove if from the Menu options this.TabAreaPanel.ToolBar.MenuOptions.RemoveAt(indexRemoved); }
void _listMenuOptions_onItemAdded(UEditorWidgetBase sender, int indexAdded) { UEditorPanelVertical __newPanel = UWidget.Create <UEditorPanelVertical>(); __newPanel.Name = TabAreaPanel.Name + "_" + _listMenuOptions.StringList[indexAdded]; __newPanel.LayoutMode = ePositioningLayout.Layout; __newPanel.WidgetShouldRender = false; this.TabPanelData.Insert(indexAdded, new UEditorPanelTab_TabPanelItem() { Panel = __newPanel }); this.TabAreaPanel.AddChild(__newPanel); this.TabAreaPanel.Raise_onContainerChange(); TabAreaPanel.ToolBar.MenuOptions.Insert(indexAdded, _listMenuOptions.StringList[indexAdded]); }
public void BuildHericRecursive(UEditorWidgetFoldout ParentFoldout, List <UEditorWidgetBase> widgetList) { ParentFoldout.ClearChilden(); foreach (var item in widgetList) { UEditorWidgetFoldout __newFoldout = UWidget.Create <UEditorWidgetFoldout>(); __newFoldout.IndentLevel = ParentFoldout.IndentLevel + 1; __newFoldout.BindTo(item, "Name"); __newFoldout.LayoutMode = ePositioningLayout.Layout; __newFoldout.OnClick += __newFoldout_OnClick; //Set the widget ID to match the one on the canvas. //This little bit of hackery help us keep the desinger hierarchy and the toolbox layout in sync. __newFoldout.ObjectID = item.ObjectID; if (item.GetType().IsSubclassOf(typeof(UEditorPanelBase))) { ParentFoldout.AddChild(__newFoldout); UEditorPanelBase __castPanel = (UEditorPanelBase)item; __castPanel.onContainerChange += Hierarchy_onContainerChange; List <UEditorWidgetBase> __childList = new List <UEditorWidgetBase>(); foreach (var __childWidgets in __castPanel.Children) { if (item.GetType().IsSubclassOf(typeof(UEditorWidgetBase))) { UEditorWidgetBase __castChild = (UEditorWidgetBase)__childWidgets; __childList.Add(__castChild); } } BuildHericRecursive(__newFoldout, __childList); } else { __newFoldout.BaseStyle = "label"; ParentFoldout.AddChild(__newFoldout); } } }
public void Canvas_CanvasActiveControlChanged(UEditorWidgetBase ActiveControl) { if (ActiveControl == null) { return; } if (ActiveControl.Name == "__widgetDesignerRoot") { this._vertLayoutFormSettings.WidgetShouldRender = true; this._vertLayoutPropSettings.WidgetShouldRender = false; this.lblPropertyName.Label = "Form settings"; } else { this._vertLayoutFormSettings.WidgetShouldRender = false; this._vertLayoutPropSettings.WidgetShouldRender = true; this.lblPropertyName.Label = ActiveControl.Name; this._lblWidgetType.Label = "(" + ActiveControl.GetType().FullName + ")"; this._widgetName.BindTo(ActiveControl, "Name"); this._propertiesPanel.BindTo(ActiveControl, "this"); } }
void _toolbox_OnClick(IUEditorWidgetClickable sender, EventArgs e) { UEditorWidgetBase __newControl = UWidget.Create(Type.GetType(_toolbox.LastSelectedType)); AddNewWidget(__newControl); }