Exemplo n.º 1
0
        /// <summary>
        /// Gets a preview image for the given block definitions id
        /// </summary>
        /// <param name="id">Guid of the instance definition</param>
        /// <param name="width">width of the preview image in pixels</param>
        /// <param name="height">height of the preview image in pixels</param>
        /// <returns></returns>
        public static Image GetPreviewImage(Guid id, int width, int height)
        {
            var instanceAccess = new InstanceTableDataAccess();
            var definition     = instanceAccess.GetDefinition(id);

            return(GetPreviewImage(definition, width, height));
        }
Exemplo n.º 2
0
        private static List <NestedInstanceDefinitionModel> CreateNested(InstanceDefinitionModel root)
        {
            var models     = new List <NestedInstanceDefinitionModel>();
            var access     = new InstanceTableDataAccess();
            var definition = access.GetDefinition(root.Id);

            int i = 0;

            foreach (var part in definition.GetPartInstances())
            {
                // create model for current part
                var partModel = InstanceDefinitionModelFactory.Create(part.InstanceDefinition);

                // test if not an assembly
                if (!partModel.IsAssembly)
                {
                    models.Add(NestedInstanceDefinitionModelFactory.Create(partModel, root, root, i));
                }

                // if it is an assembly we have to go deeper
                models.AddRange(
                    CreateNested(partModel));

                i += 1;
            }

            return(models);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets a preview image for the given block definitions id
        /// highlighting the supplied nested active part definitions id
        /// </summary>
        /// <param name="mainId">Guid of the main instance definition</param>
        /// <param name="activePartId">Guid of the nested part definition which should be highlighted</param>
        /// <param name="width">width of the preview image in pixels</param>
        /// <param name="height">height of the preview image in pixels</param>
        /// <returns></returns>
        public static Image GetPreviewImage(Guid mainId, Guid activePartId, int width, int height)
        {
            var instanceAccess = new InstanceTableDataAccess();
            var main           = instanceAccess.GetDefinition(mainId);
            var active         = instanceAccess.GetDefinition(activePartId);

            return(GetPreviewImage(main, active, width, height));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets all the first level children of a Instance definition
        /// given its id
        /// </summary>
        /// <param name="id">The id of the Instance definition to find the children of</param>
        /// <returns></returns>
        public static IEnumerable <InstanceDefinitionModel> GetChildrenById(Guid id)
        {
            var dataAccess = new InstanceTableDataAccess();

            return(dataAccess
                   .GetNestedDefinitions(id)
                   .Select(InstanceDefinitionModelFactory.Create));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns all Instance definition models that can be generated
        /// from the currently active <see cref="Rhino.RhinoDoc"/>
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <InstanceDefinitionModel> GetInstanceDefinitions()
        {
            var dataAccess = new InstanceTableDataAccess();

            return(dataAccess
                   .GetDocumentInstanceDefinitions()
                   .Select(InstanceDefinitionModelFactory.Create)
                   );
        }
Exemplo n.º 6
0
        /// <summary>
        /// Returns all Instance definition models that are of type assembly
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <InstanceDefinitionModel> GetAssemblies()
        {
            var dataAccess = new InstanceTableDataAccess();

            return(dataAccess
                   .GetDocumentInstanceDefinitions()
                   .Where(d => !d.IsRoot())
                   .Select(InstanceDefinitionModelFactory.Create)
                   );
        }