re-add missing files again
This commit is contained in:
115
Pilz.Updating.Client.Gui/UpdatesAvailableDialog.cs
Normal file
115
Pilz.Updating.Client.Gui/UpdatesAvailableDialog.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using Pilz.UI.Telerik;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.Updating.Client.Gui.LangRes;
|
||||
using Telerik.WinControls.UI;
|
||||
|
||||
namespace Pilz.Updating.Client.Gui;
|
||||
|
||||
internal partial class UpdatesAvailableDialog : RadFlyoutBase
|
||||
{
|
||||
public UpdatesAvailableDialog(Image appIcon, string curVersion, string curChannel, string curBuild, string newVersion, string newChannel, string newBuild, UpdateNotes updateNotes, bool installAsAdmin)
|
||||
{
|
||||
InitializeComponent();
|
||||
ActionPanelVisible = false;
|
||||
|
||||
radButton_Cancel.SvgImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.software_installer, SvgImageSize.Small);
|
||||
|
||||
if (installAsAdmin)
|
||||
radButton_Install.Image = BaseFeatures.GetUacShieldImage();
|
||||
else
|
||||
radButton_Install.SvgImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.software_installer, SvgImageSize.Small);
|
||||
|
||||
if (appIcon == null)
|
||||
radPictureBox1.SvgImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.software_installer, SvgImageSize.Large);
|
||||
else
|
||||
radPictureBox1.Image = appIcon;
|
||||
|
||||
radLabel_CurrentVersion.Text = curVersion;
|
||||
radLabel_CurrentVersionChannel.Text = curChannel;
|
||||
radLabel_CurrentVersionBuild.Text = curBuild;
|
||||
radLabel_AvailableVersion.Text = newVersion;
|
||||
radLabel_AvailableVersionChannel.Text = newChannel;
|
||||
radLabel_AvailableVersionBuild.Text = newBuild;
|
||||
|
||||
SetNotes(updateNotes);
|
||||
}
|
||||
|
||||
private void SetNotes(UpdateNotes updateNotes)
|
||||
{
|
||||
// Internal
|
||||
if (updateNotes.Mode == UpdateNotesMode.Internal && !string.IsNullOrWhiteSpace(updateNotes.ContentUrl) && TryDownloadContent(updateNotes.ContentUrl) is string content)
|
||||
{
|
||||
switch (updateNotes.ContentType)
|
||||
{
|
||||
case UpdateNotesContentType.PlainText:
|
||||
SetNotesControls(new RadRichTextEditor
|
||||
{
|
||||
Text = content
|
||||
});
|
||||
return;
|
||||
case UpdateNotesContentType.Markdown:
|
||||
SetNotesControls(new Westermo.HtmlRenderer.WinForms.HtmlPanel
|
||||
{
|
||||
Text = Markdig.Markdown.ToHtml(content)
|
||||
});
|
||||
return;
|
||||
case UpdateNotesContentType.HTML:
|
||||
SetNotesControls(new Westermo.HtmlRenderer.WinForms.HtmlPanel
|
||||
{
|
||||
Text = content
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// External
|
||||
if (updateNotes.Mode == UpdateNotesMode.External && !string.IsNullOrWhiteSpace(updateNotes.ExternalUrl))
|
||||
{
|
||||
var label = new RadLabel
|
||||
{
|
||||
AutoSize = false,
|
||||
Text = string.Format(GeneralLangRes.NotesLinkToExternal, updateNotes.ExternalUrl),
|
||||
TextAlignment = ContentAlignment.MiddleCenter,
|
||||
};
|
||||
SetNotesControls(label);
|
||||
return;
|
||||
}
|
||||
|
||||
// None or not supported or fallback
|
||||
SetNotesControls(new RadLabel
|
||||
{
|
||||
AutoSize = false,
|
||||
Text = GeneralLangRes.NotesNotAvailable,
|
||||
TextAlignment = ContentAlignment.MiddleCenter,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
private void SetNotesControls(Control updateNotesControl)
|
||||
{
|
||||
updateNotesControl.Dock = DockStyle.Fill;
|
||||
panel_ChangelogPanel.Controls.Add(updateNotesControl);
|
||||
}
|
||||
|
||||
private static string TryDownloadContent(string contentUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new HttpClient().GetStringAsync(contentUrl).Result;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void RadButton_Install_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close(DialogResult.OK);
|
||||
}
|
||||
|
||||
private void RadButton_Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close(DialogResult.Cancel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user