public void SetPosition(Vector3 p3d) { transform.localPosition = p3d; var shape = Shapes.Get(Shape.Edge8, NodeBaseScale, transform.localPosition.x, transform.localPosition.z); var platform = Instantiate(quadZonePrefab); platform.name = "NodeBase"; MapCreatorLoader.Instance.Attach(platform.gameObject); platform.Color = Colors.RoadColor; platform.Init(shape); var platformRender = platform.gameObject.GetComponent <MeshRenderer>(); platformRender.sortingOrder = SortingOrder.Is(Layer.NodeBase); PlatformObject = platform.gameObject; MagnetPoints = new List <Vector2>(); foreach (var i in shape) { MagnetPoints.Add(i); } SelfShape = MapCreatorLoader.Instance.ParkingZone.AddShape(shape, false); ReDraw(); }
public void SpawnShape(List <Vector2> v, bool can) { var quad = Instantiate(quadZonePrefab); MapCreatorLoader.Instance.Attach(quad.gameObject); if (can) { quad.Color = Colors.PlaceColor; } else { quad.Color = Colors.CantPlace; } quad.Init(v[0], v[1], v[3], v[2]); var quadRender = quad.gameObject.GetComponent <MeshRenderer>(); int sorting = can ? SortingOrder.Is(Layer.Place) : SortingOrder.Is(Layer.WrongPlace); quadRender.sortingOrder = sorting; zone = quad; ShapeID = MapCreatorLoader.Instance.ParkingZone.AddShape(v, false); quad.name = "Place_shape_" + ShapeID; }
public static void SelectionSort <T>(IEnumerable <T> x, SortingOrder Order = SortingOrder.Ascending) { if (!typeof(T).IsSubclassOf(typeof(object))) { for (int i = 0; i < x.Count() - 1; i++) { int pivot = i; Comparer <T> comparer = Comparer <T> .Default; for (int j = i + 1; j < x.Count(); j++) { if (comparer.Compare(x.ElementAt(pivot), x.ElementAt(j)) > 0 && Order == SortingOrder.Ascending) { pivot = j; } else if (comparer.Compare(x.ElementAt(pivot), x.ElementAt(j)) < 0 && Order == SortingOrder.Descending) { pivot = j; } } if (pivot != i) { T swap = x.ElementAt(pivot); x.ToArray()[pivot] = x.ElementAt(i); x.ToArray()[i] = swap; } } } }
public SortingTask findOne(int id) { log.InfoFormat("Entering findOne with value {0}", id); IDbConnection con = DBUtils.getConnection(); using (var comm = con.CreateCommand()) { comm.CommandText = "select id,descriere, Elems, orderC, algoritm from SortingTasks where id=@id"; IDbDataParameter paramId = comm.CreateParameter(); paramId.ParameterName = "@id"; paramId.Value = id; comm.Parameters.Add(paramId); using (var dataR = comm.ExecuteReader()) { if (dataR.Read()) { int idV = dataR.GetInt32(0); String desc = dataR.GetString(1); int elems = dataR.GetInt32(2); SortingOrder order = (SortingOrder)Enum.Parse(typeof(SortingOrder), dataR.GetString(3)); SortingAlgorithm algo = (SortingAlgorithm)Enum.Parse(typeof(SortingAlgorithm), dataR.GetString(4)); SortingTask task = new SortingTask(idV, desc, elems, order, algo); log.InfoFormat("Exiting findOne with value {0}", task); return(task); } } } log.InfoFormat("Exiting findOne with value {0}", null); return(null); }
public IEnumerable <SortingTask> findAll() { IDbConnection con = DBUtils.getConnection(); IList <SortingTask> tasksR = new List <SortingTask>(); using (var comm = con.CreateCommand()) { comm.CommandText = "select id,descriere, Elems, orderC, algoritm from SortingTasks"; using (var dataR = comm.ExecuteReader()) { while (dataR.Read()) { int idV = dataR.GetInt32(0); String desc = dataR.GetString(1); int elems = dataR.GetInt32(2); SortingOrder order = (SortingOrder)Enum.Parse(typeof(SortingOrder), dataR.GetString(3)); SortingAlgorithm algo = (SortingAlgorithm)Enum.Parse(typeof(SortingAlgorithm), dataR.GetString(4)); SortingTask task = new SortingTask(idV, desc, elems, order, algo); tasksR.Add(task); } } } return(tasksR); }
public static void SortList <T>(ref List <T> lista, SortingOrder sort, string propertyToOrder) { if (!string.IsNullOrEmpty(propertyToOrder) && lista != null && lista.Count > 0) { Type t = lista[0].GetType(); if (sort == SortingOrder.Ascendant) { lista = lista.OrderBy( a => t.InvokeMember( propertyToOrder , System.Reflection.BindingFlags.GetProperty , null , a , null ) ).ToList(); } else { lista = lista.OrderByDescending( a => t.InvokeMember( propertyToOrder , System.Reflection.BindingFlags.GetProperty , null , a , null ) ).ToList(); } } }
public MapView() { layerDepth = SortingOrder.GetLayerDepth(0, SortingLayer.Ground); ViewGroupId = new HashSet <int>(); Enabled = true; }
public static void Sort <T>(ref T[] a, SortingOrder order) where T : IComparable { for (int outC = 0; outC < a.Length - 1; outC++) { for (int inC = 0; inC < a.Length - 1 - outC; inC++) { switch (order) { case SortingOrder.Ascending: if (Methods.IsFirstBigger(a[inC], a[inC + 1])) { Sorting.Methods.Swap(ref a[inC], ref a[inC + 1]); } break; case SortingOrder.Descending: if (!Methods.IsFirstBigger(a[inC], a[inC + 1])) { Sorting.Methods.Swap(ref a[inC], ref a[inC + 1]); } break; default: break; } } } }
public static IQueryable <TEntity> GetPage <TEntity, TProperty>( this IQueryable <TEntity> queryable, SortingOrder order, Expression <Func <TEntity, TProperty> > sortByProperty, long pageSize, long?page) where TEntity : class, IEntity { if (queryable == null) { throw new ArgumentNullException(nameof(queryable)); } if (!page.HasValue) { return(queryable); } var cPage = page.Value; return((order == SortingOrder.Descending ? queryable.OrderByDescending(sortByProperty) : queryable.OrderBy(sortByProperty)) .Skip((int)(cPage * pageSize)) .Take((int)pageSize)); }
public int SetTopMost() { var top = SortingOrder.GetNewTop(); SetOrder(top); return(top); }
public void Sort(SortingOrder order) { var items = new List <HttpTransportItem>(); foreach (HttpTransportItem item in this.List) { items.Add(item); } var result = new List <HttpTransportItem>(); if (order == SortingOrder.Ascending) { result = items.OrderBy(x => x.RequestTimestamp).ToList(); } else { result = items.OrderByDescending(x => x.RequestTimestamp).ToList(); } this.List.Clear(); foreach (HttpTransportItem item in result) { this.List.Add(item); } }
public void SortClientsByHeaderType(string type, SortingOrder order) { if (type != null) { if (type.Contains("Компьютер")) { SortClients("Компьютер", order); } else if (type.Contains("Осталось")) { SortClients("Осталось", order); } else if (type.Contains("Старт")) { SortClients("Старт", order); } else if (type.Contains("Стоп")) { SortClients("Стоп", order); } else { SortClients("", order); } } }
public WaypointConnectionView() { lineLayerDepth = SortingOrder.GetLayerDepth(-5, SortingLayer.WayPoints); pixel = new Texture2D(Game1.Graphics, 1, 1); pixel.SetData(new Color[] { Color.White }); Enabled = true; }
private void button1_Click(object sender, EventArgs e) { sortingOrder = (sortingOrder == SortingOrder.Descending) ? SortingOrder.Ascending : SortingOrder.Descending; _httpTransportCollection.Sort(sortingOrder); propGridInput.SelectedObject = _httpTransportCollection; lblItemCount.Text = _httpTransportCollection.Count.ToString(); propGridInput.Refresh(); }
public static IOrderedQueryable <TEntity> OrderByEx <TEntity, TKey>( this IQueryable <TEntity> queryable, Expression <Func <TEntity, TKey> > selector, SortingOrder order) { return(order == SortingOrder.Descending ? queryable.OrderByDescending(selector) : queryable.OrderBy(selector)); }
public SortingContext(Expression <Func <T, object> > fieldSelector, SortingOrder order = SortingOrder.Ascending) { if (fieldSelector == null) { throw new ArgumentNullException(nameof(fieldSelector)); } FieldSelector = fieldSelector; Order = order; }
public static IOrderedEnumerable <TEntity> OrderBy <TEntity, TKey>( this IEnumerable <TEntity> enumerable, Func <TEntity, TKey> selector, SortingOrder order) { return(order == SortingOrder.Descending ? enumerable.OrderByDescending(selector) : enumerable.OrderBy(selector)); }
public WaypointView(WaypointSelector pointSelector) { this.pointSelector = pointSelector; selectedWaypointHightLight = Circle.GetTexture(Game1.Graphics, (int)(WaypointManager.DefaultWaypointRadius * 2 * 1.3f)); waypointLayerDepth = SortingOrder.GetLayerDepth(0, SortingLayer.WayPoints); Enabled = true; }
public static void SetNextOrder(this SpriteRenderer spriteRenderer, string sortingLayer) { if (spriteRenderer != null) { var nextOrder = SortingOrder.GetNext(sortingLayer); spriteRenderer.sortingLayerName = sortingLayer; spriteRenderer.sortingOrder = nextOrder; } }
public BoundFilter(string dimension, T?lower, T?upper = null, bool lowerStrict = false, bool upperStrict = false, SortingOrder ordering = SortingOrder.lexicographic) { Dimension = dimension; Lower = lower; Upper = upper; LowerStrict = lowerStrict; UpperStrict = upperStrict; Ordering = ordering; }
private void MakeGround() { ground = MeshUtil.MakeSolidMesh("Ground", sizeX, sizeY, color); ground.transform.SetParent(baseMapObject.transform, false); MeshRenderer render = ground.GetComponent <MeshRenderer>(); render.sortingOrder = SortingOrder.Is(Layer.Ground); groundPlane = new Plane(Vector3.up, Vector3.zero); }
private void ChangeOrder() { if (this.SortStat == SortingOrder.Asc) { this.SortStat = SortingOrder.Desc; } else { this.SortStat = SortingOrder.Asc; } }
private void DrawSortingOrderSection() { var newSortingOrder = (SortingOrder)EditorGUILayout.EnumPopup("Sorting Order", m_SortingOrder); if (newSortingOrder != m_SortingOrder) { m_SortingOrder = newSortingOrder; EditorPrefs.SetInt(SortingOrderKey, (int)m_SortingOrder); RefreshEventIdsOrder(); } }
private void InitializeList() { if (_sorter.CustomSettingsList == null || _sorter.CustomSettingsList.IsEmpty()) { _sorter.FillCustomList(); } _sorter.CustomSettingsList?.ForEach(item => { SortingOrder.Add(new SettingSortingOrderVM(item)); }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var service = ScopeNodeExtensions.GetServiceGateway(); sortingOrder = SortingOrder.Descending; _httpTransportCollection = service.HttpTransport.GetAll(); _httpTransportCollection.Sort(sortingOrder); propGridInput.SelectedObject = _httpTransportCollection; propGridInput.Refresh(); lblItemCount.Text = _httpTransportCollection.Count.ToString(); }
public void BuildIntGridValues() { RoundTilemapPos(); SortingOrder.Next(); GameObject tilemapGameObject = LayerGameObject.CreateChildGameObject(Layer.Type); /*if (Importer.DeparentInRuntime) * { * tilemapGameObject.AddComponent<LDtkDetachChildren>(); * }*/ Tilemap = tilemapGameObject.AddComponent <Tilemap>(); if (Importer.IntGridValueColorsVisible) { TilemapRenderer renderer = tilemapGameObject.AddComponent <TilemapRenderer>(); renderer.sortingOrder = SortingOrder.SortingOrderValue; } TilemapCollider2D collider = tilemapGameObject.AddComponent <TilemapCollider2D>(); int[] intGridValues = Layer.IntGridCsv.Select(p => (int)p).ToArray(); for (int i = 0; i < intGridValues.Length; i++) { int intGridValue = intGridValues[i]; //all empty intgrid values are 0 if (intGridValue == 0) { continue; } LayerDefinition intGridDef = Layer.Definition; IntGridValueDefinition intGridValueDef = intGridDef.IntGridValues[intGridValue - 1]; string intGridValueKey = LDtkKeyFormatUtil.IntGridValueFormat(intGridDef, intGridValueDef); LDtkIntGridTile intGridTile = Importer.GetIntGridValueTile(intGridValueKey); if (intGridTile == null) { intGridTile = LDtkResourcesLoader.LoadDefaultTile(); } BuildIntGridValue(intGridValueDef, i, intGridTile); } Tilemap.SetOpacity(Layer); }
public void BuildIntGridValues() { RoundTilemapPos(); SortingOrder.Next(); int[] intGridValues = Layer.IntGridCsv.Select(p => (int)p).ToArray(); for (int i = 0; i < intGridValues.Length; i++) { int intGridValue = intGridValues[i]; //all empty intgrid values are 0 if (intGridValue == 0) { continue; } LayerDefinition intGridDef = Layer.Definition; IntGridValueDefinition intGridValueDef = intGridDef.IntGridValues[intGridValue - 1]; string intGridValueKey = LDtkKeyFormatUtil.IntGridValueFormat(intGridDef, intGridValueDef); LDtkIntGridTile intGridTile = TryGetIntGridTile(intGridValueKey); if (intGridTile == null) { Debug.LogError("LDtk: Issue loading a IntGridTile. This is always expected to not be null"); continue; } TilemapKey key = new TilemapKey(intGridTile.TilemapTag, intGridTile.TilemapLayerMask, intGridTile.PhysicsMaterial); Tilemap tilemapToBuildOn = GetTilemapToBuildOn(key); BuildIntGridValue(tilemapToBuildOn, intGridValueDef, i, intGridTile); } foreach (KeyValuePair <TilemapKey, Tilemap> pair in _tilemaps) { TilemapKey key = pair.Key; Tilemap tilemap = pair.Value; tilemap.SetOpacity(Layer); AddLayerOffset(tilemap); GameObject obj = tilemap.gameObject; obj.tag = key.Tag; obj.layer = key.LayerMask; if (obj.TryGetComponent(out Rigidbody2D rb)) { rb.sharedMaterial = key.PhysicsMaterial; } } }
/// <summary> /// code: /// 0 - sort by IsSessionStarted /// 1 - sort by Name /// 2 - sort by RemainingTime /// 3 - sort by StartSessionTime /// 4 - sort by EndSessionTime /// </summary> /// <param name="code"></param> /// <param name="order"></param> public void SortClients(string sortBy, SortingOrder order) { switch (sortBy) { case "": { clientsCollection = new ObservableCollection <Client>( order == SortingOrder.Descending ? clientsCollection.OrderByDescending(c => c.IsSessionStarted) : clientsCollection.OrderBy(c => c.IsSessionStarted)); break; } case "Осталось": { clientsCollection = new ObservableCollection <Client>( order == SortingOrder.Ascending ? clientsCollection.OrderByDescending(c => c.RemainingTimeInDouble).OrderByDescending(c => c.IsSessionStarted) : clientsCollection.OrderBy(c => c.RemainingTimeInDouble).OrderByDescending(c => c.IsSessionStarted)); break; } case "Старт": { clientsCollection = new ObservableCollection <Client>( order == SortingOrder.Descending ? clientsCollection.OrderByDescending(c => c.StartSession).OrderByDescending(c => c.IsSessionStarted) : clientsCollection.OrderBy(c => c.StartSession).OrderByDescending(c => c.IsSessionStarted)); break; } case "Стоп": { clientsCollection = new ObservableCollection <Client>( order == SortingOrder.Descending ? clientsCollection.OrderByDescending(c => c.EndSessionTime).OrderByDescending(c => c.IsSessionStarted) : clientsCollection.OrderBy(c => c.EndSessionTime).OrderByDescending(c => c.IsSessionStarted)); break; } case "Компьютер": default: { clientsCollection = new ObservableCollection <Client>( order == SortingOrder.Descending ? clientsCollection.OrderByDescending(c => c.Name) : clientsCollection.OrderBy(c => c.Name)); break; } } //clientsCollection.Order }
public void Run(string[] args) { for (int i = 0; i < SortingOrder_Generator.Count(); i++) { SortingOrder order = new SortingOrder(); string[] a1 = null; int[] a2 = null; int[] a3 = null; string result = SortingOrder_Generator.Generate(i, out a1, out a2, out a3); Console.WriteLine("Test {0}: {1}\tcorrect result is {2}", i, result == order.Solve(a1, a2, a3), result); } Console.ReadLine(); }
private void listView_clients_Header_Click(object sender, RoutedEventArgs e) { GridViewColumnHeader headerClicked = (GridViewColumnHeader)e.OriginalSource; //ListSortDirection direction; SortingOrder order = SortingOrder.Ascending; if (headerClicked != null) { if (headerClicked.Role != GridViewColumnHeaderRole.Padding) { if (headerClicked != lastHeaderClicked) { order = SortingOrder.Ascending; } else { if (lastOrder == SortingOrder.Ascending) { order = SortingOrder.Descending; } else { order = SortingOrder.Ascending; } } if (headerClicked.Column.Header is string) { string sortBy = headerClicked.Column.Header as string; mainHandler.SortClients(sortBy, order); } else if (headerClicked.Column.Header is Object) { Object header = headerClicked.Column.Header as Object; string type = header.ToString(); mainHandler.SortClientsByHeaderType(type, order); } else { return; } listView_clients.ItemsSource = mainHandler.GetClients(); //Sort(sortBy, direction); lastHeaderClicked = headerClicked; lastOrder = order; } } }
public HighscoreKeeper(SortingOrder sorting, string path, string GRAV = "") : base(path, GRAV) { this.sorting = sorting; highscoreTable = new List<KeyValuePair<string, TimeSpan>>(); if (data.Count == 0) { // Highscore table not yet made ConstructDefaultHighscoreTable(); } else { // parse data to highscore table ParseData(); } }
/// <summary> /// Gets an instance of PHP comparer parametrized by specified method, order, and compared item type. /// </summary> /// <param name="method">The <see cref="ComparisonMethod"/>.</param> /// <param name="order">The <see cref="SortingOrder"/>.</param> /// <param name="keyComparer">Whether to compare keys (<B>false</B> for value comparer).</param> /// <returns>A comparer (either a new instance or existing singleton instance).</returns> public static IComparer<KeyValuePair<IntStringKey, object>>/*!*/ GetComparer(ComparisonMethod method, SortingOrder order, bool keyComparer) { if (keyComparer) { switch (method) { case ComparisonMethod.Numeric: return (order == SortingOrder.Descending) ? KeyComparer.ReverseNumeric : KeyComparer.Numeric; case ComparisonMethod.String: return (order == SortingOrder.Descending) ? KeyComparer.ReverseString : KeyComparer.String; case ComparisonMethod.LocaleString: return new KeyComparer(Locale.GetStringComparer(false), order == SortingOrder.Descending); default: return (order == SortingOrder.Descending) ? KeyComparer.Reverse : KeyComparer.Default; } } else { switch (method) { case ComparisonMethod.Numeric: return (order == SortingOrder.Descending) ? ValueComparer.ReverseNumeric : ValueComparer.Numeric; case ComparisonMethod.String: return (order == SortingOrder.Descending) ? ValueComparer.ReverseString : ValueComparer.String; case ComparisonMethod.LocaleString: return new ValueComparer(Locale.GetStringComparer(false), order == SortingOrder.Descending); default: return (order == SortingOrder.Descending) ? ValueComparer.Reverse : ValueComparer.Default; } } }
void Awake() { GameObject player = GameObject.FindGameObjectWithTag ("Player"); playerSorting = player.GetComponent<SortingOrder> (); sr = player.GetComponent<SpriteRenderer> (); }
/// <summary> /// Sorts the specified data. /// </summary> /// <param name="data">The data.</param> /// <param name="sort">The sort.</param> /// <returns></returns> private static Dictionary<string, long> Sort(Dictionary<string, long> data, SortingOrder sort) { #region Access Log #if TRACE { Handler.LogHandler.Tracking("Access Method: " + typeof(Util).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;"); } #endif #endregion Access Log List<KeyValuePair<string, long>> result = new List<KeyValuePair<string, long>>(data); Dictionary<string, long> returnVal = new Dictionary<string, long>(); result.Sort( delegate( KeyValuePair<string, long> first, KeyValuePair<string, long> second) { if (sort == SortingOrder.Desc) { return second.Value.CompareTo(first.Value); } else { return first.Value.CompareTo(second.Value); } } ); foreach (KeyValuePair<string, long> kvp in result) returnVal.Add(kvp.Key, kvp.Value); return returnVal; }
public void Sort(SortingOrder order) { var items = new List<HttpTransportItem>(); foreach (HttpTransportItem item in this.List) { items.Add(item); } var result = new List<HttpTransportItem>(); if (order == SortingOrder.Ascending) result = items.OrderBy(x => x.RequestTimestamp).ToList(); else result = items.OrderByDescending(x => x.RequestTimestamp).ToList(); this.List.Clear(); foreach (HttpTransportItem item in result) { this.List.Add(item); } }
public void Awake() { _collisionLevel = gameObject.TryAddComponent<CollisionLevel>(); _sortingOrder = gameObject.TryAddComponent<SortingOrder>(); _rigidbody = GetComponent<Rigidbody2D>(); }