コード例 #1
0
        private void DidSelectPathsForOpenFile(bool pathsSelected, string[] paths)
        {
            isBusy = false;

            if (_filesCallback == null)
            {
                return;
            }

            if (pathsSelected)
            {
                var files = NativeFileSOMacWin.FilesFromPaths(paths);

                if (files.Length > 0)
                {
                    _filesCallback(true, files);
                }
                else
                {
                    _filesCallback(false, _noFiles);
                }
            }
            else
            {
                _filesCallback(false, _noFiles);
            }
        }
コード例 #2
0
        public OpenedFile[] OpenFilesSync(SupportedFileType[] fileTypes, bool canSelectMultiple,
                                          string title, string directory)
        {
            var paths = SelectOpenPathsSync(fileTypes, canSelectMultiple, title, directory);
            var files = new List <OpenedFile>();

            for (int i = 0; i < paths.Length; i++)
            {
                files.Add(NativeFileSOMacWin.FileFromPath(paths[i]));
            }

            return(files.ToArray());
        }
コード例 #3
0
        private void DidSelectPathForSave(bool pathsSelected, string[] paths)
        {
            isBusy = false;

            var toSave = _cachedFileToSave;

            if (toSave == null || !pathsSelected)
            {
                return;
            }

            var path = paths[0];

            NativeFileSOMacWin.SaveFileToPath(toSave, path);
        }
コード例 #4
0
        public OpenedFile[] OpenFilesSync(SupportedFileType[] fileTypes, bool canSelectMultiple = true,
                                          string title = "", string directory = "")
        {
            var paths       = SelectOpenPathsSync(fileTypes, canSelectMultiple, title, directory);
            var openedFiles = new List <OpenedFile>();

            foreach (var path in paths)
            {
                var file = NativeFileSOMacWin.FileFromPath(path);
                if (file != null)
                {
                    openedFiles.Add(file);
                }
            }
            isBusy = false;

            return(openedFiles.ToArray());
        }
コード例 #5
0
        public void SaveFile(FileToSave file, string title, string directory)
        {
            if (isBusy)
            {
                return;
            }
            isBusy = true;

            var dialog = new VistaSaveFileDialog();

            if (string.IsNullOrEmpty(directory))
            {
                dialog.RestoreDirectory = true;
                dialog.FileName         = file.Name;
            }
            else
            {
                dialog.FileName = CreateFilenameForSaveDialog(directory, file.Name);
            }

            dialog.DefaultExt = file.Extension;
            if (dialog.DefaultExt.Length > 0)
            {
                dialog.AddExtension = true;
                dialog.SupportMultiDottedExtensions = true;
            }
            if (file.FileType != null)
            {
                dialog.Filter = EncodeFilters(new [] { file.FileType });
            }

            dialog.Title = title;

            var result = dialog.ShowDialog(new Win32Window(GetActiveWindow()));

            isBusy = false;
            if (result == DialogResult.OK)
            {
                NativeFileSOMacWin.SaveFileToPath(file, dialog.FileName);
            }
            dialog.Dispose();
        }