public ActionResult EmailTemplate() { var listTemplate = new List <Template>(); //listTemplate.Add(new Template() { Id= 1, Name= "Tiger Nixon", Description= "System Architect" }); //listTemplate.Add(new Template() { Id = 2, Name = "Garrett Winters", Description = "Accountant" }); using (var repository = new Repository <Template>()) { listTemplate = repository.All().ToList(); } var uilistTemplate = new List <UITemplate>(); int i = 1; foreach (var template in listTemplate) { var uiTemplate = new UITemplate(); uiTemplate.UiId = i; uiTemplate.Id = template.Id; uiTemplate.Name = template.Name; uiTemplate.Description = template.Description.ToString(); uiTemplate.Description = uiTemplate.Description.Replace("\r\n", " ").Replace("\t", " "); uilistTemplate.Add(uiTemplate); i++; } return(View(uilistTemplate)); }
private void bRemoveUI_Click(object sender, EventArgs e) { if (listUis.SelectedItems.Count <= 0) { return; } foreach (ListViewItem item in listUis.Items) { UITemplate template = item.Tag as UITemplate; EditorEngine.Instance.World.UIContainer.Remove(template); listUis.Items.Remove(item); UITemplate current = uiScriptBox.Tag as UITemplate; if (current != template) { continue; } uiScriptBox.Text = ""; uiScriptBox.Tag = null; uiScriptBox.ReadOnly = true; uiScriptBox.Enabled = false; } }
protected override void CreateChildControls() { TemplateItem tItem = new TemplateItem(); UITemplate.InstantiateIn(tItem); tItem.DataBind(); Controls.Add(tItem); }
public override void init() { //Console.WriteLine("New Game"); ui = new UITemplate(Resource.getXml("UI\\Templates\\options_menu.xml")); ui.addEventListener(MouseEvent.CLICK, onClick); ui.layout.x = 0; Game.interfaceView.addChild(ui.layout); }
private void OnEnable() { _uiTemplate = (UITemplate)target; if (IsTemplatePrefabInInProjectView(_uiTemplate.gameObject)) { ShowHierarchy(); } CreatDirectory(); }
static int GetLength(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); UITemplate obj = (UITemplate)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UITemplate"); int o = obj.GetLength(); LuaScriptMgr.Push(L, o); return(1); }
static int GetControl(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); UITemplate obj = (UITemplate)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UITemplate"); int arg0 = (int)LuaScriptMgr.GetNumber(L, 2); GameObject o = obj.GetControl(arg0); LuaScriptMgr.Push(L, o); return(1); }
override public void init() { ui = new UITemplate(Resource.getXml("UI\\Templates\\main_menu.xml")); keeper.add(ui, MouseEvent.CLICK, onClick); keeper.add(Game.mouse, MouseEvent.MOUSE_MOVE, onMove); keeper.add(Game.interfaceView, ui.layout); keeper.add(Game.interfaceView, tf); tf.x = 600; ui.layout.x = 150; }
private void bAddUI_Click(object sender, EventArgs e) { UITemplate template = new UITemplate(); template.Name = "Rename me"; template.Code = template.DefaultCode(); EditorEngine.Instance.World.UIContainer.Add(template); ListViewItem item = new ListViewItem { Text = template.Name, Tag = template }; listUis.Items.Add(item); }
public override void init() { ui = new UITemplate(GCore.Resource.getXml("UI\\Templates\\loading.xml")); keeper.add(Game.interfaceView, ui.layout); WorldFactory wf = new WorldFactory(GCore.Resource.getXml("SETTINGS\\world.xml")); wf.generate(); Player player = new Player(); Registry.getInstance().addElement(player, "player"); dispatchEvent(new StateEvent(this, StateEvent.CHANGE_STATE, "gameplay")); }
public override void Start() { m_uiManager = new UIManager(); m_label = new UILabel() { Color = new Color4ub(0xFF, 0x80, 0x80, 0xFF), Font = InternalFonts.RegularBigVariableWidthFont // BoldSmallVariableWidthFont }; m_uiManager.Root = m_label; Engine.Display.SetCursor(Cursor.IBeam); var template = UITemplate <Menu> .Load(typeof(Menu).GetAssociatedResource("xml")); m_menu = template.Create(new Menu()); }
public JsonResult TemplateSave(UITemplate template) { try { using (var repository = new Repository <Template>()) { if (template.Id != 0) { var uiTemp = repository.Filter(q => q.Id == template.Id).FirstOrDefault(); if (uiTemp != null && !string.IsNullOrEmpty(uiTemp.Name)) { uiTemp.Name = template.Name; uiTemp.Description = template.Description; uiTemp.Id = template.Id; uiTemp.UpdateDate = DateTime.Now; repository.Update(uiTemp); } } //else //{ // var temp = new Template() // { // Name = template.Name, // CreateDate = DateTime.Now, // Description = template.Description, // UpdateDate = DateTime.Now // }; // repository.Create(temp); //} repository.SaveChanges(); } // TODO: Add insert logic here // return RedirectToAction("Index"); } catch (Exception ex) { UserException.LogException(ex); return(Json("Failiure", JsonRequestBehavior.AllowGet)); } return(Json("Success", JsonRequestBehavior.AllowGet)); }
public static Project CreateFromTemplates(CoreTemplate core, UITemplate ui, List <PackTemplate> packs, string filePath, string name) { Project project = new Project { Name = name, FileName = "Project.json", FilePath = filePath, Version = AppMeta.CurrentVersion }; List <Template> templates = new List <Template> { core, ui }; templates.AddRange(packs); foreach (Template template in templates.Where(x => !x.FilePath.IsNullOrWhiteSpace())) { Log.Information("Copying files for template {TemplateName}.", template.Name); foreach (string dirPath in Directory.GetDirectories(template.FilePath, "*", SearchOption.AllDirectories)) { DirectoryInfo info = Directory.CreateDirectory(dirPath.Replace(template.FilePath, filePath)); Log.Information("Creating Directory: {Directory}", info.Name); } foreach (string newPath in Directory.GetFiles(template.FilePath, "*.*", SearchOption.AllDirectories)) { FileInfo file = new FileInfo(newPath); if (file.Name == "Template.json") { continue; } Log.Information("Copying File: {File} to {Directory}.", file.Name, file.DirectoryName); File.Copy(newPath, newPath.Replace(template.FilePath, filePath), true); } } return(project); }
static int set_ItemList(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); UITemplate obj = (UITemplate)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name ItemList"); } else { LuaDLL.luaL_error(L, "attempt to index ItemList on a nil value"); } } obj.ItemList = (List <UITemplate.UIControl>)LuaScriptMgr.GetNetObject(L, 3, typeof(List <UITemplate.UIControl>)); return(0); }
static int get_ItemList(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); UITemplate obj = (UITemplate)o; if (obj != null) { LuaDLL.lua_newtable(L); for (int i = 0; i < obj.ItemList.Count; i++) { LuaScriptMgr.Push(L, i + 1); LuaScriptMgr.PushObject(L, obj.ItemList[i]); LuaDLL.lua_settable(L, -3); } } else { LuaDLL.lua_pushnil(L); } return(1); }
static private void CreatPrefab(GameObject prefab) { if (!prefab.GetComponent <UITemplate>()) { prefab.AddComponent <UITemplate>().InitGUID(TEMPLATE_PREFAB_PATH); } int prefabGuid = prefab.GetComponent <UITemplate>().m_GUID; List <GameObject> childList = new List <GameObject>(); new EditTools().GetChild(prefab, childList); foreach (GameObject childGo in childList) { UITemplate tem = childGo.GetComponent <UITemplate>(); UITemplateChild temc = childGo.GetComponent <UITemplateChild>(); if (tem || temc) { continue; } childGo.AddComponent <UITemplateChild>().InitGUID(prefabGuid); } PrefabUtility.CreatePrefab(TEMPLATE_PREFAB_PATH + "/" + prefab.name + ".prefab", prefab); Refresh(); }
/// <summary> /// 将目标label的值复制到目标label /// 并且由子模板的身份变成父模板 /// </summary> /// <param name="sourceGo">要被复制属性的目标uilabel对象</param> public static void CopyTemplateLabelValue(GameObject sourceGo) { UILabel sourceLab = sourceGo.GetComponent <UILabel>(); UITemplate sourceTem = sourceGo.GetComponent <UITemplate>(); if (!sourceLab) { return; } UnityEngine.Object[] selectionAsset = Selection.GetFiltered(typeof(GameObject), SelectionMode.TopLevel); //获取当前鼠标选中的所有对象 foreach (GameObject sGo in selectionAsset) { UILabel lab = sGo.GetComponent <UILabel>(); if (lab) { CopyComponent(sourceLab, lab); UITemplate tem = sGo.GetComponent <UITemplate>(); UITemplateChild temc = sGo.GetComponent <UITemplateChild>(); if (tem) { } else if (temc) { DestroyImmediate(temc); tem = sGo.AddComponent <UITemplate>(); //由子模板的身份变成父模板 } else { tem = sGo.AddComponent <UITemplate>(); } EditorUtility.CopySerialized(sourceTem, tem); EditorUtility.SetDirty(lab); } } }
static private void ApplyPrefab(GameObject prefab, Object targetPrefab, bool replace) { if (EditorUtility.DisplayDialog("注意!", "是否进行递归查找批量替换模板?", "ok", "cancel")) { GameObject replacePrefab; //int count = 0; if (replace) { PrefabUtility.ReplacePrefab(prefab, targetPrefab, ReplacePrefabOptions.ConnectToPrefab); Refresh(); replacePrefab = targetPrefab as GameObject; //count = prefab.GetComponentsInChildren<UITemplate>().Length; } else { replacePrefab = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(targetPrefab), typeof(GameObject)) as GameObject;; //GameObject checkPrefab = PrefabUtility.InstantiatePrefab(replacePrefab) as GameObject; //count = checkPrefab.GetComponentsInChildren<UITemplate>().Length; //DestroyImmediate(checkPrefab); } //if (count != 1) //{ // EditorUtility.DisplayDialog("注意!", "无法批量替换,因为模板不支持嵌套。", "ok"); // return; //} UITemplate template = replacePrefab.GetComponent <UITemplate>(); if (template != null) { List <GameObject> references; if (TrySearchPrefab(template.m_GUID, out references)) { GameObject checkPrefab = PrefabUtility.InstantiatePrefab(replacePrefab) as GameObject; for (int i = 0; i < references.Count; i++) { GameObject reference = references[i]; GameObject go = PrefabUtility.InstantiatePrefab(reference) as GameObject; UITemplate[] instanceTemplates = go.GetComponentsInChildren <UITemplate>(); for (int j = 0; j < instanceTemplates.Length; j++) { UITemplate instance = instanceTemplates[j]; if (instance.m_GUID == template.m_GUID) { EditTools.CopyComponents(template.gameObject, instance.gameObject); UITemplateChild[] instanceTemplatesChild = go.GetComponentsInChildren <UITemplateChild>(); UITemplateChild[] templateTemplatesChild = checkPrefab.gameObject.GetComponentsInChildren <UITemplateChild>(); for (int x = 0; x < templateTemplatesChild.Length; x++) { UITemplateChild templateChild = templateTemplatesChild[x]; for (int y = 0; y < instanceTemplatesChild.Length; y++) { UITemplateChild instanceChild = instanceTemplatesChild[y]; if (instanceChild.m_GUID == templateChild.m_GUID) { EditTools.CopyComponents(templateChild.gameObject, instanceChild.gameObject); } } } } PrefabUtility.ReplacePrefab(go, PrefabUtility.GetPrefabParent(go), ReplacePrefabOptions.ConnectToPrefab); } DestroyImmediate(go); } DestroyImmediate(checkPrefab); } } ClearHierarchy(); Refresh(); } }
override public void init() { ui = new UITemplate(Resource.getXml("UI\\Templates\\pause_menu.xml")); keeper.add(Game.interfaceView, ui.layout); }