コード例 #1
0
        /// <summary>
        /// Event handler for when a DragDrop operation completed on top of the changesview
        /// </summary>
        void changesView_DragDrop(object sender, DragEventArgs e)
        {
            //Check if we have a file/list of filfes
            if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList())
            {
                DataObject       dataObject = (DataObject)e.Data;
                StringCollection dropList   = dataObject.GetFileDropList();

                List <string> filePaths = new List <string>();
                foreach (string path in dropList)
                {
                    if (File.GetAttributes(path).HasFlag(FileAttributes.Directory))
                    {
                        filePaths.AddRange(Util.GetAllChildFiles(path));//Directory.GetFiles(rootPath, "**", SearchOption.AllDirectories);
                    }
                    else
                    {
                        filePaths.Add(path);
                    }
                }
                if (filePaths.Count == 1) //test if its a project
                {
                    if (filePaths[0].ToLower().EndsWith(".rmproj"))
                    {
                        if (HasProjectChanged)
                        {
                            PromptSaveToClose();
                        }

                        //Load the project
                        LoadProject(filePaths[0]);
                        return;
                    }
                }

                //Iterate through all files
                StringQueryDialog nameQueryDialog = new StringQueryDialog("Type File Group Name:");
                nameQueryDialog.ShowDialog();
                if (nameQueryDialog.Value.Trim() == "")
                {
                    Log("Invalid name '{0}' given.  ".F(nameQueryDialog.Value.Trim()));
                    return;
                }
                TristateTreeNode topNode = new TristateTreeNode(nameQueryDialog.Value);
                topNode.HasCheckBox = true;
                for (int z = 0; z < filePaths.Count; z++)
                {
                    SetTaskbarProgress(z * 100 / filePaths.Count);
                    string filePath = filePaths[z].Replace("\\", "/");
                    //Console.WriteLine(filePath);

                    //ADD TO VIEW HERE
                    TristateTreeNode node;
                    topNode.Nodes.Add(
                        node = new TristateTreeNode(filePath)
                        );
                    node.HasCheckBox = true;

                    //changesView.Rows[rowIndex].Cells[CN_LOCALPATH].Style.Alignment = DataGridViewContentAlignment.MiddleRight;

                    //Split the path into pieces split by FSOs...  Search the RAF archives and see if we can link it to the raf path

                    string[]                pathParts    = filePath.Split("/");
                    RAFFileListEntry        matchedEntry = null;
                    List <RAFFileListEntry> lastMatches  = null;
                    bool done = false;

                    //Smart search insertion
                    for (int i = 1; i < pathParts.Length + 1 && !done; i++)
                    {
                        string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i);
                        string   searchPath      = String.Join("/", searchPathParts);
                        //Console.WriteLine(searchPath);
                        List <RAFFileListEntry> matches  = new List <RAFFileListEntry>();
                        RAFArchive[]            archives = rafArchives.Values.ToArray();
                        for (int j = 0; j < archives.Length; j++)
                        {
                            List <RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath);
                            matches.AddRange(newmatches);
                        }
                        if (matches.Count == 1)
                        {
                            matchedEntry = matches[0];
                            done         = true;
                        }
                        else if (matches.Count == 0)
                        {
                            done = true;
                        }
                        else
                        {
                            lastMatches = matches;
                        }
                    }
                    if (matchedEntry == null)
                    {
                        if (lastMatches != null && lastMatches.Count > 0)
                        {
                            //Resolve ambiguity
                            FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "!");
                            ambiguityResolver.ShowDialog();
                            RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem;
                            if (resolvedItem != null)
                            {
                                matchedEntry = resolvedItem;
                            }
                        }
                        else if (advancedUser)
                        {
                            //We'll use the file browser to select where we want to save...
                            string     rafPath = PickRafPath(false) + "/";
                            RAFArchive archive = rafArchives[rafPath.Replace("\\", "/").Split("/").First()];
                            rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now...
                            if (rafPath.Length != 0)
                            {
                                Console.WriteLine("FRP: " + "len!= 0");
                                if (rafPath[rafPath.Length - 1] == '/')
                                {
                                    Console.WriteLine("FRP: " + rafPath);
                                    rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later
                                }
                            }
                            Console.WriteLine("FRP: " + rafPath);
                            if (rafPath == "")
                            {
                                matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(filePath).Length, UInt32.MaxValue);
                            }
                            else
                            {
                                matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(filePath).Length, UInt32.MaxValue);
                            }

                            //Add the tree node to the raf viewer
                        }
                    }
                    if (matchedEntry != null) //If it's still not resolved
                    {
                        node.Tag = new ChangesViewEntry(filePath, matchedEntry, node);
                        node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                        node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName));
                        node.Nodes[0].HasCheckBox = false;
                        node.Nodes[1].HasCheckBox = false;
                        //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName;
                        //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry;
                    }
                    else
                    {
                        node.Tag = new ChangesViewEntry(filePath, null, node);
                        node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                        node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined"));
                        node.Nodes[0].HasCheckBox = false;
                        node.Nodes[1].HasCheckBox = false;
                        Log("Unable to link file '" + filePath + "' to RAF Archive.  Please manually select RAF path");
                    }
                }
                changesView.Nodes.Add(topNode);
                changesView.Invalidate();
                SetTaskbarProgress(0);
            }
        }
