System.Windows.Forms.CommonDialog.ShowDialog()

Here are the examples of the csharp api System.Windows.Forms.CommonDialog.ShowDialog() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3087 Examples 7

19 Source : Settings.xaml.cs
with GNU General Public License v3.0
from 00000vish

private void changeSteamLoc_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SteamTwoProperties.jsonSetting.steamLocation = fd.FileName;
            }
            else
            {
                SteamTwoProperties.jsonSetting.steamLocation = "C:\\Program Files (x86)\\Steam\\Steam.exe";
            }
            SteamTwoProperties.updateSettingFile();
            updateGUI();
        }

19 Source : Settings.xaml.cs
with GNU General Public License v3.0
from 00000vish

private void SDALink(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SteamTwoProperties.jsonSetting.SDALinkSetting = fd.FileName;
            }
            else
            {
                SteamTwoProperties.jsonSetting.SDALinkSetting = "";
            }
            SteamTwoProperties.updateSettingFile();
            updateGUI();
        }

19 Source : fMain.cs
with MIT License
from 0xPh0enix

private void bSelectFile_Click(object sender, EventArgs e)
        {
            using(OpenFileDialog fOpenDialog = new OpenFileDialog())
            {
                fOpenDialog.Filter = "Executable (*.exe)|*.exe";
                fOpenDialog.replacedle = "Select .NET File to crypt...";

                if(fOpenDialog.ShowDialog() == DialogResult.OK)
                {
                    tServer.Text = fOpenDialog.FileName;
                }
            }
        }

19 Source : fMain.cs
with MIT License
from 0xPh0enix

private void bSelectIcon_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog fOpenDialog = new OpenFileDialog())
            {
                fOpenDialog.Filter = "Icon (*.ico)|*.ico";
                fOpenDialog.replacedle = "Select Icon...";

                if (fOpenDialog.ShowDialog() == DialogResult.OK)
                {
                    tIcon.Text = fOpenDialog.FileName;
                }
            }
        }

19 Source : fMain.cs
with MIT License
from 0xPh0enix

private void bCrypt_Click(object sender, EventArgs e)
        {
            if (!File.Exists(tServer.Text))
            {
                MessageBox.Show("Error, server is not exists!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!File.Exists(tIcon.Text) && tIcon.Text.Trim() != "")
            {
                MessageBox.Show("Error, icon is not exists!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            using (SaveFileDialog fSaveDialog = new SaveFileDialog())
            {

                fSaveDialog.Filter = "Executable (*.exe)|*.exe";
                fSaveDialog.replacedle = "Save crypted Server...";

                if (fSaveDialog.ShowDialog() == DialogResult.OK)
                {

                    string sFileName = cUtils.GenStr(8);
                    string sKey = cUtils.GenStr(40);

                    string sStub = Properties.Resources.Stub

                        .Replace("%RES_NAME%", sFileName)
                        .Replace("%ENC_KEY%", sKey);

                    File.WriteAllBytes(sFileName, nAES256.cAES256.Encrypt(File.ReadAllBytes(tServer.Text), System.Text.Encoding.Default.GetBytes(sKey)));


                    using (CSharpCodeProvider csCodeProvider = new CSharpCodeProvider(new Dictionary<string, string>
            {
                {"CompilerVersion", "v2.0"}
            }))
                    {
                        CompilerParameters cpParams = new CompilerParameters(null, fSaveDialog.FileName, true);


                        if (tIcon.Text.Trim() == "")
                            cpParams.CompilerOptions = "/t:winexe /unsafe /platform:x86 /debug-";
                        else
                            cpParams.CompilerOptions = "/t:winexe /unsafe /platform:x86 /debug- /win32icon:\"" + tIcon.Text + "\"";

                        cpParams.Referencedreplacedemblies.Add("System.dll");
                        cpParams.Referencedreplacedemblies.Add("System.Management.dll");
                        cpParams.Referencedreplacedemblies.Add("System.Windows.Forms.dll");

                        cpParams.EmbeddedResources.Add(sFileName);

                        csCodeProvider.CompilereplacedemblyFromSource(cpParams, sStub);

                        MessageBox.Show("Your nj server crypted successfully!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    File.Delete(sFileName);
                }

            }
        }

19 Source : Form1.cs
with MIT License
from 2401dem

private void button1_Click(object sender, EventArgs e)
        {
            if (IsFolder)
            {
                CommonOpenFileDialog dialog = new CommonOpenFileDialog();
                dialog.IsFolderPicker = true;


                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    string tmp = dialog.FileName;
                    if (tmp.LastIndexOf('\\') != -1)
                    {
                        textBox1.Text = tmp;
                        if (!Directory.Exists(textBox2.Text))
                            textBox2.Text = tmp;
                    }
                }

            }
            else
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Supported Files (*.bmp, *.jpg, *.png, *.tif, *.exr)|*.jpg;*.png;*.bmp;*.tif;*.exr|Bitmap Images (*.bmp)|*.bmp|JPEG Images (*.jpg)|*.jpg|PNG Images (*.png)|*.png|TIFF Images (*.tif)|*.tif|OpenEXR Images (*.exr)|*.exr";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string tmp = dialog.FileName;
                    if (tmp.LastIndexOf('\\') != -1)
                    {
                        textBox1.Text = tmp;
                        textBox2.Text = tmp.Substring(0, tmp.LastIndexOf('\\') + 1) + "out_" + tmp.Substring(tmp.LastIndexOf('\\') + 1);
                    }
                }
            }
        }

19 Source : Form1.cs
with MIT License
from 2401dem

private void button2_Click(object sender, EventArgs e)
        {
            if (IsFolder)
            {
                CommonOpenFileDialog dialog = new CommonOpenFileDialog();
                dialog.IsFolderPicker = true;


                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    string tmp = dialog.FileName;
                    if (tmp.LastIndexOf('\\') != -1)
                    {
                        textBox2.Text = tmp;
                    }
                }
            }
            else
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "Bitmap Images (*.bmp)|*.bmp|JPEG Images (*.jpg)|*.jpg|PNG Images (*.png)|*.png|TIFF Images (*.tif)|*.tif|OpenEXR Images (*.exr)|*.exr";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string tmp = dialog.FileName;
                    if (tmp.LastIndexOf('\\') != -1)
                    {
                        textBox2.Text = tmp;
                    }
                }
            }
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from 2dust

private void menuAddCustomServer_Click(object sender, EventArgs e)
        {
            UI.Show(UIRes.I18N("CustomServerTips"));

            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Multiselect = false,
                Filter = "Config|*.json|All|*.*"
            };
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }

            if (ConfigHandler.AddCustomServer(ref config, fileName) == 0)
            {
                RefreshServers();
                //LoadV2ray();
                UI.Show(UIRes.I18N("SuccessfullyImportedCustomServer"));
            }
            else
            {
                UI.ShowWarning(UIRes.I18N("FailedImportedCustomServer"));
            }
        }

