Exemplo n.º 1
0
        private static void ExtractFolderEntry(FolderEntry folderEntry, string destination, ref ProgresHandler progresHandler)
        {
            string destinationPath = Path.Combine(destination, folderEntry.Name);

            if (!Directory.Exists(destinationPath))
            {
                Directory.CreateDirectory(destinationPath);
            }

            foreach (var file in folderEntry.Files)
            {
                if (progresHandler.IsCancellationRequested)
                {
                    break;
                }

                ExtractFileEntry(file, destinationPath, ref progresHandler);
            }

            foreach (var folder in folderEntry.Folders)
            {
                if (progresHandler.IsCancellationRequested)
                {
                    break;
                }

                ExtractFolderEntry(folder, destinationPath, ref progresHandler);
            }
        }
Exemplo n.º 2
0
            public override void VisitFolder(FolderEntry entry)
            {
                string extractedPosition = Path.Combine(_folder, entry.RelativePath);

                Directory.Exists(extractedPosition).Should().BeTrue(because: "Directory " + extractedPosition + " does not exist.");
                VisitChildren(entry);
            }
Exemplo n.º 3
0
        public FolderEntry Copy(string from, string to)
        {
            from = _fileSystem.RestorePath(from);
            to   = _fileSystem.RestorePath(to);
            var copyCount = 0;

            if (from == to)
            {
                var copyTo = to;
                var exists = false;
                while (!exists)
                {
                    exists = Directory.Exists(from);
                    if (exists)
                    {
                        copyCount++;
                        copyTo = $"{to}-Copy{copyCount}";
                        exists = Directory.Exists(copyTo);
                        if (!exists)
                        {
                            break;
                        }
                    }
                }
                to = copyTo;
            }

            _fileSystem.Copy(from, to);

            return(FolderEntry.FromFolderEntry(to, _fileSystem));
        }
Exemplo n.º 4
0
        private void BuildTree()
        {
            var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id");

            rootFolder      = new FolderEntry();
            rootFolder.guid = rootGuid;
            BuildTreeItem(rootFolder);
            wantsMouseMove = true;
            banks          = new List <BankEntry>();

            EditorUtils.GetScriptOutput("children = \"\";");
            EditorUtils.GetScriptOutput("func = function(val) {{ children += \",\" + val.id + val.name; }};");
            EditorUtils.GetScriptOutput("studio.project.workspace.masterBankFolder.items.forEach(func, this); ");
            string bankList = EditorUtils.GetScriptOutput("children;");

            string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var bank in bankListSplit)
            {
                var entry = new BankEntry();
                entry.guid = bank.Substring(0, 38);
                entry.name = bank.Substring(38);
                banks.Add(entry);
            }

            banks.Sort((a, b) => a.name.CompareTo(b.name));
        }
Exemplo n.º 5
0
            public override void VisitFolder(FolderEntry entry)
            {
                string extractedPosition = Path.Combine(_folder, entry.RelativePath);

                Assert.IsTrue(Directory.Exists(extractedPosition), "Directory " + extractedPosition + " does not exist.");
                VisitChildren(entry);
            }
Exemplo n.º 6
0
        /// <summary>
        /// Returns a recursive list of all files in the specified path with the specified extension.
        /// </summary>
        public string[] GetFileList(string path, string extension, bool recursive)
        {
            // Get the references.
            string[]      results     = references.GetFileList(path, extension, recursive);
            List <string> resultsList = new List <string>(results);

            // Add all project references from the template tag list (if they aren't already in the list).
            if (!recursive)
            {
                FolderEntry entry = templates.TemplateTagHierarchy.LocateFolderByPath(path);
                if (entry != null)
                {
                    string[] entries = entry.FileList();
                    foreach (string filename in entries)
                    {
                        if (extension == "*" || filename.EndsWith(extension))
                        {
                            resultsList.Add(filename);
                        }
                    }
                }
            }
            else
            {
                resultsList.AddRange(templates.TemplateTagHierarchy.GetRecursiveFileList(path));
            }

            return(resultsList.ToArray());
        }
