Ejemplo n.º 1
0
        //public string Name => Path.Split(new[] { '/' }).Last();

        public FileInfoExtended[] GetAllFiles()
        {
            return(Subfolders.Flatten(f => f.Subfolders)
                   .SelectMany(f => f.Files)
                   .Concat(Files)
                   .ToArray());
        }
Ejemplo n.º 2
0
 public static Bitmap GetImage(string img_name, Subfolders sub)//get image from source using image name and subfolder
 {
     using (Image img = Image.FromFile(Path.Combine(basePath, sub.ToString(), img_name)))
     {
         return(new Bitmap(img));
     }
 }
Ejemplo n.º 3
0
        public void SubFolderButtonClicked(SubfolderButtonClickedEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (Directory.Exists(e.SubfolderInfo.directory))
                {
                    Move(e.SubfolderInfo.directory);

                    //TODO: What to do about moving focus between controls when moving files?
                    //form.tagSearchTextBox.Focus();
                }
                else
                {
                    DialogResult result = MessageBox.Show($"The selected directory \"{e.SubfolderInfo.directory}\" does not exist, would you like to remove it from the list?",
                                                          "Directory does not exist",
                                                          MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Error);

                    if (result == DialogResult.Yes)
                    {
                        Subfolders.Remove(e.SubfolderInfo);
                    }
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (e.SubfolderInfo.custom)
                {
                    Subfolders.Remove(e.SubfolderInfo);
                }
            }
        }
Ejemplo n.º 4
0
        public void AddCustomSubfolder()
        {
            AddDirectoryForm adf = new AddDirectoryForm((name, directory) =>
            {
                Subfolders.Add(new SubfolderInfo(name, directory, true));
            });

            adf.ShowDialog();
        }
Ejemplo n.º 5
0
 public bool Matches(IliasFile other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Subfolders.SequenceEqual(other.Subfolders) &&
            Name == other.Name && Id == other.Id &&
            Url == other.Url);
 }
Ejemplo n.º 6
0
 public bool Equals(IliasFile other)
 {
     if (other == null)
     {
         return(false);
     }
     return(Subfolders.SequenceEqual(other.Subfolders) &&
            Name == other.Name && Id == other.Id &&
            Url == other.Url && Date.CompareTo(other.Date) == 0 &&
            LastModified.CompareTo(other.LastModified) == 0);
 }
Ejemplo n.º 7
0
        private void GetDirectories()
        {
            var dirs = Directory.GetDirectories(NormalizedPath);

            foreach (var dir in dirs)
            {
                var dirName = System.IO.Path.GetFileName(dir);
                if (!dirName.StartsWith("_"))
                {
                    Subfolders.Add(new Folder(dir));
                }
            }
        }
Ejemplo n.º 8
0
        ///<summary>Serializes this instance to XML.</summary>
        public XElement ToXml()
        {
            return(new XElement("Folder",
                                new XAttribute("name", Name),

                                new XElement("Books",
                                             Books.Select(f => f.ToXml())
                                             ),
                                new XElement("Subfolders",
                                             Subfolders.Select(f => f.ToXml())
                                             )
                                ));
        }
Ejemplo n.º 9
0
        public void SaveSettings()
        {
            // On exit, set all these prefs but dont save after each one, save after setting them all.
            Settings.Default.Tags = Tags.ToList();

            Settings.Default.SubfolderNames       = Subfolders.Where(t => t.custom).Select(t => t.name).ToList();
            Settings.Default.SubfolderDirectories = Subfolders.Where(t => t.custom).Select(t => t.directory).ToList();

            //Settings.Default.VideoMute = mediaViewer.Mute;
            //Settings.Default.VideoVolume = mediaViewer.VolumeLevel;

            Settings.Default.Save();
        }
Ejemplo n.º 10
0
        public IEnumerable <KeyValuePair <string, string> > GetInfoPairs()
        {
            var list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("diskcache_autoclean", AutoClean ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_asyncwrites", AsyncWrites ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_subfolders", Subfolders.ToString()));
            list.Add(new KeyValuePair <string, string>("diskcache_network_drive", CacheDriveOnNetwork() ? "1" : "0"));
            list.Add(new KeyValuePair <string, string>("diskcache_filesystem", GetCacheDrive()?.DriveFormat ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_drive_avail", GetCacheDrive()?.AvailableFreeSpace.ToString() ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_drive_total", GetCacheDrive()?.TotalSize.ToString() ?? ""));
            list.Add(new KeyValuePair <string, string>("diskcache_virtualpath", VirtualCacheDir));
            return(list);
        }