19 Source : TaskBuild.cs
with MIT License
from 2881099

[JSFunction]
        public string folderBrowserDialog()
        {
            var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return folderBrowserDialog.SelectedPath;
            }
            return string.Empty;
        }

19 Source : RoutingRuleSettingForm.cs
with GNU General Public License v3.0
from 2dust

private void menuImportRulesFromFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Multiselect = false,
                Filter = "Rules|*.json|All|*.*"
            };
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            string result = Utils.LoadResource(fileName);
            if (Utils.IsNullOrEmpty(result))
            {
                return;
            }

            if (AddBatchRoutingRules(ref routingItem, result) == 0)
            {
                RefreshRoutingsView();
                UI.Show(UIRes.I18N("OperationSuccess"));
            }
        }

19 Source : AddServerForm.cs
with GNU General Public License v3.0
from 2dust

private void MenuItemImport(int type)
        {
            ClearServer();

            OpenFileDialog fileDialog = new OpenFileDialog
            {
                Multiselect = false,
                Filter = "Config|*.json|All|*.*"
            };
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            string msg;
            VmessItem vmessItem;
            if (type.Equals(1))
            {
                vmessItem = V2rayConfigHandler.ImportFromClientConfig(fileName, out msg);
            }
            else
            {
                vmessItem = V2rayConfigHandler.ImportFromServerConfig(fileName, out msg);
            }
            if (vmessItem == null)
            {
                UI.ShowWarning(msg);
                return;
            }

            txtAddress.Text = vmessItem.address;
            txtPort.Text = vmessItem.port.ToString();
            txtId.Text = vmessItem.id;
            txtAlterId.Text = vmessItem.alterId.ToString();
            txtRemarks.Text = vmessItem.remarks;
            cmbNetwork.Text = vmessItem.network;
            cmbHeaderType.Text = vmessItem.headerType;
            txtRequestHost.Text = vmessItem.requestHost;
            txtPath.Text = vmessItem.path;
            cmbStreamSecurity.Text = vmessItem.streamSecurity;
        }

19 Source : MainFormHandler.cs
with GNU General Public License v3.0
from 2dust

public void Export2ClientConfig(int index, Config config)
        {
            //int index = GetLvSelectedIndex();
            if (index < 0)
            {
                return;
            }
            if (config.vmess[index].configType != (int)EConfigType.Vmess
                && config.vmess[index].configType != (int)EConfigType.VLESS)
            {
                UI.Show(UIRes.I18N("NonVmessService"));
                return;
            }

            SaveFileDialog fileDialog = new SaveFileDialog
            {
                Filter = "Config|*.json",
                FilterIndex = 2,
                RestoreDirectory = true
            };
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            Config configCopy = Utils.DeepCopy(config);
            configCopy.index = index;
            if (V2rayConfigHandler.Export2ClientConfig(configCopy, fileName, out string msg) != 0)
            {
                UI.Show(msg);
            }
            else
            {
                UI.ShowWarning(string.Format(UIRes.I18N("SaveClientConfigurationIn"), fileName));
            }
        }

19 Source : MainFormHandler.cs
with GNU General Public License v3.0
from 2dust

public void Export2ServerConfig(int index, Config config)
        {
            //int index = GetLvSelectedIndex();
            if (index < 0)
            {
                return;
            }
            if (config.vmess[index].configType != (int)EConfigType.Vmess
                && config.vmess[index].configType != (int)EConfigType.VLESS)
            {
                UI.Show(UIRes.I18N("NonVmessService"));
                return;
            }

            SaveFileDialog fileDialog = new SaveFileDialog
            {
                Filter = "Config|*.json",
                FilterIndex = 2,
                RestoreDirectory = true
            };
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            Config configCopy = Utils.DeepCopy(config);
            configCopy.index = index;
            if (V2rayConfigHandler.Export2ServerConfig(configCopy, fileName, out string msg) != 0)
            {
                UI.Show(msg);
            }
            else
            {
                UI.ShowWarning(string.Format(UIRes.I18N("SaveServerConfigurationIn"), fileName));
            }
        }

19 Source : MainFormHandler.cs
with GNU General Public License v3.0
from 2dust

public void BackupGuiNConfig(Config config, bool auto = false)
        {
            string fileName = string.Empty;
            if (auto)
            {
                fileName = Utils.GetTempPath($"guiNConfig{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.json");
            }
            else
            {
                SaveFileDialog fileDialog = new SaveFileDialog
                {
                    Filter = "guiNConfig|*.json",
                    FilterIndex = 2,
                    RestoreDirectory = true
                };
                if (fileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                fileName = fileDialog.FileName;
            }
            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            var ret = Utils.ToJsonFile(config, fileName);
            if (!auto)
            {
                if (ret == 0)
                {

                    UI.Show(UIRes.I18N("OperationSuccess"));
                }
                else
                {
                    UI.ShowWarning(UIRes.I18N("OperationFailed"));
                }
            }
        }

19 Source : dlgSettings.cs
with MIT License
from 86Box

private void btnBrowse3_Click(object sender, EventArgs e)
        {
            SaveFileDialog ofd = new SaveFileDialog();
            ofd.DefaultExt = "log";
            ofd.replacedle = "Select a file where 86Box logs will be saved";
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
            ofd.Filter = "Log files (*.log)|*.log";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                txtLogPath.Text = ofd.FileName;
            }

            ofd.Dispose();
        }

19 Source : FrmSettings.cs
with GNU General Public License v3.0
from 9vult

private void BtnChangeDirectory_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog
            {
                SelectedPath = txtDirectory.Text
            };
            DialogResult result = fbd.ShowDialog();
            if (result == DialogResult.OK)
            {
                txtDirectory.Text = fbd.SelectedPath;
            }
        }

19 Source : FrmSettings.cs
with GNU General Public License v3.0
from 9vult

private void BtnBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            DialogResult dr = fbd.ShowDialog();
            if (dr == DialogResult.OK)
            {
                txtDir.Text = fbd.SelectedPath;
            }
        }

19 Source : ZUART.cs
with MIT License
from a2633063

private void lkbSaveRev_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //if (txtShowData.Text.Length < 1)
            //{
            //    MessageBox("");
            //    return;
            //}

            StreamWriter myStream;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();
            saveFileDialog1.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*";
            saveFileDialog1.RestoreDirectory = true;
            saveFileDialog1.replacedle = "保存接受区数据";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                myStream = new StreamWriter(saveFileDialog1.FileName);
                myStream.Write(txtShowData.Text); //写入
                myStream.Close();//关闭流
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from a4004

private async void Flash()
        {
            await Task.Delay(1000);
FileMode:
            CreateRequest("Device software installation", "You are installing software on your device, you can choose where to get it from.", 
                "Get the latest image from the Internet (Recommended)", "Use a local image on this PC", out int option);

            if (option == 2)
            {
                Invoke(new Action(() =>
                {
                    OpenFileDialog fileDialog = new OpenFileDialog()
                    {
                        Multiselect = false,
                        SupportMultiDottedExtensions = true,
                        Filter = "Binary files (*.bin)|*.bin|Hex files (*.hex)|*.hex|All files (*.*)|*.*",
                        replacedle = "Choose a software image file",
                    };

                    if (fileDialog.ShowDialog() == DialogResult.OK)
                        Program.Settings.Bin = fileDialog.FileName;
                }));

                if (Program.Settings.Bin == default)
                    goto FileMode;
            }
            else if (option == 1)
            {
                if (!CreateSelRequest(out string file))
                    goto FileMode;
                else
                {
                    WaitFm.Debug($"User selected file: {file}");

                    WaitFm.replacedle("Downloading software");
                    WaitFm.Caption("");

                    WaitFm.Debug($"Downloading {file}...");

                    try
                    {
                        WebClient client = new WebClient();

                        client.DownloadProgressChanged += (s, e) =>
                        {
                            WaitFm.Caption($"Downloading {Path.GetFileName(file)} from github.com ({e.ProgressPercentage}%)");
                        };
                        client.DownloadFileCompleted += delegate
                        {
                            WaitFm.Debug($"Successfully downloaded {Path.GetFileName(file)} from github.com", Event.Success);
                        };

                        await client.DownloadFileTaskAsync(file, Path.GetFileName(file));
                        Program.Settings.Bin = Path.GetFileName(file);
                    }
                    catch (Exception ex)
                    {
                        WaitFm.Debug($"Download failed due to an error: {ex.Message}", Event.Critical);
                        await CreateMessage("A problem was encountered", "The required file could not be downloaded. You can try again.");

                        WaitFm.Host.CloseTask();
                        WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
                        TaskManager.ReleaseFLock();
                        return;
                    }          
                }

                WaitFm.replacedle("Getting ready");
                await Task.Delay(1000);
            }
            else
                throw new Exception($"The selection could not be determined due to an invalid value. {option}");

            CreateRequest("Flash Operation", "The program is about to install software to your Espressif device. " +
                    "Existing data on the device will be PERMANENTLY DELETED, are you sure?", "Allow software installation",
                    "Cancel flash operation, no changes will be made", out int result);

            if (result == 2)
            {
                WaitFm.Debug("User cancelled the flash operation.", Event.Critical);
                await CreateMessage("Software installation aborted", "You've chosen to cancel the installation " +
                    "of software to your Espressif device. No changes have been made. You can close this window.");

                WaitFm.Host.CloseTask();
                WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
                TaskManager.ReleaseFLock();

                return;
            }
            else if (result == 1)
            {
                WaitFm.Debug("Flash operation started.");
                WaitFm.replacedle("Installing software");

                WaitFm.Caption("Checking device connection");
                WaitFm.Debug("Checking device connection...");

                if (!Program.Settings.PortFix)
                    WaitFm.Debug($"Connecting to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}...");

                string output = string.Empty;

                if (!Program.Portable)
                {
                    if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
                    {
                        if (!Program.Settings.PortFix)
                            WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
                        WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);

                        WaitFm.Caption("Connection was successful");
                    }
                    else
                        throw new Exception("Could not connect to the device.");
                }
                else
                {
                    if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} read_mac"))
                    {
                        if (!Program.Settings.PortFix)
                            WaitFm.Debug($"Connected to {Program.Settings.SelectedName} on {Program.Settings.SelectedPort}", Event.Success);
                        WaitFm.Debug($"Espressif device MAC: {output.Substring(output.IndexOf("MAC:") + 5, 17).ToUpper()}", Event.Success);

                        WaitFm.Caption("Connection was successful");
                    }
                    else
                        throw new Exception("Could not connect to the device.");
                }

                WaitFm.Caption("Erasing flash memory");
                WaitFm.Debug("Erasing flash memory chip...");

                if (!Program.Portable)
                {
                    if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
                    {
                        WaitFm.Debug("Erase successful!", Event.Success);
                        WaitFm.Caption("Erased.");
                    }
                    else
                        throw new Exception("Failed to erase the device.");
                }
                else
                {
                    if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} erase_flash"))
                    {
                        WaitFm.Debug("Erase successful!", Event.Success);
                        WaitFm.Caption("Erased.");
                    }
                    else
                        throw new Exception("Failed to erase the device.");
                }

                WaitFm.Caption("Writing new software image");
                WaitFm.Debug("Writing new software image...");

                if (!Program.Portable)
                {
                    if (ShellManager.RunCommand(out output, "py", $"-m esptool {(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
                    {
                        WaitFm.Debug("Flash complete!", Event.Success);
                        WaitFm.Caption("Installed.");
                    }
                    else
                        throw new Exception("Failed to flash the device.");
                }
                else
                {
                    if (ShellManager.RunCommand(out output, Program.Settings.EsptoolExe, $"{(!Program.Settings.PortFix ? $"--port {Program.Settings.SelectedPort}" : "")} write_flash 0x0 \"{Program.Settings.Bin}\""))
                    {
                        WaitFm.Debug("Erase successful!", Event.Success);
                        WaitFm.Caption("Erased.");
                    }
                    else
                        throw new Exception("Failed to flash the device.");
                }


                await Task.Delay(500);

                await CreateMessage("Installation complete", $"The software package {Program.Settings.Bin} has been successfully" +
                    $" installed on your device. You can close this window.");

                WaitFm.Host.CloseTask();
                WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
                TaskManager.ReleaseFLock();

                return;
            }
            else
            {
                WaitFm.Debug("Failsafe: the selection was invalid.", Event.Critical);
                await CreateMessage("Software installation aborted", "A problem was encountered with the selection. " +
                    "No changes have been made to your Espressif device. You can close this window.");

                WaitFm.Host.CloseTask();
                WindowManager.UnmountWindow(Controls, TaskManager.ForegroundWindow);
                TaskManager.ReleaseFLock();

                return;
            }
        }

19 Source : Program.cs
with GNU General Public License v3.0
from a4004

[STAThread]
        static void Main(string[] argv)
        {
            if (argv.Any(o => o.Contains("--debug") || o.Contains("-d")))
            {
                NativeMethods.AllocConsole();
                Default = Console.ForegroundColor;
                DebugMode = true;

                Console.replacedle = "Espressif Flash Manager - Debugging Console";
            }

            AllowFileDebugging = -1;
            Debug("Application init.");

            if (argv.Any(o => o.Contains("--fixdriver") || o.Contains("-fd")))
            {
                Debug("Program executed with --fixdriver flag. Device picker will be disabled and esptool will autodetect" +
                    " in order to mitigate access denied error messages.");

                Settings.PortFix = true;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            if (argv.Any(o => o.Contains("--portable") || o.Contains("-p")))
            {
                Portable = true;

                Debug("Program executed with the --portable flag which removes the need for Python and the esptool module" +
                    " and instead uses a precompiled (outdated) copy of the esptool.", Event.Warning);
                Debug("You are warned that using untrusted executables not provided by N2D22 exposes your computer system" +
                    " to security risks. It's recommended that you do not use this mode and instead use the Python utility.", Event.Warning);

                if (!File.Exists("esptool.exe"))
                {
                    Debug("Could not find a matching file for esptool.exe in the current working directory.", Event.Critical);

                    OpenFileDialog fileDialog = new OpenFileDialog()
                    {
                        Multiselect = false,
                        SupportMultiDottedExtensions = true,
                        Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*",
                        replacedle = "Browse for esptool binary",
                    };

                    if (fileDialog.ShowDialog() == DialogResult.OK)
                        Settings.EsptoolExe = fileDialog.FileName;
                    else
                        Terminate();                  
                }
                else
                    Settings.EsptoolExe = "esptool.exe";
            }

            Application.ThreadException += (s, e) =>
            {
                Debug("threadexception", e.Exception.ToString(), Event.Critical);

                MainWindow.Instance.Invoke(new Action(() =>
                {
                    MessageBox.Show($"{e.Exception.Message}\nThe application will terminate immediately.", "Unexpected Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Terminate();
                }));
            };
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Debug("appdomain", e.ExceptionObject.ToString(), Event.Critical);

                MainWindow.Instance.Invoke(new Action(() =>
                {
                    MessageBox.Show($"{(e.ExceptionObject as Exception).Message}\nThe application will terminate immediately.", "Unexpected Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Terminate();
                }));
            };

            if (!argv.Any(o => o.Contains("--debugyes") || o.Contains("-dyes")) && DebugMode)
            {
                Debug("[WARN] Do not close this debugging window, doing so will prevent logging " +
                    "to the disk and may cause unintended behaviour.", Event.Critical);
                Debug("If you wish to hide this window, please run N2D22 without the --debug flag.", Event.Warning);

                string conf = string.Empty;

                do
                {
                    Console.Write("Please type \"understood\" without the quotes to continue: ");
                    conf = Console.ReadLine();
                }
                while (conf != "understood");

                Debug("To debug faster, simply append 'yes' to the --debug flag i.e. \"--debugyes\" to skip the confirmation.", Event.Success);

                Console.Write("Press any key to continue . . .");
                Console.ReadKey();
            }

            Debug("Creating MainWindow");
            Application.Run(new MainWindow());
            Debug("Window destroyed. Exiting", Event.Critical);

            if (argv.Any(o => o.Contains("--debug") || o.Contains("-d")))
                NativeMethods.FreeConsole();

            Terminate();
        }

19 Source : DirectoryHelper.cs
with MIT License
from ABTSoftware

public static string GetPathForExport(string defaultPath)
        {
            var isGoodPath = false;
            string ret = null;
            while (!isGoodPath)
            {
                var dialog = new FolderBrowserDialog { SelectedPath = defaultPath };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string error;
                    isGoodPath = HasWriteAccessToFolder(dialog.SelectedPath, out error);
                    if (isGoodPath)
                    {
                        ret = dialog.SelectedPath;
                    }
                    else
                    {
                        MessageBox.Show(error, "SciChart", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
                else
                {
                    isGoodPath = true;
                }
            }

            return ret;
        }

19 Source : OffScreenExportView.xaml.cs
with MIT License
from ABTSoftware

private void OnPickFolder_Clicked(object sender, RoutedEventArgs e)
        {
            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    FolderTxtblck.Text = dialog.SelectedPath;
                }
            }
        }

19 Source : DLLForm.xaml.cs
with GNU General Public License v3.0
from AdhocAdam

private void btn_BrowsePIIHTMLTemplatePath(object sender, RoutedEventArgs e)
        {
            var openFolderDialog = new System.Windows.Forms.FolderBrowserDialog();
            if (openFolderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtHTMLSuggestionTemplates.Text = openFolderDialog.SelectedPath + "\\";
            }
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v2.0
from adrifcastr

private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            using (var ofd = new System.Windows.Forms.OpenFileDialog())
            {
                ofd.Filter = "Audible Audio Files|*.aax";
                ofd.replacedle = "Select an Audible Audio File";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    inputdisplay.Text = ofd.FileName;
                    outputdisplay.Text = Path.GetDirectoryName(ofd.FileName);
                    convertbutton.IsEnabled = true;
                }
            }
            statuslbl.Content = "";
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v2.0
from adrifcastr

private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            using (var fbd = new System.Windows.Forms.FolderBrowserDialog())
            {
                var result = fbd.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    outputdisplay.Text = fbd.SelectedPath;
                    convertbutton.IsEnabled = true;
                }
            }
        }

19 Source : Form_SteamID64_Editor.cs
with MIT License
from Aemony