Exemplo n.º 7
0
        private void UpdateListFromText()
        {
            int endFolders = eventFolder.LastIndexOf("/");

            currentFilter = eventFolder.Substring(endFolders + 1);

            var         folders = eventFolder.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            FolderEntry entry   = rootFolder;
            int         i;

            for (i = 0; i < folders.Length; i++)
            {
                var newEntry = entry.entries.Find((x) => x.name.Equals(folders[i], StringComparison.CurrentCultureIgnoreCase));
                if (newEntry == null)
                {
                    break;
                }
                entry = newEntry;
            }
            currentFolder = entry;

            // Treat an exact filter match as being in that folder and clear the filter
            if (entry.name != null && entry.name.Equals(currentFilter, StringComparison.CurrentCultureIgnoreCase))
            {
                currentFilter = "";
            }
        }
Exemplo n.º 8
0
        private FolderEntry Traverse(string path, bool create)
        {
            var split   = path.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            var current = root;

            foreach (var part in split)
            {
                var lower = part.ToLower();
                if (current.children.TryGetValue(lower, out var next))
                {
                    current = next;
                }
                else if (create)
                {
                    var entry = new FolderEntry(part);
                    current.children.Add(lower, entry);
                    current = entry;
                }
                else
                {
                    throw new NoSuchEntryException();
                }
            }

            return(current);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Renames the folder at the specified path.
        /// </summary>
        /// <param name="oldPath">The path of the folder to be renamed.</param>
        /// <param name="newPath">The new full path to the folder.</param>
        public void RenameFolder(string oldPath, string newPath)
        {
            FolderEntry folder        = projectReferencesTable.LocateFolderByPath(oldPath);
            string      newFolderName = newPath.Substring(newPath.LastIndexOf("\\") + 1);

            folder.Name = newFolderName;
            OnDirty();
        }
Exemplo n.º 10
0
        public FolderEntry SetupFolderEntry(TreeNode node)
        {
            FolderEntry folder = new FolderEntry();

            folder.Text = node.Text;

            return(folder);
        }
Exemplo n.º 11
0
        void FillTreeNodes(TreeNode root, Dictionary <string, byte[]> files, bool HashOnly)
        {
            var rootText       = root.Text;
            var rootTextLength = rootText.Length;
            var nodeStrings    = files;

            foreach (var node in nodeStrings)
            {
                string nodeString = node.Key;

                if (HashOnly)
                {
                    nodeString = SARCExt.SARC.TryGetNameFromHashTable(nodeString);
                }

                var roots = nodeString.Split(new char[] { '/' },
                                             StringSplitOptions.RemoveEmptyEntries);

                // The initial parent is the root node
                var parentNode = root;
                var sb         = new StringBuilder(rootText, nodeString.Length + rootTextLength);
                for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
                {
                    // Build the node name
                    var parentName = roots[rootIndex];
                    sb.Append("/");
                    sb.Append(parentName);
                    var nodeName = sb.ToString();

                    // Search for the node
                    var index = parentNode.Nodes.IndexOfKey(nodeName);
                    if (index == -1)
                    {
                        // Node was not found, add it

                        var folder = new FolderEntry(parentName, 0, 0);
                        if (rootIndex == roots.Length - 1)
                        {
                            var file = SetupFileEntry(node.Value, parentName, node.Key);
                            file.Name = nodeName;
                            parentNode.Nodes.Add(file);
                            parentNode = file;
                        }
                        else
                        {
                            folder.Name = nodeName;
                            parentNode.Nodes.Add(folder);
                            parentNode = folder;
                        }
                    }
                    else
                    {
                        // Node was found, set that as parent and continue
                        parentNode = parentNode.Nodes[index];
                    }
                }
            }
        }
Exemplo n.º 12
0
 private void NavigateToParent()
 {
     if (this.currentFolder.Parent == null)
     {
         return;
     }
     this.currentFolder = this.currentFolder.Parent;
     this.BuildSelectableMenu();
 }
Exemplo n.º 13
0
        private void startBackup(int jobId, string source, string destination)
        {
            DataComparer comparer          = new DataComparer();
            FolderEntry  sourceFolder      = comparer.IndexDirectory(source);
            FolderEntry  destinationFolder = comparer.IndexDirectory(destination);

            comparer.progress += Comparer_progress;
            comparer.SyncFolders(jobId, sourceFolder, destinationFolder);
        }
Exemplo n.º 14
0
 private void BuildFileTree()
 {
     root = new FolderEntry("");
     foreach (var block in metaFile.FileBlocks)
     {
         var folder = Traverse(block.FolderName, true);
         folder.children.Add(block.FileName, new FolderEntry(block));
     }
 }
        private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e)
        {
            GroupEntry group;
            int        index;
            bool       editGroup;

            if (tvwGroups.Items.Count == 0)
            {
                group = new GroupEntry(QTUtility.TextResourcesDic["Options_Page09_Groups"][6]);
                CurrentGroups.Add(group);
                group.IsSelected = true;
                index            = 0;
                editGroup        = true;
            }
            else
            {
                object sel = tvwGroups.SelectedItem;
                if (sel == null)
                {
                    return;
                }
                if (sel is FolderEntry)
                {
                    FolderEntry entry = (FolderEntry)sel;
                    group = (GroupEntry)entry.ParentItem;
                    index = group.Folders.IndexOf(entry) + 1;
                }
                else
                {
                    group = (GroupEntry)sel;
                    index = group.Folders.Count;
                }
                editGroup = false;
            }

            FolderBrowserDialogEx dlg = new FolderBrowserDialogEx();

            if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            FolderEntry folder = new FolderEntry(dlg.SelectedPath);

            group.Folders.Insert(index, folder);
            group.IsExpanded = true;

            if (editGroup)
            {
                group.IsSelected = true;
                group.IsEditing  = true;
            }
            else
            {
                folder.IsSelected = true;
            }
        }
 public void PopulateFiles(List <VirtualFileDataObject.FileDescriptor> files, FolderEntry parent, string removeDirectory)
 {
     foreach (var entry in parent.GetAllChildren())
     {
         if (entry is FileEntry file)
         {
             PopulateFile(files, file, removeDirectory);
         }
     }
 }
