Barra de titol amb la versió actual

This commit is contained in:
2021-01-07 13:06:51 +01:00
parent 031da4cea9
commit d0b5466280
2 changed files with 20 additions and 2 deletions

View File

@@ -7,7 +7,8 @@
mc:Ignorable="d"
Loaded="Window_Loaded"
ContentRendered="CheckNewUpdates"
Title="UtilitatPdf 1.3" Height="450" Width="550" Icon="pdf.ico" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
Title="{Binding Titol, RelativeSource={RelativeSource Mode=Self}}"
Height="450" Width="550" Icon="pdf.ico" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Window.Resources>
<Style x:Key="Opacity1" TargetType="Image">
<Style.Triggers>

View File

@@ -29,18 +29,35 @@ namespace UtilitatPdf
public partial class MainWindow : Window
{
ObservableCollection<PdfInfo> list = new ObservableCollection<PdfInfo>();
public string Titol
{
get { return (string)GetValue(PropietatsTitol); }
set { SetValue(PropietatsTitol, value); }
}
public static readonly DependencyProperty PropietatsTitol =
DependencyProperty.Register("Titol", typeof(string), typeof(MainWindow), new UIPropertyMetadata(null));
public MainWindow()
{
InitializeComponent();
Titol = "UtilitatPdf";
}
async void CheckNewUpdates(object sender, EventArgs e)
{
Updater needUpdate = new Updater();
Titol = "UtilitatPdf " + needUpdate.CurrentVersion;
if (needUpdate.IsNewerVersion)
{
MessageBoxResult result = MessageBox.Show("Hi Ha disponible una nova versió de l'aplicació.\n Actual: "+ needUpdate.CurrentVersion +" Nova Versió: " + needUpdate.NewReleaseVersion + "\n\nVols Actualizarla ara?", "Actualització", MessageBoxButton.YesNo, MessageBoxImage.Question);
MessageBoxResult result = MessageBox.Show("Hi Ha disponible una nova versió de l'aplicació.\n Actual: " +
needUpdate.CurrentVersion +
" Nova Versió: " +
needUpdate.NewReleaseVersion +
"\n\nVols Actualizarla ara?",
"Actualització",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
await needUpdate.DownloadReleaseAsync();