public ICommand CreateCommand()
        {
            ICommand ret = null;
            List<AssetDesc> assetList = app.Assets.Select("SpeedWind");
            string title;
            // bool add = false;
            String regSet;

            fileName = app.Config.ForestSpeedWindFileDefault;
            // add = true;
            title = "Add A Forest";
            regSet = (string)Registry.GetValue(app.Config.WorldEditorBaseRegistryKey, "DontShowSpeedTreeLicenseDialog", "False");
            if (String.Equals(regSet, "False"))
            {
                using (SpeedTreeLicenseDialog dlg = new SpeedTreeLicenseDialog())
                {
                    if (dlg.ShowDialog() == DialogResult.Cancel)
                    {
                        return null;
                    }
                    if (dlg.DoNotShowAgain)
                    {
                        Registry.SetValue(app.Config.WorldEditorBaseRegistryKey, "DontShowSpeedTreeLicenseDialog", true);
                    }
                }
            }
            using (ForestDialog dlg = new ForestDialog(assetList, fileName, title))
            {

                dlg.Seed = app.Config.ForestSeedDefault;
                dlg.WindDirection = app.Config.ForestWindDirectionDefault;
                dlg.WindSpeed = app.Config.ForestWindSpeedDefault;

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    bool showAgain = false;
                    DialogResult result = DialogResult.OK;
                    do
                    {
                        if (showAgain)
                        {
                            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)
                    {
                        windFilename = app.Assets.assetFromName(dlg.SpeedWindFile).AssetName;

                        ret = new AddForestCommand(app, bound, dlg.Seed, dlg.WindSpeed, dlg.WindDirection, windFilename);
                    }
                }
                return ret;
            }
        }
Beispiel #2
0
        public ICommand CreateCommand()
        {
            ICommand         ret       = null;
            List <AssetDesc> assetList = app.Assets.Select("SpeedWind");
            string           title;
            // bool add = false;
            String regSet;

            fileName = app.Config.ForestSpeedWindFileDefault;
            // add = true;
            title  = "Add A Forest";
            regSet = (string)Registry.GetValue(app.Config.WorldEditorBaseRegistryKey, "DontShowSpeedTreeLicenseDialog", "False");
            if (String.Equals(regSet, "False"))
            {
                using (SpeedTreeLicenseDialog dlg = new SpeedTreeLicenseDialog())
                {
                    if (dlg.ShowDialog() == DialogResult.Cancel)
                    {
                        return(null);
                    }
                    if (dlg.DoNotShowAgain)
                    {
                        Registry.SetValue(app.Config.WorldEditorBaseRegistryKey, "DontShowSpeedTreeLicenseDialog", true);
                    }
                }
            }
            using (ForestDialog dlg = new ForestDialog(assetList, fileName, title))
            {
                dlg.Seed          = app.Config.ForestSeedDefault;
                dlg.WindDirection = app.Config.ForestWindDirectionDefault;
                dlg.WindSpeed     = app.Config.ForestWindSpeedDefault;


                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    bool         showAgain = false;
                    DialogResult result    = DialogResult.OK;
                    do
                    {
                        if (showAgain)
                        {
                            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)
                    {
                        windFilename = app.Assets.assetFromName(dlg.SpeedWindFile).AssetName;

                        ret = new AddForestCommand(app, bound, dlg.Seed, dlg.WindSpeed, dlg.WindDirection, windFilename);
                    }
                }
                return(ret);
            }
        }