Commit 9b4210c1 authored by tsuji's avatar tsuji

比較ボタンをクリックしたときにTIFF出力を行うように修正

parent 24fda800
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="CompareButtonSetting.cs" /> <Compile Include="CompareTIFF.cs" />
<Compile Include="CustomMsgBox.cs" /> <Compile Include="CustomMsgBox.cs" />
<Compile Include="TIFFButtonsSetting.cs" /> <Compile Include="OurputTIFF.cs" />
<Compile Include="ComboBox.cs" /> <Compile Include="ComboBox.cs" />
<Compile Include="FilePathSelect.cs" /> <Compile Include="FilePathSelect.cs" />
<Compile Include="MainWindow.xaml.cs"> <Compile Include="MainWindow.xaml.cs">
......
...@@ -19,10 +19,11 @@ using System.IO; ...@@ -19,10 +19,11 @@ using System.IO;
namespace CSRender namespace CSRender
{ {
public partial class MainWindow : Window class CompareTIFF
{ {
private void CompareButtonClick(object sender, RoutedEventArgs e) public static string runPureVerify(string targetDir, string referenceDir, string workPath)
{ {
//実行用コンソールの呼び出し
ProcessStartInfo processStartInfo = new ProcessStartInfo(); ProcessStartInfo processStartInfo = new ProcessStartInfo();
string stCurrentDir = System.IO.Directory.GetCurrentDirectory(); string stCurrentDir = System.IO.Directory.GetCurrentDirectory();
string exePath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "bin", "x64"); string exePath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "bin", "x64");
...@@ -34,23 +35,11 @@ namespace CSRender ...@@ -34,23 +35,11 @@ namespace CSRender
//引数設定 //引数設定
//指定ファイル //指定ファイル
processStartInfo.Arguments = "/tar "; processStartInfo.Arguments = "/tar ";
if (!Directory.Exists(targetBox.Text) && !File.Exists(targetBox.Text))//pathのチェック processStartInfo.Arguments += targetDir;
{
CustomMsgBox.Show(mainWindow, "指定されたファイルあるいはフォルダが存在しません。" +
"\nもう一度設定してください。", "The specified file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
processStartInfo.Arguments += targetBox.Text;
//リファレンスファイル //リファレンスファイル
if (!Directory.Exists(referenceBox.Text) && !File.Exists(referenceBox.Text))//pathのチェック
{
CustomMsgBox.Show(mainWindow, "指定されたリファレンスファイルあるいはフォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
processStartInfo.Arguments += " /ref "; processStartInfo.Arguments += " /ref ";
processStartInfo.Arguments += referenceBox.Text; processStartInfo.Arguments += referenceDir;
//EquiosCenterの場所 //EquiosCenterの場所
string EquiosCenter = System.IO.Path.Combine(stCurrentDir, "PureVerify.Data", "EquiosCenter_small"); string EquiosCenter = System.IO.Path.Combine(stCurrentDir, "PureVerify.Data", "EquiosCenter_small");
...@@ -59,17 +48,10 @@ namespace CSRender ...@@ -59,17 +48,10 @@ namespace CSRender
//出力ファイル形式の引数 //出力ファイル形式の引数
processStartInfo.Arguments += " /work "; processStartInfo.Arguments += " /work ";
if (!Directory.Exists(workBox.Text) && !File.Exists(workBox.Text))//pathのチェック
{
CustomMsgBox.Show(mainWindow, "指定された作業フォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//processStartInfo.Arguments += workBox.Text;
string workDir = System.IO.Path.Combine(stCurrentDir, "PureVerify.Data", "RipVerify");
processStartInfo.Arguments += workDir;
//processStartInfo.Arguments += workPath;
string workDir = System.IO.Path.Combine(stCurrentDir, "PureVerify.Data", "RipVerify");
processStartInfo.Arguments += workDir;
//検版の指定(2だとNGログ検版(LOG-Diff)になる) //検版の指定(2だとNGログ検版(LOG-Diff)になる)
processStartInfo.Arguments += " /operation \"1\""; processStartInfo.Arguments += " /operation \"1\"";
...@@ -85,19 +67,24 @@ namespace CSRender ...@@ -85,19 +67,24 @@ namespace CSRender
//CSRender.exeを実行 //CSRender.exeを実行
Process process = Process.Start(processStartInfo); Process process = Process.Start(processStartInfo);
//ResultConsole.Text = process.StandardOutput.ReadToEnd(); //ResultConsole.Text = process.StandardOutput.ReadToEnd();
process.OutputDataReceived += process_DataReceived; //process.OutputDataReceived += process_DataReceived;
process.BeginOutputReadLine(); process.BeginOutputReadLine();
//ResultConsole.ScrollToEnd(); //ResultConsole.ScrollToEnd();
process.WaitForExit(); process.WaitForExit();
process.Close(); process.Close();
//指定先にレポートを移動 return workDir;
string reportPath = System.IO.Path.Combine(workBox.Text, "report"); }
//指定先にレポートを移動
public static void moveReport(string resultPath, string workPath)
{
string reportPath = System.IO.Path.Combine(resultPath, "report");
if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか
{ {
Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成 Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成
} }
var allReport = Directory.EnumerateFiles(System.IO.Path.Combine(workDir, "report") var allReport = Directory.EnumerateFiles(System.IO.Path.Combine(workPath, "report")
, "*", SearchOption.TopDirectoryOnly);//reportフォルダ内の全てのファイルを取得 , "*", SearchOption.TopDirectoryOnly);//reportフォルダ内の全てのファイルを取得
foreach (string file in allReport) foreach (string file in allReport)
{ {
...@@ -105,31 +92,5 @@ namespace CSRender ...@@ -105,31 +92,5 @@ namespace CSRender
File.Move(file, System.IO.Path.Combine(reportPath, fileTarget));//指定先に移動 File.Move(file, System.IO.Path.Combine(reportPath, fileTarget));//指定先に移動
} }
} }
//コンソール出力を読み取りする関数
public void process_DataReceived(object sender, DataReceivedEventArgs e)
{
string VerifyResult = e.Data;
Dispatcher.BeginInvoke(new Action(() =>
{
ResultConsole.Text = VerifyResult;
ResultConsole.ScrollToEnd();
}));
}
private string outputLog(string workDir)
{
StreamReader logString = new StreamReader(System.IO.Path.Combine(workDir, "report" + "hironimo.txt"));
string toString = "";
string tranceString = logString + toString;
string cutString = "*****************************************************" + "\r\n"
+ "Number of Processors = 8" + "\r\n"
+ "HostName = I-N-21-00008" + "\r\n"
+ "PlatformId = 0" + "\r\n" + "PureVerifyMainSetUp.txt" + "\r\n"
+ " MakeThreadNums = 0" + " PDFREPORT_SPLIT_PAGENUM = 32" + "\r\n"
+ "*****************************************************";
string outputString = tranceString.Replace(cutString, "");
return outputString;
}
} }
} }
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</StackPanel> </StackPanel>
<TextBox x:Name="pageBox" Grid.Column="1" Height="23" Margin="192,3.667,11.333,0" Grid.Row="5" <TextBox x:Name="pageBox" Grid.Column="1" Height="23" Margin="192,3.667,11.333,0" Grid.Row="5"
TextWrapping="Wrap" Text="1,2,4-6" VerticalAlignment="Top" FontSize="14" IsEnabled="{Binding PageRange_SelectionChanged}"/> TextWrapping="Wrap" Text="1,2,4-6" VerticalAlignment="Top" FontSize="14" IsEnabled="{Binding PageRange_SelectionChanged}"/>
<TextBox x:Name="ResultConsole" Margin="55,10.333,55.333,10" Grid.Row="6" TextWrapping="Wrap" Grid.ColumnSpan="3" VerticalScrollBarVisibility="Auto" FontSize="14" IsReadOnly="True"/> <TextBox x:Name="ResultConsole" Margin="55,10.333,55.333,10" Grid.Row="6" Grid.ColumnSpan="3" VerticalScrollBarVisibility="Auto" FontSize="14" IsReadOnly="True" HorizontalScrollBarVisibility="Auto"/>
<Button x:Name="TIFFButton" Content="TIFF出力" HorizontalAlignment="Left" Height="22" Margin="54,1,0,0" Grid.Row="7" VerticalAlignment="Top" Width="82" Grid.RowSpan="2" Click="TIFFButtonClick"/> <Button x:Name="TIFFButton" Content="TIFF出力" HorizontalAlignment="Left" Height="22" Margin="54,1,0,0" Grid.Row="7" VerticalAlignment="Top" Width="82" Grid.RowSpan="2" Click="TIFFButtonClick"/>
<Button x:Name="CompareButton" Content="比較" HorizontalAlignment="Left" Height="22" Margin="13,1,0,0" Grid.Row="7" VerticalAlignment="Top" Width="82" Grid.Column="1" Grid.RowSpan="2" Click="CompareButtonClick"/> <Button x:Name="CompareButton" Content="比較" HorizontalAlignment="Left" Height="22" Margin="13,1,0,0" Grid.Row="7" VerticalAlignment="Top" Width="82" Grid.Column="1" Grid.RowSpan="2" Click="CompareButtonClick"/>
<Button x:Name="closeButton" Content="Close" Height="22" Margin="0,1,55.333,0" Grid.Row="7" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Right" Width="77" Click="CloseButton_Click"/> <Button x:Name="closeButton" Content="Close" Height="22" Margin="0,1,55.333,0" Grid.Row="7" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2" Grid.RowSpan="2" HorizontalAlignment="Right" Width="77" Click="CloseButton_Click"/>
......
...@@ -15,6 +15,8 @@ using System.Windows.Shapes; ...@@ -15,6 +15,8 @@ using System.Windows.Shapes;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
namespace CSRender namespace CSRender
{ {
...@@ -65,9 +67,156 @@ namespace CSRender ...@@ -65,9 +67,156 @@ namespace CSRender
workBox.AddHandler(TextBox.DropEvent, new DragEventHandler(WorkBox_Drop), true); workBox.AddHandler(TextBox.DropEvent, new DragEventHandler(WorkBox_Drop), true);
} }
//Closeボタン //Closeボタン実行
private void CloseButton_Click(object sender, RoutedEventArgs e) => private void CloseButton_Click(object sender, RoutedEventArgs e) =>
Close(); Close();
//比較ボタン実行
private void CompareButtonClick(object sender, RoutedEventArgs e)
{
//対象フォルダのpathチェック
if (!Directory.Exists(targetBox.Text) && !File.Exists(targetBox.Text))
{
CustomMsgBox.Show(mainWindow, "指定されたファイルあるいはフォルダが存在しません。" +
"\nもう一度設定してください。", "The specified file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//リファレンスファイルのpathチェック
if (!Directory.Exists(referenceBox.Text) && !File.Exists(referenceBox.Text))
{
CustomMsgBox.Show(mainWindow, "指定されたリファレンスファイルあるいはフォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//出力ファイルpathのチェック
if (!Directory.Exists(workBox.Text) && !File.Exists(workBox.Text))
{
CustomMsgBox.Show(mainWindow, "指定された作業フォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//TIFF画像の生成
ResultConsole.Text += "<TIFF変換開始>\r\n";
ResultConsole.Text += " 対象ファイルをTIFF画像に変換中\r\n";
//必要に応じてページ引数を指定
bool pageFlag = false;
string selectedPage = "";
if (PageRange.Text == "指定")
{
pageFlag = true;
selectedPage = pageBox.Text;
}
//対象フォルダ
string targetTIFFPath = System.IO.Path.Combine(workBox.Text, "work", "targetTIFF");
if (!Directory.Exists(targetTIFFPath))//指定先にTIFF用フォルダがあるか
{
Directory.CreateDirectory(targetTIFFPath);//なければ新規でTIFF用フォルダを作成
}
//CSRenderの実行
string targetTIFFResult =
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, targetBox.Text, targetTIFFPath);
ResultConsole.Text += " リファレンスファイルをTIFF画像に変換中\r\n";
//リファレンスフォルダ
string referenceTIFFPath = System.IO.Path.Combine(workBox.Text, "work", "referenceTIFF");
if (!Directory.Exists(referenceTIFFPath))//指定先にTIFF用フォルダがあるか
{
Directory.CreateDirectory(referenceTIFFPath);//なければ新規でTIFF用フォルダを作成
}
//CSRenderの実行
string referenceTIFFResult =
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, referenceBox.Text, referenceTIFFPath);
ResultConsole.Text += "<TIFF変換完了>\r\n\r\n";
//PureVerifyの実行
//string workDir = CompareTIFF.runPureVerify(targetBox.Text, referenceBox.Text, workBox.Text);
string workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text);
//レポートを出力
outputLog(System.IO.Path.Combine(workDir, "report"));
//指定先にレポートを移動
CompareTIFF.moveReport(workBox.Text, workDir);
}
//UIに検版結果を出力
private void outputLog(string workDir)
{
//logファイルを読み取り
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.log", System.IO.SearchOption.TopDirectoryOnly);
string logfileName = reportFiles[0];
StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング
string tranceString = "";
int lineCount = 0;
//ファイルから読み取った結果をUIに出力
while (logString.EndOfStream == false)
{
tranceString = logString.ReadLine();
lineCount++;
if (lineCount > 13 && lineCount < 40)//必要なところだけをUIに記述
{
ResultConsole.Text += tranceString + "\r\n";
ResultConsole.ScrollToEnd();
}
}
logString.Close();
}
//TIFFボタンを実行
private void TIFFButtonClick(object sender, RoutedEventArgs e)
{
ResultConsole.Text += "<変換開始>\r\n";
ResultConsole.Text += "PDFを" + FileSelect.Text + "に変換します\r\n";
ResultConsole.Text += "\r\n";
//必要に応じてページ引数を指定
bool pageFlag = false;
string selectedPage = "";
if (PageRange.Text == "指定")
{
pageFlag = true;
selectedPage = pageBox.Text;
}
//対象フォルダのpathが存在するかチェック
if (!Directory.Exists(targetBox.Text) && !File.Exists(targetBox.Text))
{
CustomMsgBox.Show(mainWindow, "指定されたファイルあるいはフォルダが存在しません。" +
"\nもう一度TIFF出力する対象を設定してください。", "The specified file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
//出力フォルダのpathチェック
if (workBox.Text != "")
{
if (!Directory.Exists(workBox.Text) && !File.Exists(workBox.Text))//pathのチェック
{
CustomMsgBox.Show(mainWindow, "指定された作業フォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
}
//CSRenderの実行
string TIFFresult =
OutputTIFF.runCSRender(ResolutionBox.Text, FileSelect.Text, pageFlag, selectedPage, targetBox.Text, workBox.Text);
ResultConsole.Text += TIFFresult;
ResultConsole.Text += "\r\n<変換終了>\r\n";
ResultConsole.ScrollToEnd();
}
} }
} }
...@@ -19,10 +19,12 @@ using System.IO; ...@@ -19,10 +19,12 @@ using System.IO;
namespace CSRender namespace CSRender
{ {
public partial class MainWindow : Window class OutputTIFF
{ {
private void TIFFButtonClick(object sender, RoutedEventArgs e) public static string runCSRender(string resolutionNum, string outputFile,
bool pageFlag, string filePage, string targetPath, string workPath)
{ {
//実行用コンソール呼び出し
ProcessStartInfo processStartInfo = new ProcessStartInfo(); ProcessStartInfo processStartInfo = new ProcessStartInfo();
string stCurrentDir = System.IO.Directory.GetCurrentDirectory(); string stCurrentDir = System.IO.Directory.GetCurrentDirectory();
processStartInfo.FileName = System.IO.Path.Combine(stCurrentDir, "CSRender.Data", "CSRender.exe"); processStartInfo.FileName = System.IO.Path.Combine(stCurrentDir, "CSRender.Data", "CSRender.exe");
...@@ -31,58 +33,40 @@ namespace CSRender ...@@ -31,58 +33,40 @@ namespace CSRender
processStartInfo.RedirectStandardOutput = true;//標準出力をリダイレクト processStartInfo.RedirectStandardOutput = true;//標準出力をリダイレクト
//解像度の引数 //解像度の引数
if (NumericScroll1.Value < 9)
{
CustomMsgBox.Show(mainWindow, "解像度が正しく設定されていません。" +
"\nもう一度設定してください。", "The resolution value is not set correctly", MessageBoxButton.OK, MessageBoxImage.Information);
ResolutionBox.Text = "9";
return;
}
processStartInfo.Arguments = "/D "; processStartInfo.Arguments = "/D ";
processStartInfo.Arguments += ResolutionBox.Text; processStartInfo.Arguments += resolutionNum;
//出力ファイル形式の引数 //出力ファイル形式の引数
processStartInfo.Arguments += " /"; processStartInfo.Arguments += " /";
processStartInfo.Arguments += FileSelect.Text; processStartInfo.Arguments += outputFile;
processStartInfo.Arguments += " "; processStartInfo.Arguments += " ";
//必要に応じてページ引数を指定 //必要に応じてページ引数を指定
if (PageRange.Text == "指定") if (pageFlag == true)
{ {
processStartInfo.Arguments += "/P \""; processStartInfo.Arguments += "/P \"";
processStartInfo.Arguments += pageBox.Text; processStartInfo.Arguments += filePage;
processStartInfo.Arguments += "\" "; processStartInfo.Arguments += "\" ";
} }
//指定ファイル //指定ファイル
if (!Directory.Exists(targetBox.Text) && !File.Exists(targetBox.Text))//pathが存在するかチェック
{
CustomMsgBox.Show(mainWindow, "指定されたファイルあるいはフォルダが存在しません。" +
"\nもう一度設定してください。", "The specified file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
processStartInfo.Arguments += "/F "; processStartInfo.Arguments += "/F ";
processStartInfo.Arguments += targetBox.Text; processStartInfo.Arguments += targetPath;
//出力フォルダ //出力フォルダ
if(workBox.Text != "") if (workPath != "")
{ {
if (!Directory.Exists(workBox.Text) && !File.Exists(workBox.Text))//pathのチェック
{
CustomMsgBox.Show(mainWindow, "指定された作業フォルダが存在しません。" +
"\nもう一度設定してください。", "The specified reference file or folder does not exist", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
processStartInfo.Arguments += " /O "; processStartInfo.Arguments += " /O ";
processStartInfo.Arguments += workBox.Text; processStartInfo.Arguments += workPath;
} }
//CSRender.exeを実行 //CSRender.exeを実行
Process process = Process.Start(processStartInfo); Process process = Process.Start(processStartInfo);
ResultConsole.Text = process.StandardOutput.ReadToEnd(); string resuletString = process.StandardOutput.ReadToEnd();
ResultConsole.ScrollToEnd();
process.WaitForExit(); process.WaitForExit();
process.Close(); process.Close();
return resuletString;
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment