Ejemplo n.º 1
0
        public bool OperateThread(Control parentControl)
        {
            WaitForForm form = new WaitForForm(ctrl => {
                ctrl.OperationTitle = _operation.GetDescription();
                ctrl.FormTitle      = _operation.GetTitle();
                this.Operate(parentControl);
                ctrl.DialogResult = DialogResult.OK;
            }, () => this.GetProgress());

            return(form.ShowDialog() == DialogResult.OK);
        }
        private void DialogMotionOperation_Load(object sender, EventArgs e)
        {
            if (_console == null)
            {
                return;
            }
            if (_operation == null)
            {
                return;
            }
            // ダイアログのタイトルを適当に設定
            this.Text = _operation.GetTitle();
            // ビューの設定
            motionDataViewer.AttachDataSet(_console.MotionDataSet);
            motionDataViewer.AttachTimeController(TimeController.Singleton);
            // 引数の値が変わったらプレビューしなおすよう設定する
            foreach (ProcParam <MotionProcEnv> param in _exec.Parameters)
            {
                param.ValueChanged += new EventHandler(param_ValueChanged);
            }
            // 引数のパネルを作って表示
            Panel panel = _exec.GetPanel();

            panel.AutoScroll = true;
            panel.Dock       = DockStyle.Fill;
            groupBoxSettings.Controls.Add(panel);

            // 選択されているオブジェクトが不適切だったらダイアログを閉じる
            string errorStr = "";

            if (!_operation.ValidateSelection(_targetInfoList, ref errorStr))
            {
                MessageBox.Show("Error: " + (errorStr ?? "something wrong"));
                this.Close();
                return;
            }
            // 説明書きを処理オブジェクトからもらって表示
            textBoxDescription.Text = _operation.GetDescription();

            // 選択されているオブジェクトを表示
            listBoxTarget.Items.Clear();
            foreach (MotionObjectInfo info in _targetInfoList)
            {
                listBoxTarget.Items.Add(string.Format("{0} ({1})", info.Name, info.ObjectType.Name));
            }
            // プレビューを更新
            this.SetPreview();
            // 引数がない場合にダイアログを表示しないオプションが付いていたら勝手に実行する
            if (checkIgnoreForm.Checked && _exec.Parameters.Count == 0)
            {
                this.Invoke(new EventHandler(buttonOK_Click), sender, e);
            }
        }