Skip to content

Commit

Permalink
added Mantano Reader as target type
Browse files Browse the repository at this point in the history
It is now possible to export annotations to Mantano Reader (lite or
premium). Added a form to choose import and export readers.
  • Loading branch information
PescheHelfer committed Dec 14, 2014
1 parent 43bbcb6 commit 80c2b76
Show file tree
Hide file tree
Showing 25 changed files with 3,244 additions and 800 deletions.
26 changes: 21 additions & 5 deletions AnnotationConverter/AbsExport.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnnotationConverter
{
abstract class AbsExport
{
abstract internal void PrepareDocument(string targetFile);
abstract internal void ExportRow(long iD, int markupType, string strMark, string strMarkEnd, string strName, string strMarkedText, string page, DateTime addedDate);
abstract internal void CloseDocument();
internal int RecordsSkipped { get; set; }
internal int RecordsInserted { get; set; }
internal int RecordsUpdated { get; set; }
internal int RecordErrors { get; set; }

/// <summary>
/// Target is an individual file (e.g. each books stores the annotations in its own xml)
/// </summary>
/// <param name="targetFile">path including filename</param>
abstract internal void PrepareTarget(string targetFile);

/// <summary>
/// Target resides in a DB
/// </summary>
/// <param name="bookId">ID of the book within the DB</param>
abstract internal void PrepareTarget(long bookId);

abstract internal void ExportRow(ExportRowParams exportRowParams);

abstract internal void CloseTarget();
}
}
23 changes: 13 additions & 10 deletions AnnotationConverter/AbsImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ abstract class AbsImport
internal string DataSource { get; set; }
internal long ContentID { get; set; }
internal string FileName { get; set; }
internal int Color { get; set; }
internal int HighlightStyle { get; set; }
internal int CountAnnotations { get; set; }
internal int CountBookmarks { get; set; }
internal int TotalCount { get; set; } // Annotations + Bookmarks

protected DateTime _addedDate;
protected long _iD;
protected int _markupType;
protected int _page;
protected string _strMarkStart;
protected string _strMarkedText;
protected string _strMarkEnd;
protected string _strName;
//protected DateTime _addedDate;
//protected DateTime _modifiedDate;
//protected long _iD;
//protected int _markupType;
//protected int _page;
//protected string _strMarkStart;
//protected string _strMarkedText;
//protected string _strMarkEnd;
//protected string _strName;
protected AbsExport _absExport;

internal AbsImport(AbsExport absExport) // constructor
Expand All @@ -43,15 +46,15 @@ protected virtual void OnProgressChanged(ProgressChangedEventArgs e)

abstract protected object ProvideConnection();

abstract internal void BuildBookList(List<Tuple<long, string, string>> liBooksContent);
abstract internal void BuildBookList(List<Tuple<long, string, string, string>> liBooksContent); // id, title+author, title only, filename

abstract internal void GetTotalCountOfAnnotations();

abstract internal void ReadAnnotations();

abstract internal void ReadBookmarks();

abstract protected void ConsumeAnnotationRow(SQLiteDataReader row);
abstract protected void ConsumeAnnotationRow(SQLiteDataReader row, bool isBookmark);
//ToDo: make the row generic, so tha t not only SQLite is supported!
}
}
42 changes: 35 additions & 7 deletions AnnotationConverter/AnnotationConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,45 @@
<ItemGroup>
<Compile Include="AbsExport.cs" />
<Compile Include="AbsImport.cs" />
<Compile Include="ConverterGUI.cs">
<Compile Include="ChooseReaders.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConverterGUI.Designer.cs">
<DependentUpon>ConverterGUI.cs</DependentUpon>
<Compile Include="ChooseReaders.Designer.cs">
<DependentUpon>ChooseReaders.cs</DependentUpon>
</Compile>
<Compile Include="ConverterGuiADE.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConverterGuiADE.Designer.cs">
<DependentUpon>ConverterGuiADE.cs</DependentUpon>
</Compile>
<Compile Include="ConverterGuiMantano.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConverterGuiMantano.Designer.cs">
<DependentUpon>ConverterGuiMantano.cs</DependentUpon>
</Compile>
<Compile Include="ExportRowParams.cs" />
<Compile Include="ExportToADE.cs" />
<Compile Include="ExportToMantano.cs" />
<Compile Include="ImportFromSonyPRST.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="ClassDiagram1.cd" />
<None Include="ClassDiagram2.cd" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>PublicSettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="x64\SQLite.Interop.dll">
Expand All @@ -83,8 +105,14 @@
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ConverterGUI.resx">
<DependentUpon>ConverterGUI.cs</DependentUpon>
<EmbeddedResource Include="ChooseReaders.resx">
<DependentUpon>ChooseReaders.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ConverterGuiADE.resx">
<DependentUpon>ConverterGuiADE.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ConverterGuiMantano.resx">
<DependentUpon>ConverterGuiMantano.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
106 changes: 106 additions & 0 deletions AnnotationConverter/ChooseReaders.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions AnnotationConverter/ChooseReaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AnnotationConverter.Helpers;

namespace AnnotationConverter
{
public partial class FrmChooseReaders : Form
{
private Dictionary<Utils.EReader, string> _diImportReaders = new Dictionary<Utils.EReader, string>();
private Dictionary<Utils.EReader, string> _diExportReaders = new Dictionary<Utils.EReader, string>();

public FrmChooseReaders()
{
_diImportReaders.Add(Utils.EReader.SonyPRST, "Sony PRS-T1/-T2/-T3");
_diExportReaders.Add(Utils.EReader.Mantano, "Mantano Ebook Reader Free/Pro");
_diExportReaders.Add(Utils.EReader.AdobeDigitalEditions, "Adobe Digital Editions 2.x/3.x");
InitializeComponent();
}

#region Handler Methods
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
var rdb = sender as RadioButton;
if (rdb != null && rdb.Checked)
{
rdb.Parent.Tag = (Utils.EReader)rdb.Tag;
}
}

private void AddRadioButtons(Dictionary<Utils.EReader, string> readers, GroupBox targetBox)
{
int vPos = 20;
int i = 0;
foreach (KeyValuePair<Utils.EReader, string> pair in readers)
{
var rdb = new RadioButton
{
Name = "rdb" + pair.Value,
Text = pair.Value,
Tag = pair.Key,
Location = new Point(20, vPos),
AutoSize = true
};
rdb.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
targetBox.Controls.Add(rdb);
rdb.Checked = (i == 0);
vPos += 20;
i++;
}
}

private void OpenFormCloseThis(Form form)
{
this.Hide();
form.Closed += (sender, args) => this.Close();
form.Show();
}

private void btnOK_Click(object sender, EventArgs e)
{
if ((Utils.EReader)gbImport.Tag == Utils.EReader.SonyPRST)
{
switch ((Utils.EReader)gbExport.Tag)
{
case Utils.EReader.AdobeDigitalEditions:
OpenFormCloseThis(new ConverterGuiADE());
break;
case Utils.EReader.Mantano:
OpenFormCloseThis(new ConverterGuiMantano());
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}

private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion

#region Various Methods
private void ChooseReaders_Load(object sender, EventArgs e)
{
int radioHeight = 20 * Math.Max(_diImportReaders.Count(), _diExportReaders.Count());
gbImport.Height = gbExport.Height = radioHeight + 30;
this.Height = radioHeight + 140;
AddRadioButtons(_diImportReaders, gbImport);
AddRadioButtons(_diExportReaders, gbExport);
}
#endregion
}
}
Loading

0 comments on commit 80c2b76

Please sign in to comment.