private void ReadSteamID()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata";
            dlg.Filter = "Data files (*.dat)|*.dat";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                filePath = dlg.FileName;

                if (filePath.Contains("SlotData"))
                {
                    // SlotData files stores the SteamID64 in offset 04-11, GameData and SystemData files stores the SteamID64 in offset 00-07
                    fileOffset = 4;
                }
                else
                {
                    fileOffset = 0;
                }
                
                try {
                    using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                    {
                        stream.Position = fileOffset;
                        stream.Read(byteSteamID64, 0, 8);
                    }


                    // Convert to proper IDs.
                    // SteamID64 is stored as Little-Endian in the files, but as Intel is little-endian as well no reversal is needed
                    steamID3 = BitConverter.ToUInt32(byteSteamID64, 0);
                    textBoxSteamID3.Text = steamID3.ToString();

                    steamID64 = BitConverter.ToUInt64(byteSteamID64, 0);
                    textBoxSteamID64.Text = steamID64.ToString();
#if DEBUG
                    Console.WriteLine("Read: " + BitConverter.ToString(byteSteamID64));
                    Console.WriteLine("SteamID3: " + steamID3.ToString());
                    Console.WriteLine("SteamID64: " + steamID64.ToString());
#endif

                    // Misc
                    textBoxWorkingFile.Text = filePath;
                    textBoxWorkingFile.SelectionStart = textBoxWorkingFile.TextLength;
                    toolStripStatusLabel1.Text = "Read from " + Path.GetFileName(filePath) + ": " + BitConverter.ToString(byteSteamID64);
                    lastStatus = toolStripStatusLabel1.Text;

                    // Check if a new ID is already written, and if so, enable the button
                    if (String.IsNullOrWhiteSpace(textBoxSteamID64_New.Text) == false && String.IsNullOrWhiteSpace(filePath) == false && textBoxSteamID64_New.Text != textBoxSteamID64.Text)
                    {
                        buttonUpdate.Enabled = true;
                    }
                    else
                    {
                        buttonUpdate.Enabled = false;
                    }
                } catch (Exception ex)
                {
                    throw ex;
                }
            }

        }

19 Source : Form1.cs
with GNU General Public License v3.0
from Aemony

private void buttonOpen_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = DialogResult.Yes;

            if (_filePath == null && fastObjectListView1.GereplacedemCount() > 0)
            {
                dialogResult = MessageBox.Show("You already have an inventory list imported. Opening a slot file will discard all unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }
            else if (_filePath != null)
            {
                dialogResult = MessageBox.Show("You already have a file opened. Opening another will discard all unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }

            if (dialogResult == DialogResult.Yes)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
                    Filter = "Save File (SlotData_#.dat)|SlotData_*.dat",
                    replacedle = "Open slot file"
                };

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    _filePath = openFileDialog.FileName;
                    textBoxFilePath.Text = _filePath;
                    textBoxFilePath.SelectionStart = textBoxFilePath.Text.Length;
                    // Ensure that the view is empty
                    fastObjectListView1.ClearObjects();
                    fastObjectListView2.ClearObjects();

                    // Read the file
                    using (Stream stream = openFileDialog.OpenFile())
                    {
                        stream.Position = _intBlockOffset;
                        stream.Read(_byteInventory, 0, _intBlockLength);
                    }

                    // Populate the active/main inventory
                    for (int i = 0; i < 256; i++)
                    {
                        _itemInventoryActive[i] = new Item
                        {
                            Slot = i,
                            ID = BitConverter.ToUInt32(_byteInventory, i * 12),
                            Status = BitConverter.ToUInt32(_byteInventory, i * 12 + 4),
                            Amount = BitConverter.ToUInt32(_byteInventory, i * 12 + 8)
                        };
                    }

                    // Populate the inactive/corpse inventory
                    for (int i = 256; i < 512; i++)
                    {
                        _itemInventoryCorpse[i - 256] = new Item
                        {
                            Slot = i - 256,
                            ID = BitConverter.ToUInt32(_byteInventory, i * 12),
                            Status = BitConverter.ToUInt32(_byteInventory, i * 12 + 4),
                            Amount = BitConverter.ToUInt32(_byteInventory, i * 12 + 8)
                        };
                    }

#if DEBUG
                Console.WriteLine("Read:");
                Console.WriteLine(BitConverter.ToString(_byteInventory));
#endif
                    
                    // Populate the view
                    fastObjectListView1.SetObjects(_itemInventoryActive);
                    fastObjectListView2.SetObjects(_itemInventoryCorpse);

                    // Enable the buttons
                    buttonSave.Enabled = true;
                    buttonResetActive.Enabled = true;
                    buttonResetCorpse.Enabled = true;
                    buttonExport.Enabled = true;

                    // Finally update the background stuff to reflect the new file
                    _byteInventoryImportedActive = null;
                    _byteInventoryImportedCorpse = null;
                    textBoxInventoryPath.Text = "No inventory list imported...";
                }
            }
        }

19 Source : Form1.cs
with GNU General Public License v3.0
from Aemony

