Exemple #1
0
        public override void CopyFrom(Datum other, CopyDepth depth, Mapping mapID)
        {
            SharedResource otherResource = (SharedResource)other;

            CRC      = otherResource.CRC;
            Buffer   = otherResource.Buffer;
            Filename = otherResource.Filename;
        }
Exemple #2
0
        public static SharedResource CreateFromBuffer(byte[] buffer, string fileExtension)
        {
            Debug.Assert(fileExtension.StartsWith("."));
            SharedResource resource = new SharedResource();

            resource.Buffer   = buffer;
            resource.CRC      = CRCCalc.Calc(resource.Buffer);
            resource.Filename = "auto" + fileExtension;
            return(resource);
        }
Exemple #3
0
        public static SharedResource CreateFromFile(string file, int CRC = 0)
        {
            SharedResource resource = new SharedResource();

            resource.Buffer   = File.ReadAllBytes(file);
            resource.Filename = Path.GetFileName(file);
            if (CRC == 0)
            {
                CRC = CRCCalc.Calc(resource.Buffer);
            }
            resource.CRC = CRC;
            return(resource);
        }
Exemple #4
0
        private void btnSoundBrowse_Click(object sender, EventArgs e)
        {
            string path = FileDialog.ShowOpen(FileDialog.Context.Sound);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            SharedResource sound = (SharedResource)Globals.Root.CurrentDocument.AddSharedResourceFromFile(path, m_Transaction, false);

            m_Scriptables.First().Sound = new SharedReference <SharedResource>(sound);
            pnlGraphic.Invalidate();
            ReflectSoundButtons();
            Updated();
        }
Exemple #5
0
        public static SharedResource CreateFromStream(Stream strm, string fileExtension, int intCRC = 0)
        {
            Debug.Assert(fileExtension.StartsWith("."));
            SharedResource resource = new SharedResource();
            int            length   = (int)strm.Length;

            strm.Seek(0, SeekOrigin.Begin);
            resource.Buffer = new byte[length - 1 + 1];
            strm.Read(resource.Buffer, 0, length);
            // we don't keep the original stream, just the buffer we have filled from it
            if (intCRC == 0)
            {
                intCRC = CRCCalc.Calc(resource.Buffer);
            }
            resource.CRC      = intCRC;
            resource.Filename = "auto" + fileExtension;
            return(resource);
        }