コード例 #1
0
        protected override bool ApplyChanges()
        {
            ExcludedFiles.Clear();
            foreach (string item in excludedFilesControl.ExcludedItems)
            {
                ExcludedFiles.Add(item);
            }

            ExcludedFolders.Clear();
            foreach (string item in excludedFoldersControl.ExcludedItems)
            {
                ExcludedFolders.Add(item);
            }

            foreach (CheckBox child in tableLayoutPanel1.Controls)
            {
                string tag = (string)child.Tag;

                if (child.Checked)
                {
                    if (!ExcludedAttributes.Contains(tag))
                    {
                        ExcludedAttributes += tag;
                    }
                }
                else
                {
                    ExcludedAttributes = ExcludedAttributes.Replace(tag, string.Empty);
                }
            }

            return(true);
        }
コード例 #2
0
        public static bool IsScriptExcluded(string scriptName)
        {
            bool isExcluded = false;

#if GENERATED_FILES
            GameObject      go         = GameObject.FindWithTag("Generated");
            ExcludedFolders expFolders = go.GetComponent <ExcludedFolders>();

            if (expFolders != null)
            {
                if (SortScripts.scriptsDict.ContainsKey(scriptName))
                {
                    for (int i = 0; i < SortScripts.scriptsDict[scriptName].Count; i++)
                    {
                        for (int j = 0; j < expFolders.excludedFolders.Count; j++)
                        {
                            if (expFolders.excludedFolders[j].ToString().Equals(SortScripts.scriptsDict[scriptName][i]))
                            {
                                isExcluded = true;
                                break;
                            }
                        }

                        if (isExcluded)
                        {
                            break;
                        }
                    }
                }
            }
#endif
            return(isExcluded);
        }
コード例 #3
0
        private async void AddExcluded()
        {
            var picker = new FolderPicker
            {
                SuggestedStartLocation = PickerLocationId.MusicLibrary,
                ViewMode = PickerViewMode.List
            };

            picker.FileTypeFilter.Add("*");
            var folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                if (!LibraryFolders.Any(f => folder.Path.IsSubPathOf(f.Path)))
                {
                    await new MessageDialog(CommonSharedStrings.SelectionNotInLibraryPrompt).ShowAsync();
                }
                else
                {
                    var folderModel = new FolderModel
                    {
                        Path = folder.Path,
                        Name = folder.Name
                    };
                    PathExclusion.AddExcludedPath(folder.Path);
                    folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>(e =>
                    {
                        PathExclusion.RemoveExcludedPath(folder.Path);
                        ExcludedFolders.Remove(folderModel);
                    });
                    ExcludedFolders.Add(folderModel);
                }
            }
        }
コード例 #4
0
 public void Save(ISettingsStore settings)
 {
     settings.Set(Constants.Settings.Version, CurrentVersion);
     settings.Set(Constants.Settings.Include.Folders, string.Join("|", IncludedFolders.Select(p => p.FullPath)));
     settings.Set(Constants.Settings.Include.Extensions, string.Join("|", IncludedExtensions));
     settings.Set(Constants.Settings.Exclude.Folders, string.Join("|", ExcludedFolders.Select(p => p.FullPath)));
     settings.Set(Constants.Settings.Exclude.Patterns, string.Join("|", ExcludedPatterns));
 }
コード例 #5
0
        /// <summary>
        /// Method for loading library folders.
        /// </summary>
        /// <returns></returns>
        public async Task LoadFoldersAsync()
        {
            // Library
            var libraryFolders = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music);

            foreach (var folder in libraryFolders.Folders)
            {
                LibraryFolders.Add(new FolderModel
                {
                    Path = folder.Path,
                    Name = folder.Name,
                    RemoveFolderButtonClickedRelayCommand = _removeFolderButtonClickedRelayCommand
                });
            }
            var excludedFolders = PathExclusion.GetExcludedPath();

            foreach (var folder in excludedFolders)
            {
                var folderModel = new FolderModel
                {
                    Path = folder,
                    Name = Path.GetDirectoryName(folder)
                };
                folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>(e =>
                {
                    PathExclusion.RemoveExcludedPath(folder);
                    ExcludedFolders.Remove(folderModel);
                });
                ExcludedFolders.Add(folderModel);
            }
            var accessFolders = await FutureAccessListHelper.Instance.GetAuthroizedStorageItemsAsync();

            foreach (var item in accessFolders)
            {
                var folderModel = new FolderModel
                {
                    Path = item.Item2.Path,
                    Name = item.Item2.Name
                };
                var token = item.Item1;
                folderModel.RemoveFolderButtonClickedRelayCommand = new RelayCommand <RoutedEventArgs>(
                    async(e) =>
                {
                    await FutureAccessListHelper.Instance.RemoveAuthorizedItemAsync(token);
                    AccessFolders.Remove(folderModel);
                });
                AccessFolders.Add(folderModel);
            }
        }