Ejemplo n.º 11
0
        public IEnumerable <IIssue> GetIssues()
        {
            List <IIssue> issues = new List <IIssue>();

            if (cleaner != null)
            {
                issues.AddRange(cleaner.GetIssues());
            }

            if (!c.get("diskcache.hashModifiedDate", true))
            {
                issues.Add(new Issue("DiskCache", "V4.0 no longer supports hashModifiedDate=false. Please remove this attribute.", IssueSeverity.ConfigurationError));
            }

            if (!HasFileIOPermission())
            {
                issues.Add(new Issue("DiskCache", "Failed to start: Write access to the cache directory is prohibited by your .NET trust level configuration.",
                                     "Please configure your .NET trust level to permit writing to the cache directory. Most medium trust configurations allow this, but yours does not.", IssueSeverity.ConfigurationError));
            }

            if (!HasNTFSPermission())
            {
                issues.Add(new Issue("DiskCache", "Not working: Your NTFS Security permissions are preventing the application from writing to the disk cache",
                                     "Please give user " + GetExecutingUser() + " read and write access to directory \"" + PhysicalCacheDir + "\" to correct the problem. You can access NTFS security settings by right-clicking the aforementioned folder and choosing Properties, then Security.", IssueSeverity.ConfigurationError));
            }

            if (!Started && !Enabled)
            {
                issues.Add(new Issue("DiskCache", "DiskCache is disabled in Web.config. Set enabled=true on the <diskcache /> element to fix.", null, IssueSeverity.ConfigurationError));
            }

            //Warn user about setting hashModifiedDate=false in a web garden.
            if (this.AsyncBufferSize < 1024 * 1024 * 2)
            {
                issues.Add(new Issue("DiskCache", "The asyncBufferSize should not be set below 2 megabytes (2097152). Found in the <diskcache /> element in Web.config.",
                                     "A buffer that is too small will cause requests to be processed synchronously. Remember to set the value to at least 4x the maximum size of an output image.", IssueSeverity.ConfigurationError));
            }


            if (CacheDriveOnNetwork())
            {
                issues.Add(new Issue("DiskCache", "It appears that the cache directory is located on a network drive.",
                                     "Both IIS and ASP.NET have trouble hosting websites with large numbers of folders over a network drive, such as a SAN. The cache will create " +
                                     Subfolders.ToString() + " subfolders. If the total number of network-hosted folders exceeds 100, you should contact [email protected] and consult the documentation for details on configuring IIS and ASP.NET for this situation.", IssueSeverity.Warning));
            }

            return(issues);
        }
Ejemplo n.º 12
0
        public static void SaveImage(OpenFileDialog openfile, Subfolders sub)
        {
            string savePath = Path.Combine(basePath, sub.ToString()); //Remote SubFolder path

            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            //save to remote destination
            var destination = Path.Combine(savePath, openfile.SafeFileName);

            File.Copy(openfile.FileName, destination, true); //Overwrite set to true
        }
Ejemplo n.º 13
0
 public void Copy(Resource rl)
 {
     foreach (Resource item in rl.Embedded)
     {
         if (item.Type == YandexDiskSharp.Type.dir)
         {
             Subfolders.Add(new CloudFolder(item));
         }
         else
         {
             CloudFile r = new CloudFile(item);
             Files.Add(r);
             Size += r.Size;
         }
     }
     SizeTopDirectoryOnly = Size;
 }
