Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6b52a691e | |||
| d0b5466280 |
@@ -7,7 +7,8 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
ContentRendered="CheckNewUpdates"
|
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>
|
<Window.Resources>
|
||||||
<Style x:Key="Opacity1" TargetType="Image">
|
<Style x:Key="Opacity1" TargetType="Image">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
|
|||||||
@@ -29,18 +29,35 @@ namespace UtilitatPdf
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
ObservableCollection<PdfInfo> list = new ObservableCollection<PdfInfo>();
|
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()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Titol = "UtilitatPdf";
|
||||||
}
|
}
|
||||||
async void CheckNewUpdates(object sender, EventArgs e)
|
async void CheckNewUpdates(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Updater needUpdate = new Updater();
|
Updater needUpdate = new Updater();
|
||||||
|
Titol = "UtilitatPdf " + needUpdate.CurrentVersion;
|
||||||
|
|
||||||
if (needUpdate.IsNewerVersion)
|
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)
|
if (result == MessageBoxResult.Yes)
|
||||||
{
|
{
|
||||||
await needUpdate.DownloadReleaseAsync();
|
await needUpdate.DownloadReleaseAsync();
|
||||||
@@ -136,12 +153,8 @@ namespace UtilitatPdf
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PdfMergeFiles mClas = new PdfMergeFiles(FinalPdfFile);
|
PdfMergeFiles mClas = new PdfMergeFiles(FinalPdfFile);
|
||||||
|
mClas.AddFiles(list);
|
||||||
foreach (PdfInfo fi in list)
|
mClas.Generate();
|
||||||
{
|
|
||||||
mClas.AddFile(fi.FileName);
|
|
||||||
}
|
|
||||||
mClas.Copy();
|
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using iText.Kernel.Pdf;
|
using iText.Kernel.Pdf;
|
||||||
using iText.Kernel.Utils;
|
using iText.Kernel.Utils;
|
||||||
@@ -31,9 +32,19 @@ namespace UtilitatPdf
|
|||||||
{
|
{
|
||||||
if (new FileInfo(_FinalPdfFile).Exists) File.Delete(_FinalPdfFile);
|
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)
|
public bool AddFile(string PdfFilename)
|
||||||
{
|
{
|
||||||
checkVars(PdfFilename);
|
checkVars(PdfFilename);
|
||||||
@@ -52,7 +63,7 @@ namespace UtilitatPdf
|
|||||||
_pdfMerger = new PdfMerger(_pdfDocument);
|
_pdfMerger = new PdfMerger(_pdfDocument);
|
||||||
_pdfMerger.Merge(_pdfDocument2, 1, _pdfDocument2.GetNumberOfPages());
|
_pdfMerger.Merge(_pdfDocument2, 1, _pdfDocument2.GetNumberOfPages());
|
||||||
|
|
||||||
this.Close();
|
this.ClosePdfDocs();
|
||||||
}
|
}
|
||||||
catch (IOException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
@@ -72,11 +83,11 @@ namespace UtilitatPdf
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void Copy()
|
public void Generate()
|
||||||
{
|
{
|
||||||
File.Copy(_tmpFile, _FinalPdfFile);
|
File.Copy(_tmpFile, _FinalPdfFile);
|
||||||
}
|
}
|
||||||
private void Close()
|
private void ClosePdfDocs()
|
||||||
{
|
{
|
||||||
_pdfDocument?.Close();
|
_pdfDocument?.Close();
|
||||||
_pdfDocument2?.Close();
|
_pdfDocument2?.Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user