37 lines
954 B
C#
37 lines
954 B
C#
using Sarand.Net.Mobile.Maui.Views;
|
|
using Sarand.Net.Mobile.Maui.Controls;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Sarand.Net.Mobile.Maui.Logic
|
|
{
|
|
// --- Sam view tree operations ---
|
|
public static class SamViewTreeUtil
|
|
{
|
|
public static void ConfigureChildren(Element? root)
|
|
{
|
|
foreach (Element element in GetElements(root))
|
|
if (element is ISamView samView)
|
|
samView.ConfigureComponents();
|
|
}
|
|
|
|
public static void SetChildControlActivity(Element? root, bool enabled)
|
|
{
|
|
foreach (Element element in GetElements(root))
|
|
{
|
|
if (element is ISamView samView)
|
|
samView.SetControlActivity(enabled);
|
|
if (element is ISamControl samControl)
|
|
samControl.SetControlActivity(enabled);
|
|
}
|
|
}
|
|
|
|
private static IEnumerable<Element> GetElements(Element? root)
|
|
{
|
|
if (root == null) yield break;
|
|
yield return root;
|
|
foreach (Element descendant in root.GetVisualTreeDescendants())
|
|
yield return descendant;
|
|
}
|
|
}
|
|
}
|