Пример #1
0
        public string[] OpenFilePanel(BrowserParameters args)
        {
            var fd = new VistaOpenFileDialog();

            fd.Title = args.Title;
            if (args.Extensions != null)
            {
                fd.Filter      = GetFilterFromFileExtensionList(args.Extensions);
                fd.FilterIndex = (args.FilterIndex > 0) ? args.FilterIndex : 1;
            }
            else
            {
                fd.Filter = string.Empty;
            }
            fd.Multiselect = args.Multiselect;
            if (!string.IsNullOrEmpty(args.Directory))
            {
                fd.FileName = GetDirectoryPath(args.Directory);
            }
            var res       = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
            var filenames = res == DialogResult.OK ? fd.FileNames : new string[0];

            fd.Dispose();
            return(filenames);
        }
Пример #2
0
        public string[] OpenFilePanel(string title, string directory, ExtensionFilter[] extensions, bool multiselect)
        {
            var fd = new VistaOpenFileDialog();

            fd.Title = title;
            if (extensions != null)
            {
                fd.Filter      = GetFilterFromFileExtensionList(extensions);
                fd.FilterIndex = 1;
            }
            else
            {
                fd.Filter = string.Empty;
            }

            fd.Multiselect = multiselect;
            if (!string.IsNullOrEmpty(directory))
            {
                fd.FileName = GetDirectoryPath(directory);
            }
            var res       = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
            var filenames = res == DialogResult.OK ? fd.FileNames : new string[0];

            fd.Dispose();
            return(filenames);
        }
    public bool OpenFilePanel(ExtensionFilter filter, string defExt, out string resultPath)
    {
        var fd = new VistaOpenFileDialog();

        fd.Title       = "Open file";
        fd.Filter      = GetFilterFromFileExtensionList(filter);
        fd.FilterIndex = 1;
        fd.Multiselect = false;

        var res      = fd.ShowDialog(new WindowWrapper(GetActiveWindow()));
        var filename = res == DialogResult.OK ? fd.FileNames[0] : string.Empty;

        fd.Dispose();

        resultPath = filename;
        return(!string.IsNullOrEmpty(resultPath));
    }