From 0a73b5298b189503110363e7f6513f3e786ae74f Mon Sep 17 00:00:00 2001 From: Evan Dixon Date: Mon, 2 Jan 2017 10:51:23 -0600 Subject: [PATCH] Simplified OpenFileDialog logic Also added appropriate filters --- PKHeX/MainWindow/Main.cs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index d1326306c..8cab33ab9 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -280,27 +280,19 @@ private void mainMenuOpen(object sender, EventArgs e) OpenFileDialog ofd = new OpenFileDialog { - Filter = $"Decrypted PKM File|{supported}" + + Filter = $"Supported Files|main;*.sav;*.bin;*.{ekx};{supported}" + + $"|3DS Main Files|main" + + $"|Save Files|*.sav" + + $"|Decrypted PKM File|{supported}" + $"|Encrypted PKM File|*.{ekx}" + "|Binary File|*.bin" + - "|All Files|*.*", - RestoreDirectory = true, - FilterIndex = 4, - FileName = "main", - }; - - // Reset file dialog path if it no longer exists - if (!Directory.Exists(ofd.InitialDirectory)) - ofd.InitialDirectory = WorkingDirectory; + "|All Files|*.*" + }; // Detect main string path = SaveUtil.detectSaveFile(); if (path != null) - { ofd.InitialDirectory = Path.GetDirectoryName(path); } - else if (File.Exists(Path.Combine(ofd.InitialDirectory, "main"))) - { } - else if (!Directory.Exists(ofd.InitialDirectory)) - { ofd.RestoreDirectory = false; ofd.FilterIndex = 1; ofd.FileName = ""; } + { ofd.FileName = path; } if (ofd.ShowDialog() == DialogResult.OK) openQuick(ofd.FileName);