private void ParseGroupOptions(XElement root, IList <GroupOption> groupOptions) { root.Elements(GroupElement.OptionElement.ElementName) .ForEach(element => { var option = ParseOption(element); if (KeyIsValid(option.Id)) { if (KeyIsUniqueForGroupOption(option.Id, groupOptions)) { var groupOption = new GroupOption(); groupOption.Option = option; ParseOptionSuggestions(element, groupOption.Suggestions); groupOptions.AddIfUnique(groupOption); } else { _optionSetValidator.AddError($"Key '{option.Id}' isn`t unique among options.", element); } } else { _optionSetValidator.AddError($"Key '{option.Id}' ('{option.Name}') isn`t valid.", element); } }); }
private void ParseCoatOfArms(Dynasty dyn, ParadoxParser parser, string tag) { Option.ParseGeneric(parser, tag); GroupOption og = (GroupOption)Option.GetLastRoot(); dyn.CoatOfArms = og; }
public void TestToStringMultipleMembers() { var line = "GROUP group_name user_name1 user_name2"; var actual = new GroupOption(line); Assert.Equal(line, actual.ToString()); }
public void TestConstructorWithValidAttributes() { var line = "GROUP group_name user_name1"; var actual = new GroupOption(line); Assert.IsType <GroupOption>(actual); }
public void TestGroupNameAttribute() { var groupName = "group_name"; var line = $"GROUP {groupName} user_name1"; var actual = new GroupOption(line); Assert.Equal(groupName, actual.GroupName); }
public void TestMembersAttributeSingle() { var member = "user_name1"; var members = new List <string>(new string[] { member }); var line = $"GROUP group_name {member}"; var actual = new GroupOption(line); Assert.Equal(members, actual.Members); }
public void TestMembersAttributeMultiple() { var member1 = "user_name1"; var member2 = "user_name2"; var members = $"{member1} {member2}"; var line = $"GROUP group_name {members}"; var membersList = new List <string>(new string[] { member1, member2 }); var actual = new GroupOption(line); Assert.Equal(membersList, actual.Members); }
public static Func <ListedItem, string> GetItemGroupKeySelector(GroupOption option) { return(option switch { GroupOption.Name => x => new string(x.ItemName.Take(1).ToArray()).ToUpper(), GroupOption.Size => x => x.PrimaryItemAttribute != StorageItemTypes.Folder ? GetGroupSizeKey(x.FileSizeBytes) : x.FileSizeDisplay, GroupOption.DateCreated => x => x.ItemDateCreatedReal.GetUserSettingsFriendlyTimeSpan().text, GroupOption.DateModified => x => x.ItemDateModifiedReal.GetUserSettingsFriendlyTimeSpan().text, GroupOption.FileType => x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsShortcutItem ? x.ItemType : x.FileExtension?.ToLower() ?? " ", GroupOption.OriginalFolder => x => (x as RecycleBinItem)?.ItemOriginalFolder, GroupOption.DateDeleted => x => (x as RecycleBinItem)?.ItemDateDeletedReal.GetUserSettingsFriendlyTimeSpan().text, _ => null, });
public static Func <ListedItem, string> GetItemGroupKeySelector(GroupOption option) { return(option switch { GroupOption.Name => x => new string(x.ItemName.Take(1).ToArray()).ToUpperInvariant(), GroupOption.Size => x => x.PrimaryItemAttribute != StorageItemTypes.Folder ? GetGroupSizeKey(x.FileSizeBytes) : x.FileSizeDisplay, GroupOption.DateCreated => x => dateTimeFormatter.ToTimeSpanLabel(x.ItemDateCreatedReal).Text, GroupOption.DateModified => x => dateTimeFormatter.ToTimeSpanLabel(x.ItemDateModifiedReal).Text, GroupOption.FileType => x => x.PrimaryItemAttribute == StorageItemTypes.Folder && !x.IsShortcutItem ? x.ItemType : x.FileExtension?.ToLowerInvariant() ?? " ", GroupOption.SyncStatus => x => x.SyncStatusString, GroupOption.FileTag => x => x.FileTags?.FirstOrDefault(), GroupOption.OriginalFolder => x => (x as RecycleBinItem)?.ItemOriginalFolder, GroupOption.DateDeleted => x => dateTimeFormatter.ToTimeSpanLabel((x as RecycleBinItem)?.ItemDateDeletedReal ?? DateTimeOffset.Now).Text, GroupOption.FolderPath => x => PathNormalization.GetParentDir(x.ItemPath.TrimPath()), _ => null, });
public LayoutPreferences() { this.LayoutMode = UserSettingsService.LayoutSettingsService.DefaultLayoutMode; this.GridViewSize = UserSettingsService.LayoutSettingsService.DefaultGridViewSize; this.DirectorySortOption = UserSettingsService.LayoutSettingsService.DefaultDirectorySortOption; this.DirectoryGroupOption = UserSettingsService.LayoutSettingsService.DefaultDirectoryGroupOption; this.DirectorySortDirection = UserSettingsService.LayoutSettingsService.DefaultDirectorySortDirection; this.SortDirectoriesAlongsideFiles = UserSettingsService.LayoutSettingsService.DefaultSortDirectoriesAlongsideFiles; this.IsAdaptiveLayoutOverridden = false; this.ColumnsViewModel = new ColumnsViewModel(); this.ColumnsViewModel.DateCreatedColumn.UserCollapsed = !UserSettingsService.LayoutSettingsService.ShowDateCreatedColumn; this.ColumnsViewModel.DateModifiedColumn.UserCollapsed = !UserSettingsService.LayoutSettingsService.ShowDateColumn; this.ColumnsViewModel.ItemTypeColumn.UserCollapsed = !UserSettingsService.LayoutSettingsService.ShowTypeColumn; this.ColumnsViewModel.SizeColumn.UserCollapsed = !UserSettingsService.LayoutSettingsService.ShowSizeColumn; this.ColumnsViewModel.TagColumn.UserCollapsed = !UserSettingsService.LayoutSettingsService.ShowFileTagColumn; }
/// <summary> /// Groups a list of customers by last name or company. /// </summary> private void GroupList(GroupOption option) { CollectionViewSource cvs = Resources["CustomersCVS"] as CollectionViewSource; if (cvs != null) { cvs.IsSourceGrouped = true; switch (option) { case GroupOption.ByName: cvs.Source = ViewModel.Customers.GroupBy(customer => customer.LastName); break; case GroupOption.ByCompany: cvs.Source = ViewModel.Customers.GroupBy(customer => customer.Company); break; default: cvs.IsSourceGrouped = false; break; } } }
public GroupDrawerInternal(float labelWidth = -1f, GroupOption options = GroupOption.None, params ActionDrawer[] actionDrawers) { this.actionDrawers = actionDrawers; m_LabelWidth = labelWidth; isIndented = (options & GroupOption.Indent) != 0; }
/// <summary> Group of drawing function for inspector with a set width for labels </summary> /// <param name="labelWidth">Width used for all labels in the group</param> /// <param name="options">Allow to add indentation on this group</param> /// <param name="contentDrawers">The content of the group</param> /// <returns>A IDrawer object</returns> public static IDrawer Group(float labelWidth, GroupOption options, params ActionDrawer[] contentDrawers) { return(new GroupDrawerInternal(labelWidth, options, contentDrawers)); }
/// <summary> /// Group of drawing function for inspector. /// They will be drawn one after the other. /// </summary> /// <param name="options">Allow to add indentation on this group</param> /// <param name="contentDrawers">The content of the group</param> /// <returns>A IDrawer object</returns> public static IDrawer Group(GroupOption options, params ActionDrawer[] contentDrawers) { return(new GroupDrawerInternal(-1f, options, contentDrawers)); }
// Main method that do the job public async static void GroupImages(string sourcePath, string destinPath, List <string> extensions, GroupOption option) { // Condition checks if (!Directory.Exists(sourcePath)) { throw new System.IO.DirectoryNotFoundException(); } if (!Directory.Exists(destinPath)) { throw new System.IO.DirectoryNotFoundException(); } if (option == null) { throw new Exception("Group option not selected"); } if (extensions.Count > 0) { allFiletypes = false; } List <string> filesOnSource = Directory.GetFiles(sourcePath).ToList(); List <string> filteredFiles = allFiletypes ? filesOnSource : filesOnSource.Where(f => extensions.Contains(Path.GetExtension(f))).ToList(); // Copy or Move files foreach (string fileName in filteredFiles) { using (FileStream fs = File.Open(fileName, FileMode.Open)) { var newFullName = Path.Combine(new string[] { destinPath, File.GetCreationTime(fileName).ToLongDateString(), Path.GetFileName(fileName) }); var directory = Path.GetDirectoryName(newFullName); if (!Directory.Exists(directory)) { var dir = Directory.CreateDirectory(Path.GetDirectoryName(newFullName)); } using (FileStream destination = File.Create(newFullName)) { if (option == GroupOption.Copy) { await fs.CopyToAsync(destination); } } } } }
/// <summary> Group of drawing function for inspector with a set width for labels </summary> /// <param name="header">Adds a header on top <see cref="GUIContent"/></param> /// <param name="options">Allow to add indentation on this group</param> /// <param name="contentDrawers">The content of the group</param> /// <returns>A IDrawer object</returns> public static IDrawer Group(GUIContent header, GroupOption options, params IDrawer[] contentDrawers) { return(new GroupDrawerInternal(-1f, header, options, contentDrawers.Draw)); }