Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DasherCore
8 changes: 8 additions & 0 deletions src/Dasher.Windows/Controls/DasherCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public void Initialize(string dataDir, string userDir)
var errorMsg = errorPtr != IntPtr.Zero ? Marshal.PtrToStringUTF8(errorPtr) ?? "Unknown error" : "Unknown error";
throw new InvalidOperationException($"Failed to create Dasher session: {errorMsg}");
}
}

/// <summary>
/// Starts the engine (sets screen size, triggers Realize, starts timer).
/// Call AFTER any pre-Realize parameter migration.
/// </summary>
public void StartEngine()
{
NativeBridge.dasher_set_screen_size(_handle, 700, 640);
_timer.Start();
}
Expand Down
128 changes: 128 additions & 0 deletions src/Dasher.Windows/Controls/SettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ private void ShowCategoryCore(string category)
public event EventHandler<(EyeGazeIntegration.TrackerType trackerType, int udpPort)>? InputSourceChanged;
public event EventHandler? JoystickRequested;
public event Action<string, int>? OutputFontChanged;
public event Action? ResetSettingsRequested;
public event Action<double>? KeyboardOpacityChanged;

private static readonly string[] OutputFontPresets =
Expand Down Expand Up @@ -1273,6 +1274,133 @@ private void BuildPrivacySettings()
Foreground = mutedText,
});

// ── Dasher 5 Import section ──
section.Children.Add(new Border
{
BorderBrush = Application.Current?.FindResource("BorderLight") as IBrush ?? Brushes.LightGray,
BorderThickness = new Thickness(0, 1, 0, 0),
Margin = new Thickness(0, 24, 0, 0),
});

section.Children.Add(new TextBlock
{
Text = "Dasher 5 Import",
FontSize = 15,
FontWeight = FontWeight.SemiBold,
Foreground = titleText,
});

if (V5MigrationService.HasV5Data)
{
var scan = V5MigrationService.Scan();

var statusText = V5MigrationService.HasBeenOffered
? "Status: Imported"
: "Status: Not imported (Dasher 5 data detected)";

section.Children.Add(new TextBlock
{
Text = statusText,
FontSize = 12,
Foreground = bodyText,
});

if (!string.IsNullOrEmpty(scan.Alphabet))
section.Children.Add(new TextBlock { Text = $" Alphabet: {scan.Alphabet}", FontSize = 11, Foreground = mutedText });
if (!string.IsNullOrEmpty(scan.Colour))
section.Children.Add(new TextBlock { Text = $" Colour: {scan.Colour}", FontSize = 11, Foreground = mutedText });
if (!string.IsNullOrEmpty(scan.Speed))
section.Children.Add(new TextBlock { Text = $" Speed: {scan.Speed}", FontSize = 11, Foreground = mutedText });
if (scan.ControlMode)
section.Children.Add(new TextBlock { Text = " Control mode: enabled", FontSize = 11, Foreground = mutedText });
if (scan.CustomFileCount > 0)
section.Children.Add(new TextBlock { Text = $" {scan.CustomFileCount} custom file(s)", FontSize = 11, Foreground = mutedText });

var importBtn = new Button
{
Content = "Import from Dasher 5",
Padding = new Thickness(16, 6),
FontSize = 12,
Margin = new Thickness(0, 8, 0, 0),
HorizontalAlignment = HorizontalAlignment.Left,
Background = Application.Current?.FindResource("ControlBg") as IBrush ?? Brushes.LightGray,
BorderThickness = new Thickness(0),
};
importBtn.Click += (s, e) =>
{
var result = V5MigrationService.Import(_handle);
// Apply deferred params immediately (engine is already realized)
foreach (var (key, value) in result.DeferredParameters)
{
if (value == "true" || value == "false")
NativeBridge.dasher_set_bool_parameter(_handle, key, value == "true" ? 1 : 0);
else if (int.TryParse(value, out var intVal))
NativeBridge.dasher_set_long_parameter(_handle, key, intVal);
else
NativeBridge.dasher_set_string_parameter(_handle, key, value);
}
// Refresh the panel
ShowCategory("Privacy");
};
section.Children.Add(importBtn);
}
else
{
section.Children.Add(new TextBlock
{
Text = "No Dasher 5 data found on this computer.",
FontSize = 12,
Foreground = mutedText,
});
}

// ── Reset to defaults ──
section.Children.Add(new Border
{
BorderBrush = Application.Current?.FindResource("BorderLight") as IBrush ?? Brushes.LightGray,
BorderThickness = new Thickness(0, 1, 0, 0),
Margin = new Thickness(0, 24, 0, 0),
});

section.Children.Add(new TextBlock
{
Text = "Reset Settings",
FontSize = 15,
FontWeight = FontWeight.SemiBold,
Foreground = titleText,
});

section.Children.Add(new TextBlock
{
Text = "Restore all Dasher settings to their default values. This cannot be undone.",
FontSize = 12,
TextWrapping = TextWrapping.Wrap,
Foreground = bodyText,
});

var resetSettingsBtn = new Button
{
Content = "Reset to defaults",
Padding = new Thickness(16, 6),
FontSize = 12,
Margin = new Thickness(0, 8, 0, 0),
HorizontalAlignment = HorizontalAlignment.Left,
Background = new SolidColorBrush(Color.FromRgb(0xEB, 0x5B, 0x5C)),
Foreground = Brushes.White,
BorderThickness = new Thickness(0),
};
resetSettingsBtn.Click += (s, e) =>
{
var btn = s as Button;
if (btn != null)
{
btn.Content = "Restarting engine...";
btn.IsEnabled = false;
}
ResetSettingsRequested?.Invoke();
};
section.Children.Add(resetSettingsBtn);

_panel.Children.Add(section);
}

Expand Down
Loading
Loading