diff options
author | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
commit | acea7b2e728787a0d83bbf83c8c1f042d2c32e7e (patch) | |
tree | 0bfec05c1ca2d71be2c337bcd110a0421f19318b /Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs | |
parent | 88febcb02bf127d961c6471d9e846c0e1315f5c3 (diff) |
+ plugins project
Diffstat (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs')
-rw-r--r-- | Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs new file mode 100644 index 0000000..f0babaf --- /dev/null +++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Gui/Controls/ItemsControl.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; + +namespace MonoGame.Extended.Gui.Controls +{ + public abstract class ItemsControl : Control + { + protected ItemsControl() + { + Items = new ControlCollection(this); + //{ + // ItemAdded = x => UpdateRootIsLayoutRequired(), + // ItemRemoved = x => UpdateRootIsLayoutRequired() + //}; + } + + public override IEnumerable<Control> Children => Items; + + public ControlCollection Items { get; } + + ///// <summary> + ///// Recursive Method to find the root element and update the IsLayoutRequired property. So that the screen knows that something in the controls + ///// have had a change to their layout. Also, it will reset the size of the element so that it can get a clean build so that the background patches + ///// can be rendered with the updates. + ///// </summary> + //private void UpdateRootIsLayoutRequired() + //{ + // var parent = Parent as ItemsControl; + + // if (parent == null) + // IsLayoutRequired = true; + // else + // parent.UpdateRootIsLayoutRequired(); + + // Size = Size2.Empty; + //} + + //protected List<T> FindControls<T>() + // where T : Control + //{ + // return FindControls<T>(Items); + //} + + //protected List<T> FindControls<T>(ControlCollection controls) + // where T : Control + //{ + // var results = new List<T>(); + // foreach (var control in controls) + // { + // if (control is T) + // results.Add(control as T); + + // var itemsControl = control as ItemsControl; + + // if (itemsControl != null && itemsControl.Items.Any()) + // results = results.Concat(FindControls<T>(itemsControl.Items)).ToList(); + // } + // return results; + //} + } +}
\ No newline at end of file |