Move MatterControl source code into a subdirectory

This commit is contained in:
Nettika 2026-01-28 21:30:58 -08:00
parent 2c6e34243a
commit 70af2d9ae8
Signed by: nettika
SSH key fingerprint: SHA256:f+PJrfIq49zrQ6dQrHj18b+PJKmAldeAMiGdj8IzXCA
2007 changed files with 13 additions and 8 deletions

View file

@ -0,0 +1,66 @@
using System;
using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.UI;
using MatterHackers.MatterControl.CustomWidgets;
namespace MatterHackers.MatterControl.ConfigurationPage
{
public class SettingsItem : SettingsRow
{
public class ToggleSwitchConfig
{
public bool Checked { get; set; }
public string Name { get; set; }
public Action<bool> ToggleAction { get; set; }
}
public SettingsItem(string text, ThemeConfig theme, ToggleSwitchConfig toggleSwitchConfig = null, GuiWidget optionalControls = null, ImageBuffer iconImage = null)
: this(text, CreateToggleSwitch(toggleSwitchConfig, theme), theme, optionalControls, iconImage)
{
}
public SettingsItem (string text, GuiWidget settingsControls, ThemeConfig theme, GuiWidget optionalControls = null, ImageBuffer imageBuffer = null)
: base (text, "", theme, imageBuffer)
{
this.SettingsControl = settingsControls;
if (optionalControls != null)
{
this.AddChild(optionalControls);
}
if (settingsControls != null)
{
this.AddChild(settingsControls);
}
}
public GuiWidget SettingsControl { get; }
private static GuiWidget CreateToggleSwitch(ToggleSwitchConfig toggleSwitchConfig, ThemeConfig theme)
{
if (toggleSwitchConfig == null)
{
return null;
}
var toggleSwitch = new RoundedToggleSwitch(theme)
{
VAnchor = VAnchor.Center,
Checked = toggleSwitchConfig.Checked,
Name = toggleSwitchConfig.Name,
Margin = new BorderDouble(left: 16),
};
toggleSwitch.CheckedStateChanged += (sender, e) =>
{
toggleSwitchConfig.ToggleAction?.Invoke(toggleSwitch.Checked);
};
return toggleSwitch;
}
}
}