Example #1
0
 /// <summary>
 /// Goes through each ConfigurablePart and find its associated spaces
 /// </summary>
 private void SetSpacesToConfigurableParts()
 {
     foreach (var part in ExistingParts.OfType <ConfigurablePart>())
     {
         part.FindAssociatedSpaces();
     }
 }
Example #2
0
    /// <summary>
    /// Reads a structre file and creates the parts, feeding them into the _existingParts list
    /// </summary>
    /// <param name="file">The file to be read</param>
    private void ReadStructure(string file)
    {
        var newParts = JSONReader.ReadStructureAsList(this, file);

        foreach (var item in newParts)
        {
            ExistingParts.Add(item);
        }
    }
Example #3
0
    /// <summary>
    /// Method to creat a single <see cref="ConfigurablePart"/> on this grid in a given position with
    /// a given rotation and returns the ConfigurablePart object. The method attempts to create the component and the result parameter
    /// represents the success of the operation
    /// </summary>
    /// <param name="origin">The ReferenceIndex to create the part on</param>
    /// <param name="rotation">The clockwise rotation to be applied to the part</param>
    /// <param name="name">The name to be given to the part</param>
    /// <param name="showVoxels">A boolean representing if the initial state should be with the voxels or GameObjects visible</param>
    /// <param name="result">The output boolean representing the result of the operation</param>
    /// <returns>The resulting <see cref="ConfigurablePart"/></returns>
    public ConfigurablePart CreateSinglePart(Vector3Int origin, int rotation, string name, bool showVoxels, out bool result)
    {
        ConfigurablePart p = new ConfigurablePart(this, origin, rotation, !showVoxels, name, out bool success);

        if (success)
        {
            ExistingParts.Add(p);
        }
        result = success;
        return(p);
    }
Example #4
0
    /// <summary>
    /// Clears the grid and populate a given amount of new configurable parts on the grid
    /// </summary>
    /// <param name="amt">The amount of parts to populate</param>
    /// <returns>The Texture that represents the grid state</returns>
    private Texture2D PopulateRandomConfigurableGetImage(int amt)
    {
        ClearGrid();
        var configurables = ExistingParts.OfType <ConfigurablePart>();

        foreach (var c in configurables)
        {
            c.DestroyGO();
        }
        ExistingParts = new List <Part>();
        for (int i = 0; i < amt; i++)
        {
            ConfigurablePart p = new ConfigurablePart(this, !_showVoxels, _popSeed);
            ExistingParts.Add(p);
        }
        //Write image to temp_sr folder
        return(ImageReadWrite.TextureFromGridOriginal(this));
    }
Example #5
0
        private void ExportMatrixPart(Package package, WfProcessDescriptor processDesc)
        {
            var matrix = WfMatrixAdapter.Instance.LoadByProcessKey(processDesc.Key, false);

            if (matrix == null)
            {
                return;
            }
            matrix.Loaded = true;

            Uri partUri = CreatePartUri(this.MatrixCounter.ToString(), PackagePartType.MatrixPart);

            if (ExistingParts.Contains(partUri.ToString()))
            {
                return;
            }

            this.MappingInfo.Add(new PackageRelationMapping()
            {
                MatrixPath           = partUri.ToString(),
                MatrixDefID          = matrix.Definition.Key,
                ProcessDescriptionID = processDesc.Key
            });

            ExportMatrixDefPart(package, matrix.Definition);


            PackagePart part = package.CreatePart(partUri, MediaTypeNames.Application.Octet);

            using (MemoryStream bytes = matrix.ExportToExcel2007(this.IsRoleAsPerson))
            {
                using (var stream = part.GetStream())
                {
                    bytes.CopyTo(stream);
                    //stream.Write(bytes, 0, bytes.Length);
                    stream.Flush();
                }
            }

            ExistingParts.Add(partUri.ToString());
            this.MatrixCounter++;
        }
Example #6
0
        private void ExportMatrixDefPart(Package package, WfMatrixDefinition matrixDef)
        {
            Uri partUri = CreatePartUri(matrixDef.Key, PackagePartType.MatrixDefPart);

            if (ExistingParts.Contains(partUri.ToString()))
            {
                return;
            }

            XElement    matrixDefXml = XmlFormatter.Serialize(matrixDef);
            var         xDoc         = new XDocument(new XDeclaration("1.0", "utf-8", "true"), matrixDefXml);
            PackagePart part         = package.CreatePart(partUri, MediaTypeNames.Text.Xml);

            using (var stream = part.GetStream())
            {
                xDoc.Save(stream);
                stream.Flush();
            }

            ExistingParts.Add(partUri.ToString());
        }
Example #7
0
        private void ExportProcessPart(Package package, WfProcessDescriptor processDesc)
        {
            Uri partUri = CreatePartUri(processDesc.Key, PackagePartType.ProcessPart);

            if (ExistingParts.Contains(partUri.ToString()))
            {
                return;
            }

            XElement xeWfProcess = this.XmlFormatter.Serialize(processDesc);
            var      xDoc        = new XDocument(new XDeclaration("1.0", "utf-8", "true"), xeWfProcess);

            PackagePart part = package.CreatePart(partUri, MediaTypeNames.Text.Xml);

            using (var stream = part.GetStream())
            {
                xDoc.Save(stream);
                stream.Flush();
            }

            ExistingParts.Add(partUri.ToString());
        }