Separate concerns.
This commit is contained in:
parent
813d91dfa4
commit
8c620c25ab
@ -156,36 +156,6 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
#region Static library display functions
|
#region Static library display functions
|
||||||
|
|
||||||
public static (string mouseoverText, Bitmap buttonImage) GetLiberateDisplay(LiberatedState liberatedStatus, PdfState pdfStatus)
|
|
||||||
{
|
|
||||||
(string libState, string image_lib) = liberatedStatus switch
|
|
||||||
{
|
|
||||||
LiberatedState.Liberated => ("Liberated", "green"),
|
|
||||||
LiberatedState.PartialDownload => ("File has been at least\r\npartially downloaded", "yellow"),
|
|
||||||
LiberatedState.NotDownloaded => ("Book NOT downloaded", "red"),
|
|
||||||
_ => throw new Exception("Unexpected liberation state")
|
|
||||||
};
|
|
||||||
|
|
||||||
(string pdfState, string image_pdf) = pdfStatus switch
|
|
||||||
{
|
|
||||||
PdfState.Downloaded => ("\r\nPDF downloaded", "_pdf_yes"),
|
|
||||||
PdfState.NotDownloaded => ("\r\nPDF NOT downloaded", "_pdf_no"),
|
|
||||||
PdfState.NoPdf => ("", ""),
|
|
||||||
_ => throw new Exception("Unexpected PDF state")
|
|
||||||
};
|
|
||||||
|
|
||||||
var mouseoverText = libState + pdfState;
|
|
||||||
|
|
||||||
if (liberatedStatus == LiberatedState.NotDownloaded ||
|
|
||||||
liberatedStatus == LiberatedState.PartialDownload ||
|
|
||||||
pdfStatus == PdfState.NotDownloaded)
|
|
||||||
mouseoverText += "\r\nClick to complete";
|
|
||||||
|
|
||||||
var buttonImage = (Bitmap)Properties.Resources.ResourceManager.GetObject($"liberate_{image_lib}{image_pdf}");
|
|
||||||
|
|
||||||
return (mouseoverText, buttonImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This information should not change during <see cref="GridEntry"/> lifetime, so call only once.
|
/// This information should not change during <see cref="GridEntry"/> lifetime, so call only once.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -22,12 +22,42 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
if (value is (LiberatedState liberatedState, PdfState pdfState))
|
if (value is (LiberatedState liberatedState, PdfState pdfState))
|
||||||
{
|
{
|
||||||
(string mouseoverText, Bitmap buttonImage) = GridEntry.GetLiberateDisplay(liberatedState, pdfState);
|
(string mouseoverText, Bitmap buttonImage) = GetLiberateDisplay(liberatedState, pdfState);
|
||||||
|
|
||||||
DrawButtonImage(graphics, buttonImage, cellBounds);
|
DrawButtonImage(graphics, buttonImage, cellBounds);
|
||||||
|
|
||||||
ToolTipText = mouseoverText;
|
ToolTipText = mouseoverText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static (string mouseoverText, Bitmap buttonImage) GetLiberateDisplay(LiberatedState liberatedStatus, PdfState pdfStatus)
|
||||||
|
{
|
||||||
|
(string libState, string image_lib) = liberatedStatus switch
|
||||||
|
{
|
||||||
|
LiberatedState.Liberated => ("Liberated", "green"),
|
||||||
|
LiberatedState.PartialDownload => ("File has been at least\r\npartially downloaded", "yellow"),
|
||||||
|
LiberatedState.NotDownloaded => ("Book NOT downloaded", "red"),
|
||||||
|
_ => throw new Exception("Unexpected liberation state")
|
||||||
|
};
|
||||||
|
|
||||||
|
(string pdfState, string image_pdf) = pdfStatus switch
|
||||||
|
{
|
||||||
|
PdfState.Downloaded => ("\r\nPDF downloaded", "_pdf_yes"),
|
||||||
|
PdfState.NotDownloaded => ("\r\nPDF NOT downloaded", "_pdf_no"),
|
||||||
|
PdfState.NoPdf => ("", ""),
|
||||||
|
_ => throw new Exception("Unexpected PDF state")
|
||||||
|
};
|
||||||
|
|
||||||
|
var mouseoverText = libState + pdfState;
|
||||||
|
|
||||||
|
if (liberatedStatus == LiberatedState.NotDownloaded ||
|
||||||
|
liberatedStatus == LiberatedState.PartialDownload ||
|
||||||
|
pdfStatus == PdfState.NotDownloaded)
|
||||||
|
mouseoverText += "\r\nClick to complete";
|
||||||
|
|
||||||
|
var buttonImage = (Bitmap)Properties.Resources.ResourceManager.GetObject($"liberate_{image_lib}{image_pdf}");
|
||||||
|
|
||||||
|
return (mouseoverText, buttonImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user