diff --git a/TBO/TBO.csproj b/TBO/TBO.csproj
index 92932fe..9097062 100644
--- a/TBO/TBO.csproj
+++ b/TBO/TBO.csproj
@@ -47,8 +47,10 @@
+
+ xIO2.cs
+
-
diff --git a/TBO/TBOFile.cs b/TBO/TBOFile.cs
index 59a7bec..621632f 100644
--- a/TBO/TBOFile.cs
+++ b/TBO/TBOFile.cs
@@ -4,6 +4,7 @@
using System.Drawing.Imaging;
using System.IO;
using System.Text;
+using XWolf.IO;
namespace TBO
{
@@ -73,7 +74,7 @@
List poses = new List();
long pos = fs.Position;
int lng;
- while ((lng = ReadInt()) > 0)
+ while ((lng = fs.ReadInt32()) > 0)
{
poses.Add(pos);
fs.Position = pos = fs.Position + lng;
@@ -86,7 +87,7 @@
metapos = fs.Position;
if (fs.Position >= fs.Length)
return;
- string metaJSON = ReadString();
+ string metaJSON = fs.ReadString();
}
#region I/O
@@ -95,7 +96,7 @@
{
empty = false;
fs.Position = 0;
- if (Encoding.ASCII.GetString(Read(FILEHEADER.Length)) != FILEHEADER)
+ if (Encoding.ASCII.GetString(fs.Read(FILEHEADER.Length)) != FILEHEADER)
throw new Exception("El arhivo no es un tebeo");
if (fs.ReadByte() != EOF)
throw new Exception("Error al leer el tebeo");
@@ -107,91 +108,54 @@
{
empty = true;
fs.Position = 0;
- Write(Encoding.ASCII.GetBytes(FILEHEADER));
+ fs.Write(Encoding.ASCII.GetBytes(FILEHEADER));
fs.WriteByte(EOF);
fs.WriteByte(FILEVERSION);
}
- private void Write(byte[] buf)
- {
- fs.Write(buf, 0, buf.Length);
- }
-
- private byte[] Read(int len)
- {
- byte[] buf = new byte[len];
- fs.Read(buf, 0, len);
- return buf;
- }
-
- private void WriteInt(int i)
- {
- Write(BitConverter.GetBytes(i));
- }
-
- private int ReadInt()
- {
- byte[] buf = Read(sizeof(int));
- return BitConverter.ToInt32(buf, 0);
- }
-
- private void WriteBlock(byte[] buf)
- {
- if (buf == null)
- WriteInt(0);
- else
- {
- WriteInt(buf.Length);
- Write(buf);
- }
- }
-
- private byte[] ReadBlock()
- {
- int lng = ReadInt();
- if (lng == 0)
- return null;
- return Read(lng);
- }
-
- private void WriteString(string data)
- {
- if (data == null)
- data = string.Empty;
- WriteBlock(Encoding.UTF8.GetBytes(data));
- }
-
- private string ReadString()
- {
- return Encoding.UTF8.GetString(ReadBlock());
- }
-
private Image ReadImage()
{
- MemoryStream ms = new MemoryStream(ReadBlock());
+ MemoryStream ms = new MemoryStream(fs.ReadBlock());
return Image.FromStream(ms);
}
private void WriteImage(Image i)
{
- WriteBlock(ImageJPEG(i));
+ fs.WriteBlock(ImageJPEG(i));
}
- #endregion
-
public void AppendImage(string filename)
{
byte[] image;
FileInfo fi = new FileInfo(filename);
- using (Image i = Image.FromFile(filename))
+ Image i;
+ try
+ {
+ i = Image.FromFile(filename);
+ }
+ catch
+ {
+ return;
+ }
+ using (i)
{
image = GetImageBytes(i);
if (image.Length > fi.Length)
image = File.ReadAllBytes(filename);
}
- WriteBlock(image);
+ fs.WriteBlock(image);
}
+ ///
+ /// Closes the TBO writing procedure
+ ///
+ public void Commit()
+ {
+
+ }
+
+ #endregion
+
private byte[] GetImageBytes(Image i)
{
byte[] img = ImageJPEG(i);
@@ -285,25 +249,25 @@
return ImagePNG(bmp);
}
- [oDBSerialize("Titl")]
+ [xIO.Serializable("Titl")]
public string Title { get; set; }
- [oDBSerialize("Var")]
+ [xIO.Serializable("Var")]
public string Variant { get; set; }
- [oDBSerialize("Vol")]
+ [xIO.Serializable("Vol")]
public string Volume { get; set; }
- [oDBSerialize("Auth")]
+ [xIO.Serializable("Auth")]
public string Author { get; set; }
- [oDBSerialize("Publ")]
+ [xIO.Serializable("Publ")]
public string Publisher { get; set; }
- [oDBSerialize("Year")]
+ [xIO.Serializable("Year")]
public int Year { get; set; }
- [oDBSerialize("Com")]
+ [xIO.Serializable("Com")]
public string Comments { get; set; }
public int Grayscale { get; set; } = 16;
diff --git a/TBO/UI/Windows/Studio.cs b/TBO/UI/Windows/Studio.cs
index f78767d..29378d3 100644
--- a/TBO/UI/Windows/Studio.cs
+++ b/TBO/UI/Windows/Studio.cs
@@ -114,11 +114,12 @@
lbInfo.Text = FBytes(tbo.Size);
Application.DoEvents();
}
+ tbo.W
}
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
+ //catch (Exception ex)
+ //{
+ // MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ //}
finally
{
btGo.Enabled = true;
diff --git a/TBO/oDB.cs b/TBO/oDB.cs
deleted file mode 100644
index 3dafa63..0000000
--- a/TBO/oDB.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace TBO
-{
- [AttributeUsage(AttributeTargets.Property)]
- class oDBSerialize : Attribute
- {
- public oDBSerialize(string name)
- {
- Name = name;
- }
-
- public string Name { get; set; }
- }
-
- class oDB
- {
-
- private Dictionary data = new Dictionary();
-
- #region Serialization
- public static oDB Serialize(Object o)
- {
- return null;
- }
-
- public T Deserialize() where T : new()
- {
- return default(T);
- }
- #endregion
-
- private object GetValue(string name)
- {
- object result;
- if (data.TryGetValue(name, out result))
- return result;
- return data[name]= new oDB();
- }
-
- public object this[string name] { get => GetValue(name); set => data[name] = value; }
- }
-
-}