コード例 #2
0
        ///<summary>
        ///Returns a guess of the RAF Path, including the archive id or "undefined"
        ///</summary>
        public string GuessRafPathFromPath(string basePath)
        {
            string[]                pathParts    = basePath.Replace("\\", "/").Split("/");
            RAFFileListEntry        matchedEntry = null;
            List <RAFFileListEntry> lastMatches  = null;
            bool done = false;

            //Smart search insertion
            for (int i = 1; i < pathParts.Length + 1 && !done; i++)
            {
                string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i);
                string   searchPath      = String.Join("/", searchPathParts);
                //Console.WriteLine(searchPath);
                List <RAFFileListEntry> matches  = new List <RAFFileListEntry>();
                RAFArchive[]            archives = rafManager.Archives.ToArray();
                for (int j = 0; j < archives.Length; j++)
                {
                    List <RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath);
                    matches.AddRange(newmatches);
                }
                if (matches.Count == 1)
                {
                    matchedEntry = matches[0];
                    done         = true;
                }
                else if (matches.Count == 0)
                {
                    done = true;
                }
                else
                {
                    lastMatches = matches;
                }
            }
            if (matchedEntry == null)
            {
                if (lastMatches != null && lastMatches.Count > 0)
                {
                    //Resolve ambiguity
                    FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "Notes: " + basePath);
                    ambiguityResolver.ShowDialog();
                    RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem;
                    if (resolvedItem != null)
                    {
                        matchedEntry = resolvedItem;
                    }
                }
                else if (permitExperimentalFileAddingCB.Checked)//advanced user
                {
                    //We'll use the file browser to select where we want to save...
                    string     rafPath = PickRafPath(false) + "/";
                    RAFArchive archive = rafManager.Archives.Where(
                        (Func <RAFArchive, bool>) delegate(RAFArchive arc)
                    {
                        return(arc.GetID().ToLower() == rafPath.Replace("\\", "/").Split("/").First().ToLower());
                    }
                        ).First();
                    rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now...
                    if (rafPath.Length != 0)
                    {
                        Console.WriteLine("FRP: " + "len!= 0");
                        if (rafPath[rafPath.Length - 1] == '/')
                        {
                            Console.WriteLine("FRP: " + rafPath);
                            rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later
                        }
                    }
                    Console.WriteLine("FRP: " + rafPath);
                    if (rafPath == "")
                    {
                        matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(basePath).Length, UInt32.MaxValue);
                    }
                    else
                    {
                        matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(basePath).Length, UInt32.MaxValue);
                    }

                    //Add the tree node to the raf viewer
                }
            }
            if (matchedEntry != null) //If it is resolved
            {
                /*
                 * node.Tag = new ChangesViewEntry(filePath, matchedEntry, node);
                 * node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                 * node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName));
                 * node.Nodes[0].HasCheckBox = false;
                 * node.Nodes[1].HasCheckBox = false;
                 */
                //Don't add it
                return(matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName);
                //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName;
                //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry;
            }
            else
            {
                /*
                 * node.Tag = new ChangesViewEntry(filePath, null, node);
                 * node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                 * node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined"));
                 * node.Nodes[0].HasCheckBox = false;
                 * node.Nodes[1].HasCheckBox = false;
                 * Log("Unable to link file '" + filePath + "' to RAF Archive.  Please manually select RAF path");
                 */
                //Log("Unable to resolve local path to RAF path: " + basePath);
                return("undefined");
            }
        }
