feat: add recall as internal function to overlay dialog.
This commit is contained in:
@@ -48,5 +48,8 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||||
|
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||||
|
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||||
|
<u:NumericIntUpDown u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></u:NumericIntUpDown>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -212,5 +212,11 @@ public static class OverlayDialog
|
|||||||
control.CanDragMove = options.CanDragMove;
|
control.CanDragMove = options.CanDragMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static T? Recall<T>(string? hostId) where T: Control
|
||||||
|
{
|
||||||
|
var host = OverlayDialogManager.GetHost(hostId);
|
||||||
|
if (host is null) return null;
|
||||||
|
var item = host.Recall<T>();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,13 @@ public class NumPad: TemplatedControl
|
|||||||
|
|
||||||
private static void OnTargetGotFocus(object sender, GotFocusEventArgs e)
|
private static void OnTargetGotFocus(object sender, GotFocusEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (sender is not InputElement) return;
|
||||||
|
var existing = OverlayDialog.Recall<NumPad>(null);
|
||||||
|
if (existing is not null)
|
||||||
|
{
|
||||||
|
existing.Target = sender as InputElement;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var numPad = new NumPad() { Target = sender as InputElement };
|
var numPad = new NumPad() { Target = sender as InputElement };
|
||||||
OverlayDialog.ShowCustom(numPad, new object());
|
OverlayDialog.ShowCustom(numPad, new object());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,6 +216,11 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnTextInput(TextInputEventArgs e)
|
||||||
|
{
|
||||||
|
_textBox?.RaiseEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDragPanelPointerReleased(object sender, PointerReleasedEventArgs e)
|
private void OnDragPanelPointerReleased(object sender, PointerReleasedEventArgs e)
|
||||||
{
|
{
|
||||||
_point = null;
|
_point = null;
|
||||||
|
|||||||
@@ -189,4 +189,10 @@ public partial class OverlayDialogHost: Canvas
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal T? Recall<T>()
|
||||||
|
{
|
||||||
|
var element = _layers.LastOrDefault(a => a.Element.Content?.GetType() == typeof(T));
|
||||||
|
return element?.Element.Content is T t ? t : default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user