public DummyForm(OpenFileDialogEx fileDialogEx, string lable_OpenFloder, string lable_SelectTexg, string lable_CancelText) { this.Lable_OpenFloder = lable_OpenFloder; this.Lable_SelectTexg = lable_SelectTexg; this.Lable_CancelText = lable_CancelText; mFileDialogEx = fileDialogEx; this.Text = ""; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(-32000, -32000); this.ShowInTaskbar = false; }
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; ParentHandle = parentHandle; mOpenDialogHandle = handle; mSourceControl = sourceControl; AssignHandle(mOpenDialogHandle); }
private void OpenFilesDialog_FileNameChanged(OpenFileDialogEx sender, string filePath) { cando = true; fileConvert.Clear(); if (!string.IsNullOrWhiteSpace(filePath)) { if (filePath.IsFileOrDirectory()) { FolderParent = string.Empty; fileConvert.Add(filePath); } else { var lastindex = filePath.LastIndexOf("\\"); if (lastindex != -1 && lastindex <= filePath.Length) { var filestr = new string(filePath.Skip(lastindex).ToArray()); var filelist = filestr.Split(new string[] { "\\", "/", "\"" }, StringSplitOptions.RemoveEmptyEntries); if (filelist != null && filelist.Count() > 0) { var first = filelist.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); int firstindex = filePath.IndexOf(first); FolderParent = firstindex != -1 ? new string(filePath.Take(firstindex - 1).ToArray()) : string.Empty; filelist.ToList().ForEach(i => { if (!string.IsNullOrWhiteSpace(i)) { fileConvert.Add(i); } }); } } } } }
private void OpenFilesDialog_FilesSelected(OpenFileDialogEx sender, IntPtr handle) { if (!cando) { return; } StringBuilder floderparent = new StringBuilder(256); NativeMethods.SendMessage(NativeMethods.GetParent(handle), (int)DialogChangeProperties.CDM_GETFOLDERPATH, (int)256, floderparent); if (!string.IsNullOrWhiteSpace(floderparent.ToString())) { FolderParent = floderparent.ToString(); } FilesPath.Clear(); List <string> names = new List <string>(); this.textBox1.Text = string.Empty; var parenthandle = NativeMethods.GetParent(handle); var syslistview32handle = parenthandle.GetSysListView32Handle(); if (syslistview32handle != IntPtr.Zero) { var selectstext = syslistview32handle.GetSlectedItemsText(); if (selectstext != null && selectstext.Count > 0) { if (selectstext.Count > 1) { selectstext = selectstext.OrderBy <string, string>((Func <string, string>)((i) => i)).ToList(); if (fileConvert.Count > 0) { fileConvert = fileConvert.OrderBy <string, string>((Func <string, string>)((i) => i)).ToList(); } int filecount = 0; int count = selectstext.Count; for (int i = 0; i < count; i++) { var name = selectstext[i].Split(new string[] { "\0" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); var path = Path.Combine(FolderParent, name); if (!Directory.Exists(path)) { var floderparentTemp = FolderParent; string text = string.Empty; if (!string.IsNullOrWhiteSpace(FolderParent)) { var filepath = Path.Combine(FolderParent, name); try { var f = (new FileInfo(filepath)); if (f != null && string.IsNullOrWhiteSpace(f.Extension)) { filepath = filepath + ".lnk"; } if (f != null && !f.Exists) { if (fileConvert.Count > filecount) { if (!Directory.Exists(fileConvert[filecount])) { filepath = fileConvert[filecount]; } } } text = CheckFile(name, filepath, ref floderparentTemp); } catch { } } else { if (fileConvert.Count > filecount) { text = CheckFile(name, fileConvert[filecount], ref floderparentTemp); } } if (!string.IsNullOrWhiteSpace(text)) { names.Add("\"" + text + "\""); filecount++; } } else { var showpath = Path.Combine(FolderParent, name); if (!FilesPath.Contains(showpath)) { FilesPath.Add(showpath); names.Add("\"" + name + "\""); } } } var files = string.Join(" ", names.ToArray()); if (names.Count == 1) { files = files.Replace("\"", ""); } this.textBox1.Text = files; } else { if (fileConvert.Count == 1) { this.textBox1.Text = CheckFile(selectstext[0], fileConvert[0], ref FolderParent); } } } } }
private void OpenFilesDialog_FolderNameChanged(OpenFileDialogEx sender, string filePath) { cando = true; fileConvert.Clear(); }