Esempio n. 1
0
        public static SharedImage PickTexture(Document document)
        {
            // returns nothing if cancelled
            if (g_SystemTextures == null)
            {
                try
                {
                    g_SystemTextures = new DatumList();
                    if (System.IO.File.Exists(Globals.Root.InternalFolder + System.IO.Path.DirectorySeparatorChar + "textures"))
                    {
                        using (DataReader reader = new DataReader(Globals.Root.InternalFolder + System.IO.Path.DirectorySeparatorChar + "textures", FileMarkers.SharedBitmap))
                        {
                            g_SystemTextures.Add(reader.ReadDataList(FileMarkers.SharedBitmap));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utilities.LogSubError("Failed to load textures: " + ex.Message);
                    g_SystemTextures = new DatumList();
                }
            }

            frmTexture frm = new frmTexture(g_SystemTextures, document);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }
            return(frm.m_Chosen);
        }
Esempio n. 2
0
        public static DatumList CloneList(IEnumerable <Datum> original, Document document)
        {
            // makes a copy of all of the objects in the list, returning the new list
            // contained objects are cloned, but don't appear in the list (they do appear in the ID lookup table)
            // the new list will also contain any necessary objects referenced by these (e.g. textures)
            // links between objects will be updated if both halves are in the list, or broken if only the linking object (e.g. connector, paint splat)
            // is in the list
            DatumList newList = new DatumList();
            Mapping   mapID   = new Mapping();                     // lookup table from old to new IDs

            foreach (Datum data in original.Where(x => x != null)) // will ignore any missing objects in list
            {
                if (!mapID.ContainsKey(data.ID))                   // check is needed because containers will include contents, and original list could include both container and content if selected from page (select all especially)
                {
                    newList.Add(data.Clone(mapID));
                }
            }
            foreach (Datum data in original.Where(x => x != null))
            {
                // It would have been much easier to just iterate colNew, but we can't because the line below might modify the list
                mapID[data.ID].AddRequiredReferencesRecurseToContained(newList.Add, mapID);
            }
            foreach (Datum shape in newList.Values)
            {
                shape.UpdateReferencesIDsChanged(mapID, document);
            }
            return(newList);
        }
Esempio n. 3
0
        private DatumList m_Changed = new DatumList();         // list of the ones which have changed

        internal void WrittenToCurrent()
        {
            if (!m_Changed.Contains(m_Config))
            {
                m_Changed.Add(m_Config);
            }
        }