Accessing UIFactory.SeparatorTemplate and UIFactory.HeadAddition #181
Replies: 3 comments 13 replies
-
Just spotted the Issues section (new to GitHub) maybe ths belongs there... |
Beta Was this translation helpful? Give feedback.
-
Technically, you can create your own UIFactory class instead, rather than overwriting the built-in one. public class MyUIFactory : NetSparkleUpdater.UI.WinForms.UIFactory
{
public string SeparatorTemplate { get; set; }
public string HeadAddition { get; set; }
// your constructor here if necessary...
public override virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater sparkle, List<AppCastItem> updates, bool isUpdateAlreadyDownloaded = false)
{
var window = new UpdateAvailableWindow(sparkle, updates, _applicationIcon, isUpdateAlreadyDownloaded);
if (HideReleaseNotes)
{
(window as IUpdateAvailable).HideReleaseNotes();
}
if (HideSkipButton)
{
(window as IUpdateAvailable).HideSkipButton();
}
if (HideRemindMeLaterButton)
{
(window as IUpdateAvailable).HideRemindMeLaterButton();
}
return window;
}
} Then just pass in that UIFactory subclass to There's already default parameters for the properties that eventually get sent to the Clearly there needs to be a little API rework here to make the separator template and head addition properties more easily settable/modifiable across all the UI libs, which probably means pulling them into the |
Beta Was this translation helpful? Give feedback.
-
This is now working in |
Beta Was this translation helpful? Give feedback.
-
Hi there.
I see in NetSparkle.UI.Winforms.NetFramework the UpdateAvailableWindow constructor has a "Head Addition" to allow one to splice a piece of HTML into the header of the release notes HTML. But it's never called and there is no way to use it. I'd like to use Markdown for my release notes and I'd like to have the following HTML in the head so that I don't have ye olde Times New Roman font:
"<style> body { font-family: Arial, Helvetica, sans-serif; } </style>".
But, of course you can't include HTML in Markdown (that's the point of Markdown, I guess). So I decided to use the Head Addition to inject this piece of HTML. While I was at it, I added SeparatorTemplate even though I have no need to replace it.
public class UIFactory : IUIFactory
{
...
}
which means I can now do this in my code:
private void NetSparkleCheckForUpdates()
{
_sparkle = new SparkleUpdater("myurl/appcast.xml", new Ed25519Checker(...))
{
UIFactory = new NetSparkleUpdater.UI.WinForms.UIFactory(Icon)
{
HeadAddition = "<style> body { font-family: Arial, Helvetica, sans-serif; } </style>"
},
ShowsUIOnMainThread = true
};
}
Of course, I now have a non-standard NetSparkle. Is this the right way to handle this? Have I missed something? If this is, indeed a good idea, how does one go about getting it added to NetSparkle so I can get back to your wonderful standard? I suppose it should also be added to NetSparkleUpdater.UI.WinForms.NetCore code?
Cheers
Sean
While we're at it, I also did this...
A little bit of constructor chaining to save having to duplicate the initialisation code... (And Occam's razor suggested that I should mark the parameterless constructor private as it's never directly called)
Beta Was this translation helpful? Give feedback.
All reactions