public void SetCorrectVisibilityStates(object sender, EventArgs e) { UiThread.RunOnIdle(PostUpdateSetCorrectVisibilityStates); }
private void DoCallAppWidgetOnIdle() { IdleCount++; UiThread.DoRunAllPending(); }
protected void DoWrappingLayout() { if (doingLayout) { needAnotherLayout = true; return; } using (this.LayoutLock()) { doingLayout = true; // remove all the children we added foreach (var child in addedChildren) { if (child.Parent != null) { using (child.Parent.LayoutLock()) { child.Parent.RemoveChild(child); child.ClearRemovedFlag(); } } } // close all the row containers this.CloseChildren(); // add in new row container FlowLayoutWidget childContainerRow = new FlowLayoutWidget() { Margin = RowMargin, Padding = RowPadding, HAnchor = HAnchor.Stretch, }; base.AddChild(childContainerRow); var rowPaddingWidth = RowPadding.Width + RowMargin.Width + this.Margin.Width + this.Padding.Width; double runningSize = 0; MaxLineWidth = 0; foreach (var child in addedChildren) { var childWidth = child.Width + child.DeviceMarginAndBorder.Width; if (child.HAnchor == HAnchor.Stretch) { childWidth = child.MinimumSize.X + child.DeviceMarginAndBorder.Width; } if (runningSize + childWidth > this.Width - rowPaddingWidth || child is IHardBreak) { MaxLineWidth = Math.Max(MaxLineWidth, runningSize); runningSize = 0; var lastItemWasHorizontalSpacer = false; if (childContainerRow != null) { childContainerRow.PerformLayout(); if (childContainerRow.Children.LastOrDefault() is HorizontalSpacer) { lastItemWasHorizontalSpacer = true; } } childContainerRow = new FlowLayoutWidget() { Margin = RowMargin, Padding = RowPadding, HAnchor = HAnchor.Stretch, Border = RowBoarder, BorderColor = RowBoarderColor, }; if (lastItemWasHorizontalSpacer) { childContainerRow.AddChild(new HorizontalSpacer()); } base.AddChild(childContainerRow); } if (runningSize > 0 || !(child is ISkipIfFirst)) { // add the new child to the current row using (childContainerRow.LayoutLock()) { childContainerRow.AddChild(child); } runningSize += childWidth; MaxLineWidth = Math.Max(MaxLineWidth, runningSize); } } if (childContainerRow != null) { childContainerRow.PerformLayout(); } MakeProportionalIfRequired(); MakeCenterIfRequired(); doingLayout = false; } if (needAnotherLayout) { UiThread.RunOnIdle(DoWrappingLayout); needAnotherLayout = false; } // change the size to force a recursive layout event this.Height--; this.Height++; this.PerformLayout(); }