public ByteBuffer(GR.Memory.ByteBuffer bbRHS) { if (bbRHS.Length > 0) { Append(bbRHS.Data()); } }
public void SetHexData(GR.Memory.ByteBuffer Data) { long oldOffset = hexView.VScrollPos; hexView.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); hexView.PerformScrollToLine(oldOffset); }
private void SetLayoutFromData(GR.Memory.ByteBuffer Data) { PanelMain.SuspendLayout(true); // need to clear all foreach (var toolEntry in Tools) { toolEntry.Value.Document.DockPanel = null; } Main.CloseAllDocuments(); //Debug.Log( Data.ToAsciiString() ); System.IO.MemoryStream memIn = new System.IO.MemoryStream(Data.Data(), false); try { PanelMain.LoadFromXml(memIn, m_deserializeDockContent); } catch (Exception ex) { Debug.Log("SetLayoutFromData: " + ex.Message); } memIn.Close(); memIn.Dispose(); PanelMain.ResumeLayout(true, true); }
public void SetHexData(GR.Memory.ByteBuffer Data) { if (Data == null) { return; } hexView.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); hexView.ByteProvider.Changed += new EventHandler(ByteProvider_Changed); }
public static bool WriteAllBytes(string Filename, GR.Memory.ByteBuffer Data) { try { System.IO.File.WriteAllBytes(Filename, Data.Data()); } catch (Exception) { return(false); } return(true); }
public bool Save(string Filename) { Settings.Filename = Filename; GR.Memory.ByteBuffer projectData = Save(); try { System.IO.File.WriteAllBytes(Filename, projectData.Data()); } catch (System.IO.IOException) { return(false); } m_Modified = false; return(true); }
public bool Save(string Filename) { GR.Memory.ByteBuffer bufferProject = new GR.Memory.ByteBuffer(); GR.IO.FileChunk chunkProject = new GR.IO.FileChunk(Types.FileChunk.PROJECT); chunkProject.AppendU32(1); chunkProject.AppendString(Settings.Name); chunkProject.AppendString(Filename); chunkProject.AppendU16(Settings.DebugPort); chunkProject.AppendU16(Settings.DebugStartAddress); chunkProject.AppendString(Settings.BuildTool); chunkProject.AppendString(Settings.RunTool); chunkProject.AppendString(Settings.MainDocument); bufferProject.Append(chunkProject.ToBuffer()); foreach (ProjectElement element in Elements) { GR.IO.FileChunk chunkElement = new GR.IO.FileChunk(Types.FileChunk.PROJECT_ELEMENT); chunkElement.AppendU32(1); chunkElement.AppendU32((uint)element.Type); chunkElement.AppendString(element.Name); chunkElement.AppendString(element.Filename); GR.IO.FileChunk chunkElementData = new GR.IO.FileChunk(Types.FileChunk.PROJECT_ELEMENT_DATA); element.Document.SaveToChunk(chunkElementData); chunkElement.Append(chunkElementData.ToBuffer()); chunkElement.AppendString(element.TargetFilename); chunkElement.AppendU32((uint)element.TargetType); bufferProject.Append(chunkElement.ToBuffer()); } try { System.IO.File.WriteAllBytes(Filename, bufferProject.Data()); } catch (System.IO.IOException) { return(false); } m_Modified = false; return(true); }
public override bool WriteBlock(GR.Memory.ByteBuffer Buffer, UInt32 BytesToWrite) { if (m_Stream == null) { return(false); } try { m_Stream.Write(Buffer.Data(), 0, (int)BytesToWrite); return(true); } catch (System.Exception) { return(false); } }
public override UInt32 ReadBlock(GR.Memory.ByteBuffer BufferTarget, UInt32 BytesToRead) { if (m_Stream == null) { return(0); } int bytesInCache = (int)m_Cache.Length - m_CacheBytesUsed; // full in cache if (BytesToRead <= bytesInCache) { BufferTarget.Resize(BytesToRead); m_Cache.CopyTo(BufferTarget, m_CacheBytesUsed, (int)BytesToRead); m_CacheBytesUsed += (int)BytesToRead; return(BytesToRead); } UInt32 bytesRead = 0; // partially in cache BufferTarget.Resize((uint)bytesInCache); m_Cache.CopyTo(BufferTarget, m_CacheBytesUsed, bytesInCache); m_CacheBytesUsed += bytesInCache; BytesToRead -= (uint)bytesInCache; bytesRead = (UInt32)bytesInCache; UInt32 BytesToReadNow = BytesToRead; if (m_Stream.Position + BytesToRead > m_Stream.Length) { BytesToReadNow = (UInt32)(m_Stream.Length - m_Stream.Position); } UInt32 OriginalLength = (UInt32)BufferTarget.Length; BufferTarget.Resize((UInt32)(BufferTarget.Length + BytesToReadNow)); m_Stream.Read(BufferTarget.Data(), (int)OriginalLength, (int)BytesToReadNow); bytesRead += BytesToReadNow; return(bytesRead); }
private byte NextByte() { if (m_CacheBytesUsed + 1 <= m_Cache.Length) { ++m_CacheBytesUsed; return(m_Cache.ByteAt(m_CacheBytesUsed - 1)); } int bytesRead = m_Stream.Read(m_Cache.Data(), 0, (int)m_Cache.Length); if (bytesRead < m_Cache.Length) { m_Cache.TruncateAt((uint)bytesRead); } m_CacheBytesUsed = 0; if (bytesRead > 0) { return(NextByte()); } return(0); }
private void SetHexData(GR.Memory.ByteBuffer Data) { hexView.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); hexView.ByteProvider.Changed += new EventHandler(ByteProvider_Changed); }
private void SetHexData(Be.Windows.Forms.HexBox HexBox, GR.Memory.ByteBuffer Data) { HexBox.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); }
public GR.Memory.ByteBuffer GetAsData() { GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(m_ImageData.Data()); return(data); }
public bool GetFromClipboard() { IDataObject dataObj = Clipboard.GetDataObject(); if (dataObj == null) { return(false); } if (!dataObj.GetDataPresent("C64Studio.ImageList")) { return(false); } System.IO.MemoryStream ms = (System.IO.MemoryStream)dataObj.GetData("C64Studio.ImageList"); GR.Memory.ByteBuffer spriteData = new GR.Memory.ByteBuffer((uint)ms.Length); ms.Read(spriteData.Data(), 0, (int)ms.Length); GR.IO.MemoryReader memIn = spriteData.MemoryReader(); int numEntries = memIn.ReadInt32(); ColumnBased = (memIn.ReadInt32() > 0) ? true : false; var incomingColorSettings = new ColorSettings(); incomingColorSettings.BackgroundColor = memIn.ReadInt32(); incomingColorSettings.MultiColor1 = memIn.ReadInt32(); incomingColorSettings.MultiColor2 = memIn.ReadInt32(); incomingColorSettings.BGColor4 = memIn.ReadInt32(); incomingColorSettings.Palettes.Clear(); int numPalettes = memIn.ReadInt32(); for (int j = 0; j < numPalettes; ++j) { int numPaletteEntries = memIn.ReadInt32(); var pal = new Palette(numPaletteEntries); for (int i = 0; i < numPaletteEntries; ++i) { pal.ColorValues[i] = memIn.ReadUInt32(); } pal.CreateBrushes(); incomingColorSettings.Palettes.Add(pal); } for (int i = 0; i < numEntries; ++i) { var entry = new Entry(); entry.Index = memIn.ReadInt32(); entry.Tile.Mode = (GraphicTileMode)memIn.ReadInt32(); entry.Tile.CustomColor = memIn.ReadInt32(); int palIndex = memIn.ReadInt32(); entry.Tile.Width = memIn.ReadInt32(); entry.Tile.Height = memIn.ReadInt32(); uint dataLength = memIn.ReadUInt32(); entry.Tile.Data = new GR.Memory.ByteBuffer(); memIn.ReadBlock(entry.Tile.Data, dataLength); entry.Tile.Colors = new ColorSettings(incomingColorSettings); entry.Tile.Colors.ActivePalette = palIndex; int originalIndex = memIn.ReadInt32(); Entries.Add(entry); } return(true); }