コード例 #1
0
        public string OpenFolder(string title, string initialDirectory = null, IntPtr?owner = null)
        {
            var builder = new CommonOpenDialogBuilder()
                          .Initialize(title, initialDirectory)
                          .SetAsFolderDialog();

            return(OpenSingle(builder, owner));
        }
コード例 #2
0
        public string OpenFile(string title, string initialDirectory = null, List <DialogFilterPair> filters = null)
        {
            var builder = new CommonOpenDialogBuilder()
                          .Initialize(title, initialDirectory)
                          .SetAsFileDialog(false)
                          .AddFilters(filters);

            return(OpenSingle(builder));
        }
コード例 #3
0
        public List <string> OpenFiles(string title, string initialDirectory = null, List <DialogFilterPair> filters = null, IntPtr?owner = null)
        {
            var builder = new CommonOpenDialogBuilder()
                          .Initialize(title, initialDirectory)
                          .SetAsFileDialog(true)
                          .AddFilters(filters);

            return(Open(builder, owner));
        }
コード例 #4
0
        private string OpenSingle(CommonOpenDialogBuilder builder, IntPtr?owner = null)
        {
            var files = Open(builder, owner);

            if (files?.Count == 1)
            {
                return(files[0]);
            }
            return(null);
        }
コード例 #5
0
        public List <string> Open(CommonOpenDialogBuilder builder, IntPtr?owner = null)
        {
            List <string> result = null;

            using (var dialog = builder.Dialog)
            {
                if (dialog.ShowDialog(GetOwnerHandle(owner)) == CommonFileDialogResult.Ok)
                {
                    result = dialog.FileNames.ToList();
                }
            }
            return(result);
        }
コード例 #6
0
        public List <string> Open(CommonOpenDialogBuilder builder)
        {
            List <string> result = null;

            using (var dialog = builder.Dialog)
            {
                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    result = dialog.FileNames.ToList();
                }
            }
            return(result);
        }
コード例 #7
0
        public string OpenFolder(string title, string initialDirectory)
        {
            var builder = new CommonOpenDialogBuilder()
                          .Initialize(title, initialDirectory)
                          .SetAsFolderDialog();

            string result = null;

            using (var dialog = builder.Build())
            {
                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    result = dialog.FileName;
                }
            }
            return(result);
        }
コード例 #8
0
        public List <string> OpenFiles(string title, string initialDirectory, List <DialogFilterPair> filters)
        {
            var builder = new CommonOpenDialogBuilder()
                          .Initialize(title, initialDirectory)
                          .SetAsFileDialog(true)
                          .AddFilters(filters);

            List <string> result = null;

            using (var dialog = builder.Build())
            {
                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    result = dialog.FileNames.ToList();
                }
            }
            return(result);
        }