public PaginationSettings() { PageIndex = 0; PageSize = 15; SortSettings = new SortSettings { OrderBy = "", Direction = SortDirection.Asc }; }
/// <summary> /// Creates a FlexComparer with the specified sort order. /// </summary> /// <param name="sortOrder">The sort order to use.</param> public FlexComparer(SortSettings sortOrder) { sortSetting = sortOrder; this.sortOrder = (sortOrder == SortSettings.SortGenericAscending || sortOrder == SortSettings.SortNumericAscending || sortOrder == SortSettings.SortStringAscending || sortOrder == SortSettings.SortStringNoCaseAscending) ? 1 : -1; }
public void DeleteSortBit(SortSettings.SETTINGS_TYPE settings_type) { int num = sortSaveData.FindIndex((string _data) => settings_type == SortSettings.GetSettingsTypeBySortBit(_data)); if (num != -1) { sortSaveData.RemoveAt(num); } }
public void SetSortBit(SortSettings settings) { int num = sortSaveData.FindIndex((string _data) => settings.settingsType == SortSettings.GetSettingsTypeBySortBit(_data)); if (num != -1) { sortSaveData.RemoveAt(num); } sortSaveData.Add(SortSettings.GetSortBit(settings)); }
protected override void InitSort() { if (MonoBehaviourSingleton <InventoryManager> .I.IsWeaponInventoryType(MonoBehaviourSingleton <InventoryManager> .I.changeInventoryType)) { sortSettings = SortSettings.CreateMemSortSettings(SortBase.DIALOG_TYPE.WEAPON, SortSettings.SETTINGS_TYPE.EQUIP_ITEM); } else { sortSettings = SortSettings.CreateMemSortSettings(SortBase.DIALOG_TYPE.ARMOR, SortSettings.SETTINGS_TYPE.EQUIP_ITEM); } }
protected void _OnCloseDialogSort() { SortSettings sortSettings = (SortSettings)GameSection.GetEventData(); if (sortSettings != null) { this.sortSettings = sortSettings; SetDirty(UI.GRD_ORDER_QUEST); RefreshUI(); } }
public void Sort(int[] propIDs, bool[] sortDirections) { if (propIDs.Length != sortDirections.Length) { throw new ArgumentException("Property ID count does not match sort direction count"); } SortSettings settings = new SortSettings(propIDs, sortDirections); DoSort(new ResourceComparer(this, settings, false), false); }
public void Sort(string propNames, bool ascending) { Guard.NullArgument(propNames, "propNames"); SortSettings settings = SortSettings.Parse(MyPalStorage.Storage, propNames); if (!ascending) { settings = settings.Reverse(); } Sort(settings); }
private void OnCloseDialog_SmithSkillGrowSort() { SortSettings sortSettings = (SortSettings)GameSection.GetEventData(); if (sortSettings != null && inventory.Sort(sortSettings)) { SetDirty(UI.GRD_INVENTORY); SetDirty(UI.GRD_INVENTORY_SMALL); RefreshUI(); } }
private ResourceComparer CreateColumnComparer(ResourcePropsColumn col, SortSettings sortSettings) { if (col.CustomComparer != null) { return(new ResourceComparer(_resourceList, col.CustomComparer, sortSettings.SortAscending)); } else { return(new ResourceComparer(_resourceList, sortSettings, true)); } }
public void allows_any_sorting_attempt() { var settings = new SortSettings { PropertyName = nameof(MySortableType.Name), SortAscending = true }; var set = new List <MySortableType>().AsQueryable().ApplySortSettings(settings); var sut = set.ToList(); sut.Should().BeEmpty(); }
static (float, double) RunSort(SortSettings settings, Action randomizeList, Action sorting) { float timeMs = 0; for (int i = 0; i < settings.TestCount; i++) { randomizeList(); timeMs += Profiling.ExecutingProfile(sorting); } return(timeMs / settings.TestCount, 0); }
public void SaveState(ColumnDescriptor[] columns, SortSettings sortSettings, bool async) { _columns = columns; _sortSettings = sortSettings; if (async) { Core.ResourceAP.QueueJob(JobPriority.Immediate, new MethodInvoker(DoSaveState)); } else { Core.ResourceAP.RunUniqueJob(new MethodInvoker(DoSaveState)); } }
public string GetSortBit(SortSettings.SETTINGS_TYPE settings_type) { if (sortSaveData == null || sortSaveData.Count == 0) { return(string.Empty); } int num = sortSaveData.FindIndex((string _data) => settings_type == SortSettings.GetSettingsTypeBySortBit(_data)); if (num == -1) { return(string.Empty); } return(sortSaveData[num]); }
public void should_generate_correct_ascending_string_representation() { var setting = new SortSettings { SortAscending = true, PropertyName = nameof(SortSettings), ThenBy = null }; var sut = setting.ToSqlOrderBy(); sut.Equals( $"order by [{nameof(SortSettings)}] asc", StringComparison.InvariantCultureIgnoreCase ).Should().BeTrue(); }
public void sorts_correctly_given_a_single_ascending_sort() { var settings = new SortSettings { PropertyName = nameof(MySortableType.Name), SortAscending = true }; var set = GenerateTestSet().ApplySortSettings(settings); var sut = set.ToArray(); sut[0].Id.Should().Be(3); sut[1].Id.Should().Be(4); sut[2].Id.Should().Be(2); sut[3].Id.Should().Be(1); }
public string Run(SortSettings settings) { switch (settings.elementType) { case "UInt32": return(RunUIntSort(settings)); case "Int32": return(RunIntSort(settings)); case "Single": return(RunFloatSort(settings)); } return("type not supported!!"); }
private void OnCloseDialog_SmithSkillGrowSort() { SortSettings sortSettings = (SortSettings)GameSection.GetEventData(); if (sortSettings != null) { inventory.sortSettings.indivComparison = CustomCompare; m_defaultComparison = new SortComparison(inventory.sortSettings.orderTypeAsc).comparison; if (inventory.Sort(sortSettings)) { SetDirty(UI.GRD_INVENTORY); SetDirty(UI.GRD_INVENTORY_SMALL); RefreshUI(); } } }
/// <summary> /// Constructs a comparer that uses a hierarchical set of properties to compare by. /// </summary> /// <param name="owner">A resource list that has a property provider /// that will be queried to get the property values for individual resources.</param> /// <param name="sortSettings">Deinfes the sorting columns and ascending/descending directions for them.</param> /// <param name="propsEquivalent">Specifies whether all the properties are treated equivalent, /// which means that if two sorting properties are suggested, the first of them which is defined for that particular object /// will take part in the comparison, not necessarily the same props on both objects.</param> public ResourceComparer(IResourceList owner, SortSettings sortSettings, bool propsEquivalent) { if (sortSettings == null) { throw new ArgumentNullException("sortSettings"); } _owner = (ResourceList)owner; _sortSettings = sortSettings; _propTypes = new PropDataType [_sortSettings.SortProps.Length]; for (int i = 0; i < _sortSettings.SortProps.Length; i++) { _propTypes [i] = GetSortPropType(_sortSettings.SortProps [i]); } _propsEquivalent = propsEquivalent; }
static (float, double) RunSortWithMemoryDebug(SortSettings settings, Action randomizeList, Action sorting) { float timeMs = 0; double memoryKb = 0; for (int i = 0; i < settings.TestCount; i++) { randomizeList(); memoryKb += Profiling.MemoryProfile(() => { timeMs += Profiling.ExecutingProfile(sorting); }); } return(timeMs / settings.TestCount, memoryKb / settings.TestCount); }
public SortSettings Clone() { SortSettings sortSettings = new SortSettings(); sortSettings.dialogType = dialogType; sortSettings.rarity = rarity; sortSettings.type = type; sortSettings.requirement = requirement; sortSettings.orderTypeAsc = orderTypeAsc; sortSettings.settingsType = settingsType; sortSettings.equipSetInfo = equipSetInfo; sortSettings.indivComparison = indivComparison; sortSettings.equipFilter = equipFilter; sortSettings.element = element; sortSettings.TYPE_ALL = TYPE_ALL; return(sortSettings); }
/// <summary> /// formatEditName = null значит что не будет колонки с действиями /// </summary> public CoreGridFor(HttpContext context, string formatEditName = "formatEdit") : base(context) { AutoWidth = true; Height = "100%"; Width = "100%"; PagerSettings = new PagerSettings { PageSizeOptions = $"[10,20,50,100,500,1000,5000,{JqGridHelper.GridAllRecordsCount}]" }; SearchDialogSettings = new SearchDialogSettings { MultipleSearch = true, Width = 800 }; var columnModels = GetModelColumns(typeof(TModel)); var primaryKeyColumn = columnModels.FirstOrDefault(t => t.AttributeInfo.PrimaryKeyField); SortSettings = new SortSettings { InitialSortColumn = primaryKeyColumn != null ? primaryKeyColumn.PropertyInfo.Name : "Id", InitialSortDirection = SortDirection.Asc }; ToolBarSettings = new ToolBarSettings { ShowSearchToolBar = true, ShowSearchButton = true, ShowRefreshButton = true, ShowEditButton = false, ShowAddButton = false, ShowDeleteButton = false }; SetColumn(columnModels, formatEditName); EditDialogSettings.CloseAfterEditing = true; AddDialogSettings.CloseAfterAdding = true; Responsive = true; ColumnReordering = true; StoreNavigationOptions = true; AppearanceSettings.ShowRowNumbers = true; ID = "JqGrid" + typeof(TModel).Name + "s"; SearchToolBarSettings.SearchOperators = true; SearchToolBarSettings.SearchToolBarAction = SearchToolBarAction.SearchOnEnter; //TreeGridSettings.Enabled = true; }
string ListSort(SortSettings settings) { var list = ManagedDataGenerator.GenrateRandomList(settings.Count, settings.Min, settings.Max); ManagedDataGenerator.SortPartial(list, settings.Sorted); return(BaseSortRunner.GetResult(settings, () => { ManagedDataGenerator.ShuffleList(list, 1f); ManagedDataGenerator.SortPartial(list, settings.Sorted); }, () => { list.Sort(); } )); }
protected override string RunUIntSort(SortSettings settings) { var sorter = SortSource.Instance.GetManagedUIntSorter(settings.name); var list = ManagedDataGenerator.GenrateRandomList(settings.Count, (uint)settings.Min, (uint)settings.Max); return(GetResult(settings, () => { ManagedDataGenerator.ShuffleList(list, 1f); ManagedDataGenerator.SortPartial(list, settings.Sorted); }, () => { sorter(list); } )); }
public static string ToSqlOrderBy(this SortSettings sort) { var builder = new StringBuilder(); var prefix = string.IsNullOrEmpty(sort.PropertyTableAlias) ? "" : $"[{sort.PropertyTableAlias}]."; builder.Append($"order by {prefix}[{sort.PropertyName}] {SortDirectionAsSqlSort(sort.SortAscending)}"); var then = sort.ThenBy; while (then != null) { var thenPrefix = string.IsNullOrEmpty(then.PropertyTableAlias) ? "" : $"[{then.PropertyTableAlias}]."; builder.Append($", {thenPrefix}[{then.PropertyName}] {SortDirectionAsSqlSort(then.SortAscending)}"); then = then.ThenBy; } return(builder.ToString()); }
protected void OnCloseSortDialog() { SortSettings sortSettings = (SortSettings)GameSection.GetEventData(); if (sortSettings != null) { this.sortSettings = sortSettings; if (localInventoryEquipData != null && sorting()) { selectInventoryIndex = GetSelectItemIndex(); SetDirty(UI.GRD_INVENTORY); SetDirty(UI.GRD_INVENTORY_SMALL); SetDirty(UI.GRD_INVENTORY_DEF); SetDirty(UI.GRD_INVENTORY_SMALL_DEF); RefreshUI(); } } }
public static string GetResult(SortSettings settings, Action randomizeList, Action sorting) { string result = ""; var res = settings.MemoryDebug ? RunSortWithMemoryDebug(settings, randomizeList, sorting) : RunSort(settings, randomizeList, sorting); result += string.Format("> average run time for {0} after {1} test is {2} ms " + "for {3} element of type {4} with sorted percentage {5}/100 with numbers ranges" + "from {6} to {7} \n" , settings.name, settings.TestCount, res.Item1, settings.Count, settings.elementType, settings.Sorted, settings.Min, settings.Max); if (settings.MemoryDebug) { result += string.Format("> the average memory cost is {0} kb", res.Item2); } return(result); }
protected override string RunUIntSort(SortSettings settings) { var sorter = SortSource.Instance.GetNativeUIntSorter(settings.name); var array = NativeDataGenerator.GenrateRandomArray(settings.Count, (uint)settings.Min, (uint)settings.Max); var result = GetResult(settings, () => { NativeDataGenerator.ShuffleList(array, 1f); NativeDataGenerator.SortPartial(array, settings.Sorted); }, () => { sorter(array); } ); array.Dispose(); return(result); }
public HomeViewModel(IImageManager imageManager, IShellViewModel shellViewModel, XMLRepository xmlRepository) { _shellViewModel = shellViewModel; TestList = new SortableBindableCollection <SingleTest>(); SelectedTest = new ObservableValue <SingleTest> { Changed = _ => { TestProperties4Debug.Clear(); } }; TestProperties4Debug = new BindableCollection <ResourcePropertyModel>(); SortSettings = new SortSettings("TestCell", ListSortDirection.Ascending); SortSettings.Changed += (sender, args) => this.Sort(TestList); ColumnNameToSortKey = new Dictionary <string, Func <SingleTest, IComparable> > { }; ColumnNameToSortKey.Add("TestCell", i => i.TestCell); ColumnNameToSortKey.Add("TestID", i => i.TestIDNumber); ColumnNameToSortKey.Add("VehicleID", i => i.VehicleID); ColumnNameToSortKey.Add("ProjectID", i => i.ProjectID); ColumnNameToSortKey.Add("TestTypeCode", i => i.TestTypeCode); ColumnNameToSortKey.Add("Priority", i => i.Priority); ColumnNameToSortKey.Add("ModificationDate", i => i.ModificationDate); GetTestListCommand = new GetTestListCommand(imageManager, TestList, xmlRepository); ShowTestPropertiesCommand = new ShowTestPropertiesCommand(imageManager, SelectedTest, TestProperties4Debug, xmlRepository); RunTestCommand = new RunTestCommand(imageManager, SelectedTest, ShowTestPropertiesCommand, xmlRepository); SaveAsNewResourcesCommand = new SaveAsNewResourcesCommand(imageManager, SelectedTest, this, ShowTestPropertiesCommand, xmlRepository); ControlSaveAsCommand = new ControlSaveAsCommand(imageManager, SelectedTest, this); var imagePathPattern = "/STARS.Applications.VETS.Plugins.VTS.UI;component/Images/{0}.png"; DisplayInfo = new ExplorerDisplayInfo { Description = Resources.VtsVets, Image16 = string.Format(imagePathPattern, "green_car_16"), Image32 = string.Format(imagePathPattern, "green_car_32"), ExplorerImage16 = string.Format(imagePathPattern, "white_car_16"), }; DisplayName = Resources.VtsVets; OnTestFinish.TestFinished += OnTestFinished; }
[Test] public void TypeComparer() { SortSettings settings = SortSettings.Parse(_storage, "Type- FirstName"); Assert.AreEqual(2, settings.SortProps.Length); Assert.AreEqual(2, settings.SortDirections.Length); Assert.AreEqual(ResourceProps.Type, settings.SortProps [0]); Assert.AreEqual(_propFirstName, settings.SortProps [1]); Assert.AreEqual(false, settings.SortDirections [0]); Assert.AreEqual(true, settings.SortDirections [1]); ResourceComparer comparer = new ResourceComparer(_ownerList, settings, false); IResource res1 = _storage.NewResource("Email"); IResource res2 = _storage.NewResource("Person"); Assert.IsTrue(comparer.CompareResources(res1, res2) > 0); }
public void generates_correct_sql_when_then_by_sort_has_alias() { var setting = new SortSettings { SortAscending = false, PropertyName = nameof(SortSettings), ThenBy = new SortSettings { SortAscending = true, PropertyName = nameof(SortSettings.SortAscending), PropertyTableAlias = "p" } }; var sut = setting.ToSqlOrderBy(); sut.Equals( $"order by [{nameof(SortSettings)}] desc, [p].[{nameof(SortSettings.SortAscending)}] asc", StringComparison.InvariantCultureIgnoreCase ).Should().BeTrue(); }