Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcapp committed Jan 10, 2025
1 parent c6de55b commit 2bf4531
Show file tree
Hide file tree
Showing 13 changed files with 527 additions and 83 deletions.
4 changes: 2 additions & 2 deletions KindleMate2/AutoUpdater_x64.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2025.01.09</version>
<url>https://github.com/lzcapp/KindleMate2/releases/download/2025.01.09/KindleMate2_x64.zip</url>
<version>2025.01.10</version>
<url>https://github.com/lzcapp/KindleMate2/releases/download/2025.01.10/KindleMate2_x64.zip</url>
<changelog>https://github.com/lzcapp/KindleMate2/releases/latest/</changelog>
<mandatory>false</mandatory>
</item>
4 changes: 2 additions & 2 deletions KindleMate2/AutoUpdater_x86.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>2025.01.09</version>
<url>https://github.com/lzcapp/KindleMate2/releases/download/2025.01.09/KindleMate2_x86.zip</url>
<version>2025.01.10</version>
<url>https://github.com/lzcapp/KindleMate2/releases/download/2025.01.10/KindleMate2_x86.zip</url>
<changelog>https://github.com/lzcapp/KindleMate2/releases/latest/</changelog>
<mandatory>false</mandatory>
</item>
10 changes: 1 addition & 9 deletions KindleMate2/FrmAboutBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,7 @@ private void FrmAboutBox_Load(object sender, EventArgs e) {
}

private void pictureBox1_Click(object sender, EventArgs e) {
const string repoUrl = "https://github.com/lzcapp/KindleMate2/releases/latest";
try {
Process.Start(new ProcessStartInfo {
FileName = repoUrl,
UseShellExecute = true
});
} catch (Exception) {
// ignored
}
StaticData.CheckUpdate();
}
}
}
35 changes: 18 additions & 17 deletions KindleMate2/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public FrmMain() {
_staticData.DisposeConnection();
};

AutoUpdater.Start(Environment.Is64BitProcess ? "https://github.lzc.app/KindleMate2/KindleMate2/AutoUpdater_x64.xml" : "https://github.lzc.app/KindleMate2/KindleMate2/AutoUpdater_x86.xml");

_programsDirectory = Environment.CurrentDirectory;
_filePath = Path.Combine(_programsDirectory, "KM2.dat");
_kindleClippingsPath = Path.Combine("documents", "My Clippings.txt");
Expand Down Expand Up @@ -220,6 +218,8 @@ private void FrmMain_Load(object? sender, EventArgs e) {
treeViewBooks.Focus();

CmbSearch_SelectedIndexChanged(this, e);

StaticData.CheckUpdate();
}

private DialogResult MessageBox(string message, string title, MessageBoxButtons buttons, MessageBoxIcon icon) {
Expand Down Expand Up @@ -858,7 +858,7 @@ .. File.ReadAllLines(clippingsPath)
return Strings.Parsed_X + Strings.Space + delimiterIndex.Count + Strings.Space + Strings.X_Clippings + Strings.Symbol_Comma + Strings.Imported_X + Strings.Space + insertedCount + Strings.Space + Strings.X_Clippings;
}

