public void testToJsonArray() { MasterObject masterObject = new MasterObject(); masterObject.theTopArray = new string[] { "a", "b", "b" }; masterObject.theStringArray = new string[] { "iii", "iv", "v", "vi" }; MasterObject result; Json2Object j2O = new Json2Object(); //j2O.setToUseFields(); Type type = typeof(MasterObject); Object2Json o2J = new Object2Json(); o2J.NodeExpander = new FieldReflectionNodeExpander(); //todo json 2 object should understand TypeAliaser o2J.TypeAliaser = (t) => { return(t.FullName); }; o2J.TypeAliasProperty = j2O.TypeSpecifier; string json = o2J.toJson(masterObject); System.Console.Out.WriteLine("testToJsonLeafTypesViaFields json:" + json); result = (MasterObject)j2O.toObject(json); string expression = "theTopArray[0]"; Assert.AreEqual(masterObject.theTopArray.Length, result.theTopArray.Length, " Length"); Assert.AreEqual(masterObject.theTopArray[0], result.theTopArray[0], expression + " value"); Assert.AreEqual(masterObject.theStringArray.Length, result.theStringArray.Length, " Length"); Assert.AreEqual(masterObject.theStringArray[3], result.theStringArray[3], expression + " value"); }
private void PutObjectFromFloor() { animator.SetLayerWeight(1, 0); objectInHand.SetParent(null); objectInHand.transform.position = this.gameObject.transform.position + this.gameObject.transform.forward; objectInHand = null; }
public static void Main() { var defaultObj = new MasterObject(); var notDefaultObject = new MasterObject(); var defaultJson = JsonConvert.SerializeObject(defaultObj); var notDefaultJson = JsonConvert.SerializeObject(notDefaultObject); Console.WriteLine("First Test"); if (defaultJson == notDefaultJson) { Console.WriteLine("Same thing"); } else { Console.WriteLine("Not same thing"); } notDefaultObject.Sub1.SomeObject.SomeOtherValue = "Not a default Value"; notDefaultJson = JsonConvert.SerializeObject(notDefaultObject); Console.WriteLine("Second Test"); if (defaultJson == notDefaultJson) { Console.WriteLine("Same thing"); } else { Console.WriteLine("Not same thing"); } }
void LinkActionOnExecute(object sender, PopupWindowShowActionExecuteEventArgs e) { if (e.PopupWindow.View.SelectedObjects.Count > 0) { MasterObject.CreateMembersFromInterfaces(); } }
/// <summary> /// Remove a html object /// </summary> /// <param name="o">htmlObject</param> public void Remove(HTMLObject o) { Accessor a = new Accessor(Project.InstancesName, o.Unique); this.Hierarchy.Find(Project.InstancesName).Remove(a); this.Instances.Remove(o); if (o.BelongsTo != null) { // ce serait un master object MasterObject mo = this.MasterObjects.Find(x => { return(x.Name == o.BelongsTo); }); if (mo != null) { mo.Objects.Remove(o); } else { Page p = this.Pages.Find(x => { return(x.Name == o.BelongsTo); }); if (p != null) { p.Objects.Remove(o); } else { // il appartient plutot à un tool MasterPage mp = this.MasterPages.Find(x => { return(x.Name == o.BelongsTo); }); if (mp != null) { mp.Objects.Remove(o); } } } } }
private void menuTransformToolToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode t = this.prv_currentNodeContext; if (t != null) { if (t.Tag != null) { if (t.Tag is Library.MasterObject) { DialogResult dr = MessageBox.Show(Translate("TransformTool"), Translate("TransformToolTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == System.Windows.Forms.DialogResult.Yes) { HTMLTool tool = new HTMLTool(); MasterObject mo = t.Tag as MasterObject; OutputHTML html = mo.GenerateProduction(); tool.HTML = html.HTML.ToString(); tool.JavaScript.Code = html.JavaScript.ToString(); tool.JavaScriptOnLoad.Code = html.JavaScriptOnLoad.ToString(); string error; CSSValidation.CSSValidate(html.CSS.ToString(), false, tool.CSSList.List, out error); tool.Width = mo.Width; tool.Height = mo.Height; tool.ConstraintWidth = mo.ConstraintWidth; tool.ConstraintHeight = mo.ConstraintHeight; Project.CurrentProject.Add(tool, "generated/" + mo.Title); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } } } } }
public void testToJsonEmbedded() { MasterObject masterObject = new MasterObject(); masterObject.subObject = new SubObject(); masterObject.subObject.fieldA = "abc"; MasterObject result; Json2Object j2O = new Json2Object(); //j2O.setToUseFields(); Type type = typeof(MasterObject); Object2Json o2J = new Object2Json(); o2J.NodeExpander = new FieldReflectionNodeExpander(); //todo json 2 object should understand TypeAliaser o2J.TypeAliaser = (t) => { return(t.FullName); }; o2J.TypeAliasProperty = j2O.TypeSpecifier; string json = o2J.toJson(masterObject); System.Console.Out.WriteLine("testToJsonLeafTypesViaFields json:" + json); result = (MasterObject)j2O.toObject(json); string expression = "subObject.fieldA"; Assert.AreEqual(masterObject.subObject.fieldA, result.subObject.fieldA, expression + " value"); }
override protected void Awake() { base.Awake(); MasterObject = transform.Find("CardSetBG/Master").gameObject; assert.set(MasterObject); MasterObject.SetActive(false); }
public override void Interracted(MasterObject interractedObject) { base.Interracted(interractedObject); if (interractedObject.GetType() == typeof(Garlic)) { StartCoroutine(delaySpawnParticle()); } }
/** prend un object de sur la table * * @return l'object pris */ public virtual MasterObject PickItemOnTable() { MasterObject objectToReturn = objectOnTable; objectOnTable = null; return(objectToReturn); }
/// <summary> /// Remove a master object /// </summary> /// <param name="mo">master object</param> public void Remove(MasterObject mo) { Accessor a = new Accessor(Project.MasterObjectsName, mo.Unique); this.Hierarchy.Find(Project.MasterObjectsName).Remove(a); this.MasterObjects.Remove(mo); foreach (HTMLObject obj in mo.Objects) { this.Remove(obj); } }
static public bool EditItem(int key, string value) { MasterObject item = Find(key); if (item == null) { return(false); } item.Value = value; return(true); }
static public bool DeleteItem(int key) { MasterObject item = Find(key); if (item == null) { return(false); } Data.Remove(item); return(true); }
private void PickupObjectFromFloor() { animator.SetLayerWeight(1, 1); animator.SetTrigger("grab"); objectInHand = objectOnFloorInteractable; objectInHand.transform.position = transformObjectInHand.position; objectInHand.transform.rotation = transformObjectInHand.rotation; objectInHand.SetParent(transformObjectInHand); objectOnFloorInteractable = null; }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.GetComponent <Table>()) { tableInteractable = collision.gameObject.GetComponent <Table>(); } if (collision.gameObject.GetComponent <MasterObject>()) { objectOnFloorInteractable = collision.gameObject.GetComponent <MasterObject>(); } }
/// <summary> /// Import selected master object from an existing project /// </summary> /// <param name="src">project source</param> /// <param name="dest">project destination</param> private static void ImportMasterObjects(Project src, Project dest) { Tree <string, Accessor> t = new Tree <string, Accessor>(src.Hierarchy.Find(Project.MasterObjectsName)); BindingList <KeyValuePair <IEnumerable <string>, Accessor> > b = new BindingList <KeyValuePair <IEnumerable <string>, Accessor> >(); Node <string, Accessor> destNode = dest.Hierarchy.Find(Project.MasterObjectsName); t.EnumerateSelected(b); foreach (KeyValuePair <IEnumerable <string>, Accessor> kv in b) { MasterObject srcMo = kv.Value.GetObject(src); dest.Add(srcMo, String.Join("/", kv.Key.Skip(1).ToArray())); } }
private void PutObjectOnTable() { if (tableInteractable == null || objectInHand == null) { Debug.LogError("PlayerMovement (PutObjectOnTable) : no table or no object to place"); return; } tableInteractable.PutObjectOnTable(objectInHand); objectInHand = null; animator.SetLayerWeight(1, 0); }
/**Place un object sur la table * * @return Si l'object a été placer ou pas */ public virtual void PutObjectOnTable(MasterObject newObjectOnTable) { if (objectOnTable != null) { Debug.LogError("object already on table"); return; } objectOnTable = newObjectOnTable; //objectOnTable.PlaceOnTable(transformPointForObject); objectOnTable.transform.position = transformPointForObject.position; objectOnTable.transform.rotation = transformPointForObject.rotation; objectOnTable.SetParent(transformPointForObject); }
/// <summary> /// Constructor for an accessor with a master object /// </summary> /// <param name="mo">master object list</param> /// <param name="u">unique name to search</param> public Accessor(List <MasterObject> mo, string u) { MasterObject m = mo.Find(x => x.Unique == u); if (m != null) { this.Set(dataTypeName, Project.MasterObjectsName); this.Set(uniqueName, u); } else { throw new IndexOutOfRangeException(); } }
public void Test() { MasterObject obj = (MasterObject)TypeAccessor.CreateInstance(typeof(MasterObject)); Assert.IsNotNull(obj.Object1); Assert.IsNotNull(obj.Object2); Assert.AreEqual(100, obj.Object3.ID); Assert.AreEqual(200, obj.Object4.ID); obj.Object1.ID = 50; Assert.AreEqual("Object1.ID", obj.ChangedProperty); }
/// <summary> /// Render a selectable table /// </summary> /// <param name="data"></param> public void RenderControl(UXViewSelectableDataTable data) { MasterObject mo = new MasterObject(); RenderCSSProperties(data, mo.CSS); mo.Name = data.Name + "_outer_masterObject"; mo.Width = 100; mo.Height = 100; mo.ConstraintWidth = EnumConstraint.RELATIVE; mo.ConstraintHeight = EnumConstraint.RELATIVE; mo.CountColumns = 1; mo.CountLines = 1; mo.HTMLBefore = "<div id='" + mo.Name + "_in' onmouseout='javascript:LeaveArrow();'>"; mo.HTMLAfter = "</div>"; HorizontalZone h = new HorizontalZone(); h.ConstraintWidth = EnumConstraint.RELATIVE; h.ConstraintHeight = EnumConstraint.RELATIVE; h.Width = 100; h.Height = 100; h.CountLines = 1; mo.HorizontalZones.Add(h); VerticalZone v = new VerticalZone(); v.Width = 100; v.Height = 100; data.Get("Disposition", (s, x) => { v.Disposition = Enum.Parse(typeof(Disposition), x.Value); }); v.ConstraintWidth = EnumConstraint.RELATIVE; v.ConstraintHeight = EnumConstraint.RELATIVE; v.CountLines = 1; v.CountColumns = 1; h.VerticalZones.Add(v); this.project.MasterObjects.Add(mo); HTMLObject obj = new HTMLObject(mo); obj.Container = this.currentContainer; this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); currentContainer = mo.HorizontalZones[0].VerticalZones[0].Name; RenderControl(data as UXViewDataTable); }
/// <summary> /// Add a master object /// given a specific path to organize project's element /// </summary> /// <param name="mo">master object</param> /// <param name="path">path</param> public void Add(MasterObject mo, string path) { this.MasterObjects.Add(mo); string u = this.Unique.ComputeNewString(); mo.Unique = u; Accessor a = new Accessor(Project.MasterObjectsName, u); this.Hierarchy.Find(Project.MasterObjectsName).Find(path.Split('/')).AddLeaf(a); // objects foreach (HTMLObject obj in mo.Objects) { this.Add(obj, ""); } }
static public bool DeleteDetailItem(int masterKey, int key) { MasterObject masterItem = Find(masterKey); if (masterItem == null) { return(false); } DetailObject item = masterItem.Items.Find(d => d.Key == key); if (item == null) { return(false); } masterItem.Items.Remove(item); return(true); }
/// <summary> /// Generate design from a page and its objects /// </summary> /// <param name="refPage">page reference</param> /// <param name="objects">object list</param> /// <param name="parentConstraint">parent constraint</param> /// <returns>html output</returns> public OutputHTML GenerateDesign(Page refPage, List <MasterObject> objects, ParentConstraint parentConstraint) { if (this.IsMasterObject) { MasterObject selectedMo = Project.CurrentProject.MasterObjects.Find(mo => { return(mo.Name == this.MasterObjectName); }); if (selectedMo != null) { // calcul de la taille maximum de l'objet ParentConstraint newParent = new ParentConstraint(this.Name, parentConstraint); newParent.maximumWidth = selectedMo.Width; newParent.maximumHeight = selectedMo.Height; Routines.MoveConstraint(newParent, selectedMo.Width, selectedMo.Height, selectedMo.ConstraintWidth, selectedMo.ConstraintHeight); OutputHTML output = selectedMo.GenerateDesign(refPage, objects, newParent); return(output); } else { throw new KeyNotFoundException(String.Format(Localization.Strings.GetString("ExceptionMasterObjectNotExists"), this.MasterObjectName, this.Title)); } } else { OutputHTML html = new OutputHTML(); CodeCSS myCss = new CodeCSS(this.CSS); string myId = "obj" + Project.IncrementedTraceCounter.ToString(); ParentConstraint newInfos = Routines.ComputeObject(parentConstraint, this); Routines.SetObjectDisposition(newInfos, myCss, newInfos); ConstraintSize cs = new ConstraintSize(newInfos.constraintWidth, newInfos.precedingWidth, newInfos.maximumWidth, newInfos.constraintHeight, newInfos.precedingHeight, newInfos.maximumHeight); myCss.Ids = "#" + myId; Routines.SetCSSPart(myCss, cs); string tag; this.Attributes.ToHTML("div", myId, myCss, this.Events, html.CSS, out tag); html.HTML.Append(tag); html.HTML.Append(this.GeneratedHTML); html.HTML.Append("</div>"); html.AppendCSS(this.CSSList.GetListWithoutPrincipal(this.Id)); html.JavaScript.Append(this.JavaScript.GeneratedCode); html.JavaScriptOnLoad.Append(this.JavaScriptOnLoad.GeneratedCode); return(html); } }
private void PickupObjectFromTable() { if (tableInteractable == null) { Debug.LogError("PlayerMovement (PickupObjectFromTable) : no table in range)"); return; } animator.SetLayerWeight(1, 1); animator.SetTrigger("grab"); animator.SetInteger("compteurTake", 0); objectInHand = tableInteractable.PickItemOnTable(); objectInHand.transform.position = transformObjectInHand.position; objectInHand.transform.rotation = transformObjectInHand.rotation; objectInHand.SetParent(transformObjectInHand); }
/// <summary> /// Computes the adjustement size for a master object /// </summary> /// <param name="p">given a project</param> /// <param name="mo">given a master object</param> /// <returns>an adjustement size</returns> public static AdjustementSize ComputeMasterObject(Project p, MasterObject mo) { uint maxWidth = 0; uint height = 0; EnumConstraint cWidth = EnumConstraint.FIXED, cHeight = EnumConstraint.FIXED; foreach (HorizontalZone hz in mo.HorizontalZones) { AdjustementSize ads = SizeCompute.ComputeHorizontalZones(p, hz, mo.Objects); if (ads.ConstraintWidth == EnumConstraint.FIXED) { if (maxWidth < ads.Width) { maxWidth = ads.Width; } } else { cWidth = EnumConstraint.AUTO; } if (ads.ConstraintHeight == EnumConstraint.FIXED) { height += ads.Height; } else { cHeight = EnumConstraint.AUTO; } } // set information AdjustementSize container = new AdjustementSize(mo.ConstraintWidth, mo.ConstraintHeight, mo.Width, mo.Height); AdjustementSize content = new AdjustementSize(cWidth, cHeight, maxWidth, height); // compute SizeCompute.CheckConstraints(container, content); // update information mo.ConstraintWidth = container.ConstraintWidth; mo.ConstraintHeight = container.ConstraintHeight; mo.Width = container.Width; mo.Height = container.Height; return(new AdjustementSize(mo.ConstraintWidth, mo.ConstraintHeight, mo.Width, mo.Height)); }
/// <summary> /// Generate design from nothing /// Function to design this object /// a master object or a tool /// </summary> /// <returns>html output</returns> public OutputHTML GenerateDesign() { if (this.IsMasterObject) { MasterObject selectedMo = Project.CurrentProject.MasterObjects.Find(mo => { return(mo.Name == this.MasterObjectName); }); if (selectedMo != null) { OutputHTML output = selectedMo.GenerateDesign(); return(output); } else { throw new KeyNotFoundException(String.Format(Localization.Strings.GetString("ExceptionMasterObjectNotExists"), this.MasterObjectName, this.Title)); } } else { return(Routines.GenerateDesignObject(this)); } }
private void supprimerToolStripMenuItem1_Click(object sender, EventArgs e) { TreeNode t = this.prv_currentNodeContext; if (t != null) { if (t.Tag != null) { if (t.Tag is Library.MasterObject) { DialogResult dr = MessageBox.Show(Translate("SuppressText"), Translate("SuppressTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == System.Windows.Forms.DialogResult.Yes) { MasterObject mo = t.Tag as MasterObject; Project.CurrentProject.Remove(mo); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } } } } }
/// <summary> /// Constructor for a master object /// </summary> /// <param name="masterObject">master object to use</param> public HTMLObject(MasterObject masterObject) { int val = Project.CurrentProject.IncrementedCounter; this.Set(automaticNameName, String.Format("object{0}", val)); this.Set(automaticIdName, String.Format("idObject{0}", val)); this.Set(masterObjectName, masterObject.Name); this.Width = masterObject.Width; this.Height = masterObject.Height; this.ConstraintWidth = masterObject.ConstraintWidth; this.ConstraintHeight = masterObject.ConstraintHeight; this.Title = ExtensionMethods.CloneThis(masterObject.Title); this.Set(eventsName, masterObject.Events.Clone()); this.Set(javascriptName, masterObject.JavaScript.Clone()); this.Set(javascriptOnloadName, masterObject.JavaScriptOnLoad.Clone()); this.Set(cssListName, new CSSList((from CodeCSS c in masterObject.CSSList.List select c.Clone() as CodeCSS).ToList())); this.CSSList.RenamePrincipalCSS(masterObject.Id, this.Id); this.Set(attributesName, masterObject.Attributes.Clone()); this.Attributes.RenameId(this.Id); this.Attributes.HasId = false; }
/// <summary> /// Generate the content /// </summary> /// <param name="list">list of sized rectangle</param> internal void GenerateContent(List <AreaSizedRectangle> list) { if (this.Type == RefObject.MasterPage) { MasterPage mp = this.Destination; mp.HorizontalZones.Clear(); mp.MakeZones(list); this.FillContainerObject(mp.HorizontalZones, mp.Objects); SizeCompute.ComputeMasterPage(Project.CurrentProject, mp); } else if (this.Type == RefObject.Page) { Page p = this.Destination; MasterPage mp = this.SecondObject; p.MasterPageName = mp.Name; mp.HorizontalZones.Clear(); mp.MakeZones(list); this.FillContainerObject(mp.HorizontalZones, mp.Objects); SizeCompute.ComputePage(Project.CurrentProject, p); } else if (this.Type == RefObject.MasterObject) { MasterObject mo = this.Destination; mo.HorizontalZones.Clear(); mo.MakeZones(list); this.FillContainerObject(mo.HorizontalZones, mo.Objects); SizeCompute.ComputeMasterObject(Project.CurrentProject, mo); } else if (this.Type == RefObject.Tool) { HTMLTool obj = this.Destination; MasterObject mo = this.SecondObject; mo.HorizontalZones.Clear(); mo.MakeZones(list); this.FillContainerObject(mo.HorizontalZones, mo.Objects); SizeCompute.ComputeHTMLObject(Project.CurrentProject, new HTMLObject(obj)); } }
public void testToJsonEmbedded() { MasterObject masterObject = new MasterObject(); masterObject.subObject = new SubObject(); masterObject.subObject.fieldA = "abc"; MasterObject result; Json2Object j2O = new Json2Object(); //j2O.setToUseFields(); Type type = typeof(MasterObject); Object2Json o2J = new Object2Json(); o2J.NodeExpander = new FieldReflectionNodeExpander(); //todo json 2 object should understand TypeAliaser o2J.TypeAliaser = (t) => { return t.FullName; }; o2J.TypeAliasProperty = j2O.TypeSpecifier; string json = o2J.toJson(masterObject); System.Console.Out.WriteLine("testToJsonLeafTypesViaFields json:" + json); result = (MasterObject)j2O.toObject(json); string expression = "subObject.fieldA"; Assert.AreEqual(masterObject.subObject.fieldA, result.subObject.fieldA, expression + " value"); }
public void testToJsonArray() { MasterObject masterObject = new MasterObject(); masterObject.theTopArray = new string[] {"a", "b", "b"}; masterObject.theStringArray = new string[] { "iii", "iv", "v", "vi"}; MasterObject result; Json2Object j2O = new Json2Object(); //j2O.setToUseFields(); Type type = typeof(MasterObject); Object2Json o2J = new Object2Json(); o2J.NodeExpander = new FieldReflectionNodeExpander(); //todo json 2 object should understand TypeAliaser o2J.TypeAliaser = (t) => { return t.FullName; }; o2J.TypeAliasProperty = j2O.TypeSpecifier; string json = o2J.toJson(masterObject); System.Console.Out.WriteLine("testToJsonLeafTypesViaFields json:" + json); result = (MasterObject)j2O.toObject(json); string expression = "theTopArray[0]"; Assert.AreEqual(masterObject.theTopArray.Length, result.theTopArray.Length, " Length"); Assert.AreEqual(masterObject.theTopArray[0], result.theTopArray[0], expression + " value"); Assert.AreEqual(masterObject.theStringArray.Length, result.theStringArray.Length, " Length"); Assert.AreEqual(masterObject.theStringArray[3], result.theStringArray[3], expression + " value"); }