예제 #1
0
        private void lstEffects_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            pnlControl.Child = null;

            if (lstEffects.SelectedIndex < 0)
            {
                return;
            }

            IEffect effect = (lstEffects.SelectedItem as EffectListBoxItem).Tag as IEffect;

            //Create the control element
            if (effect.HasUI)
            {
                effect.ReinitializeUI();
                effect.EffectController.Width  = Double.NaN;
                effect.EffectController.Height = Double.NaN;
                effect.EffectController.HorizontalAlignment = HorizontalAlignment.Stretch;
                effect.EffectController.VerticalAlignment   = VerticalAlignment.Stretch;
                effect.EffectController.ValueChanged       += (s, args) =>
                {
                    imgDest.Source = effect.DoEffect((imgSource.Source as BitmapSource), null);
                };
                pnlControl.Child = effect.EffectController;
            }

            //The first time effect on image
            imgDest.Source = effect.DoEffect((imgSource.Source as BitmapSource), null);
        }
예제 #2
0
        private void btnUse_Click(object sender, RoutedEventArgs e)
        {
            DoDoEffect();

            imgSource.Source = imgDest.Source;
            IEffect effect = (lstEffects.SelectedItem as EffectListBoxItem).Tag as IEffect;

            imgDest.Source = effect.DoEffect((imgSource.Source as BitmapSource), null);
        }
예제 #3
0
        public static void Init()
        {
            currentEffect.SetPosition(0, 0);

            app         = new RenderWindow(new VideoMode((uint)WINDOW_WIDTH, (uint)WINDOW_HEIGHT), "Demo Effects");
            app.Closed += new EventHandler(OnClose);

            int currentEffectIndex = 0;

            while (app.IsOpen)
            {
                app.DispatchEvents();
                app.Clear(Color.Red);


                switch (currentEffectIndex)
                {
                case 0:
                    currentEffect = new LineEffect(false, WINDOW_WIDTH, WINDOW_HEIGHT);
                    break;

                case 1:
                    currentEffect = new CircleEffect(WINDOW_WIDTH, WINDOW_HEIGHT);
                    break;

                case 2:
                    currentEffect = new PlasmaEffect(WINDOW_WIDTH, WINDOW_HEIGHT);
                    break;

                case 3:
                    currentEffect = new ChessEffect(WINDOW_WIDTH, WINDOW_HEIGHT);
                    break;

                case 4:
                    currentEffect = new LineEffect(true, WINDOW_WIDTH, WINDOW_HEIGHT);
                    break;
                }

                int someVal = random.Next(0, 100);
                if (someVal == 73)
                {
                    currentEffectIndex++;
                }
                if (currentEffectIndex >= 5)
                {
                    currentEffectIndex = 0;
                }


                currentEffect.DoEffect();
                app.Draw(currentEffect.GetCurrentFrame());

                // Update the window
                app.Display();
            }
        }
        private void lstEffect_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstEffect.SelectedIndex < 0)
            {
                lblEffectDescription.Text = "";
                imgEffectPreview.Source   = original;
                return;
            }

            IEffect eff = (lstEffect.SelectedItem as ListBoxItem).Tag as IEffect;

            lblEffectDescription.Text = eff.Description;
            imgEffectPreview.Source   = eff.DoEffect(original as BitmapSource, 0);
        }