예제 #1
0
        public void Initialize(Cockpit cockpit)
        {
            ActiveCockpit = cockpit;
            cockpit.Name  = "fileSaveCockpit";

            float fHUDRadius = this.HUDRadius;

            cockpit.DefaultCursorDepth = fHUDRadius;

            ListView = new IconFilesystemPanel()
            {
                IconSize   = this.IconSize,
                FolderPath = InitialPath
            };
            if (ValidExtensions != null)
            {
                foreach (string s in ValidExtensions)
                {
                    ListView.Source.ValidExtensions.Add(s);
                }
            }
            ListView.Source.FilterInaccessibleFolders = true;
            ListView.Initialize(cockpit, fHUDRadius);

            add_text_entry_field(cockpit);

            // setup interactions
            cockpit.AddKeyHandler(new FileBrowserTextFieldKeyHandler(cockpit.Context, entryField)
            {
                OnReturn = () => { SaveFile(Path.GetFullPath(Path.Combine(ListView.FolderPath, entryField.Text))); }
            });
            cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context)
            {
                Priority = 0
            });

            FolderListAdapter adapter = new FolderListAdapter()
            {
                OnFileClickedAction       = (s) => { entryField.Text = s; },
                OnFileDoubleClickedAction = (s) => SaveFile(s),
                OnListChanged             = (l) => { ListView = l; }
            };

            adapter.OnFolderChanged(ListView);
            cockpit.InputBehaviors.Add(new FolderScrollBehavior(adapter));

            cockpit.OverrideBehaviors.Add(new ScreenCaptureBehavior()
            {
                Priority       = 0,
                ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\"
            });
        }
예제 #2
0
        public void OnFolderChanged(IconFilesystemPanel newFolder)
        {
            if (FolderList != null)
            {
                FolderList.OnFolderChanged -= OnFolderChanged;
                if (OnFileClickedAction != null)
                {
                    FolderList.OnFileClicked -= OnFileClickedAction.Invoke;
                }
                if (OnFileDoubleClickedAction != null)
                {
                    FolderList.OnFileDoubleClicked -= OnFileDoubleClickedAction.Invoke;
                }
            }

            FolderList = newFolder;

            FolderList.OnFolderChanged += OnFolderChanged;
            if (OnFileClickedAction != null)
            {
                FolderList.OnFileClicked += OnFileClickedAction.Invoke;
            }
            if (OnFileDoubleClickedAction != null)
            {
                FolderList.OnFileDoubleClicked += OnFileDoubleClickedAction.Invoke;
            }

            if (OnListChanged != null)
            {
                OnListChanged(newFolder);
            }
        }
예제 #3
0
        private void IconButton_DoubleClick(object sender, InputEvent e)
        {
            HUDButton button   = (HUDButton)sender;
            string    sName    = button.Name;
            string    sNewPath = Path.Combine(FolderPath, sName);

            sNewPath = Path.GetFullPath(sNewPath);
            if (Directory.Exists(sNewPath))
            {
                Dismiss();

                // create new folder source
                IconFilesystemPanel list = new IconFilesystemPanel()
                {
                    IconSize   = this.IconSize,
                    FolderPath = sNewPath,
                    Source     = this.Source
                };
                list.Initialize(activeCockpit, activeHUDRadius);

                // notify listeners that we have changed folder
                if (OnFolderChanged != null)
                {
                    OnFolderChanged(list);
                }
            }
            else if (File.Exists(sNewPath))
            {
                OnFileDoubleClicked(sNewPath);
            }
        }
예제 #4
0
        public void Initialize(Cockpit cockpit)
        {
            ActiveCockpit = cockpit;
            cockpit.Name  = "fileOpenCockpit";

            float fHUDRadius = this.HUDRadius;

            cockpit.DefaultCursorDepth = fHUDRadius;

            ListView = new IconFilesystemPanel()
            {
                IconSize   = this.IconSize,
                FolderPath = InitialPath
            };
            if (ValidExtensions != null)
            {
                foreach (string s in ValidExtensions)
                {
                    ListView.Source.ValidExtensions.Add(s);
                }
            }
            ListView.Source.FilterInaccessibleFolders = true;
            ListView.Initialize(cockpit, fHUDRadius);

            add_text_entry_field(cockpit);

            // setup interactions
            cockpit.AddKeyHandler(new FileBrowserTextFieldKeyHandler(cockpit.Context, entryField)
            {
                OnReturn = () => { LoadFile(Path.GetFullPath(Path.Combine(ListView.FolderPath, entryField.Text))); }
            });
            cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context)
            {
                Priority = 0
            });

            // IconFileSystemPanel objects basically replace themselves in the scene when
            //  the user changes directories. So, we need a way to transfer event handlers
            //  between these objects. This is what FolderListAdapter does.
            FolderListAdapter adapter = new FolderListAdapter()
            {
                OnFileClickedAction       = (s) => { entryField.Text = s; },
                OnFileDoubleClickedAction = (s) => LoadFile(s),
                OnListChanged             = (l) => { ListView = l; }
            };

            adapter.OnFolderChanged(ListView);
            cockpit.InputBehaviors.Add(new FolderScrollBehavior(adapter));


            //cockpit.OverrideBehaviors.Add(new ScreenCaptureBehavior() { Priority = 0,
            //    ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\" });
            cockpit.OverrideBehaviors.Add(new FBEncoderCaptureBehavior()
            {
                Priority       = 0,
                ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\"
            });
        }