using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ChamChat
{
    public static class PromptProgramNo
    {
        public static int Value = 0;
        private static bool valueSet;



        public static bool ShowDialog(int Minimum,  int Maximum)
        {
            Form prompt = new Form();
            prompt.Width = 235;
            prompt.Height = 130;
            prompt.Text = "Import program form client";
            //prompt.TopMost = true;
            prompt.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            prompt.ControlBox = false;
            prompt.StartPosition = FormStartPosition.CenterParent;
            Label textLabel = new Label() { Left = 16, Top = 16, Text = "Select the program to import!" };
            textLabel.AutoSize = true;
            
            NumericUpDown inputBox = new NumericUpDown() { Left = 163, Top = 14, Width = 43, Height = 20 };
            inputBox.Minimum = Minimum;
            inputBox.Maximum = Maximum;
            inputBox.Value = Minimum;
            Value = Minimum;
            inputBox.ValueChanged += (sender, e) => { Value = (int)inputBox.Value; };

            Button confirmation = new Button() { Text = "OK", Left = 131, Top = 54, Width = 75, Height = 23 };
            confirmation.Click += (sender, e) => { valueSet = true; prompt.Close(); };

            Button cancel = new Button() { Text = "Cancel", Left = 19, Top = 54, Width = 75, Height = 23 };
            cancel.Click += (sender, e) => { valueSet= false; prompt.Close(); };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(inputBox);
            prompt.ShowDialog();
            return valueSet;
        }
    }
}
