Exemplo n.º 1
0
        public ICommand CreateCommand()
        {
            ICommand         ret       = null;
            List <AssetDesc> assetList = app.Assets.Select("SpeedTree");
            string           treeName;
            string           title;

            // bool add = false;

            // add = true;
            title = "Add A Tree";

            using (TreeDialog dlg = new TreeDialog(assetList, "", title))
            {
                dlg.scale         = app.Config.TreeScaleDefault;
                dlg.scaleVariance = app.Config.TreeScaleVarianceDefault;
                bool         showAgain = false;
                DialogResult result;
                do
                {
                    result    = dlg.ShowDialog();
                    showAgain = false;
                    if (result == DialogResult.OK)
                    {
                        // do validation here
                        // if validation fails, set showAgain to true
                        showAgain = ((result == DialogResult.OK) && (!dlg.okButton_validating()));
                    }
                } while (showAgain);
                if (result == DialogResult.OK)
                {
                    treeName      = dlg.TreeFileNameComboBox.SelectedItem.ToString();
                    scale         = dlg.scale;
                    scaleVariance = dlg.scaleVariance;
                    instances     = dlg.instances;
                    ret           = new AddTreeCommand(app, parent, dlg.scale, dlg.scaleVariance, app.Assets.assetFromName(treeName).AssetName, treeName, dlg.instances);
                }
            }
            return(ret);
        }
        public ICommand CreateCommand()
        {
            ICommand ret = null;
            List<AssetDesc> assetList = app.Assets.Select("SpeedTree");
            string treeName;
            string title;
            // bool add = false;

            // add = true;
            title = "Add A Tree";

            using (TreeDialog dlg = new TreeDialog(assetList, "", title))
            {
                dlg.scale = app.Config.TreeScaleDefault;
                dlg.scaleVariance = app.Config.TreeScaleVarianceDefault;
                bool showAgain = false;
                DialogResult result;
                do
                {
                    result = dlg.ShowDialog();
                    showAgain = false;
                    if (result == DialogResult.OK)
                    {
                        // do validation here
                        // if validation fails, set showAgain to true
                        showAgain = ((result == DialogResult.OK) && (!dlg.okButton_validating()));
                    }

                } while (showAgain);
                if (result == DialogResult.OK)
                {
                    treeName = dlg.TreeFileNameComboBox.SelectedItem.ToString();
                    scale = dlg.scale;
                    scaleVariance = dlg.scaleVariance;
                    instances = dlg.instances;
                    ret = new AddTreeCommand(app, parent, dlg.scale, dlg.scaleVariance, app.Assets.assetFromName(treeName).AssetName, treeName, dlg.instances);
                }
            }
            return ret;
        }