Пример #1
0
        private void Button_Allow_Click(object sender, EventArgs e)
        {
            if (m_Base == null)
            {
                return;
            }

            FileFolderHolder ffh = getFfhFromNode(TreeViewFolders.SelectedNode);

            if (ffh == null)
            {
                return;
            }
            string text = "!";

            text += ffh.m_RelativePath + ffh.m_Filename;

            if (!ffh.m_IsFile)
            {
                text += "/";
            }

            GitIgnoreLine gil = new GitIgnoreLine();

            gil.setLine(text.Replace('\\', '/'));

            m_GitLines.Add(gil);

            remakeEverything();
        }
Пример #2
0
        /// <summary>
        /// has the chance to not be right, if the data is not the same
        /// </summary>
        /// <param name="a_Node"></param>
        /// <returns></returns>
        private FileFolderHolder getFfhFromNode(TreeNode a_Node)
        {
            if (a_Node == null)
            {
                return(null);
            }
            string[]         pathSplit = (a_Node.FullPath).Split('\\');
            int              index     = -1;
            FileFolderHolder current   = m_Base;

            //todo change to use a_Node.Index;

            while (current.m_Node != a_Node)
            {
                index++;
                if (index >= pathSplit.Length)
                {
                    break;
                }
                for (int i = 0; i < current.m_Children.Count; i++)
                {
                    if (pathSplit[index] == current.m_Children[i].m_Filename)
                    {
                        current = current.m_Children[i];
                        break;
                    }
                }
            }

            return(current);
        }
Пример #3
0
        private bool isParentExcluded(FileFolderHolder a_Ffh)
        {
            FileFolderHolder parent = a_Ffh.m_Parent;

            while (parent != null)
            {
                if (parent.m_IsExcluded)
                {
                    return(true);
                }
                parent = parent.m_Parent;
            }

            return(false);
        }
Пример #4
0
        private void setUpFolderList()
        {
            m_Base            = new FileFolderHolder();
            m_Base.m_Children = new List <FileFolderHolder>();
            m_Base.m_Path     = m_Dir;
            m_Base.m_Filename = "";
            m_Base.m_IsFile   = false;

            addFolders(m_Base);
            addFiles(m_Base);

            //check git ignore
            runThroughGit(m_Base);
            //run through strikeout
            updateTreeExludeStrikeout(m_Base);
        }
Пример #5
0
        private void TreeViewFolders_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (m_Base == null)
            {
                return;
            }

            m_RemoveOtherSelectedListBox = false;

            GitIgnore_Contents.ClearSelected();
            Info_IgnoreList.ClearSelected();

            m_RemoveOtherSelectedListBox = true;


            m_Selected = getFfhFromNode(e.Node);

            remakeIgnoreContents();
        }
Пример #6
0
        private void loadFolder()
        {
            m_Base = null;
            TreeViewFolders.Nodes.Clear();
            GitIgnore_Contents.Items.Clear();


            if (!loadGitFile())
            {
                return;
            }

            remakeGitList();

            setUpFolderList();

            //addFolders("", null);
            //addFiles("", null);
        }
Пример #7
0
        private void addFiles(FileFolderHolder a_Node)
        {
            //parent node is file, files cant have nested files
            if (a_Node.m_IsFile)
            {
                return;
            }

            string path = a_Node.m_Path + a_Node.m_Filename;

            string[] files = Directory.GetFiles(path);

            for (int i = 0; i < files.Length; i++)
            {
                string[] folderSlit = files[i].Split('\\');
                string   fileName   = folderSlit[folderSlit.Length - 1];

                if (fileName == ".gitignore")
                {
                    continue;
                }

                FileFolderHolder file = new FileFolderHolder();
                file.m_Path     = path + "\\";
                file.m_Filename = fileName;
                file.m_IsFile   = true;
                file.m_Parent   = a_Node;

                file.m_RelativePath = "";

                for (int q = m_DirFolderCount; q < folderSlit.Length - 1; q++)
                {
                    file.m_RelativePath += folderSlit[q] + "\\";
                }

                file.m_Node = addNode(file.m_Filename, a_Node.m_Node);


                a_Node.m_Children.Add(file);
            }
        }
