本文整理汇总了C#中System.IO.BinaryReader.PeekChar方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryReader.PeekChar方法的具体用法?C# System.IO.BinaryReader.PeekChar怎么用?C# System.IO.BinaryReader.PeekChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了System.IO.BinaryReader.PeekChar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static void Load()
{
IO.Log.Write(" Loading CampaingProgresss...");
levelsCompleted.Clear();
System.IO.BinaryReader br = new System.IO.BinaryReader(new System.IO.FileStream("Saves/progress.lpg",
System.IO.FileMode.Open));
String s = "";
int l = 0;
while (br.PeekChar() > -1)
{
s = br.ReadString();
l = br.ReadInt32();
byte[] d = new byte[l];
for (int j = 0; j < l; j++)
{
d[j] = br.ReadByte();
}
levelsCompleted.Add(s, d);
}
br.Close();
IO.Log.Write(" Loading complete");
}
示例2: split
public static void split(string input_path, string dir_path, int nb)
{
System.IO.FileStream inf = new System.IO.FileStream(input_path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader reader = new System.IO.BinaryReader(inf);
System.IO.BinaryWriter[] writers = new System.IO.BinaryWriter[nb];
for (int x = 0; x < nb; x++)
{
writers[x] = new System.IO.BinaryWriter(new System.IO.FileStream(dir_path + "/part_" + (x + 1) + ".ACDC",
System.IO.FileMode.Create,
System.IO.FileAccess.Write));
}
int i = 0;
while (reader.PeekChar() != -1)
{
writers[i % nb].Write(reader.ReadChar());
i++;
}
for (int j=0; j<nb; j++)
{
writers[j].Close();
}
}
示例3: readGameData
private void readGameData()
{
textBox2.Text = path;
if (roq != null)
roq.stop();
roq = null;
if (vdx != null)
vdx.stop();
vdx = null;
switch (game)
{
case GameID.T7G:
lblGame.Text = "The 7th Guest";
System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo(path);
System.IO.FileInfo[] files = DI.GetFiles("*.rl");
this.gjdChooser.Items.Clear();
foreach (System.IO.FileInfo rl in files)
{
this.gjdChooser.Items.Add(rl.Name);
}
break;
case GameID.T11H:
lblGame.Text = "The 11th Hour";
//ROQ roq = new ROQ(new System.IO.BinaryReader(new System.IO.FileStream(path + "\\media\\final_hr.rol", System.IO.FileMode.Open)));
this.gjdChooser.Items.Clear();
System.IO.BinaryReader idx = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\groovie\\gjd.gjd", System.IO.FileMode.Open));
string name = "";
while (idx.BaseStream.Position < idx.BaseStream.Length)
{
if (idx.PeekChar() == 0x0A)
{
idx.ReadChar();
if (name.Length > 0)
this.gjdChooser.Items.Add(name.Substring(0, name.IndexOf(" ")));
name = "";
}
else
name += "" + idx.ReadChar();
}
idx.Close();
V2_RL = new List<GJD.RLData>[this.gjdChooser.Items.Count];
for (int i = 0; i < V2_RL.Length; i++)
V2_RL[i] = new List<GJD.RLData>();
this.gjdChooser.Items.Add("Icons");
idx = new System.IO.BinaryReader(new System.IO.FileStream(path + "\\groovie\\dir.rl", System.IO.FileMode.Open));
uint ctr = 0;
while (idx.BaseStream.Position < idx.BaseStream.Length)
{
// Get RL content
GJD.RLData rl = new GJD.RLData();
idx.ReadUInt32();
rl.offset = idx.ReadUInt32();
rl.length = idx.ReadUInt32();
rl.number = ctr;
ctr++;
ushort target = idx.ReadUInt16();
byte[] filename;
filename = idx.ReadBytes(12);
rl.filename = System.Text.Encoding.ASCII.GetString(filename).Trim();
idx.ReadBytes(6);
V2_RL[target].Add(rl);
}
break;
default:
lblGame.Text = "None";
break;
}
}
示例4: RunProgram
public void RunProgram(string filename)
{
ClearRegisters();
byte Magic1;
byte Magic2;
byte Magic3;
lock (b32Screen1)
{
b32Screen1.Reset();
}
System.IO.BinaryReader br;
System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);
br = new System.IO.BinaryReader(fs);
Magic1 = br.ReadByte();
Magic2 = br.ReadByte();
Magic3 = br.ReadByte();
if (Magic1 != 'B' && Magic2 != '3' && Magic3 != '2')
{
MessageBox.Show("This is not a valid B32 file!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
StartAddr = br.ReadUInt16();
ExecAddr = br.ReadUInt16();
ushort Counter = 0;
while ((br.PeekChar() != -1))
{
byte read = br.ReadByte();
B32Memory[(StartAddr + Counter)] = read;
memory.ThreadPoke((ushort)(StartAddr + Counter), read);
Counter++;
}
br.Close();
fs.Close();
InstructionPointer = ExecAddr;
pauseProgramToolStripMenuItem.Enabled = true;
resumeProgramToolStripMenuItem.Enabled = false;
//ExecuteProgram(ExecAddr, Counter);
//System.Threading.Thread prog = new System.Threading.Thread(delegate() { ExecuteProgram(ExecAddr, Counter); });
prog = new System.Threading.Thread(delegate() { ExecuteProgram(ExecAddr, Counter); });
PauseEvent = new System.Threading.ManualResetEvent(true);
prog.Start();
}
示例5: openToolStripMenuItem_Click
private void openToolStripMenuItem_Click(object sender, System.EventArgs e)
{
byte Magic1;
byte Magic2;
byte Magic3;
DialogResult dr;
dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.Cancel) return;
lock (reallySimpleScreen1)
{
reallySimpleScreen1.Reset();
}
System.IO.BinaryReader br;
System.IO.FileStream fs = new
System.IO.FileStream(openFileDialog1.FileName, System.IO.FileMode.Open);
br = new System.IO.BinaryReader(fs);
Magic1 = br.ReadByte();
Magic2 = br.ReadByte();
Magic3 = br.ReadByte();
if (Magic1 != 'B' && Magic2 != '3' && Magic3 != '2')
{
MessageBox.Show("This is not a valid B32 file!", "Error!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
StartAddr = br.ReadUInt16();
ExecAddr = br.ReadUInt16();
ushort Counter = 0;
while ((br.PeekChar() != -1))
{
ReallySimpleMemory[(StartAddr + Counter)] = br.ReadByte();
Counter++;
}
br.Close();
fs.Close();
InstructionPointer = ExecAddr;
//ExecuteProgram(ExecAddr, Counter);
programThread = new Thread(delegate () { ExecuteProgram(ExecAddr, Counter); });
PauseEvent = new ManualResetEvent(true);
programThread.Start();
}
示例6: Command
//.........这里部分代码省略.........
new Library.Point(center.X + size, center.Y, center.Z),
new Library.Point(center.X, center.Y + size, center.Z),
new Library.Point(center.X - size, center.Y, center.Z),
new Library.Point(center.X, center.Y - size, center.Z),
new Library.Point(center.X + size, center.Y, center.Z),
center
});
Manager.Load(program, MOVE_PROGRAM);
}
break;
}
case "action":
{
if (args.Length > 0)
switch (args[0])
{
case "sit":
gsApi.UseUserCommand(Lineage.UserCommand.Sit);
break;
case "stand":
gsApi.UseUserCommand(Lineage.UserCommand.Stand);
break;
}
break;
}
case "moving":
{
if(args.Length > 0 && System.IO.File.Exists(args[0]))
{
var parts = new List<List<Library.Point>>();
var reader = new System.IO.BinaryReader(
System.IO.File.OpenRead(args[0]));
while (reader.PeekChar() != -1)
{
var points = new List<Library.Point>();
int count = reader.ReadInt32();
for (int i = 0; i < count; i++)
points.Add(new Library.Point(
reader.ReadInt32(),
reader.ReadInt32(),
reader.ReadInt32()));
parts.Add(points);
}
var graph = new Model.Graph(parts);
var program = new Program.Move.OnGraph(gsApi);
program.Play(graph);
Manager.Load(program, MOVE_PROGRAM);
}
break;
}
case "autospoil":
{
throw new NotImplementedException();
break;
}
case "autosweep": // ToDo: Нуждается в тестировании и отладке
{
if (args.Length > 0)
{
var program = new Program.AutoSweep(gsApi);
switch (args[0])
{
case "my": program.Start(true); break;
case "all": program.Start(false); break;