コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int                type       = this.cbEffect.SelectedIndex;
            Effect             effect     = null;
            EffectConfigDialog dialog     = null;
            PropertyCollection collection = null;

            effect = (Effect)available[type].GetConstructor(Type.EmptyTypes).Invoke(new object[0]);

            if ((effect.Options.Flags & EffectFlags.Configurable) != 0)
            {
                dialog        = effect.CreateConfigDialog();
                dialog.Effect = effect;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (dialog.EffectToken is PropertyBasedEffectConfigToken)
                    {
                        collection = ((PropertyBasedEffectConfigToken)dialog.EffectToken).Properties;
                    }
                }
                else
                {
                    return;
                }
            }

            this.lbEffect.Items.Add(this.cbEffect.Text);
            this.types.Add(type);
            this.effects.Add(effect);
            this.dialogs.Add(dialog);
            this.collections.Add(collection);
            FinishTokenUpdate();
        }
コード例 #2
0
        private void ChangeSelectedEffect()
        {
            if (lbScript.SelectedItem != null)
            {
                ConfigToken token = (ConfigToken)theEffectToken;
                int         i     = lbScript.SelectedIndex;
                ScriptStep  step  = token.effects[i];
                Type        type  = step.EffectType;
                if (type != null)
                {
                    Effect effect = (Effect)type.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
                    effect.EnvironmentParameters = Effect.EnvironmentParameters;
                    effect.Services = Services;
                    if (effect.CheckForEffectFlags(EffectFlags.Configurable))
                    {
                        try
                        {
                            EffectConfigDialog dialog = effect.CreateConfigDialog();
                            dialog.EffectSourceSurface = EffectSourceSurface;
                            dialog.Selection           = Selection;
                            dialog.Effect      = effect;
                            dialog.EffectToken = (EffectConfigToken)step.Token.Clone();
                            if (effect.Image != null)
                            {
                                dialog.Icon = Icon.FromHandle(((Bitmap)effect.Image).GetHicon());
                            }

                            if (dialog.ShowDialog(this) == DialogResult.OK)
                            {
                                step.Token = dialog.EffectToken;
                                FinishTokenUpdate();
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(this,
                                            "Error occurred in configuration dialog for " + effect.Name + ":\n\n" + e.ToString(),
                                            effect.Name + " Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, step.Name + " is not installed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
        void AddSelectedEffect()
        {
            if (lbAvailable.SelectedItem != null)
            {
                ConfigToken token = (ConfigToken)theEffectToken;
                string      effectidentifiername = SearchResultEffects[lbAvailable.SelectedIndex];
                Type        t      = AvailableEffects[effectidentifiername];
                Effect      effect = (Effect)t.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
                effect.EnvironmentParameters = Effect.EnvironmentParameters;
                effect.Services = Services;
                if (effect.CheckForEffectFlags(EffectFlags.Configurable))
                {
                    try
                    {
                        EffectConfigDialog dialog = effect.CreateConfigDialog();
                        dialog.EffectSourceSurface = EffectSourceSurface;
                        dialog.Selection           = Selection;
                        dialog.Effect = effect;
                        if (effect.Image != null)
                        {
                            dialog.Icon = effect.Image.ToIcon();
                        }

                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            token.effects.Add(new ScriptStep(effect.Name, effect.Image, t, dialog.EffectToken, Effect.EnvironmentParameters.PrimaryColor, Effect.EnvironmentParameters.SecondaryColor));
                            lbScript.Items.Add(effect.Name);
                            FinishTokenUpdate();
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(this,
                                        "Error occurred in configuration dialog for " + effect.Name + ":\n\n" + e.ToString(),
                                        effect.Name + " Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    token.effects.Add(new ScriptStep(effect.Name, effect.Image, t, null, Effect.EnvironmentParameters.PrimaryColor, Effect.EnvironmentParameters.SecondaryColor));
                    lbScript.Items.Add(effect.Name);
                    FinishTokenUpdate();
                }
            }
        }