Ejemplo n.º 14
0
        private void LoadDirectory(DirectoryInfo dirInfo)
        {
            ShowLoading();

            form.SuspendLayout();

            var loadedTags = (Settings.Default.Tags != null) ? Settings.Default.Tags : new List <string>();

            form.tagPanel.ReorderButtons = false;

            // Remove all tags that aren't included in the loaded tags.
            Tags.RemoveRange(Tags.Where(t => !loadedTags.Contains(t)));

            // Add all tags that are in loaded tags but not in current tags.
            //Tags.AddRange(loadedTags.Where(t => !Tags.Contains(t)).ToList());
            for (int i = 0; i < loadedTags.Count; i++)
            {
                if (!Tags.Contains(loadedTags[i]))
                {
                    Tags.Add(loadedTags[i]);
                }
            }

            form.tagPanel.ReorderButtons = true;
            form.tagPanel.ReorderTagButtons();

            // Empty all Subfolders and load custom ones from settings.
            //while (Subfolders.Count > 0)
            //Subfolders.RemoveAt(0);
            Subfolders.Clear();

            var sfnames       = Settings.Default.SubfolderNames ?? new List <string>();
            var sfdirectories = Settings.Default.SubfolderDirectories ?? new List <string>();

            for (int i = 0; i < Math.Min(sfnames.Count, sfdirectories.Count); i++)
            {
                Subfolders.Add(new SubfolderInfo(sfnames[i], sfdirectories[i], true));
            }

            // Load info specific to chosen directory.

            if (dirInfo == null)
            {
                Logs.Log("Directory open cancelled.");
                this.files = new List <string>();
            }
            else
            {
                this.directory = dirInfo.FullName;
                this.files     = dirInfo.GetFileNamesList();

                string[] folders = dirInfo.GetFolderNames();
                for (int i = 0; i < folders.Length; i++)
                {
                    Subfolders.Add(new SubfolderInfo(folders[i], Path.Combine(directory, folders[i]), false));
                }

                fileIndex = 0;

                Logs.Log($"Opened '{directory}' and found {files.Count} files and {folders.Length} subdirectories.");
            }

            form.ResumeLayout();

            HideLoading();
        }
