Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6b52a691e | |||
| d0b5466280 |
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
@@ -136,12 +153,8 @@ namespace UtilitatPdf
|
||||
try
|
||||
{
|
||||
PdfMergeFiles mClas = new PdfMergeFiles(FinalPdfFile);
|
||||
|
||||
foreach (PdfInfo fi in list)
|
||||
{
|
||||
mClas.AddFile(fi.FileName);
|
||||
}
|
||||
mClas.Copy();
|
||||
mClas.AddFiles(list);
|
||||
mClas.Generate();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Kernel.Utils;
|
||||
@@ -31,9 +32,19 @@ namespace UtilitatPdf
|
||||
{
|
||||
if (new FileInfo(_FinalPdfFile).Exists) File.Delete(_FinalPdfFile);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public bool AddFiles(ObservableCollection<PdfInfo> sourceFiles)
|
||||
{
|
||||
foreach (PdfInfo fitxer in sourceFiles)
|
||||
{
|
||||
if (!this.AddFile(fitxer.FileName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool AddFile(string PdfFilename)
|
||||
{
|
||||
checkVars(PdfFilename);
|
||||
@@ -52,7 +63,7 @@ namespace UtilitatPdf
|
||||
_pdfMerger = new PdfMerger(_pdfDocument);
|
||||
_pdfMerger.Merge(_pdfDocument2, 1, _pdfDocument2.GetNumberOfPages());
|
||||
|
||||
this.Close();
|
||||
this.ClosePdfDocs();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
@@ -72,11 +83,11 @@ namespace UtilitatPdf
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Copy()
|
||||
public void Generate()
|
||||
{
|
||||
File.Copy(_tmpFile, _FinalPdfFile);
|
||||
}
|
||||
private void Close()
|
||||
private void ClosePdfDocs()
|
||||
{
|
||||
_pdfDocument?.Close();
|
||||
_pdfDocument2?.Close();
|
||||
|
||||
Reference in New Issue
Block a user