public string Show() { FormOpenFileDialog controlex = new FormOpenFileDialog(); controlex.StartLocation = AddonWindowLocation.Right; controlex.DefaultViewMode = FolderViewMode.Default; controlex.OpenDialog.InitialDirectory = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory); //Application.ExecutablePath); controlex.OpenDialog.AddExtension = true; controlex.OpenDialog.Filter = "½£3ͼ±êÎļþ(*.UITex)|*.UITex"; //"Image Files(*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png"; //AppDomain.CurrentDomain.BaseDirectory; //controlex.SetCurrenIconRect(Rect); controlex.InitRect = Rect; DialogResult r = controlex.ShowDialog(null, FileName); if (r == DialogResult.OK) { Rect = controlex.Rect; ID = controlex.ID; return(controlex.OpenDialog.FileName); } controlex.UnInit(); controlex.Dispose(); return(string.Empty); }
/// <summary> /// 导入资源文件 /// </summary> public void ImportResource() { SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; FormOpenFileDialog OpenFile = new FormOpenFileDialog(); OpenFile.OpenDialog.Multiselect = true; OpenFile.OpenDialog.Filter = "PIC files (*.jpg,*.png,*.gif)|*.jpg;*.png;*.gif;|Flash files (.swf)|*.swf|Media files (*.rmvb,*.rm,*.avi,*.wmv)|*.rmvb;*.rm;*.avi;*.wmv|Audio files (*.mp3,*.mdi,*.wma,*.wav)|*.mp3;*.mid;*.wma;*.wav"; BaseFolderElementNode pathNode = CurrentNode as BaseFolderElementNode; string parentFolderID = ((ElementNode)CurrentNode).Element.Id; if (OpenFile.ShowDialog(this) == DialogResult.OK) { string[] fileNames = OpenFile.OpenDialog.FileNames; foreach (string srcFilePath in fileNames) { FileSimpleExXmlElement fileEle = doc.CreateFileElement(parentFolderID, srcFilePath); } } }
/// <summary> /// Open image /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnOpenImageClicked(object sender, MouseButtonEventArgs e) { HideAllSubMenus(); FormOpenFileDialog controlex = new FormOpenFileDialog(); controlex.StartLocation = AddonWindowLocation.Right; controlex.DefaultViewMode = FolderViewMode.Thumbnails; controlex.OpenDialog.InitialDirectory = GlobalContants.screenshotFolderPath; controlex.OpenDialog.AddExtension = true; controlex.OpenDialog.Filter = "Image Files(*.bmp;*.jpg;*.gif;*.png; *.jpeg)|*.bmp;*.jpg;*.jpeg;*.gif;*.png"; var result = controlex.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string filename = controlex.OpenDialog.FileName; m_ProcessManager.GenerateProcess(filename, true); Thread.Sleep(1000); SendKeys.SendWait("{F11}"); } }
private void imageToolStripMenuItem_Click(object sender, EventArgs e) {//导入资源 SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; MyListItem importFolder = null; string openfileFilter = ""; ToolStripMenuItem menuItem = (ToolStripMenuItem)(sender); switch (menuItem.Name) { case "imageToolStripMenuItem": openfileFilter = "PIC files (*.jpg,*.gif)|*.jpg;*.gif;"; break; case "medioFileToolStripMenuItem": openfileFilter = "Audio files (*.mp3,*.mdi,*.wma,*.wav)|*.mp3;*.mid;*.wma;*.wav;|"; openfileFilter += "Media files (*.rmvb,*.rm,*.avi,*.wmv)|*.rmvb;*.rm;*.avi;*.wmv;|"; openfileFilter += "Flash files (.swf)|*.swf;"; break; case "documentFileToolStripMenuItem": openfileFilter = "doc files (*.txt,*.doc)|*.txt;*.doc;"; break; case "compressFileNewToolStripMenuItem": openfileFilter = "Compress files (*.rar,*.zip)|*.rar;*.zip;"; break; } FormOpenFileDialog OpenFile = new FormOpenFileDialog(); OpenFile.OpenDialog.Multiselect = true; OpenFile.OpenDialog.Filter = openfileFilter; if (OpenFile.ShowDialog(this) == DialogResult.OK) { string[] fileNames = OpenFile.OpenDialog.FileNames; foreach (string srcFilePath in fileNames) { if (resourceFilesListView.SelectedItems.Count > 0 && resourceFilesListView.SelectedItems[0] is MyListFolderItem) { importFolder = (resourceFilesListView.SelectedItems[0] as MyListItem); MyListItem item = ItemContains(resourceFilePaths, importFolder); if (item != null) { importFolder = item; } parentResToolStripButton.Enabled = true; myResourceCurrentItem = importFolder; } else { importFolder = myResourceCurrentItem; } FileSimpleExXmlElement fileEle = doc.CreateFileElement(importFolder._element as FolderXmlElement, srcFilePath); } if (importFolder != null) { InitListView(importFolder, resourceFilesListView, _resourceCurrentType); } } }
/// <summary> /// 导入资源文件方法 /// </summary> void ImportResources() { try { string newFilePath = string.Empty; SimpleExIndexXmlElement importFolder = null; SdsiteXmlDocument doc = Service.Sdsite.CurrentDocument; FormOpenFileDialog OpenFile = new FormOpenFileDialog(); #region 筛选处理 OpenFile.OpenDialog.Multiselect = true; string openfileFilter = ""; switch (fileType) { case MediaFileType.Pic: openfileFilter = "PIC files (*.jpg,*.gif)|*.jpg;*.gif;"; break; case MediaFileType.Flash: openfileFilter = "Flash files (.swf)|*.swf"; break; case MediaFileType.Video: openfileFilter = "Media files (*.rmvb,*.rm,*.avi,*.wmv)|*.rmvb;*.rm;*.avi;*.wmv"; break; case MediaFileType.Audio: openfileFilter = "Audio files (*.mp3,*.mdi,*.wma,*.wav)|*.mp3;*.mid;*.wma;*.wav"; break; } OpenFile.OpenDialog.Filter = openfileFilter; #endregion if (OpenFile.ShowDialog(this) == DialogResult.OK) { string[] fileNames = OpenFile.OpenDialog.FileNames; foreach (string srcFilePath in fileNames) { if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0] is MyFolderItem) { importFolder = (listView.SelectedItems[0] as MyItem)._element;// filePaths[pathNum].AbsoluteFilePath; filePaths.Add(importFolder); pathNum++; backToolStripButton.Enabled = upToolStripButton.Enabled = true; } else { importFolder = filePaths[pathNum]; if (importFolder is FileSimpleExXmlElement) { importFolder = filePaths[pathNum - 1]; } } FileSimpleExXmlElement fileEle = doc.CreateFileElement(importFolder as FolderXmlElement, srcFilePath); //#region 复制文件 /////将文件名翻译成拼音,生成一个不重名的文件名 //string fileName = Path.GetFileName(srcFilePath); //string pinyinFileName = Utility.File.FormatFileName(fileName); //string formatFileName = Utility.File.BuildFileName(importFolder.AbsoluteFilePath, pinyinFileName, false, true); //bool isNoIn = false;//标识是否已经加载的资源文件 //if (listView.SelectedItems.Count > 0 && listView.SelectedItems[0] is MyFolderItem) //{ // importFolder = (listView.SelectedItems[0] as MyItem)._element;// filePaths[pathNum].AbsoluteFilePath; // filePaths.Add(importFolder); // pathNum++; // backToolStripButton.Enabled = upToolStripButton.Enabled = true; //} //else //{ // importFolder = filePaths[pathNum]; // if (importFolder is FileSimpleExXmlElement) // importFolder = filePaths[pathNum - 1]; //} //newFilePath = Path.Combine(importFolder.AbsoluteFilePath, formatFileName); //if (File.Exists(newFilePath)) //{ // if (MessageBox.Show("您确定要覆盖吗?", "确定", MessageBoxButtons.YesNo) == DialogResult.Yes) // { // isNoIn = false; // File.Copy(srcFilePath, newFilePath, true); // } //} //else //{ // isNoIn = true; // File.Copy(srcFilePath, newFilePath); //} //#endregion //#region 加入索引 //if (isNoIn) //{ // FileSimpleExXmlElement fileEle = doc.CreateFileElementNoCreateFile(importFolder as FolderXmlElement, formatFileName,fileName); //} //#endregion } if (importFolder != null) { InitListView(importFolder); } } } catch { } }