diff --git a/GetADoc/GetADoc.csproj b/GetADoc/GetADoc.csproj
index 92536253556abea5bc7dd26c161768d0a384718b..b0afc87a78520f09dab4d9f764175a5bc70426f8 100644
--- a/GetADoc/GetADoc.csproj
+++ b/GetADoc/GetADoc.csproj
@@ -64,6 +64,7 @@
MSBuild:Compile
Designer
+
MSBuild:Compile
Designer
@@ -72,7 +73,7 @@
App.xaml
Code
-
+
MainWindow.xaml
diff --git a/GetADoc/MainWindow.xaml b/GetADoc/MainWindow.xaml
index a2979fe36ad1874c384ae21939dabb0b3bf0415e..d92f60d238d8e99841a68c6b658c50ea4b370ea8 100644
--- a/GetADoc/MainWindow.xaml
+++ b/GetADoc/MainWindow.xaml
@@ -5,13 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GetADoc"
mc:Ignorable="d"
- Title="GetADoc" Height="260" Width="400" MinWidth="375" MinHeight="240">
+ Title="GetADoc" Height="260" Width="430" MinWidth="400" MinHeight="245">
-
-
-
-
+
+
+
+
@@ -19,21 +19,22 @@
-
diff --git a/GetADoc/MainWindow.xaml.cs b/GetADoc/MainWindow.xaml.cs
index 608936a973973cebc76fabf3acb56703f88af439..52fc1704bd1057c92290a6429f765c8bd42da7eb 100644
--- a/GetADoc/MainWindow.xaml.cs
+++ b/GetADoc/MainWindow.xaml.cs
@@ -90,6 +90,23 @@ namespace GetADoc
//作成ボタンClickでチェックボックスで要求された仕様のADocファイル一式を指定先フォルダに生成
private void button2_Click(object sender, RoutedEventArgs e)
{
+
+ bool IconFlag = false;
+ bool SCREENFlag = false;
+ bool SepaFlag = false;
+ if (checkbox2.IsChecked == true)//Iconsチェックボックスがオンのとき
+ {
+ IconFlag = true;
+ }
+ if (checkbox1.IsChecked == true)//SCREEN Logoチェックボックスがオンのとき
+ {
+ SCREENFlag = true;
+ }
+ if (checkbox3.IsChecked == true)//分割ドキュチェックボックスがオンのとき
+ {
+ SepaFlag = true;
+ }
+
//ファイルパスが指定されていない or 指定したフォルダが存在しない場合
if (box1.Text == "" || !Directory.Exists(box1.Text))
{
@@ -113,7 +130,7 @@ namespace GetADoc
char[] cutComma = { '.' };
if (fileName.IndexOfAny(NgChars) >= 0 || fileName.IndexOfAny(cutComma) >= 0)
{
- fileName = PushedButton.NameCalibration(fileName);
+ fileName = RunBatch.NameCalibration(fileName);
CustomMsgBox.Show(mainWindow, "ファイル名に使用できない文字が存在したため\n一部ファイル名を修正しました。" +
"\nもう一度作成ボタンをクリックしてください。", "Renamed this file", MessageBoxButton.OK, MessageBoxImage.Warning);
box2.Text = fileName;
@@ -121,7 +138,9 @@ namespace GetADoc
}
//指定したフォルダに同名の.adocや既存の付属ファイル(config.adocなど)がある場合の処理
- if (File.Exists(System.IO.Path.Combine(filePath, fileName + ".adoc")) || File.Exists(System.IO.Path.Combine(filePath, "config.adoc")))
+ if (File.Exists(System.IO.Path.Combine(filePath, fileName + ".adoc")) || File.Exists(System.IO.Path.Combine(filePath, "config.adoc"))
+ || Directory.Exists(System.IO.Path.Combine(filePath, "Images")) || Directory.Exists(System.IO.Path.Combine(filePath, "icons"))
+ || Directory.Exists(System.IO.Path.Combine(filePath, "Sub_First")) || Directory.Exists(System.IO.Path.Combine(filePath, "Sub_Second")))
{
MessageBoxResult OverwriteADoc = CustomMsgBox.Show(mainWindow, "これから生成するファイルと同名のファイルが既に存在します" +
"\n既存のファイルを上書きしますか?",
@@ -129,7 +148,7 @@ namespace GetADoc
MessageBoxButton.YesNo, MessageBoxImage.None);
if (OverwriteADoc == MessageBoxResult.Yes)
{
- PushedButton.deleteFolder(filePath, fileName);
+ RunBatch.deleteFolder(filePath, fileName, IconFlag, SepaFlag);
}
else if (OverwriteADoc == MessageBoxResult.No)
{
@@ -140,26 +159,10 @@ namespace GetADoc
}
//バッチファイルの実行
- var tempPath = System.IO.Path.GetTempPath();
- bool IconFlag = false;
- bool SCREENFlag = false;
- bool SepaFlag = false;
- if (checkbox2.IsChecked == true)//Iconsチェックボックスがオンのとき
- {
- IconFlag = true;
- }
- if (checkbox1.IsChecked == true)//SCREEN Logoチェックボックスがオンのとき
- {
- SCREENFlag = true;
- }
- if (checkbox3.IsChecked == true)//分割ドキュチェックボックスがオンのとき
- {
- SepaFlag = true;
- }
- PushedButton.runBatch(IconFlag, SCREENFlag, SepaFlag, fileName, tempPath);
-
- //指定されたフォルダに生成物を移動
- PushedButton.MoveProduct(IconFlag, SepaFlag, fileName, tempPath, filePath);
+ RunBatch.runBatch(IconFlag, SCREENFlag, SepaFlag, fileName, filePath);
+
+ //処理の完了を知らせるラベルを表示
+ CompletedLabel.Visibility = Visibility.Visible;
//指定されたファイルパスとチェックボックスを保存
Properties.Settings.Default.box1Setting = box1.Text;
@@ -168,6 +171,12 @@ namespace GetADoc
Properties.Settings.Default.checkbox3Setting = ((bool)checkbox3.IsChecked);
Properties.Settings.Default.Save();
}
+
+ //コントロール(テキストボックスなど)がフォーカスされたら処理完了のラベルを非表示にする
+ private void DeleteCompLabel(object sender, RoutedEventArgs e)
+ {
+ CompletedLabel.Visibility = Visibility.Hidden;
+ }
}
}
diff --git a/GetADoc/RunBatch.cs b/GetADoc/RunBatch.cs
new file mode 100644
index 0000000000000000000000000000000000000000..3f53fc213b9bfbf1668ef40f6c1f57ce4d82584c
--- /dev/null
+++ b/GetADoc/RunBatch.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace GetADoc
+{
+ class RunBatch
+ {
+ //ファイル名に使用不可の文字が含まれている場合の処理
+ public static string NameCalibration(string inFileName)
+ {
+ string[] charsToRemove = new string[] { @"\", ".", "/", ":", "*", "?", "<", ">", "|" };
+ foreach (var allNg in charsToRemove)
+ {
+ inFileName = inFileName.Replace(allNg, string.Empty);
+ }
+ return inFileName;
+ }
+
+ //先に同名フォルダが存在すれば削除(エラー回避のため)
+ public static void deleteFolder(string filePath, string fileName, bool icon, bool sepa)
+ {
+ File.Delete(filePath + fileName + ".adoc");
+ File.Delete(System.IO.Path.Combine(filePath, "config.adoc"));
+ if(sepa == true)
+ {
+ File.Delete(System.IO.Path.Combine(filePath, "IncDoc.adoc"));
+ }
+ if (Directory.Exists(System.IO.Path.Combine(filePath, "Images")))
+ {
+ Directory.Delete(System.IO.Path.Combine(filePath, "Images"), true);
+ }
+ if (Directory.Exists(System.IO.Path.Combine(filePath, "icons")) && icon == true)
+ {
+ Directory.Delete(System.IO.Path.Combine(filePath, "icons"), true);
+ }
+ if (Directory.Exists(System.IO.Path.Combine(filePath, "Sub_First")) && sepa == true)
+ {
+ Directory.Delete(System.IO.Path.Combine(filePath, "Sub_First"), true);
+ }
+ if (Directory.Exists(System.IO.Path.Combine(filePath, "Sub_Second")) && sepa == true)
+ {
+ Directory.Delete(System.IO.Path.Combine(filePath, "Sub_Second"), true);
+ }
+ }
+
+ //バッチファイルの実行
+ public static void runBatch(bool icon, bool screen, bool sepa, string fileName, string filePath)
+ {
+ //テンポラリフォルダの作成
+ var tempPath = TemporaryFolder.MakeTempFolder();
+
+ //コンソール呼び出し
+ ProcessStartInfo processStartInfo = new ProcessStartInfo();
+ string stCurrentDir = System.IO.Directory.GetCurrentDirectory();
+ processStartInfo.FileName = System.IO.Path.Combine(stCurrentDir, "getADoc.Data", "getADoc.bat");
+ processStartInfo.CreateNoWindow = true; // コマンドプロンプトを非表示
+ processStartInfo.UseShellExecute = false; // シェル機能オフ
+
+ //チェックボックスの状況に応じて引数を指定
+ processStartInfo.Arguments = "";
+ if (icon == true)//Iconsチェックボックスがオンのとき
+ {
+ processStartInfo.Arguments += "/Icons ";
+ }
+ if (screen == true)//SCREEN Logoチェックボックスがオンのとき
+ {
+ processStartInfo.Arguments += "/SCREEN ";
+ }
+ if (sepa == true)//分割ドキュチェックボックスがオンのとき
+ {
+ processStartInfo.Arguments += "/SepaDoc ";
+ }
+ var pathAndName = System.IO.Path.Combine(tempPath, fileName);
+ processStartInfo.Arguments += pathAndName;
+
+ //GetADoc.batを実行
+ Process process = Process.Start(processStartInfo);
+ process.WaitForExit();
+ process.Close();
+
+ //指定されたフォルダに生成物を移動
+ RunBatch.MoveProduct(icon, sepa, fileName, tempPath, filePath);
+
+ //テンポラリフォルダの消去
+ TemporaryFolder.DeleteTempFolder(tempPath);
+ }
+
+ //生成物を指定先フォルダへ移動
+ static public void MoveProduct(bool icon, bool sepa,
+ string fileName, string tempPath, string filePath)
+ {
+ File.Move(System.IO.Path.Combine(tempPath, fileName + ".adoc"), filePath + fileName + ".adoc");
+ File.Move(System.IO.Path.Combine(tempPath, "config.adoc"), System.IO.Path.Combine(filePath, "config.adoc"));
+ Directory.Move(System.IO.Path.Combine(tempPath, "Images"), System.IO.Path.Combine(filePath, "Images"));
+ if (icon == true)
+ {
+ Directory.Move(System.IO.Path.Combine(tempPath, "icons"), System.IO.Path.Combine(filePath, "icons"));
+ }
+ if (sepa == true)
+ {
+ File.Move(System.IO.Path.Combine(tempPath, "IncDoc.adoc"), System.IO.Path.Combine(filePath, "IncDoc.adoc"));
+ Directory.Move(System.IO.Path.Combine(tempPath, "Sub_First"), System.IO.Path.Combine(filePath, "Sub_First"));
+ Directory.Move(System.IO.Path.Combine(tempPath, "Sub_Second"), System.IO.Path.Combine(filePath, "Sub_Second"));
+ }
+ }
+ }
+}
diff --git a/GetADoc/TemporaryFolder.cs b/GetADoc/TemporaryFolder.cs
new file mode 100644
index 0000000000000000000000000000000000000000..9499b9253c75c276472a0485151f9aa3f94159fe
--- /dev/null
+++ b/GetADoc/TemporaryFolder.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GetADoc
+{
+ //テンポラリフォルダの作成/削除
+ class TemporaryFolder
+ {
+ //テンポラリフォルダの作成
+ public static string MakeTempFolder()
+ {
+ var TempFile = Path.GetTempFileName();
+ if (File.Exists(TempFile))
+ {
+ File.Delete(TempFile);
+ Directory.CreateDirectory(TempFile);
+ }
+ return TempFile;
+ }
+
+ //テンポラリフォルダの削除
+ public static void DeleteTempFolder(string TempFolderPath)
+ {
+ if (Directory.Exists(TempFolderPath))
+ {
+ Directory.Delete(TempFolderPath);
+ }
+ }
+ }
+}
diff --git a/Release/GetADocGUI.exe b/Release/GetADocGUI.exe
index 50fee3625e0a677a37170291d3e06c80b4364753..a5a45849ca5a27c7c95dc7867d50161c3c1c003d 100644
Binary files a/Release/GetADocGUI.exe and b/Release/GetADocGUI.exe differ
diff --git a/Release/GetADocGUI.pdb b/Release/GetADocGUI.pdb
index 62394a4b170955702354e3bf8cc17220eaa0ff98..57d964e818a4c69dea2afe177dfcc14cfb2a7b58 100644
Binary files a/Release/GetADocGUI.pdb and b/Release/GetADocGUI.pdb differ