C# How I can open a windowsForm inside a c# plugin


#1

Hello
I develop a plugin in c# and I need a lot of input datas.
I save the datas in a Text File a this moment.
I want open a WindowsForm inside the plugin.
I create the window but hwo to open and closed.

// open the window…
Unroll.StartWindow…???

namespace Unroll
{
    public partial class StartWindow : Form
    {
        public StartWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
        // Exit....????
        }
    }
}

(Dale Fugier) #2

https://github.com/dalefugier/SampleCsModalForm


#3

Thanks I think without the samle I never get a window.
now it works.

namespace Unroll
{
    public partial class StartWindow : Form
    {
        public StartWindow()
        {
            InitializeComponent();
            {
                this.OkBtn = new System.Windows.Forms.Button();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Unroll.StartWindow.ActiveForm.Close();
        }
    }


protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // TODO: start here modifying the behaviour of your command.
            // ---

            // open  window

            Result result = Result.Cancel;

            if (mode == RunMode.Interactive)
            {
                Unroll.StartWindow form = new Unroll.StartWindow();
                DialogResult dialogResult = form.ShowDialog(RhinoApp.MainWindow()); 
                if (dialogResult == DialogResult.OK)
                    result = Result.Success;
            }
            else
            {
                string msg = string.Format("Scriptable version of {0} command not implemented.", EnglishName);
                RhinoApp.WriteLine(msg);

            }
            // window is closed