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(); }
/// <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(); }