Skip to content

Commit

Permalink
only call and fire page renamed event if label acually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
t0815 committed Aug 21, 2024
1 parent 623a881 commit 4f85592
Showing 1 changed file with 39 additions and 36 deletions.
75 changes: 39 additions & 36 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2476,53 +2476,56 @@ private void PagesList_AfterLabelEdit(object sender, LabelEditEventArgs e)
ListViewItem changedItem = PagesList.Items[e.Item];
if (changedItem != null)
{

try
Page p = changedItem.Tag as Page;
if (p?.Name != e.Label)
{
//Page oldPage = new Page(((Page)changedItem.Tag)); // dont load page here! will cause Access denied
Program.ProjectModel.RenamePage((Page)changedItem.Tag, e.Label, false, true);
try
{
//Page oldPage = new Page(((Page)changedItem.Tag)); // dont load page here! will cause Access denied
Program.ProjectModel.RenamePage((Page)changedItem.Tag, e.Label, false, true);

Program.ProjectModel.MetaData.UpdatePageIndexMetaDataEntry((Page)changedItem.Tag, ((Page)changedItem.Tag).Key);
Program.ProjectModel.MetaData.UpdatePageIndexMetaDataEntry((Page)changedItem.Tag, ((Page)changedItem.Tag).Key);

AppEventHandler.OnPageChanged(sender, new PageChangedEvent(((Page)changedItem.Tag), null, PageChangedEvent.IMAGE_STATUS_RENAMED));
AppEventHandler.OnArchiveStatusChanged(sender, new CBZArchiveStatusEvent(Program.ProjectModel, CBZArchiveStatusEvent.ARCHIVE_FILE_UPDATED));
}
catch (PageDuplicateNameException eduplicate)
{
e.CancelEdit = true;
AppEventHandler.OnPageChanged(sender, new PageChangedEvent(((Page)changedItem.Tag), null, PageChangedEvent.IMAGE_STATUS_RENAMED));
AppEventHandler.OnArchiveStatusChanged(sender, new CBZArchiveStatusEvent(Program.ProjectModel, CBZArchiveStatusEvent.ARCHIVE_FILE_UPDATED));
}
catch (PageDuplicateNameException eduplicate)
{
e.CancelEdit = true;

MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, eduplicate.Message);
if (eduplicate.ShowErrorDialog)
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, eduplicate.Message);
if (eduplicate.ShowErrorDialog)
{
ApplicationMessage.ShowWarning("Error renaming page\r\n" + eduplicate.Message, "Error renaming page", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
}
}
catch (PageException pe)
{
ApplicationMessage.ShowWarning("Error renaming page\r\n" + eduplicate.Message, "Error renaming page", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
e.CancelEdit = true;
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, pe.Message);
if (pe.ShowErrorDialog)
{
ApplicationMessage.ShowException(pe, ApplicationMessage.DialogType.MT_ERROR);
}
}
}
catch (PageException pe)
{
e.CancelEdit = true;
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, pe.Message);
if (pe.ShowErrorDialog)
catch (ApplicationException ae)
{
ApplicationMessage.ShowException(pe, ApplicationMessage.DialogType.MT_ERROR);
e.CancelEdit = true;
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, ae.Message);
if (ae.ShowErrorDialog)
{
ApplicationMessage.ShowWarning("Error renaming page\r\n" + ae.Message, "Error renaming page", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
}
}
}
catch (ApplicationException ae)
{
e.CancelEdit = true;
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_WARNING, ae.Message);
if (ae.ShowErrorDialog)
catch (Exception ex)
{
ApplicationMessage.ShowWarning("Error renaming page\r\n" + ae.Message, "Error renaming page", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_ERROR, ex.Message);
e.CancelEdit = true;
}
}
catch (Exception ex)
{
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_ERROR, ex.Message);
e.CancelEdit = true;
}
finally
{
finally
{

}
}
}
}
Expand Down

0 comments on commit 4f85592

Please sign in to comment.