From e2ab9ef6d68ee52908c9c1002524a5783af5ca78 Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 12 Feb 2025 11:26:32 +0100 Subject: [PATCH] Antes de comenzar con CopilotEdit --- InputDialog.cs | 100 +++++++++++++++++++++++ MainWindow.xaml | 101 ++++++++++++++--------- MainWindow.xaml.cs | 199 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 351 insertions(+), 49 deletions(-) create mode 100644 InputDialog.cs diff --git a/InputDialog.cs b/InputDialog.cs new file mode 100644 index 0000000..7be725f --- /dev/null +++ b/InputDialog.cs @@ -0,0 +1,100 @@ +using System.Windows; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls +{ + public class InputDialogResult + { + public bool IsOk { get; set; } + public string Result { get; set; } + } + + public class InputDialog + { + public static InputDialogResult Show(string title, string promptText, string defaultValue = "") + { + var dialog = new Window + { + Title = title, + Width = 400, + Height = 150, + WindowStartupLocation = WindowStartupLocation.CenterOwner, + Owner = Application.Current.MainWindow, + ResizeMode = ResizeMode.NoResize + }; + + var grid = new Grid { Margin = new Thickness(10) }; + grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); + grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) }); + grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); + + var promptLabel = new TextBlock + { + Text = promptText, + Margin = new Thickness(0, 0, 0, 5) + }; + Grid.SetRow(promptLabel, 0); + + var inputBox = new TextBox + { + Text = defaultValue, + Margin = new Thickness(0) + }; + Grid.SetRow(inputBox, 2); + + var buttonPanel = new StackPanel + { + Orientation = Orientation.Horizontal, + HorizontalAlignment = HorizontalAlignment.Right, + Margin = new Thickness(0, 10, 0, 0) + }; + Grid.SetRow(buttonPanel, 4); + + var okButton = new Button + { + Content = "Aceptar", + Width = 75, + Height = 23, + Margin = new Thickness(0, 0, 10, 0), + IsDefault = true + }; + + var cancelButton = new Button + { + Content = "Cancelar", + Width = 75, + Height = 23, + IsCancel = true + }; + + buttonPanel.Children.Add(okButton); + buttonPanel.Children.Add(cancelButton); + + grid.Children.Add(promptLabel); + grid.Children.Add(inputBox); + grid.Children.Add(buttonPanel); + + dialog.Content = grid; + + var result = new InputDialogResult(); + + okButton.Click += (s, e) => + { + result.Result = inputBox.Text; + result.IsOk = true; + dialog.Close(); + }; + + cancelButton.Click += (s, e) => + { + result.IsOk = false; + dialog.Close(); + }; + + inputBox.Focus(); + dialog.ShowDialog(); + + return result; + } + } +} \ No newline at end of file diff --git a/MainWindow.xaml b/MainWindow.xaml index bcf5899..c16bc83 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -3,30 +3,14 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodels="clr-namespace:DirectoryCreator.ViewModels" mc:Ignorable="d" Title="Crear Directorios Base" - Height="300" Width="500" WindowStartupLocation="CenterScreen"> + Height="450" Width="700" WindowStartupLocation="CenterScreen" MinWidth="600" MinHeight="400"> - - - - - - - - - - - - - - - - - - + + @@ -35,33 +19,72 @@ + + - - - -