コミットメタ情報

リビジョン2fc7ef508a3e6fc0a5fe1c2930d3dcb7df026c95 (tree)
日時2018-06-07 20:43:55
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

設定でファイル名に空白を入力して参照を押すとエラーになるのを直す

変更サマリ

差分

--- a/KancolleSniffer/ConfigDialog.cs
+++ b/KancolleSniffer/ConfigDialog.cs
@@ -257,10 +257,7 @@ namespace KancolleSniffer
257257
258258 private void buttonOpenFile_Click(object sender, EventArgs e)
259259 {
260- openSoundFileDialog.FileName = textBoxSoundFile.Text;
261- openSoundFileDialog.InitialDirectory = String.IsNullOrEmpty(textBoxSoundFile.Text)
262- ? Config.BaseDir
263- : Path.GetDirectoryName(textBoxSoundFile.Text) ?? Config.BaseDir;
260+ SetInitialPath(openSoundFileDialog, textBoxSoundFile.Text);
264261 if (openSoundFileDialog.ShowDialog() != DialogResult.OK)
265262 return;
266263 textBoxSoundFile.Text = openSoundFileDialog.FileName;
@@ -333,13 +330,37 @@ namespace KancolleSniffer
333330
334331 private void buttonDebugLogOpenFile_Click(object sender, EventArgs e)
335332 {
336- openDebugLogDialog.FileName = textBoxDebugLog.Text;
337- openDebugLogDialog.InitialDirectory = Path.GetDirectoryName(textBoxDebugLog.Text);
333+ SetInitialPath(openDebugLogDialog, textBoxDebugLog.Text);
338334 if (openDebugLogDialog.ShowDialog(this) == DialogResult.OK)
339335 textBoxDebugLog.Text = openDebugLogDialog.FileName;
340336 textBoxDebugLog.Select(textBoxDebugLog.Text.Length, 0);
341337 }
342338
339+ private void SetInitialPath(OpenFileDialog dialog, string path)
340+ {
341+ var dir = Config.BaseDir;
342+ var file = "";
343+ if (!string.IsNullOrWhiteSpace(path))
344+ {
345+ var res = Path.GetDirectoryName(path);
346+ if (res == null) // root
347+ {
348+ dir = path;
349+ }
350+ else if (res != "") // contain directory
351+ {
352+ dir = res;
353+ file = Path.GetFileName(path);
354+ }
355+ else
356+ {
357+ file = path;
358+ }
359+ }
360+ dialog.InitialDirectory = dir;
361+ dialog.FileName = file;
362+ }
363+
343364 private void buttonPlayDebugLog_Click(object sender, EventArgs e)
344365 {
345366 _main.SetPlayLog(textBoxDebugLog.Text);
旧リポジトリブラウザで表示