示例#1
0
        private void OnSolutionEnd(object sender, GH_SolutionEventArgs e)
        {
            // Unregister the event, we don't want to get called again.
            e.Document.SolutionEnd -= OnSolutionEnd;

            // If we're not supposed to run, abort now.
            if (!_run || _running)
            {
                return;
            }

            // Reset run and running states.
            _run     = false;
            _running = true;

            try
            {
                if (_isTestFly)
                {
                    _isTestFly = false;
                    _flyParam.FlyTest(e, 3);
                }
                else
                {
                    _flyParam.Fly(e);
                }

                if (_aggObj != null)
                {
                    _aggObj.setWriteFileToFalse();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                // Always make sure that _running is switched off.
                _running       = false;
                this._flyParam = null;
            }
        }
示例#2
0
        // response to Button event
        private void OnMouseDownEvent(object sender)
        {
            if (this._doc == null)
            {
                this._doc = GH.Instances.ActiveCanvas.Document;
            }

            if (this.RuntimeMessageLevel == GH_RuntimeMessageLevel.Error)
            {
                return;
            }

            //Clean first
            this._flyParam = null;

            //recollect all params
            this._filteredSources = gatherSources();

            this._filteredSources.RemoveAll(item => item == null);
            this._filteredSources.RemoveAll(item => item.GHType == InputType.Unsupported);
            //string Para

            //checked if Aggregator is recording and the last
            if (!isAggregatorReady())
            {
                return;
            }

            //check if any vaild input source connected to Iteratior
            if (this._filteredSources.Count() > 0)
            {
                this._flyParam = new IteratorFlyParam(_filteredSources, this._selections, this._studyFolder, this._mode);
            }
            else
            {
                MessageBox.Show("No Slider, ValueList, or Panel connected!");
                return;
            }


            long testIterationNumber = this._selectedCount;

            //int totalIterationNumber = _totalCount;

            if (this._isTestFly)
            {
                testIterationNumber = 3;
            }
            string msgString = _flyParam.InputParams.Count() + " input(s) connected." +
                               "\n" + testIterationNumber + " (out of " + _totalCount + ") iterations will be done. \n\nContinue?" +
                               "\n\n-------------------------------------------------------- " +
                               "\nTo pause during progressing?\n    1.Press ESC.";

            if (!String.IsNullOrWhiteSpace(this._studyFolder))
            {
                msgString += "\n    2.Or remove \"running\" file located in foler:\n\t" + this._studyFolder;
            }

            var userClick = MessageBox.Show(msgString, "Start?", MessageBoxButtons.YesNo);

            if (userClick == DialogResult.Yes)
            {
                _run              = true;
                _doc.SolutionEnd += OnSolutionEnd;

                // only recompute those are expired flagged
                _doc.NewSolution(false);
            }
            else
            {
                _run       = false;
                _isTestFly = false;
                _flyParam  = null;
            }
        }