private void EnsureCorrectBounds() { if (Parent != null && Parent.Visible && Parent.Width > 0 && Parent.Height > 0 && Parent.Children.Count > 1) { if (Children.IndexOf(disableOverlay) != Children.Count - 1) { Children.RemoveAt(Children.IndexOf(disableOverlay)); disableOverlay.ClearRemovedFlag(); Children.Add(disableOverlay); } var childBounds = GetChildrenBoundsIncludingMargins(considerChild: (parent, child) => { if (child == disableOverlay) { return(false); } return(true); }); if (childBounds != RectangleDouble.ZeroIntersection) { disableOverlay.LocalBounds = new RectangleDouble(childBounds.Left, childBounds.Bottom, childBounds.Right, childBounds.Top - disableOverlay.Margin.Top); } } }
public void ShowContentInWindow() { if (widgetWithPopContent.HasBeenClosed) { if (systemWindowWithPopContent != null) { systemWindowWithPopContent.Close(); } return; } if (systemWindowWithPopContent == null) { // So the window is open now only change this is we close it. UserSettings.Instance.Fields.SetBool(WindowLeftOpenKey, true); string windowSize = UserSettings.Instance.get(WindowSizeKey); int width = 600; int height = 400; if (windowSize != null && windowSize != "") { string[] sizes = windowSize.Split(','); width = Math.Max(int.Parse(sizes[0]), (int)minSize.x); height = Math.Max(int.Parse(sizes[1]), (int)minSize.y); } systemWindowWithPopContent = new SystemWindow(width, height); systemWindowWithPopContent.Padding = new BorderDouble(3); systemWindowWithPopContent.Title = windowTitle; systemWindowWithPopContent.AlwaysOnTopOfMain = true; systemWindowWithPopContent.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; systemWindowWithPopContent.Closing += SystemWindow_Closing; if (widgetWithPopContent.Children.Count == 1) { GuiWidget child = widgetWithPopContent.Children[0]; widgetWithPopContent.RemoveChild(child); child.ClearRemovedFlag(); widgetWithPopContent.AddChild(CreateContentForEmptyControl()); systemWindowWithPopContent.AddChild(child); } systemWindowWithPopContent.ShowAsSystemWindow(); systemWindowWithPopContent.MinimumSize = minSize; string desktopPosition = UserSettings.Instance.get(PositionKey); if (desktopPosition != null && desktopPosition != "") { string[] sizes = desktopPosition.Split(','); //If the desktop position is less than -10,-10, override int xpos = Math.Max(int.Parse(sizes[0]), -10); int ypos = Math.Max(int.Parse(sizes[1]), -10); systemWindowWithPopContent.DesktopPosition = new Point2D(xpos, ypos); } } else { systemWindowWithPopContent.BringToFront(); } }
private void RenderRunningTasks(ThemeConfig theme, RunningTasksConfig tasks) { var rows = tasksContainer.Children.OfType <RunningTaskStatusPanel>().ToList(); var displayedTasks = new HashSet <RunningTaskDetails>(rows.Select(taskRow => taskRow.taskDetails)); var runningTasks = tasks.RunningTasks; // Remove expired items foreach (var row in rows) { if (!runningTasks.Contains(row.taskDetails)) { row.Close(); } } var progressBackgroundColor = new Color(theme.AccentMimimalOverlay, 35); // Add new items foreach (var taskItem in tasks.RunningTasks.Where(t => !displayedTasks.Contains(t))) { // TODO: find out how we are getting a null task item in the list if (taskItem == null) { continue; } var runningTaskPanel = new RunningTaskStatusPanel("", taskItem, theme) { HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Stretch, Margin = new BorderDouble(right: 2, top: 1, bottom: 1), Border = new BorderDouble(1), BorderColor = theme.SlightShade, ProgressBackgroundColor = progressBackgroundColor, Width = 200 * GuiWidget.DeviceScale }; tasksContainer.AddChild(runningTaskPanel); } if (!string.IsNullOrEmpty(ApplicationController.Instance.UiHint)) { statusMessage.Text = ApplicationController.Instance.UiHint; statusMessage.Visible = true; var parent = statusMessage.Parent; if (parent.Children.IndexOf(statusMessage) != parent.Children.Count - 1) { parent.RemoveChild(statusMessage); statusMessage.ClearRemovedFlag(); parent.AddChild(statusMessage); } } else { statusMessage.Visible = false; } tasksContainer.Invalidate(); }
private void SystemWindow_Closing(object sender, WidgetClosingEnventArgs closingEvent) { SaveSizeAndPosition(); SaveWindowShouldStartClosed(); if (PopedOutSystemWindow.Children.Count == 1) { GuiWidget child = PopedOutSystemWindow.Children[0]; PopedOutSystemWindow.RemoveChild(child); child.ClearRemovedFlag(); widgetWhosContentsPopOut.RemoveAllChildren(); widgetWhosContentsPopOut.AddChild(child); } PopedOutSystemWindow = null; }
public PopupWidget(GuiWidget contentWidget, IPopupLayoutEngine layoutEngine, bool makeScrollable) { this.contentWidget = contentWidget; this.layoutEngine = layoutEngine; ignoredWidgets = contentWidget.Children.Where(c => c is IIgnoredPopupChild).ToList(); if (contentWidget is IIgnoredPopupChild) { ignoredWidgets.Add(contentWidget); } if (makeScrollable) { scrollingWindow = new ScrollableWidget(true); { contentWidget.ClearRemovedFlag(); scrollingWindow.AddChild(contentWidget); contentWidget.HAnchor = UI.HAnchor.Left | UI.HAnchor.Fit; contentWidget.VAnchor |= UI.VAnchor.Bottom; // we may have fit or absolute so or it in Width = contentWidget.Width; Height = contentWidget.Height; } scrollingWindow.HAnchor = HAnchor.Stretch; scrollingWindow.VAnchor = VAnchor.Stretch; if (layoutEngine.MaxHeight > 0 && Height > layoutEngine.MaxHeight) { MakeMenuHaveScroll(layoutEngine.MaxHeight); } this.AddChild(scrollingWindow); } else { this.AddChild(contentWidget); Width = contentWidget.Width; // Clamp height to MaxHeight if specified, otherwise content height Height = layoutEngine.MaxHeight > 0 ? Math.Min(layoutEngine.MaxHeight, contentWidget.Height) : contentWidget.Height; } layoutEngine.ShowPopup(this); }
private void SystemWindow_Closing(object sender, ClosingEventArgs closingEvent) { if (systemWindowWithPopContent != null) { SaveSizeAndPosition(); SaveWindowShouldStartClosed(); if (systemWindowWithPopContent.Children.Count == 1) { GuiWidget child = systemWindowWithPopContent.Children[0]; systemWindowWithPopContent.RemoveChild(child); child.ClearRemovedFlag(); widgetWithPopContent.RemoveAllChildren(); widgetWithPopContent.AddChild(child); } systemWindowWithPopContent = null; } }
public DisableableWidget() { HAnchor = HAnchor.ParentLeftRight; VAnchor = VAnchor.FitToChildren; this.Margin = new BorderDouble(3); disableOverlay = new GuiWidget(0, 0); this.BoundsChanged += (s, e) => { if (Parent != null && Parent.Visible && Parent.Width > 0 && Parent.Height > 0 && Parent.Children.Count > 1) { if (Children.IndexOf(disableOverlay) != Children.Count - 1) { Children.RemoveAt(Children.IndexOf(disableOverlay)); disableOverlay.ClearRemovedFlag(); Children.Add(disableOverlay); } var childBounds = GetChildrenBoundsIncludingMargins(considerChild: (parent, child) => { if (child == disableOverlay) { return(false); } return(true); }); if (childBounds != RectangleDouble.ZeroIntersection) { disableOverlay.LocalBounds = new RectangleDouble(childBounds.Left, childBounds.Bottom, childBounds.Right, childBounds.Top - disableOverlay.Margin.Top); } } }; disableOverlay.Visible = false; base.AddChild(disableOverlay); }