コード例 #3
0
        ///<summary>
        ///Returns a guess of the RAF Path, including the archive id or "undefined"
        ///</summary>
        public string GuessRafPathFromPath(string basePath)
        {
            string[] pathParts = basePath.Replace("\\","/").Split("/");
            RAFFileListEntry matchedEntry = null;
            List<RAFFileListEntry> lastMatches = null;
            bool done = false;

            //Smart search insertion
            for (int i = 1; i < pathParts.Length + 1 && !done; i++)
            {
                string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i);
                string searchPath = String.Join("/", searchPathParts);
                //Console.WriteLine(searchPath);
                List<RAFFileListEntry> matches = new List<RAFFileListEntry>();
                RAFArchive[] archives = rafManager.Archives.ToArray();
                for (int j = 0; j < archives.Length; j++)
                {
                    List<RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath);
                    matches.AddRange(newmatches);
                }
                if (matches.Count == 1)
                {
                    matchedEntry = matches[0];
                    done = true;
                }
                else if (matches.Count == 0)
                {
                    done = true;
                }
                else
                {
                    lastMatches = matches;
                }
            }
            if (matchedEntry == null)
            {
                if (lastMatches != null && lastMatches.Count > 0)
                {
                    //Resolve ambiguity
                    FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "Notes: "+basePath);
                    ambiguityResolver.ShowDialog();
                    RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem;
                    if (resolvedItem != null)
                    {
                        matchedEntry = resolvedItem;
                    }
                }
                else if (permitExperimentalFileAddingCB.Checked)//advanced user
                {
                    //We'll use the file browser to select where we want to save...
                    string rafPath = PickRafPath(false) + "/";
                    RAFArchive archive = rafManager.Archives.Where(
                        (Func<RAFArchive, bool>)delegate(RAFArchive arc)
                        {
                            return arc.GetID().ToLower() == rafPath.Replace("\\", "/").Split("/").First().ToLower();
                        }
                    ).First();
                    rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now...
                    if (rafPath.Length != 0)
                    {
                        Console.WriteLine("FRP: " + "len!= 0");
                        if (rafPath[rafPath.Length - 1] == '/')
                        {
                            Console.WriteLine("FRP: " + rafPath);
                            rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later
                        }
                    }
                    Console.WriteLine("FRP: " + rafPath);
                    if (rafPath == "")
                        matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(basePath).Length, UInt32.MaxValue);
                    else
                        matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(basePath).Length, UInt32.MaxValue);

                    //Add the tree node to the raf viewer
                }
            }
            if (matchedEntry != null) //If it is resolved
            {
                /*
                node.Tag = new ChangesViewEntry(filePath, matchedEntry, node);
                node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName));
                node.Nodes[0].HasCheckBox = false;
                node.Nodes[1].HasCheckBox = false;
                 */
                //Don't add it
                return matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName;
                //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName;
                //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry;
            }
            else
            {
                /*
                node.Tag = new ChangesViewEntry(filePath, null, node);
                node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined"));
                node.Nodes[0].HasCheckBox = false;
                node.Nodes[1].HasCheckBox = false;
                Log("Unable to link file '" + filePath + "' to RAF Archive.  Please manually select RAF path");
                 */
                //Log("Unable to resolve local path to RAF path: " + basePath);
                return "undefined";
            }
        }
