Skip to content

Commit

Permalink
fix updating original files with processed ones [#54], fix task not g…
Browse files Browse the repository at this point in the history
…etting updated [#49]
  • Loading branch information
t0815 committed Oct 6, 2024
1 parent a64607c commit e9e8d45
Show file tree
Hide file tree
Showing 5 changed files with 438 additions and 325 deletions.
186 changes: 114 additions & 72 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,6 @@ private void PageChanged(object sender, PageChangedEvent e)
{
if (!e.Page.Closed && !e.Page.Deleted)
{
if (!WindowClosed)
{
Task.Factory.StartNew(() =>
{
PageThumbsListBox.Invoke(new Action(() =>
Expand All @@ -824,7 +822,6 @@ private void PageChanged(object sender, PageChangedEvent e)
}));

});
}
}
}
}
Expand Down Expand Up @@ -1184,6 +1181,8 @@ private void HandleRedrawThumbnail(object sender, RedrawThumbEvent e)
PageImages.Images.RemoveByKey(e.Page.Id);
}
PageThumbsListBox.Items[pageIndex] = e.Page;


}
PageThumbsListBox.Invalidate();
PageThumbsListBox.Refresh();
Expand Down Expand Up @@ -1817,6 +1816,7 @@ private void ApplicationStateChanged(object sender, ApplicationStatusEvent e)
break;

case ApplicationStatusEvent.STATE_READY:
ResetUpdateTags();
info = "Ready.";
break;

Expand Down Expand Up @@ -6097,6 +6097,40 @@ private void RadioApplyAdjustments_CheckedChanged(object sender, EventArgs e)
}
}

private void ResetUpdateTags()
{

RadioButtonResizeNever.Tag = false;
RadioButtonResizeIfLarger.Tag = false;
RadioButtonResizeTo.Tag = false;
RadioButtonResizePercent.Tag = false;

RadioButtonRotateNone.Tag = false;
RadioButtonRotate90.Tag = false;
RadioButtonRotate180.Tag = false;
RadioButtonRotate270.Tag = false;


ComboBoxTaskOrderConversion.Tag = false;
ComboBoxTaskOrderResize.Tag = false;
ComboBoxTaskOrderRotation.Tag = false;
ComboBoxTaskOrderSplit.Tag = false;

CheckBoxSplitDoublePages.Tag = false;
TextBoxSplitPageAt.Tag = false;
ComboBoxSplitAtType.Tag = false;
TextBoxResizePageIndexReference.Tag = false;
TextBoxResizeW.Tag = false;
TextBoxResizeH.Tag = false;
ComboBoxConvertPages.Tag = false;
CheckBoxDontStretch.Tag = false;
TextboxResizePercentage.Tag = false;
CheckboxKeepAspectratio.Tag = false;
PictureBoxColorSelect.Tag = false;
CheckBoxSplitOnlyIfDoubleSize.Tag = false;
CheckBoxSplitDoublepagesFirst.Tag = false;
}

private void UpdateImageAdjustments(object sender, string selected, bool dontUpdate = false)
{
ImageTask selectedTask = null;
Expand Down Expand Up @@ -6425,6 +6459,11 @@ private void ComboBoxTaskOrder_SelectedIndexChanged(object sender, EventArgs e)
selectedImageTasks.TaskOrder.Split = (ImageTaskOrderValue)cb.SelectedIndex;
break;
}

if (selectedImageTasks.PageId == "" && !dontUpdate)
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
}

private void PictureBoxColorSelect_Click(object sender, EventArgs e)
Expand All @@ -6450,13 +6489,13 @@ private void PictureBoxColorSelect_Click(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.DetectSplitAtColor)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "")
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));

}
Expand Down Expand Up @@ -6494,13 +6533,13 @@ private void CheckboxIgnoreDoublePages_CheckedChanged(object sender, EventArgs e

if (oldValue != selectedImageTasks.ImageAdjustments.IgnoreDoublePagesResizingToPage)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6542,12 +6581,13 @@ private void CheckBoxSplitDoublepagesFirst_CheckedChanged(object sender, EventAr

if (oldValue != selectedImageTasks.ImageAdjustments.SplitOnlyDoublePages)
{
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (!dontUpdate)
{
Expand Down Expand Up @@ -6583,13 +6623,14 @@ private void CheckBoxSplitOnlyIfDoubleSize_CheckedChanged(object sender, EventAr

if (oldValue != selectedImageTasks.ImageAdjustments.SplitOnlyDoublePages)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{

if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6625,13 +6666,13 @@ private void ComboBoxConvertPages_SelectedIndexChanged(object sender, EventArgs

if (oldValue.Value != selectedImageTasks.ImageAdjustments.ConvertType)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6685,13 +6726,13 @@ private void TextBoxResizePageIndexReference_TextChanged(object sender, EventArg

if (oldValue != selectedImageTasks.ImageAdjustments.ResizeToPageNumber)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6727,13 +6768,13 @@ private void CheckboxKeepAspectratio_CheckedChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.KeepAspectRatio)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6801,13 +6842,14 @@ private void TextBoxResizeW_TextChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.ResizeTo.X)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{

if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6869,13 +6911,13 @@ private void TextBoxResizeH_TextChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.ResizeTo.Y)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6930,13 +6972,13 @@ private void TextboxResizePercentage_TextChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.ResizeToPercentage)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -6971,13 +7013,13 @@ private void CheckBoxDontStretch_CheckedChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.DontStretch)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -7022,13 +7064,13 @@ private void TextBoxSplitPageAt_TextChanged(object sender, EventArgs e)

if (oldValue != selectedImageTasks.ImageAdjustments.SplitPageAt)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -7063,13 +7105,13 @@ private void ComboBoxSplitAtType_SelectedIndexChanged(object sender, EventArgs e

if (oldValue.Value != selectedImageTasks?.ImageAdjustments.SplitType)
{
if (page != null && selectedImageTasks.PageId == page.Id)
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down Expand Up @@ -7104,13 +7146,13 @@ private void CheckBoxSplitDoublePages_CheckedChanged(object sender, EventArgs e)

if (oldValue.Value != selectedImageTasks.ImageAdjustments.SplitPage)
{
if (selectedImageTasks.PageId == "" && !dontUpdate)
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (page != null && selectedImageTasks.PageId == page.Id)
{
if (selectedImageTasks.PageId == "")
{
Program.ProjectModel.GlobalImageTask = selectedImageTasks;
}

if (!dontUpdate)
{
AppEventHandler.OnPageChanged(this, new PageChangedEvent(page, null, PageChangedEvent.IMAGE_STATUS_CHANGED, true));
Expand Down
Loading

0 comments on commit e9e8d45

Please sign in to comment.