private void Test(string Script, object[][] ExpectedOutput) { Variables v = new Variables(); Expression Exp = new Expression(Script); object Obj = Exp.Evaluate(v); Console.Out.WriteLine(Expression.ToString(Obj)); ObjectMatrix M = Obj as ObjectMatrix; int NrRows, RowIndex; int NrColumns, ColumnIndex; Assert.IsNotNull(M, "Object matrix expected."); Assert.AreEqual(NrRows = ExpectedOutput.Length, M.Rows, "Number of rows in response incorrect."); for (RowIndex = 0; RowIndex < NrRows; RowIndex++) { object[] ExpectedRow = ExpectedOutput[RowIndex]; ObjectVector Row = M.GetRow(RowIndex) as ObjectVector; Assert.IsNotNull(Row, "Object row vector expected."); Assert.AreEqual(NrColumns = ExpectedRow.Length, Row.Dimension, "Number of columns in response incorrect."); for (ColumnIndex = 0; ColumnIndex < NrColumns; ColumnIndex++) { Assert.AreEqual(ExpectedRow[ColumnIndex], Row.GetElement(ColumnIndex).AssociatedObjectValue); } } }
public ObjectElement cloneForExceport(ObjectVector parent) { ScriptFileElement newInstance = new ScriptFileElement(parent); if (value != null) { newInstance.value = ((String)value) + ""; } return(newInstance); }
private IEnumerator ZoomCube(ObjectVector ov) { int steps = 100; for (int i = 0; i < steps; i++) { ov.gameobject.transform.localScale = ov.vector * i / steps; yield return(new WaitForSeconds(SingleMakeDelay / steps)); } }
public void GetNodeList(ObjectVector list) { foreach (KeyValuePair <string, BaseEditor> it in this.children) { if (it.Value.EditorType == EditorType.Node) { list.Add(it.Value); } it.Value.GetNodeList(list); } }
/// <summary> /// Evaluates the function. /// </summary> /// <param name="Arguments">Function arguments.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Function result.</returns> public override IElement Evaluate(IElement[] Arguments, Variables Variables) { int i, c = Arguments.Length; IElement ResultRef = Arguments[0]; IElement Ref; ISet ResultSet = ResultRef.AssociatedSet; ISet Set; for (i = 1; i < c; i++) { Ref = Arguments[i]; Set = Arguments[i].AssociatedSet; if (!ResultSet.Equals(Set)) { if (Expression.Upgrade(ref ResultRef, ref ResultSet, ref Ref, ref Set, this)) { Arguments[0] = ResultRef; Arguments[i] = Ref; } else { ResultRef = new ObjectVector(ResultRef.ChildElements); ResultSet = ResultRef.AssociatedSet; Arguments[0] = ResultRef; Ref = new ObjectVector(Ref.ChildElements); Arguments[i] = Ref; } } } List <IElement> Elements = new List <IElement>(); Elements.AddRange(ResultRef.ChildElements); for (i = 1; i < c; i++) { Ref = Arguments[i]; Set = Arguments[i].AssociatedSet; if (!ResultSet.Equals(Set)) { if (!Expression.Upgrade(ref ResultRef, ref ResultSet, ref Ref, ref Set, this)) { Ref = new ObjectVector(Ref.ChildElements); } } Elements.AddRange(Ref.ChildElements); } return(ResultRef.Encapsulate(Elements, this)); }
private void VectorToNode(VectorBlocks Vector, string Server, string MachineName) { VectorBlocks ReturnVector; do { ReturnVector = null; string ReturnObjectName = null; string ReturnXmlObject = null; string ReturnFromUser = null; object Obj = null; var XmlObjectVector = SendObjectSync((object)Vector, Server, null, MachineName); if (!string.IsNullOrEmpty(XmlObjectVector)) { object ReturmObj; Converter.XmlToObject(XmlObjectVector, typeof(ObjectVector), out ReturmObj); ObjectVector ObjVector = (ObjectVector)ReturmObj; ReturnObjectName = ObjVector.ObjectName; ReturnXmlObject = ObjVector.XmlObject; ReturnFromUser = ObjVector.FromUser; if (ReturnObjectName == "VectorBlocks") { Converter.XmlToObject(ReturnXmlObject, typeof(VectorBlocks), out Obj); ReturnVector = (VectorBlocks)Obj; if (ReturnVector.Blockchain == null) { ReturnVector.Blockchain = Vector.Blockchain; } if (ReturnVector.RequestSendBlocksFromPosition != -1) { var BlocksToSend = GetBlocks(ReturnVector.RequestSendBlocksFromPosition, out ReadBlocksResult ReadBlocksResult); VectorBlocks VectorToSend = new VectorBlocks() { Blockchain = this, Blocks = BlocksToSend, Position = ReturnVector.RequestSendBlocksFromPosition, ReadBlocksResult = ReadBlocksResult }; VectorToNode(VectorToSend, Server, MachineName); } else { Vector = new VectorBlocks(); //Used to repeat the operation in case of partial reception of blocks UpdateLocalBlockchain(ReturnVector, Vector); } } else { ReturnObjectName = "String"; Converter.XmlToObject(ReturnXmlObject, typeof(string), out Obj); string ErrorMessage = System.Convert.ToString(Obj); Log("BlockchainError", 1000, ErrorMessage); } } } while (ReturnVector != null && ReturnVector.ReadBlocksResult == ReadBlocksResult.Partial); }
public static SKColor[] ToPalette(ObjectVector Vector) { int i, c = Vector.Dimension; SKColor[] Palette = new SKColor[c]; for (i = 0; i < c; i++) { Palette[i] = Graph.ToColor(Vector.GetElement(i).AssociatedObjectValue); } return(Palette); }
public static Object getValue(String title, Object defValue, byte valueType, ObjectVector vectorListT) { vectorList = vectorListT; if (smallDialog_PropertyValue == null) { smallDialog_PropertyValue = new SmallDialog_PropertyValue(title); } else { smallDialog_PropertyValue.Text = title; } smallDialog_PropertyValue.setValueType(valueType, defValue); smallDialog_PropertyValue.ShowDialog(); return(smallDialog_PropertyValue.getValue()); }
private void VectorToNode(VectorBlocks Vector, string Server, string MachineName) { string ReturnObjectName = null; string ReturnXmlObject = null; string ReturnFromUser = null; object Obj = null; var XmlObjectVector = SendObjectSync((object)Vector, Server, null, MachineName); if (!string.IsNullOrEmpty(XmlObjectVector)) { object ReturmObj; Converter.XmlToObject(XmlObjectVector, typeof(ObjectVector), out ReturmObj); ObjectVector ObjVector = (ObjectVector)ReturmObj; ReturnObjectName = ObjVector.ObjectName; ReturnXmlObject = ObjVector.XmlObject; ReturnFromUser = ObjVector.FromUser; if (ReturnObjectName == "VectorBlocks") { Converter.XmlToObject(ReturnXmlObject, typeof(VectorBlocks), out Obj); VectorBlocks ReturnVector = (VectorBlocks)Obj; if (ReturnVector.Blockchain == null) { ReturnVector.Blockchain = Vector.Blockchain; } if (ReturnVector.RequestSendBlocksFromPosition != -1) { var BlocksToSend = GetBlocks(ReturnVector.RequestSendBlocksFromPosition); VectorBlocks VectorToSend = new VectorBlocks() { Blockchain = this, Blocks = BlocksToSend, Position = ReturnVector.RequestSendBlocksFromPosition }; VectorToNode(VectorToSend, Server, MachineName); } else { UpdateLocalBlockchain(ReturnVector); } } else { ReturnObjectName = "String"; Converter.XmlToObject(ReturnXmlObject, typeof(string), out Obj); string ErrorMessage = System.Convert.ToString(Obj); Log("BlockchainError", 1000, ErrorMessage); } } }
public void GetObjectList(EditorType type, ObjectVector list) { list.Clear(); if (type == EditorType.Multisel) { return; } if (type != EditorType.Node) { foreach (KeyValuePair <string, BaseEditor> it in this.namesByType[(int)type]) { list.Add(it.Value); } } else { this.rootEditor.GetNodeList(list); } }
private IEnumerator MakeWallWorker() { float singlewidth = wwidth / cwidth; float singleheight = wheight / cheight; for (int j = 0; j < cheight; j++) { for (int i = 0; i < cwidth; i++) { GameObject cube = Instantiate(cubeBasis); cube.transform.position = new Vector3((singlewidth * (i + 0.5f)) - wwidth / 2, singleheight * (j + 0.5f), 0); cube.transform.localScale = new Vector3(0, 0, 0); ObjectVector ov = new ObjectVector(cube, new Vector3(singlewidth, singleheight, vdepth)); StartCoroutine("ZoomCube", ov); cube.tag = "Simulated"; yield return(new WaitForSeconds(TotalMakeDelay / (cwidth * cheight))); } } }
//获得映射图片 public static MImgElement getMappedImage(ObjectVector imgMappingList, MImgElement imgElementFrom) { if (imgMappingList == null) { return(null); } for (int i = 0; i < imgMappingList.getElementCount(); i++) { Object obj = imgMappingList.getElement(i); if (!(obj is ImageMappingElement)) { return(null); } ImageMappingElement imgMaElement = (ImageMappingElement)obj; if (imgMaElement.ImgFrom.Equals(imgElementFrom)) { return(imgMaElement.ImgTo); } } return(null); }
public override SceneFileResult Export(bool saveAs) { MogitorsRoot mogRoot = MogitorsRoot.Instance; MogitorsSystem system = MogitorsSystem.Instance; ProjectOptions opt = mogRoot.ProjectOptions; string fileName = system.CombinePath(opt.ProjectDir, opt.ProjectName + ".mogscene"); // If saveAs is true, use the MogitorsSystem Function to retrieve // a FileName and also copy the contents of current scene to the new location if (saveAs) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; dlg.DefaultExt = ".mogscene"; dlg.Filter = "Mogitor Scene File (.mogscene)|*.mogscene"; Nullable <bool> result = dlg.ShowDialog(); if (result != true) { return(SceneFileResult.Cancel); } fileName = dlg.FileName; string oldProjDir = opt.ProjectDir; string oldProjName = opt.ProjectName; opt.ProjectName = system.ExtractFileName(fileName); opt.ProjectDir = system.ExtractFilePath(fileName); mogRoot.AdjustUserResourceDirectories(oldProjDir); string newDir = opt.ProjectDir; system.MakeDirectory(newDir); system.CopyFilesEx(oldProjDir, newDir); string delFileStr = system.GetFullPath(system.CombinePath(opt.ProjectDir, oldProjName + ".mogscene")); system.DeleteFile(delFileStr); } XmlTextWriter textWriter = new XmlTextWriter(fileName, System.Text.Encoding.Unicode); textWriter.Formatting = Formatting.Indented; textWriter.WriteStartDocument(); textWriter.WriteStartElement("MogitorScene"); mogRoot.WriteProjectOptions(textWriter, true); ObjectVector objectList = new ObjectVector(); for (EditorType type = 0; type < EditorType.LastEditor; ++type) { mogRoot.GetObjectList(type, objectList); foreach (BaseEditor obj in objectList) { // If object does not have a parent, then it is not part of the scene if (obj.Parent == null) { continue; } if (obj.IsSerializable) { textWriter.WriteStartElement("Object"); textWriter.WriteStartAttribute("Type"); textWriter.WriteValue(obj.ObjectTypeName); textWriter.WriteEndAttribute(); // If obj's parent name is "" then the parent is this.rootEditor if (obj.Parent.Name != "") { textWriter.WriteStartAttribute("ParentNode"); textWriter.WriteValue(obj.Parent.Name); textWriter.WriteEndAttribute(); } Mogre.NameValuePairList theList = new Mogre.NameValuePairList(); obj.GetObjectProperties(theList); foreach (KeyValuePair <string, string> it in theList) { textWriter.WriteStartAttribute(it.Key); textWriter.WriteValue(it.Value); textWriter.WriteEndAttribute(); } textWriter.WriteEndElement(); } obj.OnSave(); } } textWriter.WriteEndElement(); textWriter.WriteEndDocument(); textWriter.Close(); mogRoot.IsSceneModified = false; if (saveAs) { mogRoot.TerminateScene(); mogRoot.LoadScene(fileName); } return(SceneFileResult.Ok); }
public override SceneFileResult Export(bool saveAs) { MogitorsRoot mogRoot = MogitorsRoot.Instance; MogitorsSystem system = MogitorsSystem.Instance; ProjectOptions opt = mogRoot.ProjectOptions; string fileName = system.CombinePath(opt.ProjectDir, opt.ProjectName + ".mogscene"); // If saveAs is true, use the MogitorsSystem Function to retrieve // a FileName and also copy the contents of current scene to the new location if (saveAs) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = ""; dlg.DefaultExt = ".mogscene"; dlg.Filter = "Mogitor Scene File (.mogscene)|*.mogscene"; Nullable<bool> result = dlg.ShowDialog(); if (result != true) return SceneFileResult.Cancel; fileName = dlg.FileName; string oldProjDir = opt.ProjectDir; string oldProjName = opt.ProjectName; opt.ProjectName = system.ExtractFileName(fileName); opt.ProjectDir = system.ExtractFilePath(fileName); mogRoot.AdjustUserResourceDirectories(oldProjDir); string newDir = opt.ProjectDir; system.MakeDirectory(newDir); system.CopyFilesEx(oldProjDir, newDir); string delFileStr = system.GetFullPath(system.CombinePath(opt.ProjectDir, oldProjName + ".mogscene")); system.DeleteFile(delFileStr); } XmlTextWriter textWriter = new XmlTextWriter(fileName, System.Text.Encoding.Unicode); textWriter.Formatting = Formatting.Indented; textWriter.WriteStartDocument(); textWriter.WriteStartElement("MogitorScene"); mogRoot.WriteProjectOptions(textWriter, true); ObjectVector objectList = new ObjectVector(); for (EditorType type = 0; type < EditorType.LastEditor; ++type) { mogRoot.GetObjectList(type, objectList); foreach (BaseEditor obj in objectList) { // If object does not have a parent, then it is not part of the scene if (obj.Parent == null) continue; if (obj.IsSerializable) { textWriter.WriteStartElement("Object"); textWriter.WriteStartAttribute("Type"); textWriter.WriteValue(obj.ObjectTypeName); textWriter.WriteEndAttribute(); // If obj's parent name is "" then the parent is this.rootEditor if (obj.Parent.Name != "") { textWriter.WriteStartAttribute("ParentNode"); textWriter.WriteValue(obj.Parent.Name); textWriter.WriteEndAttribute(); } Mogre.NameValuePairList theList = new Mogre.NameValuePairList(); obj.GetObjectProperties(theList); foreach (KeyValuePair<string, string> it in theList) { textWriter.WriteStartAttribute(it.Key); textWriter.WriteValue(it.Value); textWriter.WriteEndAttribute(); } textWriter.WriteEndElement(); } obj.OnSave(); } } textWriter.WriteEndElement(); textWriter.WriteEndDocument(); textWriter.Close(); mogRoot.IsSceneModified = false; if (saveAs) { mogRoot.TerminateScene(); mogRoot.LoadScene(fileName); } return SceneFileResult.Ok; }
private static WebReader ExecuteServerRequest(bool Async, string WebAddress = null, OnReceivedObject ExecuteOnReceivedObject = null, int SecWaitAnswer = 0, Action ExecuteIfNoAnswer = null, object Obj = null, System.Collections.Specialized.NameValueCollection Dictionary = null, int SecTimeOut = 0, string ToUser = null, bool CancellAllMyRequest = false, bool RemoveObjectsToMe = false, bool RemoveMyObjects = false) { if (WebAddress == null) { WebAddress = UrlServer(); } WebAddress = WebAddress.TrimEnd('/'); WebAddress += "/appserver.aspx?app=" + System.Uri.EscapeDataString(AppName) + "&fromuser="******"&secwaitanswer=" + SecWaitAnswer.ToString(); if (CancellAllMyRequest) { WebAddress += "&cancellrequest=true"; } if (RemoveObjectsToMe) { WebAddress += "&removeobjects=true"; } if (RemoveMyObjects) { WebAddress += "&removemyobjects=true"; } // NUOVA VERSIONE AGGIUNGERE QUESTA LINEA if (ToUser == "") { ToUser = Setup.Network.MasterServerMachineName + "."; } if (ToUser != "") { WebAddress += "&touser="******"&nogetobject=true"; } if (Obj != null) { WebAddress += "&post=" + Obj.GetType().Name + "§imeout=" + SecTimeOut.ToString(); System.IO.StringWriter Str = new System.IO.StringWriter(); System.Xml.Serialization.XmlSerializer xml = new System.Xml.Serialization.XmlSerializer(Obj.GetType()); System.Xml.Serialization.XmlSerializerNamespaces xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(); xmlns.Add(string.Empty, string.Empty); xml.Serialize(Str, Obj, xmlns); string postData = Str.ToString(); if (Dictionary == null) { Dictionary = new System.Collections.Specialized.NameValueCollection(); } string StrCod = Converter.StringToBase64(postData); Dictionary.Add("object", StrCod); } return(ReadWeb(Async, WebAddress, Parser, null, Dictionary, SecWaitAnswer, ExecuteIfNoAnswer)); }
public ScriptFileElement(ObjectVector parentT) { parent = parentT; }
//带图片映射的绘制 public void display(Graphics g, float destX, float destY, float zoomLevel, byte transFlag, Rect limitClip, int alpha, ObjectVector imgMapList) { if (imageElement != null) { MImgElement imageElementMapped = getMappedImage(imgMapList, imageElement); if (imgMapList != null && imageElementMapped != null && imageElementMapped.image != null && imageElement.image != null && (imageElementMapped.image.Size.Equals(imageElement.image.Size))) { GraphicsUtil.drawClip(g, imageElementMapped.image, (int)(destX), (int)(destY), clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height, transFlag, zoomLevel, limitClip, alpha); } else { if (imgClip != null) { GraphicsUtil.drawClip(g, imgClip, (int)(destX), (int)(destY), 0, 0, imgClip.Width, imgClip.Height, transFlag, zoomLevel, limitClip, alpha); } else { GraphicsUtil.drawClip(g, imageElement.image, (int)(destX), (int)(destY), clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height, transFlag, zoomLevel, limitClip, alpha); } } } }
public void GetNodeList(ObjectVector list) { foreach (KeyValuePair<string, BaseEditor> it in this.children) { if (it.Value.EditorType == EditorType.Node) { list.Add(it.Value); } it.Value.GetNodeList(list); } }