コード例 #6
0
        private void WalkDirectory(string searchValue, string replaceValue, DirectoryInfo root)
        {
            FileInfo[]      files   = null;
            DirectoryInfo[] subDirs = null;

            // First, process all the files directly under this folder
            try
            {
                files = root.GetFiles("*.*").Where(fi => !ExcludedFileExtentions.Contains(fi.Extension, StringComparer.OrdinalIgnoreCase)).ToArray();
            }
            // This is thrown if even one of the files requires permissions greater
            // than the application provides.
            catch (UnauthorizedAccessException e)
            {
                Console.WriteLine(e.Message);
            }

            catch (DirectoryNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            if (files != null)
            {
                foreach (FileInfo fi in files)
                {
                    // In this example, we only access the existing FileInfo object. If we
                    // want to open, delete or modify the file, then
                    // a try-catch block is required here to handle the case
                    // where the file has been deleted since the call to TraverseTree().
                    string text = File.ReadAllText(fi.FullName);
                    if (text.Contains(searchValue) && !fi.Attributes.HasFlag(FileAttributes.Hidden) && !fi.Attributes.HasFlag(FileAttributes.ReadOnly))
                    {
                        text = text.Replace(searchValue, replaceValue);
                        File.WriteAllText(fi.FullName, text);
                    }
                    Console.WriteLine(fi.FullName);
                }

                // Now find all the subdirectories under this directory.
                subDirs = root.GetDirectories().Where(dir => !ExcludedFolders.Contains(dir.Name, StringComparer.OrdinalIgnoreCase)).ToArray();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    // Resursive call for each subdirectory.
                    WalkDirectory(searchValue, replaceValue, dirInfo);
                }
            }
        }
