/// <summary> /// Remove top view on stack /// </summary> /// <param name="animated">Flags for animation</param> public async Task Pop(bool animated) { if (Top != null) { var tobeRemoved = Top; if (animated) { if (PopAnimation != null) { await RunCustomPopAnimation(tobeRemoved, PopAnimation); } else { await RunDefaultPopAnimation(tobeRemoved); } } InternalStack.Remove(tobeRemoved); _focusStack.Remove(tobeRemoved); Remove(tobeRemoved); UpdateTopView(); tobeRemoved.Dispose(); } }
/// <summary> /// Inserts a view in the navigation stack before an existing view in the stack. /// </summary> /// <param name="before">The existing view, before which view will be inserted.</param> /// <param name="view">The view to insert</param> public void Insert(View before, View view) { view.Hide(); var idx = InternalStack.IndexOf(before); InternalStack.Insert(idx, view); Add(view); UpdateTopView(); }
public void Insert(EvasObject before, EvasObject view) { view.Hide(); var idx = InternalStack.IndexOf(before); InternalStack.Insert(idx, view); PackEnd(view); UpdateTopView(); }
public void Remove(EvasObject view) { InternalStack.Remove(view); UnPack(view); UpdateTopView(); Device.BeginInvokeOnMainThread(() => { view?.Unrealize(); }); }
private void OnResizeRequested(InternalStack stack) { if (First.Count + Second.Count + Third.Count == _array.Length) { throw new InvalidOperationException("No more room"); } if (stack == _first) { if (_second.IsFull) { _third.MoveForward(); _third.DecrementMaxCount(); _second.MoveForward(); } else { _second.MoveForward(); _second.DecrementMaxCount(); } _first.IncrementMaxCount(); } else if (stack == _second) { if (_third.IsFull) { _first.DecrementMaxCount(); _second.MoveBackward(); } else { _third.MoveForward(); _third.DecrementMaxCount(); } _second.IncrementMaxCount(); } else if (stack == _third) { if (_second.IsFull) { _first.DecrementMaxCount(); _second.MoveBackward(); } else { _second.DecrementMaxCount(); } _third.MoveBackward(); _third.IncrementMaxCount(); } }
/// <summary> /// Clear all children /// </summary> public void Clear() { foreach (var child in InternalStack) { Remove(child); child.Dispose(); } InternalStack.Clear(); _focusStack.Clear(); _lastTop = null; }
void UpdateTopView() { if (CurrentView != InternalStack.LastOrDefault()) { if (!IsPreviousViewVisible) { CurrentView?.Hide(); } CurrentView = InternalStack.LastOrDefault(); CurrentView?.Show(); (CurrentView as Widget)?.SetFocus(true); } }
public void Pop() { if (CurrentView != null) { var tobeRemoved = CurrentView; InternalStack.Remove(tobeRemoved); UnPack(tobeRemoved); UpdateTopView(); // if Pop was called by removed page, // Unrealize cause deletation of NativeCallback, it could be a cause of crash Device.BeginInvokeOnMainThread(() => { tobeRemoved.Unrealize(); }); } }
public ThreeSlidingStacks(int maxTotalCount) { _array = new int[maxTotalCount]; var firstStart = 0; var firstCount = maxTotalCount / 3; var secondStart = firstCount + 1; var secondCount = maxTotalCount / 3; var thirdStart = secondCount + 1; var thirdCount = maxTotalCount - secondCount - firstCount; _first = new InternalStack(firstStart, firstCount, _array, OnResizeRequested); _second = new InternalStack(secondStart, secondCount, _array, OnResizeRequested); _third = new InternalStack(thirdStart, thirdCount, _array, OnResizeRequested); }
public ThreeStacks(int maxTotalCount) { var array = new int[maxTotalCount]; var firstStart = 0; var firstCount = maxTotalCount / 3; var secondStart = firstCount + 1; var secondCount = maxTotalCount / 3; var thirdStart = secondCount + 1; var thirdCount = maxTotalCount - secondCount - firstCount; First = new InternalStack(firstStart, firstCount, array); Second = new InternalStack(secondStart, secondCount, array); Third = new InternalStack(thirdStart, thirdCount, array); }
public void Push(EvasObject view, bool isAnimated = false) { InternalStack.Add(view); PackEnd(view); if (isAnimated) { if (CurrentView != null) { CurrentView.AllEventsFrozen = true; } } else { UpdateTopView(); } }
public float CalculateONPExpresion(string onpExpression) { int id = 0; OutputOperationBuffer = new InternalBuffer<OutputOperation>(); InternalStack<string> stack = new InternalStack<string>(); List<string> tokenList = onpExpression.Trim().Split(' ').ToList(); string input = onpExpression.Trim(); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), string.Empty)); foreach (string token in tokenList) { if (!string.IsNullOrEmpty(input.Trim())) input = input.Trim().Remove(0, 1); if (token.IsOperator()) { string secondToken = stack.Pop(); string firstToken = stack.Pop(); string result = Calculate(token, firstToken, secondToken); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), string.Format("{0} {1} {2}", firstToken, token, secondToken))); stack.Push(result); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), string.Empty)); } else { stack.Push(token); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), string.Empty)); } } string resultToken = stack.Pop(); float resultValue = float.Parse(resultToken); return resultValue; }
/// <summary> /// Push a view on stack /// </summary> /// <param name="view">A view to push</param> /// <param name="animated">Flags for animation</param> public async Task Push(View view, bool animated) { DidSaveFocus(); view.WidthResizePolicy = ResizePolicyType.FillToParent; view.HeightResizePolicy = ResizePolicyType.FillToParent; InternalStack.Add(view); Add(view); if (animated) { if (PushAnimation != null) { await RunCustomPushAnimation(view, PushAnimation); } else { await RunDefaultPushAnimation(view); } } UpdateTopView(); }
void UpdateTopView() { if (_lastTop != InternalStack.LastOrDefault()) { if (_lastTop != null) { if (!ShownBehindPage) { _lastTop.Hide(); } _lastTop.FocusableChildren = false; } _lastTop = InternalStack.LastOrDefault(); if (_lastTop != null) { _lastTop.Show(); _lastTop.FocusableChildren = true; } SendNavigated(); DidRestoreFocus(); } }
/// <summary> /// Removes a view in the navigation stack /// </summary> /// <param name="view">The view to remove</param> public void Pop(View view) { InternalStack.Remove(view); _focusStack.Remove(view); Remove(view); }
public string ConvertToONP(string infix) { int id = 0; OutputOperationBuffer = new InternalBuffer<OutputOperation>(); InternalStack<Operator> stack = new InternalStack<Operator>(); string output = string.Empty; char[] infixArray = infix.Trim().ToArray(); string input = infix; OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); foreach (char infixChar in infixArray) { if(!string.IsNullOrEmpty(input)) input = input.Remove(0, 1); if (!infixChar.IsOperator()) { AddToOutput(ref output, infixChar); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); } else if (infixChar == Operators.OpenBracket) { AddToOutput(ref output); Operator newOperator = new Operator(infixChar); stack.Push(newOperator); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); } else if (infixChar == Operators.CloseBracket) { AddToOutput(ref output); Operator newOperator = new Operator(infixChar); while (stack.Any() && stack.Peek().OperatorType != Operators.OpenBracket) { AddToOutput(ref output, stack.Pop()); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); } stack.Pop(); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); } else { AddToOutput(ref output); Operator newOperator = new Operator(infixChar); while (stack.Any() && stack.Peek().Priority >= newOperator.Priority) { AddToOutput(ref output, stack.Pop()); } stack.Push(newOperator); OutputOperationBuffer.Push(new OutputOperation(id++, input, stack.ToReverseString(), output)); } } while (stack.Any()) { AddToOutput(ref output, stack.Pop()); } return output; }