コード例 #1
0
        /// <inheritdoc />
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            if (Arguments == null)
            {
                throw new IllegalArgumentException("You must create DirectoryChooserFragment via the FileListFragment(string, string, FilePickerMode) constructor.");
            }

            newDirectoryName = Arguments.GetString(ArgNewDirectoryName);
            initialDirectory = Arguments.GetString(ArgInitialDir);
            filePickerMode   = (FilePickerMode)Arguments.GetInt(ArgMode);

            if (savedInstanceState != null)
            {
                initialDirectory = savedInstanceState.GetString(KeyCurrentDirectory);
            }

            if (ShowsDialog)
            {
                SetStyle(DialogFragmentStyle.NoTitle, 0);
            }
            else
            {
                SetHasOptionsMenu(true);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FilePickerFragment"/> class.
        /// </summary>
        /// <param name="initialDir">The initial dirrectory.</param>
        /// <param name="newDirName">Default name for new folders.</param>
        /// <param name="mode">The filepicker mode.</param>
        public FilePickerFragment(string initialDir, string newDirName, FilePickerMode mode = FilePickerMode.File)
        {
            var args = new Bundle();

            args.PutString(ArgNewDirectoryName, newDirName ?? string.Empty);
            args.PutString(ArgInitialDir, initialDir ?? string.Empty);
            args.PutInt(ArgMode, (int)mode);
            Arguments = args;
        }
コード例 #3
0
        private void init(FilePickerMode mode = FilePickerMode.Open, string filterStr = "All files (*)|*")
        {
            FilterStr        = filterStr;
            WindowTitleMask  = Enum.GetName(typeof(FilePickerMode), mode);
            _mode            = mode;
            _tryCloseCommand = new SimpleScriptCommand("TryClose", pd => { TryClose(true); return(ResultCommand.NoError); });

            FileList.Commands.CommandDictionary.Open = FileExplorer.Script.FileList.IfSelection(evm => evm.Count() == 1,
                                                                                                FileExplorer.Script.FileList.IfSelection(evm => evm[0].EntryModel.IsDirectory,
                                                                                                                                         OpenSelectedDirectory.FromFileList, //Selected directory
                                                                                                                                         new SimpleScriptCommand("", (pd) =>
            {
                switch (mode)
                {
                case FilePickerMode.Open: Open(); break;

                case FilePickerMode.Save: Save(); break;
                }

                return(ResultCommand.NoError);
            })),                                                                                                      //Selected non-directory
                                                                                                ResultCommand.NoError //Selected more than one item.
                                                                                                );

            FileList.Selection.SelectionChanged += (o1, e1) =>
            {
                var firstDir =
                    FileList.Selection.SelectedItems.FirstOrDefault(evm => evm.EntryModel.IsDirectory);
                if (firstDir != null)
                {
                    //setFileName(firstDir.EntryModel.Label, false);
                }
                else
                {
                    string newFileName = String.Join(",",
                                                     FileList.Selection.SelectedItems.Where(evm => !evm.EntryModel.IsDirectory)
                                                     .Select(evm => evm.EntryModel.GetName()));

                    if (!String.IsNullOrEmpty(newFileName))
                    {
                        switch (mode)
                        {
                        case FilePickerMode.Save: setFileName(newFileName,
                                                              !newFileName.Contains(',')); break;

                        default: setFileName(newFileName); break;
                        }
                    }
                }
            };

            FileList.EnableDrag        = false;
            FileList.EnableDrop        = false;
            FileList.EnableMultiSelect = false;
        }
コード例 #4
0
ファイル: FilePicker.cs プロジェクト: jjhartmann/StereoKit
        void Setup(FilePickerMode mode, string initialFolder, Action <string> onSelectFile, Action onCancel, FileFilter[] filters)
        {
            _mode         = mode;
            _title        = string.Join(" | ", filters.Select(filter => filter.name));
            _filters      = filters;
            _onFileSelect = onSelectFile;
            _onCancel     = onCancel;

            _resultFolder = null;
            _resultName   = null;
            UpdateFolder(initialFolder == null ? Directory.GetCurrentDirectory() : initialFolder);
        }
コード例 #5
0
ファイル: FilePicker.cs プロジェクト: jjhartmann/StereoKit
 /// <summary>Show a file picker to the user! If one is already up, it'll be cancelled out,
 /// and this one will replace it.</summary>
 /// <param name="mode">For opening files, or for saving them?</param>
 /// <param name="initialFolder">The starting folder. By default (or null), this'll just be
 /// the working directory.</param>
 /// <param name="onSelectFile">The function to call when the user has selected a file.</param>
 /// <param name="onCancel">If the file selection has been cancelled, this'll get called!</param>
 /// <param name="filters">What file types should show up in the picker?</param>
 public static void Show(FilePickerMode mode, string initialFolder, Action <string> onSelectFile, Action onCancel, params FileFilter[] filters)
 {
     if (_inst != null)
     {
         _inst._onCancel?.Invoke();
     }
     if (_inst == null)
     {
         _inst = StereoKitApp.AddStepper(new FilePicker());
         Vec3 pos = Input.Head.position + Input.Head.Forward * .5f + Input.Head.Up * 0.2f;
         _inst._windowPose = new Pose(pos, Quat.LookAt(pos, Input.Head.position));
     }
     _inst.Setup(mode, initialFolder, onSelectFile, onCancel, filters);
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilePickerFragment"/> class.
 /// </summary>
 /// <param name="initialDir">The initial dirrectory.</param>
 /// <param name="mode">The filepicker mode.</param>
 public FilePickerFragment(string initialDir, FilePickerMode mode = FilePickerMode.File)
     : this(initialDir, null, mode)
 {
 }
コード例 #7
0
 public FilePickerViewModel(IEventAggregator events, IWindowManager windowManager, string filterStr,
                            FilePickerMode mode = FilePickerMode.Open, params IEntryModel[] rootModels)
     : this(new ExplorerInitializer(windowManager, events, rootModels), filterStr, mode)
 {
 }
コード例 #8
0
 public FilePickerViewModel(IExplorerInitializer initializer, string filterStr,
                            FilePickerMode mode = FilePickerMode.Open)
     : base(initializer)
 {
     init(mode, filterStr);
 }
コード例 #9
0
        static void PickFiles([NotNull] string[] fileTypes, Action <List <string> > onSuccess, Action onCancel, bool allowMultiple, FilePickerMode mode, string path)
        {
            if (fileTypes == null)
            {
                throw new ArgumentNullException("fileTypes");
            }

            if (fileTypes.Length == 0)
            {
                throw new ArgumentException("At least one file type must be provided");
            }

            if (IGUtils.IsIosCheck())
            {
                return;
            }

            Action <string> onSuccessStr = s =>
            {
                var paths = s.SplitString();
                onSuccess(paths.ToList());
            };

            _iosGoodiesPickFiles(fileTypes.JoinByComma(), IGUtils.ActionStringCallback, IGUtils.ActionVoidCallback,
                                 onSuccessStr.GetPointer(), onCancel.GetPointer(), allowMultiple, (int)mode, path);
        }
コード例 #10
0
ファイル: FilePicker.cs プロジェクト: jjhartmann/StereoKit
 /// <summary>Show a file picker to the user! If one is already up, it'll be cancelled out,
 /// and this one will replace it.</summary>
 /// <param name="mode">For opening files, or for saving them?</param>
 /// <param name="initialFolder">The starting folder. By default (or null), this'll just be
 /// the working directory.</param>
 /// <param name="onSelectFile">The function to call when the user has selected a file.</param>
 /// <param name="filters">What file types should show up in the picker?</param>
 public static void Show(FilePickerMode mode, string initialFolder, Action <string> onSelectFile, params FileFilter[] filters)
 => Show(mode, initialFolder, onSelectFile, null, filters);
コード例 #11
0
ファイル: FilePicker.cs プロジェクト: jjhartmann/StereoKit
 /// <summary>Show a file picker to the user! If one is already up, it'll be cancelled out,
 /// and this one will replace it.</summary>
 /// <param name="mode">For opening files, or for saving them?</param>
 /// <param name="onSelectFile">The function to call when the user has selected a file.</param>
 /// <param name="onCancel">If the file selection has been cancelled, this'll get called!</param>
 /// <param name="filters">What file types should show up in the picker?</param>
 public static void Show(FilePickerMode mode, Action <string> onSelectFile, Action onCancel = null, params FileFilter[] filters)
 => Show(mode, null, onSelectFile, onCancel, filters);
コード例 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilePickerFragment"/> class.
 /// </summary>
 /// <param name="initialDir">The initial dirrectory.</param>
 /// <param name="newDirName">Default name for new folders.</param>
 /// <param name="mode">The filepicker mode.</param>
 public FilePickerFragment(string initialDir, string newDirName, FilePickerMode mode = FilePickerMode.File)
 {
     var args = new Bundle();
     args.PutString(ArgNewDirectoryName, newDirName ?? string.Empty);
     args.PutString(ArgInitialDir, initialDir ?? string.Empty);
     args.PutInt(ArgMode, (int)mode);
     Arguments = args;
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilePickerFragment"/> class.
 /// </summary>
 /// <param name="initialDir">The initial dirrectory.</param>
 /// <param name="mode">The filepicker mode.</param>
 public FilePickerFragment(string initialDir, FilePickerMode mode = FilePickerMode.File)
     : this(initialDir, null, mode)
 {
 }
コード例 #14
0
        /// <inheritdoc />
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            if (Arguments == null)
            {
                throw new IllegalArgumentException("You must create DirectoryChooserFragment via the FileListFragment(string, string, FilePickerMode) constructor.");
            }

            newDirectoryName = Arguments.GetString(ArgNewDirectoryName);
            initialDirectory = Arguments.GetString(ArgInitialDir);
            filePickerMode = (FilePickerMode)Arguments.GetInt(ArgMode);

            if (savedInstanceState != null)
            {
                initialDirectory = savedInstanceState.GetString(KeyCurrentDirectory);
            }

            if (ShowsDialog)
            {
                SetStyle(DialogFragmentStyle.NoTitle, 0);
            }
            else
            {
                SetHasOptionsMenu(true);
            }
        }
コード例 #15
0
		internal FilePickerEventArgs(String title, FilePickerMode mode)
		{
			m_Title = title;
			m_Mode = mode;
			Result = FilePickerResult.Cancel;
		}