Ejemplo n.º 1
0
        /// <summary>
        /// Gets the list of selected graph element models. If not done yet, this
        /// function resolves the list of models from a list of GUID, using the graph.
        /// </summary>
        /// <param name="graph">The graph containing the selected models.</param>
        /// <returns>A list of selected graph element models.</returns>
        public IReadOnlyList <IGraphElementModel> GetSelection(IGraphModel graph)
        {
            if (m_SelectedModels == null)
            {
                if (graph == null)
                {
                    return(new List <IGraphElementModel>());
                }

                m_SelectedModels = new List <IGraphElementModel>();
                foreach (var guid in m_Selection)
                {
                    if (graph.TryGetModelFromGuid(new SerializableGUID(guid), out var model))
                    {
                        Debug.Assert(model != null);
                        m_SelectedModels.Add(model);
                    }
                }
            }

            return(m_SelectedModels);
        }