Exemplo n.º 17
0
        private void OpenSelected()
        {
            if (!this.selectedMenuItem.IsFolder)
            {
                return;
            }

            this.currentFolder = this.selectedMenuItem.FolderEntry;
            this.BuildSelectableMenu();
        }
Exemplo n.º 18
0
        public void AddFolders()
        {
            var mainPath        = Path.Combine(Application.dataPath, "Sample Data/Main Folder");
            var mainFolderEntry = new FolderEntry(mainPath, AddMethod.Link);
            var pbx             = LoadCopyOfOriginal();

            pbx.AddFileOrFolder(mainFolderEntry);
            pbx.Save();
            CompareFiles("AddFolder.pbxproj", pbx.SavePath);
        }
Exemplo n.º 19
0
        Node GetNode(FolderEntry x)
        {
            Node xReturn = new Node();

            xReturn.Text        = x.Name;
            xReturn.DataKey     = x;
            xReturn.ContextMenu = contextMenuStrip2;
            xReturn.NodeClick  += new EventHandler(xReturn_NodeClick);
            return(xReturn);
        }
Exemplo n.º 20
0
 private static void TraverseFolder(FolderEntry folder, ICollection <FileEntry> files)
 {
     foreach (var file in folder.Files)
     {
         files.Add(file);
     }
     foreach (var child in folder.Folders)
     {
         TraverseFolder(child, files);
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Returns a list of referenced folders located under the specified path.
        /// </summary>
        public string[] GetFolderList(string path)
        {
            // Make sure that the path we are looking in exists.
            FolderEntry folder = projectReferencesTable.LocateFolderByPath(path);

            if (folder == null)
            {
                return(new string[0]);
            }

            return(folder.FolderList());
        }
Exemplo n.º 22
0
        void FillTreeNodes(FolderEntry root, Dictionary <string, ASST> files)
        {
            var rootText       = root.Text;
            var rootTextLength = rootText.Length;
            var nodeStrings    = files;

            foreach (var node in nodeStrings)
            {
                string nodeString = node.Value.FileName;

                var roots = nodeString.Split(new char[] { '/' },
                                             StringSplitOptions.RemoveEmptyEntries);

                // The initial parent is the root node
                TreeNode parentNode = root;
                var      sb         = new StringBuilder(rootText, nodeString.Length + rootTextLength);
                for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
                {
                    // Build the node name
                    var parentName = roots[rootIndex];
                    sb.Append("/");
                    sb.Append(parentName);
                    var nodeName = sb.ToString();

                    // Search for the node
                    var index = parentNode.Nodes.IndexOfKey(nodeName);
                    if (index == -1)
                    {
                        // Node was not found, add it

                        var temp = new TreeNode(parentName, 0, 0);
                        if (rootIndex == roots.Length - 1)
                        {
                            temp = SetupFileEntry(node.Value.FileData, parentName, node.Value.FileName);
                        }
                        else
                        {
                            temp = SetupFolderEntry(temp);
                        }

                        temp.Name = nodeName;
                        parentNode.Nodes.Add(temp);
                        parentNode = temp;
                    }
                    else
                    {
                        // Node was found, set that as parent and continue
                        parentNode = parentNode.Nodes[index];
                    }
                }
                parentNode = SetupFolderEntry(parentNode);
            }
        }
Exemplo n.º 23
0
        protected override async Task OnBindedViewLoad(IView view)
        {
            this.ListenChanged(
                x => x.CurrentTask,
                x => x.SelectedHost,
                x => x.SelectedFileEntry,
                x => x.SelectedFolderEntry)
            .ObserveOnDispatcher()
            .Do(e =>
            {
                Urls =
                    new Models.UrlGroup(
                        SelectedHost?.HostName ?? "localhost",
                        CurrentTask?.Port ?? 80,
                        SelectedFileEntry,
                        SelectedFolderEntry,
                        CurrentTask);
            })
            .Subscribe()
            .DisposeWhenUnload(this);
            ;


            if (!IsInDesignMode)
            {
                _fileSystemHubService = ServiceLocator.Instance.Resolve <IFileSystemHubService>();
            }

            var nh = ServiceLocator.Instance.Resolve <INetworkService>();

            if (CurrentTask == null)
            {
                throw new InvalidOperationException("need a CurrentTask instance first");
            }
            Hosts = new ObservableCollection <HostEntry>(nh.GetHosts().Where(x => !x.HostName.EndsWith(".local")).OrderBy(x => !x.HostName.StartsWith("192")).ThenBy(x => x.HostName));

            SelectedHost = Hosts.FirstOrDefault();

            var foldere = new FolderEntry()
            {
                FullPath = CurrentTask.Path,
                Name     = Path.GetFileNameWithoutExtension(CurrentTask.Path),
            };

            SelectedFolderEntry = foldere;
            RootEntry           = new ObservableCollection <Models.FolderEntry> {
                foldere
            };
            SelectedFolderEntry = foldere;
            CommandFillCurrentFolder.Execute(null);
            await base.OnBindedViewLoad(view);
        }
Exemplo n.º 24
0
        public void LoadFile(BezelEngineArchive beaFile, bool IsCompressed)
        {
            treeView1.Nodes.Clear();
            hexBox1.ByteProvider = null;
            Compressed           = IsCompressed;

            FolderEntry root = new FolderEntry("Root");

            FillTreeNodes(root, beaFile.FileList);
            treeView1.Nodes.Add(root);

            treeView1.Sort();
        }
Exemplo n.º 25
0
        private void TreeViewItem_Collapsed(object sender, RoutedEventArgs e)
        {
            if (currentFolderSetByMouseDown)
            {
                FilePickerViewModel vm = DataContext as FilePickerViewModel;
                vm.SelectedFolder = originalFolder;
                vm.SelectedEntry  = originalEntry;

                originalFolder = null;
                originalEntry  = null;
                currentFolderSetByMouseDown = false;
            }
        }
        private void TryOpenFolder(FolderEntry folder)
        {
            var(type, instances) = GetBrowsers();

            if (instances == null || instances.Count <= 0)
            {
                return;
            }

            var method = type.GetMethod("ShowFolderContents", BindingFlags.NonPublic | BindingFlags.Instance);

            method.Invoke(instances[0], new object[] { folder.InstanceId, true });
        }
Exemplo n.º 27
0
        public void ShowPlayer()
        {
            if (IsDisposed)
            {
                return;
            }
            _currentFolder = _rootEntry;
            _currentPath   = _rootDirectory;
            RefreshView();

            _kListener.PreventDefault = true;
            _open   = true;
            Visible = true;
        }
Exemplo n.º 28
0
        public BindDesignDialog(string id, ArrayList validClasses, string baseFolder)
        {
            XML glade = new XML(null, "gui.glade", "BindDesignDialog", null);

            glade.Autoconnect(this);
            labelMessage.Text = GettextCatalog.GetString("The widget design {0} is not currently bound to a class.", id);

            fileEntry = new FolderEntry();
            fileEntryBox.Add(fileEntry);
            fileEntry.ShowAll();

            if (validClasses.Count > 0)
            {
                store = new ListStore(typeof(string));
                foreach (string cname in validClasses)
                {
                    store.AppendValues(cname);
                }
                comboClasses.Model = store;
                CellRendererText cr = new CellRendererText();
                comboClasses.PackStart(cr, true);
                comboClasses.AddAttribute(cr, "text", 0);
                comboClasses.Active = 0;
            }
            else
            {
                radioSelect.Sensitive = false;
                radioCreate.Active    = true;
            }

            fileEntry.Path = baseFolder;

            // Initialize the class name using the widget name
            int i = id.IndexOf('.');

            if (i != -1)
            {
                entryClassName.Text = id.Substring(i + 1);
                entryNamespace.Text = id.Substring(0, i);
            }
            else
            {
                entryClassName.Text = id;
                entryNamespace.Text = lastNamespace;
            }

            dialog.Response += new Gtk.ResponseHandler(OnResponse);
            UpdateStatus();
        }
Exemplo n.º 29
0
            /// <summary>
            /// Adds the child path element
            /// </summary>
            /// <returns>The child element</returns>
            /// <param name="name">The name of the path element to add</param>
            public FolderEntry AddChild(string name)
            {
                if (m_folders == null)
                {
                    m_folders = new SortedList <string, FolderEntry>(1, Duplicati.Library.Utility.Utility.ClientFilenameStringComparer);
                }

                FolderEntry r;

                if (!m_folders.TryGetValue(name, out r))
                {
                    m_folders.Add(name, r = new FolderEntry());
                }
                return(r);
            }
Exemplo n.º 30
0
        /// <summary>
        /// Returns all folders in the specified path.
        /// </summary>
        public string[] GetFolderList(string path)
        {
            // Get the references.
            string[]      results     = references.GetFolderList(path);
            List <string> resultsList = new List <string>(results);

            // Add all project references from the template tag list (if they aren't already in the list).
            FolderEntry entry = templates.TemplateTagHierarchy.LocateFolderByPath(path);

            if (entry != null)
            {
                resultsList.AddRange(entry.FolderList());
            }
            return(resultsList.ToArray());
        }
Exemplo n.º 31
0
        private void BuildTreeItem(FolderEntry entry)
        {
            // lookup the entry
            EditorUtils.GetScriptOutput(string.Format("cur = studio.project.lookup(\"{0}\");", entry.guid));

            // get child count
            string itemCountString = EditorUtils.GetScriptOutput("cur.items.length;");
            int itemCount;
            Int32.TryParse(itemCountString, out itemCount);
            
            // iterate children looking for folder
            for (int item = 0; item < itemCount; item++)
            {
                EditorUtils.GetScriptOutput(String.Format("child = cur.items[{0}]", item));
                
                // check if it's a folder
                string isFolder = EditorUtils.GetScriptOutput("child.isOfExactType(\"EventFolder\")");
                if (isFolder == "false")
                {
                    continue;
                }

                // Get guid and name
                string info = EditorUtils.GetScriptOutput("child.id + child.name");

                var childEntry = new FolderEntry();
                childEntry.guid = info.Substring(0, 38);
                childEntry.name = info.Substring(38);
                childEntry.parent = entry;
                entry.entries.Add(childEntry);
            }

            // Recurse for child entries
            foreach(var childEntry in entry.entries)
            {
                BuildTreeItem(childEntry);
            }
        }
Exemplo n.º 32
0
        private void BuildTree()
        {
            var rootGuid = EditorUtils.GetScriptOutput("studio.project.workspace.masterEventFolder.id");
            rootFolder = new FolderEntry();
            rootFolder.guid = rootGuid;
            BuildTreeItem(rootFolder);
            wantsMouseMove = true;
            banks = new List<BankEntry>();

            EditorUtils.GetScriptOutput("children = \"\";");
            EditorUtils.GetScriptOutput("func = function(val) {{ children += \",\" + val.id + val.name; }};");
            EditorUtils.GetScriptOutput("studio.project.workspace.masterBankFolder.items.forEach(func, this); ");
            string bankList = EditorUtils.GetScriptOutput("children;");
            string[] bankListSplit = bankList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach(var bank in bankListSplit)
            {
                var entry = new BankEntry();
                entry.guid = bank.Substring(0, 38);
                entry.name = bank.Substring(38);
                banks.Add(entry);
            }

            banks.Sort((a, b) => a.name.CompareTo(b.name));
        }
Exemplo n.º 33
0
 public override void VisitFolder(FolderEntry entry)
 {
     string extractedPosition = Path.Combine(_folder, entry.RelativePath);
     Directory.Exists(extractedPosition).Should().BeTrue(because: "Directory " + extractedPosition + " does not exist.");
     VisitChildren(entry);
 }
Exemplo n.º 34
0
        public void OnGUI()
        {
            var borderIcon = EditorGUIUtility.Load("FMOD/Border.png") as Texture2D;
            var border = new GUIStyle(GUI.skin.box);
            border.normal.background = borderIcon;
            GUI.Box(new Rect(1, 1, position.width - 1, position.height - 1), GUIContent.none, border);

            if (Event.current.type == EventType.layout)
            {
                isConnected = EditorUtils.IsConnectedToStudio();
            }

            if (!isConnected)
            {
                this.ShowNotification(new GUIContent("FMOD Studio not running"));
                return;
            }

            this.RemoveNotification();

            if (rootFolder == null)
            {
                BuildTree();
                currentFolder = rootFolder;
            }

            var arrowIcon = EditorGUIUtility.Load("FMOD/ArrowIcon.png") as Texture;
            var hoverIcon = EditorGUIUtility.Load("FMOD/SelectedAlt.png") as Texture2D;
            var titleIcon = EditorGUIUtility.Load("IN BigTitle") as Texture2D;
            
    
            var nextEntry = currentFolder;

            var filteredEntries = currentFolder.entries.FindAll((x) => x.name.StartsWith(currentFilter, StringComparison.CurrentCultureIgnoreCase));
            

            // Process key strokes for the folder list
            {
                if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    if (Event.current.type == EventType.keyDown)
                    {
                        lastHover = Math.Max(lastHover - 1, 0);
                        if (filteredEntries[lastHover].rect.y < scrollPos.y)
                        {
                            scrollPos.y = filteredEntries[lastHover].rect.y;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    if (Event.current.type == EventType.keyDown)
                    { 
                        lastHover = Math.Min(lastHover + 1, filteredEntries.Count - 1);
                        if (filteredEntries[lastHover].rect.y + filteredEntries[lastHover].rect.height > scrollPos.y + scrollRect.height)
                        {
                            scrollPos.y = filteredEntries[lastHover].rect.y - scrollRect.height + filteredEntries[lastHover].rect.height * 2;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.RightArrow)
                {
                    if (Event.current.type == EventType.keyDown)
                        nextEntry = filteredEntries[lastHover];
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.LeftArrow)
                {
                    if (Event.current.type == EventType.keyDown)
                        if (currentFolder.parent != null)
                            nextEntry = currentFolder.parent;
                    Event.current.Use();
                }
            }

            
            bool disabled = eventName.Length == 0;
            EditorGUI.BeginDisabledGroup(disabled);
            if (GUILayout.Button("Create Event"))
            {
                CreateEventInStudio();
                this.Close();
            }
            EditorGUI.EndDisabledGroup();

            {
                GUI.SetNextControlName("name");
                
                EditorGUILayout.LabelField("Name");
                eventName = EditorGUILayout.TextField(eventName);
            }

            {
                EditorGUILayout.LabelField("Bank");
                selectedBank = EditorGUILayout.Popup(selectedBank, banks.Select(x => x.name).ToArray());
            }

            bool updateEventPath = false;
            {
                GUI.SetNextControlName("folder");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.LabelField("Path");
                eventFolder = GUILayout.TextField(eventFolder);
                if (EditorGUI.EndChangeCheck())
                {
                    updateEventPath = true;
                }
            }
            
            if (resetCursor)
            {
                resetCursor = false;

                var textEditor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                if (textEditor != null)
                {
                    textEditor.MoveCursorToPosition(new Vector2(9999, 9999));
                }
            }

            // Draw the current folder as a title bar, click to go back one level
            {
                Rect currentRect = EditorGUILayout.GetControlRect();
                
                var bg = new GUIStyle(GUI.skin.box);
                bg.normal.background = titleIcon;
                Rect bgRect = new Rect(currentRect);
                bgRect.x = 2;
                bgRect.width = position.width-4;
                GUI.Box(bgRect, GUIContent.none, bg);


                Rect textureRect = currentRect;
                textureRect.width = arrowIcon.width;
                if (currentFolder.name != null)
                {
                    GUI.DrawTextureWithTexCoords(textureRect, arrowIcon, new Rect(1, 1, -1, -1));
                }


                Rect labelRect = currentRect;
                labelRect.x += arrowIcon.width + 50;
                labelRect.width -= arrowIcon.width + 50;
                GUI.Label(labelRect, currentFolder.name != null ? currentFolder.name : "Folders", EditorStyles.boldLabel);

                if (Event.current.type == EventType.mouseDown && currentRect.Contains(Event.current.mousePosition) &&
                    currentFolder.parent != null)
                {
                    nextEntry = currentFolder.parent;
                    Event.current.Use();
                }
            }
            
            var normal = new GUIStyle(GUI.skin.label);
            normal.padding.left = 14;
            var hover = new GUIStyle(normal);
            hover.normal.background = hoverIcon;

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);
            
            for (int i = 0; i < filteredEntries.Count; i++)
            {
                var entry = filteredEntries[i];
                var content = new GUIContent(entry.name);
                var rect = EditorGUILayout.GetControlRect();
                if ((rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseMove) || i == lastHover)
                {
                    lastHover = i;
                    
                    GUI.Label(rect, content, hover);
                    if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseDown)
                    {
                        nextEntry = entry;
                    }                    
                }
                else
                {
                    GUI.Label(rect, content, normal);
                }

                Rect textureRect = rect;
                textureRect.x = textureRect.width - arrowIcon.width;
                textureRect.width = arrowIcon.width;
                GUI.DrawTexture(textureRect, arrowIcon);

                if (Event.current.type == EventType.repaint)
                {
                    entry.rect = rect;
                }
            }
            EditorGUILayout.EndScrollView();

            if (Event.current.type == EventType.repaint)
            {
                scrollRect = GUILayoutUtility.GetLastRect();
            }

            if (currentFolder != nextEntry)
            {
                lastHover = 0;
                currentFolder = nextEntry;
                UpdateTextFromList();
                Repaint();
            }

            if (updateEventPath)
            {
                UpdateListFromText();
            }            

            if (Event.current.type == EventType.MouseMove)
            {
                Repaint();
            }
            
        }        
Exemplo n.º 35
0
        private void UpdateListFromText()
        {
            int endFolders = eventFolder.LastIndexOf("/");
            currentFilter = eventFolder.Substring(endFolders + 1);

            var folders = eventFolder.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            FolderEntry entry = rootFolder;
            int i;
            for (i = 0; i < folders.Length; i++)
            {
                var newEntry = entry.entries.Find((x) => x.name.Equals(folders[i], StringComparison.CurrentCultureIgnoreCase));
                if (newEntry == null)
                {
                    break;
                }
                entry = newEntry;
            }
            currentFolder = entry;

            // Treat an exact filter match as being in that folder and clear the filter
            if (entry.name != null && entry.name.Equals(currentFilter, StringComparison.CurrentCultureIgnoreCase))
            {
                currentFilter = "";
            }
        }
Exemplo n.º 36
0
        private void btnGroupsAddFolder_Click(object sender, RoutedEventArgs e) {
            GroupEntry group;
            int index;
            bool editGroup;
            if(tvwGroups.Items.Count == 0) {
                group = new GroupEntry(QTUtility.TextResourcesDic["Options_Page09_Groups"][6]);
                CurrentGroups.Add(group);
                group.IsSelected = true;
                index = 0;
                editGroup = true;
            }
            else {
                object sel = tvwGroups.SelectedItem;
                if(sel == null) return;
                if(sel is FolderEntry) {
                    FolderEntry entry = (FolderEntry)sel;
                    group = (GroupEntry)entry.ParentItem;
                    index = group.Folders.IndexOf(entry) + 1;
                }
                else {
                    group = (GroupEntry)sel;
                    index = group.Folders.Count;
                }
                editGroup = false;
            }

            FolderBrowserDialogEx dlg = new FolderBrowserDialogEx();
            if(dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            FolderEntry folder = new FolderEntry(dlg.SelectedPath);
            group.Folders.Insert(index, folder);
            group.IsExpanded = true;
            
            if(editGroup) {
                group.IsSelected = true;
                group.IsEditing = true;
            }
            else {
                folder.IsSelected = true;   
            }
        }
Exemplo n.º 37
0
 public override void VisitFolder(FolderEntry entry)
 {
     string extractedPosition = Path.Combine(_folder, entry.RelativePath);
     Assert.IsTrue(Directory.Exists(extractedPosition), "Directory " + extractedPosition + " does not exist.");
     VisitChildren(entry);
 }