private bool HandleClipplings(string line1, string line2, string line3, string line4, string line5) {
private bool HandleClipplings(string line1, string line2, string line3, string line4, string line5, bool isRebuild = false) {
var entityClipping = new Clipping();

var content = line4;
Expand Down Expand Up @@ -936,12 +936,14 @@ private bool HandleClipplings(string line1, string line2, string line3, string l
entityClipping.clippingdate = clippingdate;

var key = clippingdate + "|" + clippingtypelocation;
if (_staticData.IsExistOriginalClippings(key)) {
return false;
}
var isOriginClippingsInserted = _staticData.InsertOriginClippings(key, line1, line2, line3, line4, line5);
if (!isOriginClippingsInserted) {
return false;
if (!isRebuild) {
if (_staticData.IsExistOriginalClippings(key)) {
return false;
}
var isOriginClippingsInserted = _staticData.InsertOriginClippings(key, line1, line2, line3, line4, line5);
if (!isOriginClippingsInserted) {
return false;
}
}

entityClipping.key = key;
Expand Down Expand Up @@ -1856,19 +1858,18 @@ private void BackupDatabase() {
return;
}

var filePath = Path.Combine(_programsDirectory, "Backups", "KM2.dat");

if (!Directory.Exists(Path.Combine(_programsDirectory, "Backups"))) {
Directory.CreateDirectory(Path.Combine(_programsDirectory, "Backups"));
}
var filePath = Path.Combine(Environment.CurrentDirectory, "Backups", "KM2.dat");

if (File.Exists(filePath)) {
File.Delete(filePath);
}

File.Copy(_filePath, filePath);
}
if (!Directory.Exists(Path.Combine(Environment.CurrentDirectory, "Backups"))) {
Directory.CreateDirectory(Path.Combine(Environment.CurrentDirectory, "Backups"));
}

File.Copy(Path.Combine(Environment.CurrentDirectory, "KM2.dat"), filePath);
}

private void MenuRefresh_Click(object sender, EventArgs e) {
RefreshData();
Expand Down Expand Up @@ -2080,7 +2081,7 @@ private string RebuildDatabase() {
return Strings.No_Data_To_Clear;
}
_ = _staticData.EmptyTable("clippings");
var insertedCount = (from DataRow row in origin.Rows let entityClipping = new Clipping() let line1 = row["line1"].ToString() ?? string.Empty let line2 = row["line2"].ToString() ?? string.Empty let line3 = row["line3"].ToString() ?? string.Empty let line4 = row["line4"].ToString() ?? string.Empty let line5 = row["line5"].ToString() ?? string.Empty select HandleClipplings(line1, line2, line3, line4, line5)).Count(result => result);
var insertedCount = (from DataRow row in origin.Rows let entityClipping = new Clipping() let line1 = row["line1"].ToString() ?? string.Empty let line2 = row["line2"].ToString() ?? string.Empty let line3 = row["line3"].ToString() ?? string.Empty let line4 = row["line4"].ToString() ?? string.Empty let line5 = row["line5"].ToString() ?? string.Empty select HandleClipplings(line1, line2, line3, line4, line5, true)).Count(result => result);
_staticData.CommitTransaction();
var clipping = Strings.Parsed_X + Strings.Space + origin.Rows.Count + Strings.Space + Strings.X_Clippings + Strings.Symbol_Comma + Strings.Imported_X + Strings.Space + insertedCount + Strings.Space + Strings.X_Clippings;
return clipping;
Expand Down
3 changes: 2 additions & 1 deletion KindleMate2/KindleMate2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LangVersion>latest</LangVersion>
<PackageLicenseUrl>https://github.com/lzcapp/KindleMate2/blob/main/LICENSE</PackageLicenseUrl>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<Version>2025.01.09</Version>
<Version>2025.01.10</Version>
<Deterministic>false</Deterministic>
<AssemblyVersion></AssemblyVersion>
<FileVersion></FileVersion>
Expand Down Expand Up @@ -98,6 +98,7 @@

<ItemGroup>
<Content Include="bookmark.ico" />
<Content Include="Resources\bookmark.ico" />
<None Include="Resources\wastebasket.png" />
<None Include="Resources\star.png" />
<None Include="Resources\plus.png" />
Expand Down
10 changes: 10 additions & 0 deletions KindleMate2/Properties/Resources.Designer.cs

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

132 changes: 119 additions & 13 deletions KindleMate2/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
@@ -1,14 +1,120 @@
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
3 changes: 3 additions & 0 deletions KindleMate2/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,7 @@
<data name="cross-mark-button" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cross-mark-button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bookmark.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading

0 comments on commit 2bf4531

Please sign in to comment.