public void OpenFileDialog(UCCanvas canvas) { try { if (!IsNeedToSave(canvas)) { return; } List <FigureBaseModel> figures = null; FigureFilePreview figurePreview = new FigureFilePreview(); OpenFileDialogEx open = new OpenFileDialogEx(); open.Filter = "所有文件(*.*)|*.WXF;*.DXF;|WSX默认切割文件(*.WXF)|*.WXF|AutoCAD图形文件(*.DXF)|*.DXF"; open.PreviewControl = figurePreview; open.OnFileSelectChanged += (s, e) => { if (figurePreview.IsPreView) { figures = ParseFigureFile(e.Path); figurePreview.FigurePreview(figures); } else { figurePreview.FigurePreview(new List <FigureBaseModel>()); } }; if (open.ShowDialog() == DialogResult.OK) { OpenFile(open.FileName, canvas, false, figures); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OnClickKeyFileBrowse(object sender, EventArgs e) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileUseExisting, UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true), 2, null, false, AppDefs.FileDialogContext.KeyFile); if (ofd.ShowDialog() == DialogResult.OK) { string strFile = ofd.FileName; // try // { // IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); // if(ioc.IsLocalFile()) // { // FileInfo fi = new FileInfo(strFile); // if(fi.Length >= (100 * 1024 * 1024)) // { // } // } // } // catch(Exception) { Debug.Assert(false); } m_cmbKeyFile.Items.Add(strFile); m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1; } EnableUserControls(); }
private void btnAddNewMaterial_Click(object sender, EventArgs e) { string accessoryPath; string sampleImagePath; using (var ofd = new OpenFileDialogEx("Select new accessory..", "OBJ files|*.obj")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } accessoryPath = ofd.FileName; } using (var ofd = new OpenFileDialogEx("Select accessory image..", "Image files|*.jpg")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } sampleImagePath = ofd.FileName; } var directoryPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Libraries", "Accessory"); var oldFileName = Path.GetFileNameWithoutExtension(accessoryPath); var newFileName = oldFileName; var filePath = Path.Combine(directoryPath, newFileName + ".obj"); var index = 0; while (File.Exists(filePath)) { newFileName = oldFileName + string.Format("_{0}", index); filePath = Path.Combine(directoryPath, newFileName + ".obj"); ++index; } File.Copy(accessoryPath, filePath, false); var mtl = oldFileName + ".mtl"; var newMtlName = newFileName + ".mtl"; ObjLoader.CopyMtl(mtl, newMtlName, Path.GetDirectoryName(accessoryPath), "", directoryPath, ProgramCore.Project.TextureSize); if (mtl != newMtlName) // situation, when copy attribute and can change mtl filename. so, we need to rename link to this mtl in main obj file { string lines; using (var sd = new StreamReader(filePath, Encoding.Default)) { lines = sd.ReadToEnd(); lines = lines.Replace(mtl, newMtlName); } using (var sw = new StreamWriter(filePath, false, Encoding.Default)) sw.Write(lines); } var samplePath = Path.Combine(directoryPath, newFileName + ".jpg"); File.Copy(sampleImagePath, samplePath, false); InitializeListView(); }
private void btnAddNewMaterial_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialogEx("Select new material..", "Image files|*.jpg")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } var directoryPath = Path.Combine(UserConfig.DocumentsDir, "Materials"); var oldFileName = Path.GetFileNameWithoutExtension(ofd.FileName); var newFileName = oldFileName; var filePath = Path.Combine(directoryPath, newFileName + ".jpg"); var index = 0; while (File.Exists(filePath)) { newFileName = oldFileName + string.Format("_{0}", index); filePath = Path.Combine(directoryPath, newFileName + ".jpg"); ++index; } File.Copy(ofd.FileName, filePath, false); InitializeListView(); } }
private void btnImport_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialogEx("Import styles settings", "Text file(*.txt)|*.txt")) { if (ofd.ShowDialog() != DialogResult.OK) { return; } using (var reader = new StreamReader(ofd.FileName, Encoding.Default)) { while (!reader.EndOfStream) { var path = reader.ReadLine(); var size = reader.ReadLine(); var position = reader.ReadLine(); if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(size) || string.IsNullOrEmpty(position)) { continue; } UserConfig.ByName("Parts")[path, "Size"] = size; UserConfig.ByName("Parts")[path, "Position"] = position; } } } MessageBox.Show("Styles settings imported!", "Done"); }
private void btnOpenFileDlg_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialogEx("Select template file", "Image Files|*.jpg;*.png;*.jpeg;*.bmp")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } textTemplateImage.Text = ofd.FileName; using (var bmp = new Bitmap(ofd.FileName)) pictureTemplate.Image = (Bitmap)bmp.Clone(); MouthRelative = new Vector2(pictureTemplate.Image.Width * 0.5f, pictureTemplate.Image.Height / 1.5f); // примерно расставляем глаз и рот EyeRelative = new Vector2(pictureTemplate.Image.Width * 0.5f, pictureTemplate.Image.Height * 0.2f); MouthRelative = new Vector2(MouthRelative.X / (pictureTemplate.Image.Width * 1f), MouthRelative.Y / (pictureTemplate.Image.Height * 1f)); EyeRelative = new Vector2(EyeRelative.X / (pictureTemplate.Image.Width * 1f), EyeRelative.Y / (pictureTemplate.Image.Height * 1f)); btnApply.Enabled = true; RecalcRealTemplateImagePosition(); RenderTimer.Start(); } }
private string SelectImageFile(string parnFnOld = null) { string imageName = null; try { imageName = OpenFileDialogEx.GetOpenFileName("选择图片", "图片文件|*.gif;*.jpeg;*.jpg;*.png;*.tif;*.tiff", null); if (!string.IsNullOrEmpty(imageName)) { if (FileEx.IsFileLengthMoreKB(imageName, 1024)) { throw new Exception("图片大小不能超过1MB"); } BitmapImage bitmapImage; if (!BitmapImageEx.TryCreateFromFile(imageName, out bitmapImage)) { throw new Exception("无法解析图片,请选择正常的图片"); } imageName = ShortcutImageHelper.AddNewImage(imageName, parnFnOld); } } catch (Exception ex) { Log.Exception(ex); MsgBox.ShowErrTip(ex.Message, null); } return(imageName); }
private void rbImportObj_CheckedChanged(object sender, EventArgs e) { if (rbImportObj.Checked) { btnFemale.Tag = btnChild.Tag = btnMale.Tag = "2"; btnChild.Image = Properties.Resources.btnChildGray; btnMale.Image = Properties.Resources.btnMaleGray; btnFemale.Image = Properties.Resources.btnFemaleGray; if (!ProgramCore.PluginMode) { using (var ofd = new OpenFileDialogEx("Select obj file", "OBJ Files|*.obj")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { btnNext.Enabled = false; return; } btnNext.Enabled = true; CustomModelPath = ofd.FileName; } } } }
public DialogResult ShowOpenFileDialog(IWin32Window owner) { _OpenFile = new OpenFileDialogEx(); _OpenFile.Filter = Strings.ICON_FILTER; _OpenFile.Title = Strings.CHANGE_ICON; _OpenFile.SelectionChanged += (s, e) => OnFileNameChanged(_OpenFile.FileName); return(_OpenFile.ShowDialog(this, owner)); }
public OpenDialogNative(IntPtr handle, OpenFileDialogEx sourceControl, IntPtr parentHandle, string lable_OpenFloder, string lable_SelectTexg, string lable_CancelText) { this.Lable_OpenFloder = lable_OpenFloder; this.Lable_SelectTexg = lable_SelectTexg; this.Lable_CancelText = lable_CancelText; this.ParentHandle = parentHandle; this.mOpenDialogHandle = handle; this.mSourceControl = sourceControl; this.AssignHandle(this.mOpenDialogHandle); }
public override bool Export(PwExportInfo pwExportInfo, Stream sOutput, IStatusLogger slLogger) { string strFilter = UIUtil.CreateFileTypeFilter("xsl", KPRes.XslFileType, true); OpenFileDialogEx dlgXsl = UIUtil.CreateOpenFileDialog(KPRes.XslSelectFile, strFilter, 1, "xsl", false, AppDefs.FileDialogContext.Xsl); if (dlgXsl.ShowDialog() != DialogResult.OK) { return(false); } string strXslFile = dlgXsl.FileName; XslCompiledTransform xsl = new XslCompiledTransform(); try { xsl.Load(strXslFile); } catch (Exception exXsl) { throw new NotSupportedException(strXslFile + MessageService.NewParagraph + KPRes.NoXslFile + MessageService.NewParagraph + exXsl.Message); } MemoryStream msDataXml = new MemoryStream(); PwDatabase pd = (pwExportInfo.ContextDatabase ?? new PwDatabase()); KdbxFile kdb = new KdbxFile(pd); kdb.Save(msDataXml, pwExportInfo.DataGroup, KdbxFormat.PlainXml, slLogger); byte[] pbData = msDataXml.ToArray(); msDataXml.Close(); MemoryStream msDataRead = new MemoryStream(pbData, false); XmlReader xmlDataReader = XmlReader.Create(msDataRead); XmlWriterSettings xws = new XmlWriterSettings(); xws.CheckCharacters = false; xws.Encoding = new UTF8Encoding(false); xws.NewLineChars = MessageService.NewLine; xws.NewLineHandling = NewLineHandling.None; xws.OmitXmlDeclaration = true; xws.ConformanceLevel = ConformanceLevel.Auto; XmlWriter xmlWriter = XmlWriter.Create(sOutput, xws); xsl.Transform(xmlDataReader, xmlWriter); xmlWriter.Close(); xmlDataReader.Close(); msDataRead.Close(); Array.Clear(pbData, 0, pbData.Length); return(true); }
public static bool?Synchronize(PwDatabase pwStorage, IUIOperations uiOps, bool bOpenFromUrl, Form fParent) { if (pwStorage == null) { throw new ArgumentNullException("pwStorage"); } if (!pwStorage.IsOpen) { return(null); } if (!AppPolicy.Try(AppPolicyId.Import)) { return(null); } List <IOConnectionInfo> vConnections = new List <IOConnectionInfo>(); if (bOpenFromUrl == false) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.Synchronize, UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt, KPRes.KdbxFiles, true), 1, null, true, AppDefs.FileDialogContext.Sync); if (ofd.ShowDialog() != DialogResult.OK) { return(null); } foreach (string strSelFile in ofd.FileNames) { vConnections.Add(IOConnectionInfo.FromPath(strSelFile)); } } else // Open URL { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(false, null, true, true); if (UIUtil.ShowDialogNotValue(iocf, DialogResult.OK)) { return(null); } vConnections.Add(iocf.IOConnectionInfo); UIUtil.DestroyForm(iocf); } return(Import(pwStorage, new KeePassKdb2x(), vConnections.ToArray(), true, uiOps, false, fParent)); }
private void OnClickKeyFileBrowse(object sender, EventArgs e) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileUseExisting, UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true), 2, null, false, null); if (ofd.ShowDialog() == DialogResult.OK) { string str = ofd.FileName; } EnableUserControls(); }
private static string UIGetXslFile() { string strFilter = UIUtil.CreateFileTypeFilter("xsl", KPRes.XslFileType, true); OpenFileDialogEx dlgXsl = UIUtil.CreateOpenFileDialog(KPRes.XslSelectFile, strFilter, 1, "xsl", false, AppDefs.FileDialogContext.Xsl); if (dlgXsl.ShowDialog() != DialogResult.OK) { return(null); } return(dlgXsl.FileName); }
public void LoadPhoto() { using (var ofd = new OpenFileDialogEx("Select template file", "Image Files|*.jpg;*.png;*.jpeg;*.bmp")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } templateImage = ofd.FileName; Recognizer = new LuxandFaceRecognition(); if (!Recognizer.Recognize(ref templateImage, true)) { templateImage = string.Empty; pictureTemplate.Image = null; return; // это ОЧЕНЬ! важно. потому что мы во время распознавания можем создать обрезанную фотку и использовать ее как основную в проекте. } using (var ms = new MemoryStream(File.ReadAllBytes(templateImage))) // Don't use using!! { var img = (Bitmap)Image.FromStream(ms); pictureTemplate.Image = (Bitmap)img.Clone(); img.Dispose(); } RecalcRealTemplateImagePosition(); var eWidth = pictureTemplate.Width - 100; var TopEdgeTransformed = new RectangleF(pictureTemplate.Width / 2f - eWidth / 2f, 30, eWidth, eWidth); // затычка. нужен будет подгон верхней части бошки - сделаю var minX = Recognizer.GetMinX(); var topPoint = (TopEdgeTransformed.Y - ImageTemplateOffsetY) / ImageTemplateHeight; Recognizer.FaceRectRelative = new RectangleF(minX, topPoint, Recognizer.GetMaxX() - minX, Recognizer.BottomFace.Y - topPoint); var noseTip = Recognizer.FacialFeatures[2].Xy; var noseTop = Recognizer.FacialFeatures[22].Xy; var noseBottom = Recognizer.FacialFeatures[49].Xy; ProgramCore.MainForm.RenderControl.PhotoLoaded(Recognizer, TemplateImage); RenderTimer.Start(); if (Math.Abs(Recognizer.RotatedAngle) > 20) { MessageBox.Show("The head rotated more than 20 degrees. Please select an other photo..."); } } }
private void OnDatabaseBrowse(object sender, EventArgs e) { string strTitle = "Choose database"; string strDesc = KPRes.KdbxFiles; string strFilterExt = AppDefs.FileExtension.FileExt; string strContext = AppDefs.FileDialogContext.Database; string strFilter = UIUtil.CreateFileTypeFilter(strFilterExt, strDesc, false); OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(strTitle, strFilter, 1, null, false, strContext); if (ofd.ShowDialog() == DialogResult.OK) { databaseLocationValue.Text = ofd.FileName; } }
private void OnClickKeyFileBrowse(object sender, EventArgs e) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileUseExisting, UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true), 2, null, false, AppDefs.FileDialogContext.KeyFile); if (ofd.ShowDialog() == DialogResult.OK) { string str = ofd.FileName; m_cmbKeyFile.Items.Add(str); m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1; } EnableUserControls(); }
private void SelectFile(string oldFileName = null) { var fileName = OpenFileDialogEx.GetOpenFileName("选择【快捷短语】文件", "CSV格式话术文件(*.csv)|*.csv", oldFileName); if (!string.IsNullOrEmpty(fileName) && fileName != oldFileName) { this.wtboxFilename.Text = fileName; var dbAccount = this.GetDbAccount(fileName); if (!string.IsNullOrEmpty(dbAccount)) { this.SetImportDataType(dbAccount); this.ImportOtherNickDataTip(dbAccount); } } }
private void btnOpenFileDlg_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialogEx("Select template file", "Image Files|*.jpg;*.png;*.jpeg;*.bmp")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } textTemplateImage.Text = ofd.FileName; using (var bmp = new Bitmap(ofd.FileName)) pictureTemplate.Image = (Bitmap)bmp.Clone(); } }
public override byte[] GetKey(KeyProviderQueryContext ctx) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } // The key file is expected to be next to the database by default: var keyFilePath = UrlUtil.StripExtension(ctx.DatabasePath) + DefaultKeyExtension; CertificateShortcutProviderKey cspKey; if (ctx.CreatingNewKey) { // Always return null, so that it's not possible to accidentally create a composite key with this provider. MessageBox.Show("Certificate Shortcut Provider uses the encrypted master key to access the database. There is no initialization needed other than the master key.\n\nUse 'Options > Initialize Certificate Shortcut Provider...' from the menu to create the encrypted master key.", Name, MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } else { // We need to load an existing key file... while (!File.Exists(keyFilePath)) { var ofd = new OpenFileDialogEx("Select your Certificate Shortcut Provider Key file.") { Filter = $"Certificate Shortcut Provider Key files (*{DefaultKeyExtension})|*{DefaultKeyExtension}|All files (*.*)|*.*" }; if (ofd.ShowDialog() != DialogResult.OK) { return(null); } else { keyFilePath = ofd.FileName; } } using (var fs = new FileStream(keyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { cspKey = XmlUtilEx.Deserialize <CertificateShortcutProviderKey>(fs); } var secretKey = CryptoHelpers.DecryptPassphrase(cspKey); return(secretKey.ReadData()); } }
public async void BrowsePlaylistsCommand() { string[] acceptableFiles = { "xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl" }; var dialog = new OpenFileDialogEx() { Filters = new[] { new FileDialogFilter() { Name = Resources.FileFilter_PlaylistFiles, Extensions = acceptableFiles.ToList() } }, WindowTitle = Resources.ImportPlaylistFiles, AcceptButtonLabel = Resources.ImportPlaylistFiles }; var files = await dialog.ShowAsync(GetMainWindow()); if (files.Length <= 0 && files is null) { return; } var reader = PlaylistIOFactory.GetInstance().GetPlaylistIO(files[0]); foreach (var s in reader.FilePaths) { if (!File.Exists(s)) { Window.Notifications.Add(new() { ContentText = string.Format(Properties.Resources.Notification_FileInPlaylistMissing, Path.GetFileName(s)), DisplayAsToast = true, IsImportant = true, Type = NotificationType.Failure }); continue; } } Window.Player.Queue.Add(reader.FilePaths.ToArray()); await Task.Run(() => Window.Library.Import(reader.FilePaths.ToArray())); await Window.Player.PlayAsync(); }
public override byte[] GetKey(KeyProviderQueryContext ctx) { // The key file is expected to be next to the database by default: var keyFilePath = UrlUtil.StripExtension(ctx.DatabasePath) + DefaultKeyExtension; CertificateShortcutProviderKey cspKey; if (ctx.CreatingNewKey) { // Show the key file creation form and always return null, // so that it's not possible to accidentally create a composite key with this provider. using (var form = new KeyCreationForm(keyFilePath)) { form.ShowDialog(); return(null); } } else { // We need to load an existing key file... while (!File.Exists(keyFilePath)) { var ofd = new OpenFileDialogEx("Select your Certificate Shortcut Provider Key file."); ofd.Filter = $"Certificate Shortcut Provider Key files (*{DefaultKeyExtension})|*{DefaultKeyExtension}|All files (*.*)|*.*"; if (ofd.ShowDialog() != DialogResult.OK) { return(null); } else { keyFilePath = ofd.FileName; } } using (var fs = new FileStream(keyFilePath, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { cspKey = XmlUtilEx.Deserialize <CertificateShortcutProviderKey>(fs); } var secretKey = CryptoHelpers.DecryptPassphrase(cspKey); return(secretKey.ReadData()); } }
private void pictureTemplate_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textTemplateImage.Text)) { return; } using (var ofd = new OpenFileDialogEx("Select template file", "Image Files|*.jpg;*.png;*.jpeg;*.bmp")) { ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { btnApply.Enabled = false; return; } ApplyNewImage(ofd.FileName); } }
public DummyForm(OpenFileDialogEx fileDialogEx, string lable_OpenFloder, string lable_SelectTexg, string lable_CancelText) { if (CultureInfo.CurrentCulture.ToString().Equals("zh-CN")) { this.Lable_OpenFloder = lable_OpenFloder; this.Lable_SelectTexg = lable_SelectTexg; this.Lable_CancelText = lable_CancelText; } else { this.Lable_OpenFloder = "Folder:"; this.Lable_SelectTexg = "Select"; this.Lable_CancelText = "Cancel"; } this.mFileDialogEx = fileDialogEx; this.Text = ""; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(-32000, -32000); this.ShowInTaskbar = false; }
private void OnClickKeyFileBrowse(object sender, EventArgs e) { string strFile = null; if (m_bSecureDesktop) { FileBrowserForm dlg = new FileBrowserForm(); dlg.InitEx(false, KPRes.KeyFileSelect, KPRes.SecDeskFileDialogHint, AppDefs.FileDialogContext.KeyFile); if (dlg.ShowDialog() == DialogResult.OK) { strFile = dlg.SelectedFile; } UIUtil.DestroyForm(dlg); } else { string strFilter = UIUtil.CreateFileTypeFilter("key", KPRes.KeyFiles, true); OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileSelect, strFilter, 2, null, false, AppDefs.FileDialogContext.KeyFile); if (ofd.ShowDialog() == DialogResult.OK) { strFile = ofd.FileName; } } if (!string.IsNullOrEmpty(strFile)) { if ((Program.Config.UI.KeyPromptFlags & (ulong)AceKeyUIFlags.UncheckKeyFile) == 0) { UIUtil.SetChecked(m_cbKeyFile, true); } AddKeyFileSuggPriv(strFile, true); } EnableUserControls(); }
private void OpenFilesDialog_FileNameChanged(OpenFileDialogEx sender, string filePath) { this.cando = true; this.fileConvert.Clear(); if (string.IsNullOrWhiteSpace(filePath)) { return; } if (filePath.IsFileOrDirectory()) { this.FolderParent = string.Empty; this.fileConvert.Add(filePath); } else { int count = filePath.LastIndexOf("\\"); if (count != -1 && count <= filePath.Length) { string[] strArray = new string(filePath.Skip <char>(count).ToArray <char>()).Split(new string[3] { "\\", "/", "\"" }, StringSplitOptions.RemoveEmptyEntries); if (strArray != null && ((IEnumerable <string>)strArray).Count <string>() > 0) { string str = ((IEnumerable <string>)strArray).FirstOrDefault <string>((Func <string, bool>)(i => !string.IsNullOrWhiteSpace(i))); int num = filePath.IndexOf(str); this.FolderParent = num != -1 ? new string(filePath.Take <char>(num - 1).ToArray <char>()) : string.Empty; ((IEnumerable <string>)strArray).ToList <string>().ForEach((Action <string>)(i => { if (string.IsNullOrWhiteSpace(i)) { return; } this.fileConvert.Add(i); })); } } } }
private void OnClickKeyFileBrowse(object sender, EventArgs e) { string strFilter = AppDefs.GetKeyFileFilter(); OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog(KPRes.KeyFileUseExisting, strFilter, 1, null, false, AppDefs.FileDialogContext.KeyFile); if (ofd.ShowDialog() != DialogResult.OK) { return; } string strFile = ofd.FileName; try { // Test whether we can read the file IOConnectionInfo ioc = IOConnectionInfo.FromPath(strFile); IOConnection.OpenRead(ioc).Close(); // Check the file size? } catch (Exception ex) { MessageService.ShowWarning(ex); return; } if (!KfxFile.CanLoad(strFile)) { if (!MessageService.AskYesNo(strFile + MessageService.NewParagraph + KPRes.KeyFileNoXml + MessageService.NewParagraph + KPRes.KeyFileUseAnywayQ, null, false)) { return; } } m_cmbKeyFile.Items.Add(strFile); m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1; EnableUserControls(); }
public async void BrowseTracksCommand() { var dialog = new OpenFileDialogEx() { Filters = new[] { new FileDialogFilter() { Name = Resources.FileFilter_AudioFiles, Extensions = acceptableFilePaths } }, AllowMultiple = true, WindowTitle = Resources.Import, AcceptButtonLabel = Resources.Import }; var files = await dialog.ShowAsync(GetMainWindow()); if (files.Length > 0 && files is not null) { await Task.Run(() => Window.Library.Import(files)); } }
private void btnLoadProject_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialogEx("Open HeadShop/HairShop project", "HeadShop projects|*.hds|HairShop projects|*.hs")) { ofd.Multiselect = false; if (ofd.ShowDialog(false) != DialogResult.OK) { return; } textLoadProject.Text = ofd.FileName; var templateImagePath = Project.LoadTempaltePath(textLoadProject.Text); if (!string.IsNullOrEmpty(templateImagePath)) { var fi = new FileInfo(templateImagePath); if (fi.Exists) { using (var bmp = new Bitmap(fi.FullName)) pictureTemplate.Image = (Bitmap)bmp.Clone(); } } } }
private void PerformImport(string strFileExt, string strFileDesc, ImportFn f) { OpenFileDialogEx ofd = UIUtil.CreateOpenFileDialog("Import " + strFileDesc, strFileDesc + " (*." + strFileExt + ")|*." + strFileExt + "|All Files (*.*)|*.*", 1, strFileExt, false, AppDefs.FileDialogContext.Import); if (ofd.ShowDialog() != DialogResult.OK) { return; } try { f(m_trl, IOConnectionInfo.FromPath(ofd.FileName)); } catch (Exception ex) { MessageBox.Show(this, ex.Message, TrlUtilName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } UpdateStringTableUI(); UpdateControlTree(); m_tvControls.SelectedNode = m_tvControls.Nodes[0]; UpdatePreviewForm(); }