/// <summary> /// InternalChildren의 첫 인덱스를 제거합니다. /// 파라미터를 true로 설정하면 마지막 인덱스를 제거합니다. /// </summary> public void DelTile(bool revert = false) { if (InternalChildren.Count == 0) { return; } if (revert) { RemoveInternal(InternalChildren.Last()); return; } RemoveInternal(InternalChildren.First()); }
/// <summary> /// TBD /// </summary> /// <param name="name">TBD</param> /// <exception cref="InvalidOperationException">This exception is thrown if the given <paramref name="name"/> belongs to an actor that is terminating.</exception> /// <exception cref="InvalidActorNameException">This exception is thrown if the given <paramref name="name"/> is not unique in the container.</exception> /// <returns>TBD</returns> public override IChildrenContainer Reserve(string name) { if (_reason is SuspendReason.Termination) { throw new InvalidOperationException($@"Cannot reserve actor name ""{name}"". It is terminating."); } if (InternalChildren.ContainsKey(name)) { throw new InvalidActorNameException($@"Actor name ""{name}"" is not unique!"); } else { return(new TerminatingChildrenContainer(InternalChildren.SetItem(name, ChildNameReserved.Instance), _toDie, _reason)); } }
private void Cleanup(IItemContainerGenerator generator, IEnumerable <UIElement> children) { foreach (var child in children) { var childIndex = InternalChildren.IndexOf(child); if (child is SplitterGrip) { RemoveInternalChildRange(childIndex, 1); _generatedSplitterGrips.Remove((SplitterGrip)child); continue; } VirtualizeContainer(generator, child, childIndex); } }
public override ChildrenContainer Reserve(string name) { if (_reason is SuspendReason.Termination) { throw new InvalidOperationException(string.Format("Cannot reserve actor name\"{0}\". Is terminating.", name)); } if (InternalChildren.Contains(name)) { throw new InvalidActorNameException(string.Format("Actor name \"{0}\" is not unique!", name)); } else { return(new TerminatingChildrenContainer(InternalChildren.AddOrUpdate(name, ChildNameReserved.Instance), _toDie, _reason)); } }
protected override void LayoutChildren(double x, double y, double width, double height) { if (!InternalChildren.Any()) { return; } // grab a snapshot of this grid, fully-measured, so we can do the layout var structure = new GridStructure(this, width, height); for (var index = 0; index < InternalChildren.Count; index++) { var child = (View)InternalChildren[index]; if (!child.IsVisible) { continue; } int r = GetRow(child); int c = GetColumn(child); int rs = GetRowSpan(child); int cs = GetColumnSpan(child); double posx = x + c * ColumnSpacing; for (var i = 0; i < c; i++) { posx += structure.Columns[i].ActualWidth; } double posy = y + r * RowSpacing; for (var i = 0; i < r; i++) { posy += structure.Rows[i].ActualHeight; } double w = structure.Columns[c].ActualWidth; for (var i = 1; i < cs; i++) { w += ColumnSpacing + structure.Columns[c + i].ActualWidth; } double h = structure.Rows[r].ActualHeight; for (var i = 1; i < rs; i++) { h += RowSpacing + structure.Rows[r + i].ActualHeight; } // in the future we can might maybe optimize by passing the already calculated size request LayoutChildIntoBoundingRegion(child, new Rect(posx, posy, w, h)); } }
private void load(ConfigColourProvider colourProvider) { var colour = colourProvider.GetContentColour(this); // set header box and text to target color. var headerBox = InternalChildren.FirstOrDefault(); var title = (InternalChildren.LastOrDefault() as Container)?.Children?.FirstOrDefault(); if (headerBox == null || title == null) { return; } headerBox.Colour = colour; title.Colour = colour; }
void AddWindow(IWindow window) { _windows.Add(window); if (window is Element windowElement) { windowElement.Parent = this; InternalChildren.Add(windowElement); OnChildAdded(windowElement); } if (window is NavigableElement ne) { ne.NavigationProxy.Inner = NavigationProxy; } }
/// <summary> /// 子要素を配置し、パネルのサイズを決定する。 /// </summary> /// <param name="finalSize">パネル自体と子要素を配置するために使用する親の末尾の領域。</param> /// <returns>使用する実際のサイズ。</returns> protected override Size ArrangeOverride(Size finalSize) { foreach (UIElement child in InternalChildren) { var gen = ItemContainerGenerator as ItemContainerGenerator; var index = (gen != null) ? gen.IndexFromContainer(child) : InternalChildren.IndexOf(child); if (_containerLayouts.ContainsKey(index)) { var layout = _containerLayouts[index]; layout.Offset(_offset.X * -1, _offset.Y * -1); child.Arrange(layout); } } return(finalSize); }
protected override Size MeasureOverride(Size availableSize) { var visibleChildren = InternalChildren.Cast <FrameworkElement>().Where(ele => ele.Visibility != System.Windows.Visibility.Collapsed); double height = 0.0; double width = 0.0; foreach (var child in visibleChildren) { child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); width += child.DesiredSize.Width + child.Margin.Left + child.Margin.Right; height = Math.Max(height, child.DesiredSize.Height); } return(new Size(Math.Min(width, availableSize.Width), height)); }
public void Pop(bool animated) { if (StackDepth <= 1) { return; } if (InternalChildren.Remove(InternalChildren.Last())) { if (FormsContentControl != null) { FormsContentControl.Transition = animated ? TransitionType.Right : TransitionType.Normal; } CurrentPage = InternalChildren.Last(); } }
LayoutInfo GetDependency(DependencyObject element, DependencyProperty property) { var value = (UIElement)element.GetValue(property); if (value == null) { return(null); } if (!InternalChildren.Contains(value)) { throw new ArgumentException("RelativePanel error: Element does not exist in the current context"); } return(GetLayoutInfo(value)); }
/// <summary> /// <see cref="System.Windows.Media.Visual"/> オブジェクトの座標空間が表示されるまで、 /// コンテンツを強制的にスクロールする。 /// </summary> /// <param name="visual">表示可能になる <see cref="System.Windows.Media.Visual"/>。</param> /// <param name="rectangle">表示する座標空間を識別する外接する四角形。</param> /// <returns>表示される <see cref="System.Windows.Rect"/>。</returns> public Rect MakeVisible(Visual visual, Rect rectangle) { var idx = InternalChildren.IndexOf(visual as UIElement); var generator = ItemContainerGenerator as IItemContainerGenerator; if (generator != null) { var pos = new GeneratorPosition(idx, 0); idx = generator.IndexFromGeneratorPosition(pos); } if (idx < 0) { return(Rect.Empty); } if (!_containerLayouts.ContainsKey(idx)) { return(Rect.Empty); } var layout = _containerLayouts[idx]; if (HorizontalOffset + ViewportWidth < layout.X + layout.Width) { SetHorizontalOffset(layout.X + layout.Width - ViewportWidth); } if (layout.X < HorizontalOffset) { SetHorizontalOffset(layout.X); } if (VerticalOffset + ViewportHeight < layout.Y + layout.Height) { SetVerticalOffset(layout.Y + layout.Height - ViewportHeight); } if (layout.Y < VerticalOffset) { SetVerticalOffset(layout.Y); } layout.Width = Math.Min(ViewportWidth, layout.Width); layout.Height = Math.Min(ViewportHeight, layout.Height); return(layout); }
protected override Size ArrangeOverride(Size arrangeSize) { if (InternalChildren.Count == 0) { return(arrangeSize); } if (InternalChildren.Count == 1) { return(base.ArrangeOverride(arrangeSize)); } var firstItem = InternalChildren[0]; var lastItem = InternalChildren[InternalChildren.Count - 1]; var firstItemSize = firstItem.DesiredSize; var lastItemSize = lastItem.DesiredSize; var sidesRect = new Rect(0.0, 0.0, Math.Max(firstItemSize.Width, lastItemSize.Width), Math.Max(firstItemSize.Height, lastItemSize.Height)); firstItem.Arrange(sidesRect); if (InternalChildren.Count > 2) { var columns = Columns == 0 ? InternalChildren.Count : Columns; // Note this doesn't support wrapping var remainingWidth = arrangeSize.Width - (sidesRect.Width * 2); var remainingColumns = columns - 2; var finalRect = new Rect(sidesRect.Width, 0.0, remainingWidth / remainingColumns, arrangeSize.Height / Rows); var width = finalRect.Width; foreach (var child in InternalChildren.OfType <UIElement>().Skip(1).Take(remainingColumns)) { child.Arrange(finalRect); if (child.Visibility != Visibility.Collapsed) { finalRect.X += width; } } } sidesRect.X = arrangeSize.Width - lastItemSize.Width; lastItem.Arrange(sidesRect); return(arrangeSize); }
protected override Size MeasureOverride(Size constraint) { base.MeasureOverride(constraint); double width = InternalChildren .OfType <UIElement>() .Select(i => i.DesiredSize.Width + PropertyValueToDouble(i.GetValue(LeftProperty))) .Append(0.0) .Max(); double height = InternalChildren .OfType <UIElement>() .Select(i => i.DesiredSize.Height + PropertyValueToDouble(i.GetValue(TopProperty))) .Append(0.0) .Max(); return(new Size(width, height)); }
private async void VisualExtentValuesChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == string.Empty || e.PropertyName == nameof(Extent.ZoomLevel)) { PanelExtent = new Rect(Projection.FullMapSizeFor(Extent.ZoomLevel)); // Measurements only change when the zoom level changes. Screen size affects the visual port, // and GeoArea affects the geographic area under the map InvalidateMeasure(); } ScrollOwner?.InvalidateScrollInfo(); InvalidateArrange(); foreach (var child in InternalChildren.OfType <UIElement>().Where(c => !(c is MapLayer)).ToList()) { Children.Remove(child); } var tiles = tileManager.GetTilesForArea(Projection, Extent).ToList(); while (tiles.Any()) { await Task.WhenAny(tiles); foreach (var finishedDrawing in tiles.Where(t => t.IsCompleted).ToList()) { var tileContent = await finishedDrawing; var visual = new Rectangle(); Geo.SetArea(visual, Geo.GetArea(tileContent)); var brush = new DrawingBrush { Drawing = tileContent, Stretch = Stretch.Fill }; brush.Freeze(); visual.Fill = brush; SetZIndex(visual, int.MaxValue); Children.Add(visual); tiles.Remove(finishedDrawing); } } }
/// <summary> /// Realizes the children, or ensures they are already realized. /// </summary> /// <param name="start">The start.</param> /// <param name="count">The count.</param> private int RealizeChildren(int start, int count) { var generator = GetItemContainerGenerator(); var startPos = generator.GeneratorPositionFromIndex(start); var childIndex = startPos.Offset == 0 ? startPos.Index : startPos.Index + 1; var result = childIndex; using (generator.StartAt(startPos, GeneratorDirection.Forward, true)) { for (int index = 0; index < count; index++, childIndex++) { bool newlyRealized; // Get or create the child var child = (UIElement)generator.GenerateNext(out newlyRealized); if (child == null) { continue; } //var absoluteIndex = start + index; if (newlyRealized) { // Muy important: to be bound correctly, the child must be added first if (!InternalChildren.Contains(child)) { if (childIndex >= InternalChildren.Count) { AddInternalChild(child); } else { InsertInternalChild(childIndex, child); } } else { if (!ReferenceEquals(InternalChildren[childIndex], child)) { throw new Exception("WTF"); } } generator.PrepareItemContainer(child); } } } return(result); }
private IEnumerable <ChildElementWithCalculatedSize> EnumerateChildenAndCalculateSizes(Size containerSize) { var totalSpan = 0.0; return(InternalChildren.Cast <UIElement>() .Select(x => new { ChildElement = x, Span = GetSpan(x) }) .Do(x => totalSpan += x.Span) .ToArray() .Select(x => new { ChildElement = x.ChildElement, WeightedSpan = x.Span / totalSpan }) .Select(x => new ChildElementWithCalculatedSize() { ChildElement = x.ChildElement, CalculatedSize = (Orientation == Orientation.Vertical) ? new Size(containerSize.Width, (containerSize.Height * x.WeightedSpan)) : new Size((containerSize.Width * x.WeightedSpan), containerSize.Height) })); }
protected override void LoadComplete() { base.LoadComplete(); explosionStar.ScaleTo(2f, RushPlayfield.HIT_EXPLOSION_DURATION) .FadeOutFromOne(RushPlayfield.HIT_EXPLOSION_DURATION) .Expire(true); flashCircle.ScaleTo(4f, RushPlayfield.HIT_EXPLOSION_DURATION / 2) .Then() .ScaleTo(0.5f, RushPlayfield.HIT_EXPLOSION_DURATION / 2) .FadeOut(RushPlayfield.HIT_EXPLOSION_DURATION / 2) .Expire(true); // TODO: very low priority for now, but this shouldn't stay as-is in every similar composite. this.Delay(InternalChildren.Max(d => d.LatestTransformEndTime)).Expire(true); }
public void Init() { // 내머리로는 이게 한계 for (int i = 0; i < InternalChildren.Count; i++) { RemoveInternal(InternalChildren.First()); for (int e = 0; e < InternalChildren.Count; i++) { RemoveInternal(InternalChildren.First()); } } offset = 0.0f; beforeTileX = 0.0f; Position = new Vector2(0, 0); }
void OnChildModelPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (AsyncRefreshCalled) { return; } if (_fixingChildrenDockLengths.CanEnter && (e.PropertyName == "DockWidth" || e.PropertyName == "DockMinWidth") && Orientation == System.Windows.Controls.Orientation.Horizontal) { if (ColumnDefinitions.Count == InternalChildren.Count) { var changedElement = sender as ILayoutPositionableElement; var childFromModel = InternalChildren.OfType <ILayoutControl>().First(ch => ch.Model == changedElement) as UIElement; int indexOfChild = InternalChildren.IndexOf(childFromModel); if (e.PropertyName == "DockWidth") { ColumnDefinitions[indexOfChild].Width = changedElement.DockWidth; } if (e.PropertyName == "DockMinWidth") { ColumnDefinitions[indexOfChild].MinWidth = changedElement.DockMinWidth; } } } else if (_fixingChildrenDockLengths.CanEnter && (e.PropertyName == "DockHeight" || e.PropertyName == "DockMinHeight") && Orientation == System.Windows.Controls.Orientation.Vertical) { if (RowDefinitions.Count == InternalChildren.Count) { var changedElement = sender as ILayoutPositionableElement; var childFromModel = InternalChildren.OfType <ILayoutControl>().First(ch => ch.Model == changedElement) as UIElement; int indexOfChild = InternalChildren.IndexOf(childFromModel); if (e.PropertyName == "DockHeight") { RowDefinitions[indexOfChild].Height = changedElement.DockHeight; } if (e.PropertyName == "DockMinHeight") { RowDefinitions[indexOfChild].MinHeight = changedElement.DockMinHeight; } } } else if (e.PropertyName == "IsVisible" || e.PropertyName == "IsDockHeightFixed" || e.PropertyName == "IsDockWidthFixed") { UpdateRowColDefinitions(); } }
protected override Size MeasureOverride(Size constraint) { var baseSize = base.MeasureOverride(constraint); var children = InternalChildren.OfType <UIElement>(); if (children.Any()) { var width = children.Max(x => x.DesiredSize.Width + (double)x.GetValue(LeftProperty)); var height = children.Max(x => x.DesiredSize.Height + (double)x.GetValue(TopProperty)); return(new Size(width, height)); } else { return(baseSize); } }
public void AddTileLayers(int index, IEnumerable <TileLayer> tileLayers) { foreach (var tileLayer in tileLayers) { if (index < InternalChildren.Count) { InternalChildren.Insert(index, tileLayer); } else { InternalChildren.Add(tileLayer); } index++; tileLayer.UpdateTiles(tileZoomLevel, tileGrid); } }
private void RemoveChild(UIElement child) { DependencyObject visualParent = VisualTreeHelper.GetParent(child); if (visualParent == this) { InternalChildren.RemoveInternal(child); } else { ToolBarOverflowPanel overflowPanel = ToolBarOverflowPanel; if ((visualParent == overflowPanel) && (overflowPanel != null)) { overflowPanel.Children.Remove(child); } } }
public virtual void ComputeLayout() { foreach (var child in InternalChildren) { if (child is DrawableLyric drawableLyric) { if (drawableLyric.DisplayLayer != 0) { var pervous = InternalChildren.GetPrevious(drawableLyric); var next = InternalChildren.GetNext(drawableLyric); var perviousHeight = pervous?.Y + pervous?.DrawHeight ?? 0; var nextHeight = next?.Y + next?.DrawHeight ?? 0; drawableLyric.Y = Math.Max(perviousHeight, nextHeight); } } } }
protected override Size ArrangeOverride(Size finalSize) { foreach (UIElement child in InternalChildren) { var generator = ItemContainerGenerator as ItemContainerGenerator; var index = generator?.IndexFromContainer(child) ?? InternalChildren.IndexOf(child); if (!calculated_item_rects.TryGetValue(index, out var layout)) { continue; } //layout.Offset(_offset.X * -1, _offset.Y * -1); child.Arrange(layout); } return(finalSize); }
private void UpdateActiveChild() { var activeChild = InternalChildren.OfType <UIElement>().FirstOrDefault(TestChild); if (ReferenceEquals(_activeChild, activeChild)) { return; } if (_activeChild != null) { _activeChild.Visibility = Visibility.Collapsed; } _activeChild = activeChild; if (activeChild != null) { activeChild.Visibility = Visibility.Visible; } }
/// <summary> /// Creates a new instance of the <see cref="ComboBox"/> control. /// </summary> public ComboBox() { _currentDisplay = new TextBlock(); _dropdown = new SelectList(); var dropdownArrow = new Icon { FixedWidth = 16, FixedHeight = 16, VerticalAlignment = VerticalAlignment.Center, Image = GameLoop.LoadTexture("Icons/chevron-down") }; _button = new Button(); var sp = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 4 }; sp.AddChild(_currentDisplay); sp.AddChild(dropdownArrow); _button.Content = sp; InternalChildren.Add(_button); _button.Click += HandleButtonClick; _dropdown.SelectedIndexChanged += HandleItemChanged; _currentDisplay.Text = "Select..."; _dropdownBox = new Box { MaxHeight = 75, MinHeight = 4, Content = new ScrollBox { Content = _dropdown } }; _button.LostFocus += HandleLostFocus; }
void UpdateCurrentPage() { if (ItemsSource != null) { int index = _templatedItems.ListProxy.IndexOf(SelectedItem); if (index == -1) { CurrentPage = (T)InternalChildren.FirstOrDefault(); } else { CurrentPage = _templatedItems.GetOrCreateContent(index, SelectedItem); } } else if (SelectedItem is T) { CurrentPage = (T)SelectedItem; } }
protected override Size MeasureOverride(Size availableSize) { if (InternalChildren.Count == 0) { return(new Size(availableSize.Width, 0)); } var maxWidth = availableSize.Width / InternalChildren.Count; foreach (var child in InternalChildren.OfType <UIElement>()) { child.Measure(new Size(maxWidth, availableSize.Height)); } var actualHeight = InternalChildren.OfType <UIElement>().Max(e => e.DesiredSize.Height); var actualWidth = InternalChildren.OfType <UIElement>().Sum(e => e.DesiredSize.Width); return(new Size(Math.Min(availableSize.Width, actualWidth), Math.Min(availableSize.Height, actualHeight))); }
private void updateLayout() { // Get an initial sprite we can use to derive size Sprite sprite = (Sprite)InternalChildren.First(); // Work out how many copies are needed to horizontally fill the screen var spriteNum = (int)Math.Ceiling(DrawWidth / sprite.DrawWidth) + 1; // If the number needed is higher or lower than the current number of child sprites, add/remove the amount needed for them to match if (spriteNum != InternalChildren.Count) { // Update the number of sprites in the list to match the number we need to cover the whole container while (InternalChildren.Count > spriteNum) { RemoveInternal(InternalChildren.Last()); } while (InternalChildren.Count < spriteNum) { AddInternal(createSprite()); } } // Lay out all of the child sprites horizontally, and assign a looping pan animation to create the effect of constant scrolling var offset = 0.0f; foreach (var childSprite in InternalChildren) { var width = childSprite.DrawWidth * sprite.Scale.X; childSprite.Position = new Vector2(offset, childSprite.Position.Y); var fromVector = new Vector2(offset, childSprite.Position.Y); var toVector = new Vector2(offset - width, childSprite.Position.Y); if (Running) { childSprite.Loop(b => b.MoveTo(fromVector).MoveTo(toVector, Duration)); } // Change the inset to overlap slightly in order to avoid potential seam lines offset += width - 1; } }