Пример #8
0
        /// <summary>
        /// checks if parent objects have been excluded ana applied the strikeout
        /// </summary>
        /// <param name="a_Ffh"></param>
        private void updateTreeExludeStrikeout(FileFolderHolder a_Ffh)
        {
            for (int i = 0; i < a_Ffh.m_Children.Count; i++)
            {
                FileFolderHolder current = a_Ffh.m_Children[i];

                if (current.m_IsExcluded)
                {
                    current.m_Node.NodeFont = m_FontStrikeOut;
                }
                else
                {
                    current.m_Node.NodeFont = m_FontNormal;
                }

                if (!current.m_IsFile)
                {
                    updateTreeExludeStrikeout(current);
                }
            }
        }
Пример #9
0
        private void addFolders(FileFolderHolder a_Node)
        {
            string path = a_Node.m_Path + a_Node.m_Filename;

            string[] folders = Directory.GetDirectories(path);

            for (int i = 0; i < folders.Length; i++)
            {
                string[] folderSlit = folders[i].Split('\\');
                string   folderName = folderSlit[folderSlit.Length - 1];

                if (folderName == ".git")
                {
                    continue;
                }

                FileFolderHolder folder = new FileFolderHolder();
                folder.m_Children = new List <FileFolderHolder>();
                folder.m_Path     = path + "\\";
                folder.m_Filename = folderName;
                folder.m_IsFile   = false;
                folder.m_Parent   = a_Node;

                folder.m_RelativePath = "";

                for (int q = m_DirFolderCount; q < folderSlit.Length - 1; q++)
                {
                    folder.m_RelativePath += folderSlit[q] + "\\";
                }


                folder.m_Node = addNode(folder.m_Filename, a_Node.m_Node);

                a_Node.m_Children.Add(folder);

                addFolders(folder);
                addFiles(folder);
            }
        }
Пример #10
0
        private void runThroughGit(FileFolderHolder a_Ffh)
        {
            for (int i = 0; i < a_Ffh.m_Children.Count; i++)
            {
                FileFolderHolder current = a_Ffh.m_Children[i];

                if (isParentExcluded(current))
                {
                    current.m_IsExcluded = true;
                }
                else
                {
                    string prefix;
                    if (current.m_IsFile)
                    {
                        prefix = "";
                    }
                    else
                    {
                        prefix = "";
                    }
                    string suffix;
                    if (current.m_IsFile)
                    {
                        suffix = "";
                    }
                    else
                    {
                        suffix = "/";
                    }
                    string dir = prefix + current.m_RelativePath.Replace('\\', '/');

                    dir += current.m_Filename;

                    //if (dir.Length >= 1) {
                    //	dir = dir.Remove(dir.Length - 1);
                    //}

                    dir += suffix;

                    //if (!isFileAllowed(dir)) {
                    //	current.m_IsExcluded = true;
                    //}

                    current.m_Effects = new List <GitIgnoreLine>();

                    bool allowed = true;
                    for (int q = 0; q < m_GitLines.Count; q++)
                    {
                        switch (m_GitLines[q].m_Type)
                        {
                        case GitIgnoreLine.LineType.Comment:
                        case GitIgnoreLine.LineType.Empty:
                            break;

                        case GitIgnoreLine.LineType.Allow:
                        case GitIgnoreLine.LineType.Ignore:
                            if (LikeOperator.LikeString(dir, "*" + m_GitLines[q].m_Line, CompareMethod.Binary))
                            {
                                allowed = m_GitLines[q].m_Type != GitIgnoreLine.LineType.Ignore;
                                current.m_Effects.Add(m_GitLines[q]);
                            }
                            break;
                        }
                    }

                    current.m_IsExcluded = !allowed;
                }

                if (!current.m_IsFile)
                {
                    runThroughGit(current);
                }
            }
        }