Ejemplo n.º 15
0
 public static void DeleteImage(Subfolders sub, string image_name)
 {
     File.Delete(Path.Combine(basePath, sub.ToString(), image_name));
 }
 public void AddSubFolder(Folder name)
 {
     Subfolders.Add(name);
     name.RootFolder = this;
     name.level      = this.level + 1;
 }
 //Not sure if we need some other SubFolder recursive thing
 public void AddSubFolder(string name)
 {
     Subfolders.Add(new Folder(name));
     Subfolders.Last().RootFolder = this;
     Subfolders.Last().level      = this.level + 1;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Reorders all visible tag toggle buttons in custom -> non-custom order and then alphabetical order.
        /// </summary>
        public void ReorderSubfolderButtons()
        {
            if (Subfolders == null)
            {
                return;
            }

            this.SuspendLayout();

            //Do this so that we dont remove the VScrollBar

            int       position    = -1 + scrollPanel.AutoScrollPosition.Y;
            const int positionAdd = 26;

            int tabIndex = 0;

            // If there is a filter stop seperating buttons by custom/noncustom and just order them all by StartsWith and then alphabetically by name.
            if (Filter.Length > 0)
            {
                if (divider != null)
                {
                    divider.Hide();
                }

                var subfolderButtons = scrollPanel.Controls.OfType <SubfolderButton>()
                                       .Where(t => t.Visible)
                                       .OrderByDescending(t => t.subfolderInfo.name.ToLower().StartsWith(Filter.ToLower()))
                                       .ThenBy(t => t.subfolderInfo.name);

                for (int i = 0; i < subfolderButtons.Count(); i++)
                {
                    var button = subfolderButtons.ElementAt(i);
                    button.Location = new Point(0, position);
                    position       += positionAdd;
                    button.TabIndex = tabIndex;
                    tabIndex++;
                }
            }
            else    // If there is no filter than seperate buttons by custom/noncustom and order alphabetically by name.
            {
                var customSubfolders        = Subfolders.Where(t => t.custom).ToArray();
                var customSubfoldersButtons = scrollPanel.Controls.OfType <SubfolderButton>().Where(t => t.Visible && t.subfolderInfo.custom);
                var folders        = Subfolders.Where(t => !t.custom).ToArray();
                var foldersButtons = scrollPanel.Controls.OfType <SubfolderButton>().Where(t => t.Visible && !t.subfolderInfo.custom);

                for (int i = 0; i < customSubfoldersButtons.Count(); i++)
                {
                    var button = customSubfoldersButtons.ElementAt(i);
                    button.Location = new Point(0, position);
                    position       += positionAdd;
                    button.TabIndex = tabIndex;
                    tabIndex++;
                }

                if (customSubfolders.Length > 0 && folders.Length > 0)
                {
                    if (divider == null)
                    {
                        divider             = new Label();
                        divider.Text        = "";
                        divider.BorderStyle = BorderStyle.Fixed3D;
                        divider.AutoSize    = false;
                        divider.Height      = 2;
                        divider.Width       = 189 - 2 - 20;
                        scrollPanel.Controls.Add(divider);
                    }

                    divider.Location = new Point(0 + 10, position);
                    divider.BringToFront();
                    divider.Show();
                    position += 5;
                }
                else
                {
                    if (divider != null)
                    {
                        divider.Hide();
                    }
                }

                for (int i = 0; i < foldersButtons.Count(); i++)
                {
                    SubfolderButton button = foldersButtons.ElementAt(i);
                    button.Location = new Point(0, position);
                    position       += positionAdd;
                    button.TabIndex = tabIndex;
                    tabIndex++;
                }
            }



            this.ResumeLayout();
        }
Ejemplo n.º 19
0
        public IEnumerable <IIssue> GetIssues()
        {
            List <IIssue> issues = new List <IIssue>();

            if (cleaner != null)
            {
                issues.AddRange(cleaner.GetIssues());
            }

            if (!HasFileIOPermission())
            {
                issues.Add(new Issue("DiskCache", "Failed to start: Write access to the cache directory is prohibited by your .NET trust level configuration.",
                                     "Please configure your .NET trust level to permit writing to the cache directory. Most medium trust configurations allow this, but yours does not.", IssueSeverity.ConfigurationError));
            }

            if (!HasNTFSPermission())
            {
                issues.Add(new Issue("DiskCache", "Not working: Your NTFS Security permissions are preventing the application from writing to the disk cache",
                                     "Please give user " + GetExecutingUser() + " read and write access to directory \"" + PhysicalCacheDir + "\" to correct the problem. You can access NTFS security settings by right-clicking the aformentioned folder and choosing Properties, then Security.", IssueSeverity.ConfigurationError));
            }

            if (!Started && !Enabled)
            {
                issues.Add(new Issue("DiskCache", "DiskCache is disabled in Web.config. Set enabled=true on the <diskcache /> element to fix.", null, IssueSeverity.ConfigurationError));
            }

            //Warn user about setting hashModifiedDate=false in a web garden.
            if (this.cleaner != null && cleaner.ExteralProcessCleaning && !this.HashModifiedDate)
            {
                issues.Add(new Issue("DiskCache", "You should set hashModifiedDate=\"true\" on the <diskcache /> element in Web.config.",
                                     "Setting false for this value in a Web Garden scenario can cause failed requests. (DiskCache detects one or more other process on this machine working on the same cache directory).", IssueSeverity.Critical));
            }
            if (this.AsyncBufferSize < 1024 * 1024 * 2)
            {
                issues.Add(new Issue("DiskCache", "The asyncBufferSize should not be set below 2 megabytes (2097152). Found in the <diskcache /> element in Web.config.",
                                     "A buffer that is too small will cause requests to be processed synchronously. Remember to set the value to at least 4x the maximum size of an output image.", IssueSeverity.ConfigurationError));
            }

            string physicalCache = PhysicalCacheDir;

            if (!string.IsNullOrEmpty(physicalCache))
            {
                bool isNetwork = false;
                if (physicalCache.StartsWith("\\\\"))
                {
                    isNetwork = true;
                }
                else
                {
                    try {
                        DriveInfo dri = new DriveInfo(Path.GetPathRoot(physicalCache));
                        if (dri.DriveType == DriveType.Network)
                        {
                            isNetwork = true;
                        }
                    } catch { }
                }
                if (isNetwork)
                {
                    issues.Add(new Issue("DiskCache", "It appears that the cache directory is located on a network drive.",
                                         "Both IIS and ASP.NET have trouble hosting websites with large numbers of folders over a network drive, such as a SAN. The cache will create " +
                                         Subfolders.ToString() + " subfolders. If the total number of network-hosted folders exceeds 100, you should contact [email protected] and consult the documentation for details on configuring IIS and ASP.NET for this situation.", IssueSeverity.Warning));
                }
            }

            return(issues);
        }