コード例 #7
0
    /// <summary>
    /// Determines if specified folder under root is excluded or not.
    /// </summary>
    /// <param name="folderName">Path to folder</param>
    /// <returns>True if folder is excluded</returns>
    private bool IsExcluded(string folderName)
    {
        if (String.IsNullOrEmpty(ExcludedFolders))
        {
            return(false);
        }

        foreach (string folder in ExcludedFolders.Split(';'))
        {
            if (folderName.ToLowerCSafe().EqualsCSafe(Path.Combine(FullStartingPath.ToLowerCSafe(), folder), true))
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #8
0
        protected bool ApplyChanges()
        {
            ExcludedFiles.Clear();
            foreach (string item in excludedFilesControl.ExcludedItems)
            {
                ExcludedFiles.Add(item);
            }

            ExcludedFolders.Clear();
            foreach (string item in excludedFoldersControl.ExcludedItems)
            {
                ExcludedFolders.Add(item);
            }



            return(true);
        }
コード例 #9
0
    /// <summary>
    /// Reload control data.
    /// </summary>
    public void ReloadData()
    {
        try
        {
            this.treeFileSystem.Nodes.Clear();
            InitializeTree();

            // Expand current node parent
            if (!String.IsNullOrEmpty(DefaultPath))
            {
                if (!this.DefaultPath.ToLower().StartsWith(this.FullStartingPath.ToLower().TrimEnd('\\')))
                {
                    this.DefaultPath = DirectoryHelper.CombinePath(this.FullStartingPath, this.DefaultPath);
                }

                if (!String.IsNullOrEmpty(ExcludedFolders))
                {
                    foreach (string excludedFolder in ExcludedFolders.Split(';'))
                    {
                        if (DefaultPath.ToLower().StartsWith((DirectoryHelper.CombinePath(FullStartingPath, excludedFolder)).ToLower()))
                        {
                            this.DefaultPath = this.FullStartingPath;
                            break;
                        }
                    }
                }

                string preselectedPath = this.DefaultPath;
                string rootPath        = this.treeFileSystem.Nodes[0].Value;

                if (preselectedPath.ToLower().StartsWith(rootPath.ToLower()))
                {
                    TreeNode parent = this.treeFileSystem.Nodes[0];

                    string[] folders = preselectedPath.ToLower().Substring(rootPath.Length).Split('\\');
                    int      index   = 0;
                    string   path    = rootPath.ToLower() + folders[index];


                    foreach (string folder in folders)
                    {
                        foreach (TreeNode node in parent.ChildNodes)
                        {
                            if (node.Value.ToLower() == path)
                            {
                                parent = node;
                                break;
                            }
                        }
                        if (index < folders.Length - 1)
                        {
                            parent.Expand();
                            path += '\\' + folders[index + 1];
                        }
                        else
                        {
                            if (ExpandDefaultPath)
                            {
                                parent.Expand();
                            }
                        }
                        index++;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text    = GetString("ContentTree.FailedLoad") + ": " + ex.Message;
            lblError.ToolTip = ex.StackTrace;
        }
    }
コード例 #10
0
 /// <summary>
 /// Method for cleaning up.
 /// </summary>
 public override void Cleanup()
 {
     ExcludedFolders.Clear();
     LibraryFolders.Clear();
     AccessFolders.Clear();
 }
コード例 #11
0
    /// <summary>
    /// Reload control data.
    /// </summary>
    public void ReloadData()
    {
        try
        {
            treeFileSystem.Nodes.Clear();
            InitializeTree();

            // Expand current node parent
            if (!String.IsNullOrEmpty(DefaultPath))
            {
                if (!DefaultPath.ToLowerCSafe().StartsWithCSafe(FullStartingPath.ToLowerCSafe().TrimEnd('\\')))
                {
                    DefaultPath = DirectoryHelper.CombinePath(FullStartingPath, DefaultPath);
                }

                if (!String.IsNullOrEmpty(ExcludedFolders))
                {
                    foreach (string excludedFolder in ExcludedFolders.Split(';'))
                    {
                        if (DefaultPath.ToLowerCSafe().StartsWithCSafe((DirectoryHelper.CombinePath(FullStartingPath, excludedFolder)).ToLowerCSafe()))
                        {
                            DefaultPath = FullStartingPath;
                            break;
                        }
                    }
                }

                string preselectedPath = DefaultPath;
                string rootPath        = treeFileSystem.Nodes[0].Value;

                if (preselectedPath.ToLowerCSafe().StartsWithCSafe(rootPath.ToLowerCSafe()))
                {
                    TreeNode parent = treeFileSystem.Nodes[0];

                    string[] folders = preselectedPath.ToLowerCSafe().Substring(rootPath.Length).Split('\\');
                    int      index   = 0;
                    string   path    = rootPath.ToLowerCSafe() + folders[index];


                    foreach (string folder in folders)
                    {
                        foreach (TreeNode node in parent.ChildNodes)
                        {
                            if (node.Value.ToLowerCSafe() == path)
                            {
                                parent = node;
                                break;
                            }
                        }

                        if (index < folders.Length - 1)
                        {
                            parent.Expand();
                            path += '\\' + folders[index + 1];
                        }
                        else
                        {
                            if (ExpandDefaultPath)
                            {
                                parent.Expand();
                            }
                        }

                        index++;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblError.Text = GetString("ContentTree.FailedLoad");

            Service.Resolve <IEventLogService>().LogException("ContentTree", "LOAD", ex, SiteContext.CurrentSiteID);
        }
    }
コード例 #12
0
 public bool IsPathExcluded(string currentDirectoryFullName)
 {
     return(ExcludedFolders.Exists(x => String.Equals(x, currentDirectoryFullName, StringComparison.InvariantCultureIgnoreCase)));
 }