using System.Windows;
using System.Windows.Controls;

namespace Nodify.Calculator
{
    public partial class AddVariableDialog : Window
    {
        public string VariableName { get; private set; } = string.Empty;
        public string VariableType { get; private set; } = "string";
        public string DefaultValue { get; private set; } = string.Empty;

        public AddVariableDialog()
        {
            InitializeComponent();
        }

        private void OnAddClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(VariableNameBox.Text))
            {
                MessageBox.Show("Please enter a variable name.", "Validation", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            VariableName = VariableNameBox.Text.Trim();
            VariableType = ((ComboBoxItem)VariableTypeBox.SelectedItem).Content.ToString()!;
            DefaultValue = DefaultValueBox.Text.Trim();
            DialogResult = true;
        }

        private void OnCancelClick(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