コード例 #4
0
        /// <summary>
        /// Event handler for when a DragDrop operation completed on top of the changesview
        /// </summary>
        void changesView_DragDrop(object sender, DragEventArgs e)
        {
            //Check if we have a file/list of filfes
            if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList())
            {

                DataObject dataObject = (DataObject)e.Data;
                StringCollection dropList = dataObject.GetFileDropList();

                List<string> filePaths = new List<string>();
                foreach (string path in dropList)
                {
                    if (File.GetAttributes(path).HasFlag(FileAttributes.Directory))
                        filePaths.AddRange(Util.GetAllChildFiles(path));//Directory.GetFiles(rootPath, "**", SearchOption.AllDirectories);
                    else
                        filePaths.Add(path);
                }
                if (filePaths.Count == 1) //test if its a project
                {
                    if (filePaths[0].ToLower().EndsWith(".rmproj"))
                    {
                        if (HasProjectChanged)
                            PromptSaveToClose();

                        //Load the project
                        LoadProject(filePaths[0]);
                        return;
                    }
                }

                //Iterate through all files
                StringQueryDialog nameQueryDialog = new StringQueryDialog("Type File Group Name:");
                nameQueryDialog.ShowDialog();
                if (nameQueryDialog.Value.Trim() == "")
                {
                    Log("Invalid name '{0}' given.  ".F(nameQueryDialog.Value.Trim()));
                    return;
                }
                TristateTreeNode topNode = new TristateTreeNode(nameQueryDialog.Value);
                topNode.HasCheckBox = true;
                for (int z = 0; z < filePaths.Count; z++)
                {
                    SetTaskbarProgress(z * 100 / filePaths.Count);
                    string filePath = filePaths[z].Replace("\\", "/");
                    //Console.WriteLine(filePath);

                    //ADD TO VIEW HERE
                    TristateTreeNode node;
                    topNode.Nodes.Add(
                        node = new TristateTreeNode(filePath)
                    );
                    node.HasCheckBox = true;

                    //changesView.Rows[rowIndex].Cells[CN_LOCALPATH].Style.Alignment = DataGridViewContentAlignment.MiddleRight;

                    //Split the path into pieces split by FSOs...  Search the RAF archives and see if we can link it to the raf path

                    string[] pathParts = filePath.Split("/");
                    RAFFileListEntry matchedEntry = null;
                    List<RAFFileListEntry> lastMatches = null;
                    bool done = false;

                    //Smart search insertion
                    for (int i = 1; i < pathParts.Length + 1 && !done; i++)
                    {
                        string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i);
                        string searchPath = String.Join("/", searchPathParts);
                        //Console.WriteLine(searchPath);
                        List<RAFFileListEntry> matches = new List<RAFFileListEntry>();
                        RAFArchive[] archives = rafArchives.Values.ToArray();
                        for (int j = 0; j < archives.Length; j++)
                        {
                            List<RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath);
                            matches.AddRange(newmatches);
                        }
                        if (matches.Count == 1)
                        {
                            matchedEntry = matches[0];
                            done = true;
                        }
                        else if (matches.Count == 0)
                        {
                            done = true;
                        }
                        else
                        {
                            lastMatches = matches;
                        }
                    }
                    if (matchedEntry == null)
                    {
                        if (lastMatches != null && lastMatches.Count > 0)
                        {
                            //Resolve ambiguity
                            FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "!");
                            ambiguityResolver.ShowDialog();
                            RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem;
                            if (resolvedItem != null)
                            {
                                matchedEntry = resolvedItem;
                            }
                        }
                        else if (advancedUser)
                        {
                            //We'll use the file browser to select where we want to save...
                            string rafPath = PickRafPath(false) + "/";
                            RAFArchive archive = rafArchives[rafPath.Replace("\\", "/").Split("/").First()];
                            rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now...
                            if (rafPath.Length != 0)
                            {
                                Console.WriteLine("FRP: " + "len!= 0");
                                if (rafPath[rafPath.Length - 1] == '/') 
                                {
                                    Console.WriteLine("FRP: " + rafPath);
                                    rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later
                                }
                            }
                            Console.WriteLine("FRP: " + rafPath);
                            if (rafPath == "")
                                matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(filePath).Length, UInt32.MaxValue);
                            else
                                matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(filePath).Length, UInt32.MaxValue);
                            
                            //Add the tree node to the raf viewer
                        }
                    }
                    if (matchedEntry != null) //If it's still not resolved
                    {
                        node.Tag = new ChangesViewEntry(filePath, matchedEntry, node);
                        node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                        node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName));
                        node.Nodes[0].HasCheckBox = false;
                        node.Nodes[1].HasCheckBox = false;
                        //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName;
                        //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry;
                    }
                    else
                    {
                        node.Tag = new ChangesViewEntry(filePath, null, node);
                        node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath));
                        node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined"));
                        node.Nodes[0].HasCheckBox = false;
                        node.Nodes[1].HasCheckBox = false;
                        Log("Unable to link file '" + filePath + "' to RAF Archive.  Please manually select RAF path");
                    }
                }
                changesView.Nodes.Add(topNode);
                changesView.Invalidate();
                SetTaskbarProgress(0);
            }
        }