private void buttonExport_Click(object sender, EventArgs e)
        {
            byte[] byteInventoryExport = new byte[_intBlockLength];

            for (int i = 0; i < 256; i++)
            {
                BitConverter.GetBytes(_itemInventoryActive[i].ID).CopyTo(byteInventoryExport, i * 12);
                BitConverter.GetBytes(_itemInventoryActive[i].Status).CopyTo(byteInventoryExport, i * 12 + 4);
                BitConverter.GetBytes(_itemInventoryActive[i].Amount).CopyTo(byteInventoryExport, i * 12 + 8);
            }

            for (int i = 256; i < 512; i++)
            {
                BitConverter.GetBytes(_itemInventoryCorpse[i - 256].ID).CopyTo(byteInventoryExport, i * 12);
                BitConverter.GetBytes(_itemInventoryCorpse[i - 256].Status).CopyTo(byteInventoryExport, i * 12 + 4);
                BitConverter.GetBytes(_itemInventoryCorpse[i - 256].Amount).CopyTo(byteInventoryExport, i * 12 + 8);
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
                replacedle = "Export inventory to file",
                Filter = "Binary Data (*.bin)|*.bin|All Files|*",
                FileName = "inventory.bin"
            };

            if(saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                // Now export the data
                using (Stream stream = saveFileDialog.OpenFile())
                {
                    stream.Position = 0;
                    stream.Write(byteInventoryExport, 0, _intBlockLength);
                }
                
#if DEBUG
                Console.WriteLine("Wrote:");
                Console.WriteLine(BitConverter.ToString(byteInventoryExport));
#endif

                MessageBox.Show("Inventory was exported!", "Export complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

19 Source : Form1.cs
with GNU General Public License v3.0
from Aemony

private void buttonImport_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = DialogResult.Yes;

            if (_filePath != null && fastObjectListView1.GereplacedemCount() > 0)
            {
                dialogResult = MessageBox.Show("You already have a slot file opened. Importing an inventory list will overwrite the one from the slot file and discard any unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            } else if (_byteInventoryImportedActive != null || _byteInventoryImportedCorpse != null)
            {
                dialogResult = MessageBox.Show("You already have an inventory list imported. Importing another will discard any unsaved changes.\n\nAre you sure you want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
            }

            if(dialogResult == DialogResult.Yes)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents) + "\\My Games\\NieR_Automata",
                    Filter = "Binary Data (*.bin)|*.bin|All Files|*",
                    replacedle = "Import inventory to editor",
                    FileName = "inventory.bin"
                };

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    FileInfo fileInfo = new FileInfo(openFileDialog.FileName);

                    if(fileInfo.Length == _intBlockLength)
                    {
                        // Initialize the array if it isn't
                        if (_byteInventoryImportedActive == null)
                        {
                            _byteInventoryImportedActive = new byte[_intBlockLength/2];
                        }
                        if (_byteInventoryImportedCorpse == null)
                        {
                            _byteInventoryImportedCorpse = new byte[_intBlockLength/2];
                        }

                        // Read file
                        using (Stream stream = openFileDialog.OpenFile())
                        {
                            stream.Position = 0;
                            stream.Read(_byteInventoryImportedActive, 0, _intBlockLength/2);
                            stream.Read(_byteInventoryImportedCorpse, 0, _intBlockLength/2);
                        }

                        // Populate the active/main inventory
                        for (int i = 0; i < 256; i++)
                        {
                            _itemInventoryActive[i] = new Item
                            {
                                Slot = i,
                                ID = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12),
                                Status = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12 + 4),
                                Amount = BitConverter.ToUInt32(_byteInventoryImportedActive, i * 12 + 8)
                            };
                        }

                        // Populate the inactive/corpse inventory
                        for (int i = 0; i < 256; i++)
                        {
                            _itemInventoryCorpse[i] = new Item
                            {
                                Slot = i,
                                ID = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12),
                                Status = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12 + 4),
                                Amount = BitConverter.ToUInt32(_byteInventoryImportedCorpse, i * 12 + 8)
                            };
                        }

#if DEBUG
                Console.WriteLine("Read:");
                        Console.WriteLine(BitConverter.ToString(_byteInventoryImportedActive) + BitConverter.ToString(_byteInventoryImportedCorpse));
#endif

                        // Ensure that the view is empty
                        fastObjectListView1.ClearObjects();
                        fastObjectListView2.ClearObjects();

                        // Populate the view
                        fastObjectListView1.SetObjects(_itemInventoryActive);
                        fastObjectListView2.SetObjects(_itemInventoryCorpse);

                        // Enable the buttons
                        buttonExport.Enabled = true;

                        // List the path
                        textBoxInventoryPath.Text = openFileDialog.FileName;
                        textBoxInventoryPath.SelectionStart = openFileDialog.FileName.Length;
                    }
                    else
                    {
                        MessageBox.Show("Wrong size of the file you are trying to import!", "Import canceled", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

19 Source : Program.cs
with MIT License
from Aeroblast

[STAThread]
        static void Main(string[] args)
        {
#if !DEBUG
            try
            {
#endif
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                if (args.Length > 0)
                    if (File.Exists(args[0]))
                    {
                        ReadBook(args[0]);
                    }
                    else { MessageBox.Show("文件不存在:" + args[0]); }
                else
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.Multiselect = false;
                    dialog.replacedle = "请选择书";
                    dialog.Filter = "ePUB电子书(*.epub)|*.epub";
                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ReadBook(dialog.FileName);
                    }
                }
                try
                {
                    Util.DeleteDir(cachePath);
                }
                catch (Exception) { }
#if !DEBUG
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
#endif
        }

19 Source : ConfigIoModel.cs
with Mozilla Public License 2.0
from agebullhu

public void Save()
        {
            Context.StateMessage = "正在保存...";
            if (Context.FileName == null)
            {
                var sfd = new SaveFileDialog
                {
                    Filter = fileType
                };
                if (sfd.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
            }
            SaveSolution();
        }

19 Source : ConfigIoModel.cs
with Mozilla Public License 2.0
from agebullhu

public void CreateNew()
        {
            var sfd = new SaveFileDialog
            {
                Filter = fileType
            };
            if (sfd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            Context.Solution = new SolutionConfig
            {
                Name = Path.GetFileNameWithoutExtension(sfd.FileName),
                Caption = Path.GetFileNameWithoutExtension(sfd.FileName),
                SaveFileName=sfd.FileName 
            };
            DataModelDesignModel.Screen.LastFile = sfd.FileName;
            SaveSolution();
            Load(sfd.FileName);
            DataModelDesignModel.SaveUserScreen();
        }

19 Source : MainWindow.xaml.cs
with MIT License
from AgileoAutomation

private void replacedysis_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "SpreadSheets (*.xlsx) | *.xlsx";
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    SpreadsheetDoreplacedent spreadsheetDoreplacedent = SpreadsheetDoreplacedent.Open(dialog.FileName, false);
                    workbookPart = spreadsheetDoreplacedent.WorkbookPart;
                }
                catch
                {
                    System.Windows.MessageBox.Show("The specification file is open in a other process");
                }

                SheetData sheetData = null;

                try
                {
                    Sheet sheet = workbookPart.Workbook.Sheets.ChildElements.Cast<Sheet>().First(x => x.Name == "replacedembly Specification");
                    int index = workbookPart.WorksheetParts.ToList().IndexOf(workbookPart.WorksheetParts.Last()) - workbookPart.Workbook.Sheets.ToList().IndexOf(sheet);
                    sheetData = workbookPart.WorksheetParts.ElementAt(index).Worksheet.Elements<SheetData>().First();
                }
                catch
                {
                    System.Windows.MessageBox.Show("Invalid specification file :\nCouldn't find the 'replacedembly Specification' worksheet");
                }

                List<Row> rows = sheetData.Elements<Row>().ToList();
                List<Cell> headerRow = rows.First().Elements<Cell>().ToList();
                rows.RemoveAll(x => !x.Elements<Cell>().Any(y => !string.IsNullOrEmpty(TextInCell(y))));

                string replacedemblyName;

                if (headerRow.Any(x => TextInCell(x) == "Signed"))
                {
                    List<SignatureSpecification> sigspecs = new List<SignatureSpecification>();
                    int sigIndex = headerRow.IndexOf(headerRow.First(x => TextInCell(x) == "Signed"));

                    foreach (Row r in rows)
                    {
                        List<Cell> row = r.Elements<Cell>().ToList();
                        replacedemblyName = TextInCell(row.ElementAt(0));
                        sigspecs.Add(new SignatureSpecification(replacedemblyName, TextInCell(row.ElementAt(sigIndex)) == "x"));
                    }

                    Signaturereplacedyzer sigreplacedyzer = new Signaturereplacedyzer();
                    sigreplacedyzer.replacedyze(Model, sigspecs);
                }

                if (headerRow.Any(x => TextInCell(x) == "Obfuscated"))
                {
                    List<ObfuscationSpecification> obfuscationspecs = new List<ObfuscationSpecification>();
                    int obIndex = headerRow.IndexOf(headerRow.First(x => TextInCell(x) == "Obfuscated"));

                    foreach (Row r in rows)
                    {
                        List<Cell> row = r.Elements<Cell>().ToList();
                        replacedemblyName = TextInCell(row.ElementAt(0));
                        obfuscationspecs.Add(new ObfuscationSpecification(replacedemblyName, TextInCell(row.ElementAt(obIndex)) == "x"));
                    }

                    Obfuscationreplacedyzer obfuscationreplacedyzer = new Obfuscationreplacedyzer();
                    obfuscationreplacedyzer.replacedyze(Model, obfuscationspecs);
                }

                Model.SoftwareComponents.Where(x => x.Name != "System replacedemblies").ToList().ForEach(x => ModelCommonDataOrganizer.UpdateGroups(Model, x));
                UpdateTreeView();
                UpdateErrorNodes(GraphViewer.Graph);
                replacedysis.Visibility = Visibility.Hidden;
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                Filter = "Star Manager Layout (*.jsml)|*.jsml|All files (*.*)|*.*",
                FilterIndex = 1,
                RestoreDirectory = false,
                InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + "\\layout"
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    SaveLayout(saveFileDialog.FileName);
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to save layout!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void loadROMToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "ROM Files (*.z64)|*.z64",
                FilterIndex = 1,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    rm = new ROMManager(openFileDialog.FileName);
                    InvalidateCache();
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to load rom!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void importIconsFromROMToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (mm.IsDecomp)
            {
                MessageBox.Show("Cannot import replacedets from decomp ROMs", "Decomp Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "ROM Files (*.z64)|*.z64",
                FilterIndex = 1,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ROMManager rm = new ROMManager(openFileDialog.FileName);
                    if (rm == null) throw new IOException();
                    Bitmap image = rm.GetStarImage();
                    ld = new LayoutDescriptionEx(ld.courseDescription, ld.secretDescription, image, ld.starAmount, ld.starsShown);
                    InvalidateCache();
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to import star icons!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

19 Source : MainWindow.xaml.cs
with MIT License
from AgileoAutomation

private void open_Click(object sender, RoutedEventArgs e)
        {
            AllowDrop = false;
            FolderBrowserDialog dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DirectoryInfo directory = new DirectoryInfo(dialog.SelectedPath);
                if (directory.Exists
                    && directory.GetFiles().Any(x => x.Extension == ".dll" || x.Extension == ".exe"))
                {
                    SpecWindow = new SpecificationWindow();
                    SpecWindow.ShowDialog();

                    if (SpecWindow.OKClicked)
                    {
                        while (SpecWindow.OKClicked && !BuildAndDisplay(directory))
                        {
                            SpecWindow = new SpecificationWindow();
                            SpecWindow.ShowDialog();
                        }
                    }
                }
                else
                    System.Windows.MessageBox.Show("Invalid Directory");
            }
            AllowDrop = true;
        }

19 Source : DrawActions.cs
with GNU General Public License v3.0
from aglab2

public static int DrawConfigs(int height, ActionMaskForm amf)
        {
            CheckBox cb = new CheckBox
            {
                Name = configureName,
                Text = configureReadableName,
                Location = new Point(10, height),
                Checked = amf.sm.GetConfig(configureName, false),
                AutoSize = true
            };
            height += cb.Height;

            TextBox tb = new TextBox
            {
                Name = pathConfigureName,
                Text = amf.sm.GetConfig(pathConfigureName, ""),
                Location = new Point(30, height),
                AutoSize = true,
                Width = 120
            };

            Button b = new Button
            {
                Name = "backgroundPathButton",
                Text = ".",
                Location = new Point(160, height - 1),
                AutoSize = true,
                Width = 20,
                Height = tb.Height
            };

            cb.CheckedChanged += (sender, e) => {
                CheckBox cb_local = sender as CheckBox;
                amf.sm.SetConfig(cb_local.Name, cb_local.Checked);
            };
            tb.TextChanged += (sender, e) => {
                TextBox tb_local = sender as TextBox;
                amf.sm.SetConfig(tb_local.Name, tb_local.Text);
            };
            b.Click += (sender, e) =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog
                {
                    Filter = "PNG Images (*.png)|*.png",
                    FilterIndex = 1,
                    RestoreDirectory = true
                };

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    tb.Text = openFileDialog.FileName;
                }
            };

            amf.Controls.Add(cb);
            amf.Controls.Add(tb);
            amf.Controls.Add(b);

            return cb.Height + tb.Height + 10;
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void importStarMasksToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (mm.IsDecomp)
            {
                MessageBox.Show("Cannot parse decomp ROMs", "Decomp Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "ROM Files (*.z64)|*.z64",
                FilterIndex = 1,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ROMManager rm = new ROMManager(openFileDialog.FileName);
                    rm.ParseStars(ld);
                    rm.Dispose();
                    InvalidateCache();
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to import star masks!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void loadCustomFontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "Font file (*.ttf)|*.ttf",
                FilterIndex = 1,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    PrivateFontCollection collection = new PrivateFontCollection();
                    collection.AddFontFile(openFileDialog.FileName);
                    FontFamily[] fontFamilies = collection.Families;
                    FontFamily fontFamily = fontFamilies.First();
                    if (fontFamily == null) return;

                    gm.Collection = collection;
                    gm.FontFamily = fontFamily;
                    gm.FontName = fontFamily.Name;
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to load layout!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            InvalidateCache();
        }

19 Source : SpecificationWindow.xaml.cs
with MIT License
from AgileoAutomation

private void Browse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "All specifications files (*.json;*.xlsx)|*.json;*.xlsx|JSON files (*.json)|*.json|Excel files (*.xlsx)|*.xlsx";
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox.Text = dialog.FileName;
            }
        }

19 Source : MainWindow.cs
with GNU General Public License v3.0
from aglab2

private void loadFromToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "Star Manager Layout (*.sml,*.jsml,*.txt)|*.sml;*.jsml;*.txt|All files (*.*)|*.*",
                FilterIndex = 1,
                RestoreDirectory = false,
                InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath) + "\\layout"
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    LoadLayout(openFileDialog.FileName, true);
                }
                catch (IOException)
                {
                    MessageBox.Show("Failed to load layout!", "Layour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

19 Source : AudioViewController.cs
with GNU General Public License v3.0
from ahmed605

private void View_ExportWAVClicked(object sender, EventArgs e)
        {
            AudioWave wave = _view.SelectedWave;
            if (wave != null)
            {
                var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    OverwritePrompt = true,
                    replacedle = "Export Selected WAV",
                    Filter = "WAV Audio File (*.wav)|*.wav",
                    InitialDirectory = _lastSaveDirectory,
                    FileName = wave + ".wav"
                };

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    using (var f = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
                    {
                        WaveExport.Export(_file, wave, f);
                    }

                    _lastSaveDirectory = new FileInfo(sfd.FileName).Directory.FullName;

                    MessageBox.Show("Audio exported.", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

        }

19 Source : AudioViewController.cs
with GNU General Public License v3.0
from ahmed605

private void View_ExportMultichannelWAVClicked(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog
            {
                AddExtension = true,
                OverwritePrompt = true,
                replacedle = "Export Multichannel WAV",
                Filter = "WAV Audio File (*.wav)|*.wav",
                InitialDirectory = _lastSaveDirectory,
                FileName = _file.Name + ".wav",
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                using (var f = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write))
                {
                    WaveExport.ExportMultichannel(_file, f);
                }

                _lastSaveDirectory = new FileInfo(sfd.FileName).Directory.FullName;

                MessageBox.Show("Audio exported.", "Export", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

19 Source : TexturePreviewController.cs
with GNU General Public License v3.0
from ahmed605

private void View_SaveAllClicked(object sender, EventArgs e)
        {
            var fbd = new FolderBrowserDialog
            {
                Description = "Select path to save textures to...",
                SelectedPath = _lastSaveDirectory,
                ShowNewFolderButton = true
            };

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                foreach (var texture in _textureViewController.TextureFile)
                {
                    var image = texture.Decode();
                    image.Save(Path.Combine(fbd.SelectedPath, texture.replacedleName + ".png"), ImageFormat.Png);
                }

                MessageBox.Show("Textures saved.", "Save All Textures", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

19 Source : ModelViewController.cs
with GNU General Public License v3.0
from ahmed605

private void View_ExportClicked(object sender, EventArgs e)
        {
            var model = _rootModelNode;
            if (model != null)
            {
                var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    OverwritePrompt = true,
                    replacedle = "Export Model",
                    Filter = Export.ExportFactory.GenerateFilterString(),
                    InitialDirectory = _workingDirectory,
                };

                if (sfd.ShowDialog() == DialogResult.OK && sfd.FilterIndex > 0)
                {
                    Export.IExporter exporter = Export.ExportFactory.GetExporter(sfd.FilterIndex - 1);
                    exporter.Export( model, sfd.FileName );

                    _workingDirectory = new FileInfo(sfd.FileName).Directory.FullName;
                }
            }
        }

19 Source : TexturePreviewController.cs
with GNU General Public License v3.0
from ahmed605

private void View_SaveClicked(object sender, EventArgs e)
        {
            var texture = _view.TextureView.SelectedTexture;
            if (texture != null)
            {
                var sfd = new SaveFileDialog
                {
                    AddExtension = true,
                    OverwritePrompt = true,
                    replacedle = "Save Texture",
                    Filter = "Portable Network Graphics (*.png)|*.png|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg",
                    InitialDirectory = _lastSaveDirectory,
                    FileName = texture.replacedleName + ".png"
                };

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    var image = texture.Decode();

                    var format = ImageFormat.Png;
                    if (sfd.FileName.EndsWith(".jpg") || sfd.FileName.EndsWith(".jpeg"))
                    {
                        format = ImageFormat.Jpeg;
                    }

                    image.Save(sfd.FileName, format);

                    _lastSaveDirectory = new FileInfo(sfd.FileName).Directory.FullName;

                    MessageBox.Show("Texture saved.", "Save Texture", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from ahmed605

private void tsbOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.replacedle = "Open IV Archive";
            ofd.Filter = "All Supported IV Archives|*.rpf;*.img|RPF Files (*.rpf)|*.rpf|IMG Files (*.img)|*.img";
            ofd.FileName = _lastOpenPath;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                _lastOpenPath = ofd.FileName;

                FileSystem fs = null;

                if (ofd.FilterIndex == 2)
                {
                    fs = new RPFFileSystem();
                }
                else if (ofd.FilterIndex == 3)
                {
                    fs = new IMGFileSystem();
                }
                else
                {
                    if (ofd.FileName.EndsWith(".rpf"))
                    {
                        fs = new RPFFileSystem();
                    }
                    else if (ofd.FileName.EndsWith(".img"))
                    {
                        fs = new IMGFileSystem();
                    }
                    else
                    {
                        MessageBox.Show("Please select a type for the file you are trying to open.", "Open IV Archive", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                OpenFile(ofd.FileName, fs);
            }

        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from ahmed605

private void tsbExportSelected_Click(object sender, EventArgs e)
        {
            if (_fs == null) return;

            if (lvFiles.SelectedItems.Count == 1)
            {
                File file = lvFiles.SelectedItems[0].Tag as File;

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.replacedle = "Export...";

                if (_lastImportExportPath != null)
                {
                    sfd.InitialDirectory = _lastImportExportPath;
                    sfd.FileName = Path.Combine(_lastImportExportPath, file.Name);
                }
                else
                {
                    sfd.FileName = file.Name;
                }


                sfd.OverwritePrompt = true;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    _lastImportExportPath = IODirectory.GetParent(sfd.FileName).FullName;

                    using (new WaitCursor(this))
                    {
                        byte[] data = file.GetData();
                        IOFile.WriteAllBytes(sfd.FileName, data);
                    }
                }
            }
            else if (lvFiles.SelectedItems.Count > 1)
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                fbd.Description = "Export Selected...";
                fbd.ShowNewFolderButton = true;
                fbd.SelectedPath = _lastImportExportPath;

                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    _lastImportExportPath = fbd.SelectedPath;

                    string path = fbd.SelectedPath;

                    using (new WaitCursor(this))
                    {
                        foreach (ListViewItem item in lvFiles.SelectedItems)
                        {
                            File file = item.Tag as File;
                            byte[] data = file.GetData();
                            IOFile.WriteAllBytes(Path.Combine(path, file.Name), data);
                        }
                    }

                    MessageBox.Show("All selected files exported.", "Export Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

19 Source : MainForm.cs
with GNU General Public License v3.0
from ahmed605

private void tsbExportAll_Click(object sender, EventArgs e)
        {
            if (_fs == null) return;

            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "Export All...";
            fbd.ShowNewFolderButton = true;
            fbd.SelectedPath = _lastImportExportPath;

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                _lastImportExportPath = fbd.SelectedPath;

                string path = fbd.SelectedPath;
                if (!path.EndsWith("\\")) path += "\\";

                using (new WaitCursor(this))
                {
                    ExtractToPath(_fs.RootDirectory, path);
                }

                MessageBox.Show("All files in archive exported.", "Export All", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

See More Examples