Skip to content

Commit

Permalink
Fix bug in page deletion
Browse files Browse the repository at this point in the history
Bump Version
  • Loading branch information
t0815 committed Oct 15, 2023
1 parent 0361948 commit bc08806
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion MyCBZ/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<applicationSettings>
<Win_CBZ.Win_CBZSettings>
<setting name="Version" serializeAs="String">
<value>0.11.48b</value>
<value>0.11.49b</value>
</setting>
<setting name="RenamerPlaceholders" serializeAs="Xml">
<value>
Expand Down
6 changes: 6 additions & 0 deletions MyCBZ/Events/PageChangedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ internal class PageChangedEvent
{

public const int IMAGE_STATUS_NEW = 0;

public const int IMAGE_STATUS_COMPRESSED = 1;

public const int IMAGE_STATUS_DELETED = 2;

public const int IMAGE_STATUS_CHANGED = 3;

public const int IMAGE_STATUS_RENAMED = 4;

public const int IMAGE_STATUS_CLOSED = 5;

public const int IMAGE_STATUS_ERROR = 6;

public int State { get; set; }
Expand Down
23 changes: 9 additions & 14 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,6 @@ private void PageChanged(object sender, PageChangedEvent e)
break;
case PageChangedEvent.IMAGE_STATUS_DELETED:
e.Image.Deleted = true;
existingItem = FindListViewItemForPage(PagesList, e.Image);

if (existingItem == null)
{
PagesList.Items.Remove(existingItem);
}

existingItem = FindListViewItemForPage(PageView, e.Image);

if (existingItem == null)
{
PageView.Items.Remove(existingItem);
}

break;
case PageChangedEvent.IMAGE_STATUS_COMPRESSED:
e.Image.Compressed = true;
Expand Down Expand Up @@ -307,10 +293,18 @@ private void PageChanged(object sender, PageChangedEvent e)
if (e.State == PageChangedEvent.IMAGE_STATUS_CLOSED)
{
ListViewItem existingItem = FindListViewItemForPage(PagesList, e.Image);

if (existingItem != null)
{
PagesList.Items.Remove(existingItem);
}

existingItem = FindListViewItemForPage(PageView, e.Image);

if (existingItem != null)
{
PageView.Items.Remove(existingItem);
}
}
}
}));
Expand Down Expand Up @@ -2111,6 +2105,7 @@ private void ToolButtonRemoveFiles_Click(object sender, EventArgs e)
img.BackColor = Color.Transparent;

PageChanged(null, new PageChangedEvent((Page)img.Tag, PageChangedEvent.IMAGE_STATUS_DELETED));
ArchiveStateChanged(this, new CBZArchiveStatusEvent(Program.ProjectModel, CBZArchiveStatusEvent.ARCHIVE_FILE_DELETED));
}

HandleGlobalActionRequired(null, new GlobalActionRequiredEvent(Program.ProjectModel, 0, "Page order changed. Rebuild pageindex now?", "Rebuild", RebuildPageIndexMetaDataTask.UpdatePageIndexMetadata(Program.ProjectModel.Pages, Program.ProjectModel.MetaData, HandleGlobalTaskProgress, PageChanged)));
Expand Down
23 changes: 13 additions & 10 deletions MyCBZ/Models/MetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,21 @@ public void RebuildPageMetaData(List<Page> pages)
{
try
{
newPageEntry = new MetaDataEntryPage();
newPageEntry.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE, page.Name)
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_TYPE, page.ImageType)
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_SIZE, page.Size.ToString());

if (page.W > 0 && page.H > 0)
if (!page.Deleted)
{
newPageEntry.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_WIDTH, page.W.ToString())
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_HEIGHT, page.H.ToString());
}
newPageEntry = new MetaDataEntryPage();
newPageEntry.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE, page.Name)
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_TYPE, page.ImageType)
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_SIZE, page.Size.ToString());

PageIndex.Add(newPageEntry);
if (page.W > 0 && page.H > 0)
{
newPageEntry.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_WIDTH, page.W.ToString())
.SetAttribute(MetaDataEntryPage.COMIC_PAGE_ATTRIBUTE_IMAGE_HEIGHT, page.H.ToString());
}

PageIndex.Add(newPageEntry);
}
}
catch (Exception ex)
{
Expand Down
18 changes: 9 additions & 9 deletions MyCBZ/Models/ProjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,18 +1435,18 @@ protected void SaveArchiveProc()
{
try
{
if (page.Compressed)
if (!page.Deleted)
{
FileInfo NewTemporaryFileName = MakeNewTempFileName(page.Name);
page.CreateLocalWorkingCopy(NewTemporaryFileName.FullName);
if (page.TempPath == null)
if (page.Compressed)
{
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, "Failed to extract to or create temporary file for entry [" + page.Name + "]");
FileInfo NewTemporaryFileName = MakeNewTempFileName(page.Name);
page.CreateLocalWorkingCopy(NewTemporaryFileName.FullName);
if (page.TempPath == null)
{
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, "Failed to extract to or create temporary file for entry [" + page.Name + "]");
}
}
}

if (!page.Deleted)
{
page.FreeImage();

updatedEntry = BuildingArchive.CreateEntryFromFile(page.TempPath, page.Name);
Expand Down Expand Up @@ -1511,7 +1511,7 @@ protected void SaveArchiveProc()
{
Pages.Remove(deletedPage);

OnPageChanged(new PageChangedEvent(deletedPage, PageChangedEvent.IMAGE_STATUS_DELETED));
OnPageChanged(new PageChangedEvent(deletedPage, PageChangedEvent.IMAGE_STATUS_CLOSED));
OnTaskProgress(new TaskProgressEvent(deletedPage, deletedIndex, deletedPages.Count));
deletedIndex++;
}
Expand Down
2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.Designer.cs

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

2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">%APPDATA%\CBZMage\Temp\</Value>
</Setting>
<Setting Name="Version" Type="System.String" Scope="Application">
<Value Profile="(Default)">0.11.48b</Value>
<Value Profile="(Default)">0.11.49b</Value>
</Setting>
<Setting Name="RenamerPlaceholders" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Microsoft Visual Studio [Community] 2022 (64-Bit)

## Latest Release

v0.11.48b released!
v0.11.49b released!

## Third party components

Expand Down
6 changes: 3 additions & 3 deletions Win_CBZ-Setup/Win_CBZ-Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Win_CBZ"
"ProductCode" = "8:{7EBB133B-5831-4FFA-8224-672FB7CBEDFA}"
"PackageCode" = "8:{4B830FE0-0064-479B-A043-8DA4567FE9AD}"
"ProductCode" = "8:{E3C2F8CB-255B-4809-B865-1DBCA429122F}"
"PackageCode" = "8:{851E7EFF-BB5C-4341-A745-664EF40C930C}"
"UpgradeCode" = "8:{66FAEF81-1CAE-4971-9E0F-796310EFEA5E}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.11.48"
"ProductVersion" = "8:0.11.49"
"Manufacturer" = "8:Trash_s0Ft"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down

0 comments on commit bc08806

Please sign in to comment.