private ICanvasImage CreateDirectionalBlur(CanvasBitmap source)
        {
            var blurEffect = new DirectionalBlurEffect
            {
                Source = source
            };

            return(blurEffect);
        }
        private static ICanvasImage CreateDirectionalBlureEffect(ICanvasImage canvasImage)
        {
            var ef = new DirectionalBlurEffect
            {
                Source     = canvasImage,
                Angle      = 31.7106724f,
                BlurAmount = 24.8950157f
            };

            return(ef);
        }
Esempio n. 3
0
        private ICanvasImage CreateDirectionalBlur()
        {
            var blurEffect = new DirectionalBlurEffect
            {
                Source = bitmapTiger
            };

            // Animation changes the blur direction and amount.
            animationFunction = elapsedTime =>
            {
                blurEffect.Angle      = elapsedTime;
                blurEffect.BlurAmount = ((float)Math.Sin(elapsedTime * 2) + 1) * 16;
            };

            return(blurEffect);
        }
Esempio n. 4
0
        /// <summary>
        /// Generates the specified parent class.
        /// </summary>
        /// <param name="parentClass">The parent class.</param>
        /// <param name="method">The method.</param>
        /// <param name="value">The value.</param>
        /// <param name="baseName">Name of the base.</param>
        /// <param name="dictionary">The dictionary.</param>
        /// <returns></returns>
        public CodeExpression Generate(CodeTypeDeclaration parentClass, CodeMemberMethod method, object value, string baseName, ResourceDictionary dictionary = null)
        {
            CodeExpression valueExpression = null;

            if (value != null)
            {
                string variableName = baseName + "_dbef";
                var    variable     = new CodeVariableDeclarationStatement("DirectionalBlurEffect", variableName, new CodeObjectCreateExpression("DirectionalBlurEffect"));
                method.Statements.Add(variable);
                valueExpression = new CodeVariableReferenceExpression(variableName);

                DirectionalBlurEffect effect = value as DirectionalBlurEffect;
                CodeComHelper.GenerateField <float>(method, valueExpression, effect, DirectionalBlurEffect.AngleProperty);
                CodeComHelper.GenerateField <float>(method, valueExpression, effect, DirectionalBlurEffect.BlurAmountProperty);
            }

            return(valueExpression);
        }
Esempio n. 5
0
        private ICanvasImage CreateDirectionalBlur()
        {
            var blurEffect = new DirectionalBlurEffect
            {
                Source = bitmapTiger
            };

            // Animation changes the blur direction and amount.
            animationFunction = elapsedTime =>
            {
                blurEffect.Angle = elapsedTime;
                blurEffect.BlurAmount = ((float)Math.Sin(elapsedTime * 2) + 1) * 16;
            };

            return blurEffect;
        }
Esempio n. 6
0
        /// <summary>
        /// Bring the currently selected item into view.
        /// </summary>
        private void BringCurrentItemIntoView()
        {
            ListBoxItem selectedListBoxItem;
            int         numberOfItemsDelta = 0;
            int         scrollDirection    = -1;    // -1 for moving to the left and 1 for right
            double      maxBlurAmount      = 0.003; // the default DirectionalBlurEffect max amount
            double      minBlurAmount      = 0.001; // the default DirectionalBlurEffect min amount

            if (!this.IsLoaded)
            {
                return;
            }

            selectedListBoxItem = (ListBoxItem)this.ItemContainerGenerator.ContainerFromItem(this.SelectedItem);
            if (selectedListBoxItem != null)
            {
                selectedListBoxItem.BringIntoView();
            }

            if (this.SelectedIndex >= 0)
            {
                if (this.previousSelectedIndex > 0)
                {
                    numberOfItemsDelta = Math.Abs(this.SelectedIndex - this.previousSelectedIndex);
                }
                else
                {
                    // there was no previous selection
                    numberOfItemsDelta = this.SelectedIndex;
                }

                // determine if the new selected item is to the left or right of the
                // previous item
                if (this.SelectedIndex > this.previousSelectedIndex)
                {
                    scrollDirection = -1;
                }
                else
                {
                    scrollDirection = 1;
                }

                this.previousSelectedIndex = this.SelectedIndex;
            }

            // Blur the entire control as it scrolls the item into view if the new item is at least 2 items away.
            if (this.IsEffectsEnabled &&
                this.filmStripBlurEffectArea != null &&
                FacebookClientApplication.IsShaderEffectSupported)
            {
                if (!(this.filmStripBlurEffect is DirectionalBlurEffect))
                {
                    this.filmStripBlurEffect       = new DirectionalBlurEffect();
                    this.filmStripBlurEffect.Angle = 0; // horizontal blur
                }

                if (!(this.filmStripBlurEffectArea.Effect is DirectionalBlurEffect))
                {
                    this.filmStripBlurEffectArea.Effect = this.filmStripBlurEffect;
                }

                if (numberOfItemsDelta > 2)
                {
                    // The amount of blur is relative to the number of items being scrolled within the film strip
                    // clampt between minBlurAmount and maxBlurAmount. The blur direction must also match direction of the
                    // FilmStripPanel.SetHorizontalOffset's horizontal animation to prevent jittering
                    double amount = maxBlurAmount * ((numberOfItemsDelta <= 0.0 ? 1.0 : numberOfItemsDelta) / (this.Items != null && this.Items.Count > 0.0 ? this.Items.Count - 1 : 1.0));
                    amount = Math.Max(minBlurAmount, amount);
                    this.filmStripMultiItemBlurEffectAnimation.From              = amount * scrollDirection;
                    this.filmStripMultiItemBlurEffectAnimation.To                = 0;
                    this.filmStripMultiItemBlurEffectAnimation.Duration          = FilmStripControl.standardSlideFilmStripDuration + new Duration(new TimeSpan(Math.Min(MaxNumberOfItemsDelta, numberOfItemsDelta) * perItemSlideFilmStripTime));
                    this.filmStripMultiItemBlurEffectAnimation.AccelerationRatio = 0.4;
                    this.filmStripMultiItemBlurEffectAnimation.DecelerationRatio = 0.2;
                    this.filmStripBlurEffectArea.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripMultiItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
                else if (numberOfItemsDelta == 1)
                {
                    if (this.filmStripOneItemBlurEffectAnimation.From == null)
                    {
                        this.filmStripOneItemBlurEffectAnimation.From = 0;
                    }

                    // The amount of blur should slowly accumulate when moving between many items sequentially
                    // such as holding down the arrow key. The HandoffBehavior.SnapshotAndReplace behavior will ensure
                    // a smooth transition to the next animation.
                    double amount = Math.Abs(this.filmStripOneItemBlurEffectAnimation.From.Value) + (maxBlurAmount * 0.01); // accumulate blur in small increments
                    amount = Math.Min(maxBlurAmount, amount);
                    this.filmStripOneItemBlurEffectAnimation.From             += amount * scrollDirection;
                    this.filmStripOneItemBlurEffectAnimation.To                = 0;
                    this.filmStripOneItemBlurEffectAnimation.Duration          = FilmStripControl.standardSlideFilmStripDuration + new Duration(new TimeSpan(Math.Min(MaxNumberOfItemsDelta, numberOfItemsDelta) * perItemSlideFilmStripTime));
                    this.filmStripOneItemBlurEffectAnimation.AccelerationRatio = 0.4;
                    this.filmStripOneItemBlurEffectAnimation.DecelerationRatio = 0.2;
                    this.filmStripOneItemBlurEffectAnimation.Completed        += new EventHandler(this.FilmStripOneItemBlurEffectAnimationCompleted);
                    this.filmStripBlurEffectArea.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripOneItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
            }
        }
Esempio n. 7
0
 private void InitializeComponent()
 {
     Binding binding__OwnedWindowsContent = new Binding("Windows");
     this.SetBinding(UIRoot.OwnedWindowsContentProperty, binding__OwnedWindowsContent);
     this.SetResourceReference(SoundManager.SoundsProperty, "Sounds");
     InitializeElementResources(this);
     // e_0 element
     this.e_0 = new Grid();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     RowDefinition row_e_0_0 = new RowDefinition();
     row_e_0_0.Height = new GridLength(110F, GridUnitType.Pixel);
     this.e_0.RowDefinitions.Add(row_e_0_0);
     RowDefinition row_e_0_1 = new RowDefinition();
     this.e_0.RowDefinitions.Add(row_e_0_1);
     ColumnDefinition col_e_0_0 = new ColumnDefinition();
     this.e_0.ColumnDefinitions.Add(col_e_0_0);
     // e_1 element
     this.e_1 = new StackPanel();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Background = new SolidColorBrush(new ColorW(0, 0, 0, 255));
     // logo element
     this.logo = new Image();
     this.e_1.Children.Add(this.logo);
     this.logo.Name = "logo";
     this.logo.HorizontalAlignment = HorizontalAlignment.Center;
     DirectionalBlurEffect logo_dbef = new DirectionalBlurEffect();
     logo_dbef.Angle = 0F;
     logo_dbef.BlurAmount = 0.002F;
     this.logo.Effect = logo_dbef;
     BitmapImage logo_bm = new BitmapImage();
     logo_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall";
     this.logo.Source = logo_bm;
     this.logo.Stretch = Stretch.None;
     // e_2 element
     this.e_2 = new TextBlock();
     this.e_1.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_2.VerticalAlignment = VerticalAlignment.Center;
     this.e_2.Foreground = new SolidColorBrush(new ColorW(211, 211, 211, 255));
     this.e_2.TextWrapping = TextWrapping.Wrap;
     this.e_2.FontFamily = new FontFamily("Segoe UI");
     this.e_2.FontSize = 20F;
     this.e_2.FontStyle = FontStyle.Bold;
     this.e_2.SetResourceReference(TextBlock.TextProperty, "TitleResource");
     // TabControl element
     this.TabControl = new TabControl();
     this.e_0.Children.Add(this.TabControl);
     this.TabControl.Name = "TabControl";
     this.TabControl.Margin = new Thickness(10F, 10F, 10F, 10F);
     this.TabControl.ItemsSource = Get_TabControl_Items();
     Grid.SetRow(this.TabControl, 1);
     ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall");
     ImageManager.Instance.AddImage("Images/MonoGameLogo");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
 }
Esempio n. 8
0
 private void InitializeComponent()
 {
     this.FontSize = 13.33333F;
     this.SetResourceReference(SoundManager.SoundsProperty, "Sounds");
     InitializeElementResources(this);
     // e_0 element
     this.e_0 = new Grid();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     RowDefinition row_e_0_0 = new RowDefinition();
     row_e_0_0.Height = new GridLength(110F, GridUnitType.Pixel);
     this.e_0.RowDefinitions.Add(row_e_0_0);
     RowDefinition row_e_0_1 = new RowDefinition();
     this.e_0.RowDefinitions.Add(row_e_0_1);
     ColumnDefinition col_e_0_0 = new ColumnDefinition();
     this.e_0.ColumnDefinitions.Add(col_e_0_0);
     ColumnDefinition col_e_0_1 = new ColumnDefinition();
     this.e_0.ColumnDefinitions.Add(col_e_0_1);
     // e_1 element
     this.e_1 = new StackPanel();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Background = new SolidColorBrush(new ColorW(0, 0, 0, 255));
     Grid.SetColumnSpan(this.e_1, 2);
     // logo element
     this.logo = new Image();
     this.e_1.Children.Add(this.logo);
     this.logo.Name = "logo";
     this.logo.HorizontalAlignment = HorizontalAlignment.Center;
     DirectionalBlurEffect logo_dbef = new DirectionalBlurEffect();
     logo_dbef.Angle = 0F;
     logo_dbef.BlurAmount = 0.002F;
     this.logo.Effect = logo_dbef;
     this.logo.Stretch = Stretch.None;
     this.logo.SetResourceReference(Image.SourceProperty, "logoEmptyKeys");
     // e_2 element
     this.e_2 = new TextBlock();
     this.e_1.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_2.VerticalAlignment = VerticalAlignment.Center;
     this.e_2.Foreground = new SolidColorBrush(new ColorW(211, 211, 211, 255));
     this.e_2.TextWrapping = TextWrapping.Wrap;
     this.e_2.FontFamily = new FontFamily("Segoe UI");
     this.e_2.FontSize = 20F;
     this.e_2.FontStyle = FontStyle.Bold;
     this.e_2.SetResourceReference(TextBlock.TextProperty, "TitleResource");
     // e_3 element
     this.e_3 = new StackPanel();
     this.e_0.Children.Add(this.e_3);
     this.e_3.Name = "e_3";
     Grid.SetRow(this.e_3, 1);
     // combo element
     this.combo = new ComboBox();
     this.e_3.Children.Add(this.combo);
     this.combo.Name = "combo";
     this.combo.Width = 200F;
     this.combo.Margin = new Thickness(5F, 5F, 5F, 5F);
     Func<UIElement, UIElement> combo_dtFunc = combo_dtMethod;
     this.combo.ItemTemplate = new DataTemplate(combo_dtFunc);
     Binding binding_combo_ItemsSource = new Binding("ComboBoxSource");
     this.combo.SetBinding(ComboBox.ItemsSourceProperty, binding_combo_ItemsSource);
     Binding binding_combo_SelectedIndex = new Binding("SelectedIndex");
     this.combo.SetBinding(ComboBox.SelectedIndexProperty, binding_combo_SelectedIndex);
     // button1 element
     this.button1 = new Button();
     this.e_3.Children.Add(this.button1);
     this.button1.Name = "button1";
     this.button1.Height = 30F;
     this.button1.Width = 200F;
     this.button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     ToolTip tt_button1 = new ToolTip();
     this.button1.ToolTip = tt_button1;
     tt_button1.Content = "Click Me!";
     this.button1.Content = "1";
     this.button1.CommandParameter = "Click Button 1";
     Binding binding_button1_Command = new Binding("ButtonCommand");
     this.button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     this.button2 = new Button();
     this.e_3.Children.Add(this.button2);
     this.button2.Name = "button2";
     this.button2.Height = 30F;
     this.button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.button2.Content = "2";
     this.button2.CommandParameter = "Click Button 2";
     Binding binding_button2_Command = new Binding("ButtonCommand");
     this.button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     this.button2.SetResourceReference(Button.StyleProperty, "buttonStyle");
     // button3 element
     this.button3 = new Button();
     this.e_3.Children.Add(this.button3);
     this.button3.Name = "button3";
     this.button3.Height = 30F;
     this.button3.Width = 200F;
     this.button3.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.button3.FontFamily = new FontFamily("Segoe UI");
     this.button3.FontSize = 20F;
     this.button3.FontStyle = FontStyle.Bold;
     this.button3.Content = "3";
     this.button3.CommandParameter = "Click Button 3";
     Binding binding_button3_Command = new Binding("OpenMessageBox");
     this.button3.SetBinding(Button.CommandProperty, binding_button3_Command);
     this.button3.SetResourceReference(Button.ToolTipProperty, "ToolTipText");
     // buttonResult element
     this.buttonResult = new TextBlock();
     this.e_3.Children.Add(this.buttonResult);
     this.buttonResult.Name = "buttonResult";
     this.buttonResult.HorizontalAlignment = HorizontalAlignment.Center;
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     this.buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
     // slider element
     this.slider = new Slider();
     this.e_3.Children.Add(this.slider);
     this.slider.Name = "slider";
     this.slider.Width = 200F;
     this.slider.Minimum = 5F;
     this.slider.Maximum = 20F;
     Binding binding_slider_Value = new Binding("SliderValue");
     this.slider.SetBinding(Slider.ValueProperty, binding_slider_Value);
     // textBox element
     this.textBox = new TextBox();
     this.e_3.Children.Add(this.textBox);
     this.textBox.Name = "textBox";
     this.textBox.Width = 200F;
     this.textBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     Binding binding_textBox_Text = new Binding("TextBoxText");
     this.textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text);
     // checkBox element
     this.checkBox = new CheckBox();
     this.e_3.Children.Add(this.checkBox);
     this.checkBox.Name = "checkBox";
     this.checkBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.checkBox.HorizontalAlignment = HorizontalAlignment.Center;
     this.checkBox.Content = "Check Box";
     // e_5 element
     this.e_5 = new StackPanel();
     this.e_3.Children.Add(this.e_5);
     this.e_5.Name = "e_5";
     this.e_5.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_5.Orientation = Orientation.Horizontal;
     // e_6 element
     this.e_6 = new RadioButton();
     this.e_5.Children.Add(this.e_6);
     this.e_6.Name = "e_6";
     this.e_6.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.e_6.Content = "Radio Button 1";
     this.e_6.GroupName = "testGroup1";
     // e_7 element
     this.e_7 = new RadioButton();
     this.e_5.Children.Add(this.e_7);
     this.e_7.Name = "e_7";
     this.e_7.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.e_7.Content = "Radio Button 2";
     this.e_7.GroupName = "testGroup1";
     // e_8 element
     this.e_8 = new RadioButton();
     this.e_5.Children.Add(this.e_8);
     this.e_8.Name = "e_8";
     this.e_8.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.e_8.Content = "Radio Button 3";
     this.e_8.GroupName = "testGroup1";
     // e_9 element
     this.e_9 = new TabControl();
     this.e_3.Children.Add(this.e_9);
     this.e_9.Name = "e_9";
     this.e_9.Height = 150F;
     this.e_9.Width = 400F;
     this.e_9.ItemsSource = Get_e_9_Items();
     // e_22 element
     this.e_22 = new ProgressBar();
     this.e_3.Children.Add(this.e_22);
     this.e_22.Name = "e_22";
     this.e_22.Height = 30F;
     this.e_22.Width = 400F;
     this.e_22.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.e_22.Value = 39F;
     // e_23 element
     this.e_23 = new StackPanel();
     this.e_0.Children.Add(this.e_23);
     this.e_23.Name = "e_23";
     Grid.SetColumn(this.e_23, 1);
     Grid.SetRow(this.e_23, 1);
     // animButton1 element
     this.animButton1 = new Button();
     this.e_23.Children.Add(this.animButton1);
     this.animButton1.Name = "animButton1";
     this.animButton1.Content = "Mouse Over me!";
     this.animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton2 element
     this.animButton2 = new Button();
     this.e_23.Children.Add(this.animButton2);
     this.animButton2.Name = "animButton2";
     this.animButton2.Content = "Mouse Over me!";
     this.animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton3 element
     this.animButton3 = new Button();
     this.e_23.Children.Add(this.animButton3);
     this.animButton3.Name = "animButton3";
     this.animButton3.Content = "Mouse Over me!";
     this.animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton4 element
     this.animButton4 = new Button();
     this.e_23.Children.Add(this.animButton4);
     this.animButton4.Name = "animButton4";
     this.animButton4.Content = "Mouse Over me!";
     this.animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // e_24 element
     this.e_24 = new Grid();
     this.e_23.Children.Add(this.e_24);
     this.e_24.Name = "e_24";
     // animBorder1 element
     this.animBorder1 = new Border();
     this.e_24.Children.Add(this.animBorder1);
     this.animBorder1.Name = "animBorder1";
     this.animBorder1.Height = 100F;
     this.animBorder1.Width = 200F;
     this.animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F);
     EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder1);
     animBorder1.Triggers.Add(animBorder1_ET_0);
     BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard();
     animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0";
     animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0);
     Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard();
     animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB;
     animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0";
     animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0));
     animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255);
     animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255);
     ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase();
     animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1");
     Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0);
     // animBorder2 element
     this.animBorder2 = new Border();
     this.e_24.Children.Add(this.animBorder2);
     this.animBorder2.Name = "animBorder2";
     this.animBorder2.Height = 50F;
     this.animBorder2.Width = 100F;
     this.animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F);
     EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder2);
     animBorder2.Triggers.Add(animBorder2_ET_0);
     BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard();
     animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0";
     animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0);
     Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard();
     animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB;
     animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0";
     animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0));
     animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255);
     animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255);
     CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase();
     animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0);
     FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1";
     animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0));
     animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_1.From = 1F;
     animBorder2_ET_0_AC_0_SB_TL_1.To = 0F;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1);
     FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
 }
Esempio n. 9
0
        private ICanvasImage ApplyFilterTemplate(ICanvasImage source)
        {
            if (_filter_index == 0)  //无滤镜
            {
                return(source);
            }
            else if (_filter_index == 1)  // 黑白
            {
                return(new GrayscaleEffect
                {
                    Source = source
                });
            }
            else if (_filter_index == 2)  //反色
            {
                return(new InvertEffect
                {
                    Source = source
                });
            }
            else if (_filter_index == 3) //冷色
            {
                var hueRotationEffect = new HueRotationEffect
                {
                    Source = source,
                    Angle  = 0.5f
                };
                return(hueRotationEffect);
            }
            else if (_filter_index == 4)  //美食
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = 0.6f;
                temperatureAndTintEffect.Tint        = 0.6f;

                return(temperatureAndTintEffect);
            }
            else if (_filter_index == 5) //冷绿
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = -0.6f;
                temperatureAndTintEffect.Tint        = -0.6f;

                return(temperatureAndTintEffect);
            }
            else if (_filter_index == 6) //梦幻
            {
                var vignetteEffect = new VignetteEffect
                {
                    Source = source
                };
                vignetteEffect.Color  = Color.FromArgb(255, 0xFF, 0xFF, 0xFF);
                vignetteEffect.Amount = 0.6f;

                return(vignetteEffect);
            }
            else if (_filter_index == 7) //浮雕
            {
                var embossEffect = new EmbossEffect
                {
                    Source = source
                };
                embossEffect.Amount = 5;
                embossEffect.Angle  = 0;
                return(embossEffect);
            }
            else if (_filter_index == 8) //怀旧
            {
                var sepiaEffect = new SepiaEffect
                {
                    Source = source
                };
                sepiaEffect.Intensity = 1;
                return(sepiaEffect);
            }
            else if (_filter_index == 9)//运动
            {
                var directEffect = new DirectionalBlurEffect
                {
                    Source = source
                };
                directEffect.BlurAmount = 12;
                directEffect.BorderMode = EffectBorderMode.Soft;
                directEffect.Angle      = 3.14F;
                return(directEffect);
            }
            else
            {
                return(source);
            }
        }
Esempio n. 10
0
        private void InitializeComponent()
        {
            this.FontSize = 13.33333F;
            this.SetResourceReference(SoundManager.SoundsProperty, "Sounds");
            InitializeElementResources(this);
            // e_0 element
            this.e_0      = new Grid();
            this.Content  = this.e_0;
            this.e_0.Name = "e_0";
            RowDefinition row_e_0_0 = new RowDefinition();

            row_e_0_0.Height = new GridLength(110F, GridUnitType.Pixel);
            this.e_0.RowDefinitions.Add(row_e_0_0);
            RowDefinition row_e_0_1 = new RowDefinition();

            this.e_0.RowDefinitions.Add(row_e_0_1);
            ColumnDefinition col_e_0_0 = new ColumnDefinition();

            this.e_0.ColumnDefinitions.Add(col_e_0_0);
            ColumnDefinition col_e_0_1 = new ColumnDefinition();

            this.e_0.ColumnDefinitions.Add(col_e_0_1);
            // e_1 element
            this.e_1 = new StackPanel();
            this.e_0.Children.Add(this.e_1);
            this.e_1.Name       = "e_1";
            this.e_1.Background = new SolidColorBrush(new ColorW(0, 0, 0, 255));
            Grid.SetColumnSpan(this.e_1, 2);
            // logo element
            this.logo = new Image();
            this.e_1.Children.Add(this.logo);
            this.logo.Name = "logo";
            this.logo.HorizontalAlignment = HorizontalAlignment.Center;
            DirectionalBlurEffect logo_dbef = new DirectionalBlurEffect();

            logo_dbef.Angle      = 0F;
            logo_dbef.BlurAmount = 0.002F;
            this.logo.Effect     = logo_dbef;
            this.logo.Stretch    = Stretch.None;
            this.logo.SetResourceReference(Image.SourceProperty, "logoEmptyKeys");
            // e_2 element
            this.e_2 = new TextBlock();
            this.e_1.Children.Add(this.e_2);
            this.e_2.Name = "e_2";
            this.e_2.HorizontalAlignment = HorizontalAlignment.Center;
            this.e_2.VerticalAlignment   = VerticalAlignment.Center;
            this.e_2.Foreground          = new SolidColorBrush(new ColorW(211, 211, 211, 255));
            this.e_2.TextWrapping        = TextWrapping.Wrap;
            this.e_2.FontFamily          = new FontFamily("Segoe UI");
            this.e_2.FontSize            = 20F;
            this.e_2.FontStyle           = FontStyle.Bold;
            this.e_2.SetResourceReference(TextBlock.TextProperty, "TitleResource");
            // e_3 element
            this.e_3 = new StackPanel();
            this.e_0.Children.Add(this.e_3);
            this.e_3.Name = "e_3";
            Grid.SetRow(this.e_3, 1);
            // combo element
            this.combo = new ComboBox();
            this.e_3.Children.Add(this.combo);
            this.combo.Name   = "combo";
            this.combo.Width  = 200F;
            this.combo.Margin = new Thickness(5F, 5F, 5F, 5F);
            Func <UIElement, UIElement> combo_dtFunc = combo_dtMethod;

            this.combo.ItemTemplate = new DataTemplate(combo_dtFunc);
            Binding binding_combo_ItemsSource = new Binding("ComboBoxSource");

            this.combo.SetBinding(ComboBox.ItemsSourceProperty, binding_combo_ItemsSource);
            Binding binding_combo_SelectedIndex = new Binding("SelectedIndex");

            this.combo.SetBinding(ComboBox.SelectedIndexProperty, binding_combo_SelectedIndex);
            // button1 element
            this.button1 = new Button();
            this.e_3.Children.Add(this.button1);
            this.button1.Name   = "button1";
            this.button1.Height = 30F;
            this.button1.Width  = 200F;
            this.button1.Margin = new Thickness(5F, 5F, 5F, 5F);
            ToolTip tt_button1 = new ToolTip();

            this.button1.ToolTip          = tt_button1;
            tt_button1.Content            = "Click Me!";
            this.button1.Content          = "1";
            this.button1.CommandParameter = "Click Button 1";
            Binding binding_button1_Command = new Binding("ButtonCommand");

            this.button1.SetBinding(Button.CommandProperty, binding_button1_Command);
            // button2 element
            this.button2 = new Button();
            this.e_3.Children.Add(this.button2);
            this.button2.Name             = "button2";
            this.button2.Height           = 30F;
            this.button2.Margin           = new Thickness(5F, 5F, 5F, 5F);
            this.button2.Content          = "2";
            this.button2.CommandParameter = "Click Button 2";
            Binding binding_button2_Command = new Binding("ButtonCommand");

            this.button2.SetBinding(Button.CommandProperty, binding_button2_Command);
            this.button2.SetResourceReference(Button.StyleProperty, "buttonStyle");
            // button3 element
            this.button3 = new Button();
            this.e_3.Children.Add(this.button3);
            this.button3.Name             = "button3";
            this.button3.Height           = 30F;
            this.button3.Width            = 200F;
            this.button3.Margin           = new Thickness(5F, 5F, 5F, 5F);
            this.button3.FontFamily       = new FontFamily("Segoe UI");
            this.button3.FontSize         = 20F;
            this.button3.FontStyle        = FontStyle.Bold;
            this.button3.Content          = "3";
            this.button3.CommandParameter = "Click Button 3";
            Binding binding_button3_Command = new Binding("OpenMessageBox");

            this.button3.SetBinding(Button.CommandProperty, binding_button3_Command);
            this.button3.SetResourceReference(Button.ToolTipProperty, "ToolTipText");
            // buttonResult element
            this.buttonResult = new TextBlock();
            this.e_3.Children.Add(this.buttonResult);
            this.buttonResult.Name = "buttonResult";
            this.buttonResult.HorizontalAlignment = HorizontalAlignment.Center;
            Binding binding_buttonResult_Text = new Binding("ButtonResult");

            this.buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
            // slider element
            this.slider = new Slider();
            this.e_3.Children.Add(this.slider);
            this.slider.Name    = "slider";
            this.slider.Width   = 200F;
            this.slider.Minimum = 5F;
            this.slider.Maximum = 20F;
            Binding binding_slider_Value = new Binding("SliderValue");

            this.slider.SetBinding(Slider.ValueProperty, binding_slider_Value);
            // textBox element
            this.textBox = new TextBox();
            this.e_3.Children.Add(this.textBox);
            this.textBox.Name   = "textBox";
            this.textBox.Width  = 200F;
            this.textBox.Margin = new Thickness(5F, 5F, 5F, 5F);
            Binding binding_textBox_Text = new Binding("TextBoxText");

            this.textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text);
            // checkBox element
            this.checkBox = new CheckBox();
            this.e_3.Children.Add(this.checkBox);
            this.checkBox.Name   = "checkBox";
            this.checkBox.Margin = new Thickness(5F, 5F, 5F, 5F);
            this.checkBox.HorizontalAlignment = HorizontalAlignment.Center;
            this.checkBox.Content             = "Check Box";
            // e_5 element
            this.e_5 = new StackPanel();
            this.e_3.Children.Add(this.e_5);
            this.e_5.Name = "e_5";
            this.e_5.HorizontalAlignment = HorizontalAlignment.Center;
            this.e_5.Orientation         = Orientation.Horizontal;
            // e_6 element
            this.e_6 = new RadioButton();
            this.e_5.Children.Add(this.e_6);
            this.e_6.Name      = "e_6";
            this.e_6.Margin    = new Thickness(5F, 5F, 5F, 5F);
            this.e_6.Content   = "Radio Button 1";
            this.e_6.GroupName = "testGroup1";
            // e_7 element
            this.e_7 = new RadioButton();
            this.e_5.Children.Add(this.e_7);
            this.e_7.Name      = "e_7";
            this.e_7.Margin    = new Thickness(5F, 5F, 5F, 5F);
            this.e_7.Content   = "Radio Button 2";
            this.e_7.GroupName = "testGroup1";
            // e_8 element
            this.e_8 = new RadioButton();
            this.e_5.Children.Add(this.e_8);
            this.e_8.Name      = "e_8";
            this.e_8.Margin    = new Thickness(5F, 5F, 5F, 5F);
            this.e_8.Content   = "Radio Button 3";
            this.e_8.GroupName = "testGroup1";
            // e_9 element
            this.e_9 = new TabControl();
            this.e_3.Children.Add(this.e_9);
            this.e_9.Name        = "e_9";
            this.e_9.Height      = 150F;
            this.e_9.Width       = 400F;
            this.e_9.ItemsSource = Get_e_9_Items();
            // e_22 element
            this.e_22 = new ProgressBar();
            this.e_3.Children.Add(this.e_22);
            this.e_22.Name   = "e_22";
            this.e_22.Height = 30F;
            this.e_22.Width  = 400F;
            this.e_22.Margin = new Thickness(5F, 5F, 5F, 5F);
            this.e_22.Value  = 39F;
            // e_23 element
            this.e_23 = new StackPanel();
            this.e_0.Children.Add(this.e_23);
            this.e_23.Name = "e_23";
            Grid.SetColumn(this.e_23, 1);
            Grid.SetRow(this.e_23, 1);
            // animButton1 element
            this.animButton1 = new Button();
            this.e_23.Children.Add(this.animButton1);
            this.animButton1.Name    = "animButton1";
            this.animButton1.Content = "Mouse Over me!";
            this.animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
            // animButton2 element
            this.animButton2 = new Button();
            this.e_23.Children.Add(this.animButton2);
            this.animButton2.Name    = "animButton2";
            this.animButton2.Content = "Mouse Over me!";
            this.animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
            // animButton3 element
            this.animButton3 = new Button();
            this.e_23.Children.Add(this.animButton3);
            this.animButton3.Name    = "animButton3";
            this.animButton3.Content = "Mouse Over me!";
            this.animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
            // animButton4 element
            this.animButton4 = new Button();
            this.e_23.Children.Add(this.animButton4);
            this.animButton4.Name    = "animButton4";
            this.animButton4.Content = "Mouse Over me!";
            this.animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
            // e_24 element
            this.e_24 = new Grid();
            this.e_23.Children.Add(this.e_24);
            this.e_24.Name = "e_24";
            // animBorder1 element
            this.animBorder1 = new Border();
            this.e_24.Children.Add(this.animBorder1);
            this.animBorder1.Name   = "animBorder1";
            this.animBorder1.Height = 100F;
            this.animBorder1.Width  = 200F;
            this.animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F);
            EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder1);

            animBorder1.Triggers.Add(animBorder1_ET_0);
            BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard();

            animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0";
            animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0);
            Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard();

            animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB;
            animBorder1_ET_0_AC_0_SB.Name    = "animBorder1_ET_0_AC_0_SB";
            SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();

            animBorder1_ET_0_AC_0_SB_TL_0.Name           = "animBorder1_ET_0_AC_0_SB_TL_0";
            animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse    = true;
            animBorder1_ET_0_AC_0_SB_TL_0.Duration       = new Duration(new TimeSpan(0, 0, 0, 5, 0));
            animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
            animBorder1_ET_0_AC_0_SB_TL_0.From           = new ColorW(255, 255, 0, 255);
            animBorder1_ET_0_AC_0_SB_TL_0.To             = new ColorW(0, 0, 255, 255);
            ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase();

            animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA;
            Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1");
            Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
            animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0);
            // animBorder2 element
            this.animBorder2 = new Border();
            this.e_24.Children.Add(this.animBorder2);
            this.animBorder2.Name   = "animBorder2";
            this.animBorder2.Height = 50F;
            this.animBorder2.Width  = 100F;
            this.animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F);
            EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder2);

            animBorder2.Triggers.Add(animBorder2_ET_0);
            BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard();

            animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0";
            animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0);
            Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard();

            animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB;
            animBorder2_ET_0_AC_0_SB.Name    = "animBorder2_ET_0_AC_0_SB";
            SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();

            animBorder2_ET_0_AC_0_SB_TL_0.Name           = "animBorder2_ET_0_AC_0_SB_TL_0";
            animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse    = true;
            animBorder2_ET_0_AC_0_SB_TL_0.Duration       = new Duration(new TimeSpan(0, 0, 0, 3, 0));
            animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
            animBorder2_ET_0_AC_0_SB_TL_0.From           = new ColorW(255, 0, 0, 255);
            animBorder2_ET_0_AC_0_SB_TL_0.To             = new ColorW(255, 255, 255, 255);
            CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase();

            animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA;
            Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2");
            Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
            animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0);
            FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation();

            animBorder2_ET_0_AC_0_SB_TL_1.Name           = "animBorder2_ET_0_AC_0_SB_TL_1";
            animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse    = true;
            animBorder2_ET_0_AC_0_SB_TL_1.Duration       = new Duration(new TimeSpan(0, 0, 0, 4, 0));
            animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever;
            animBorder2_ET_0_AC_0_SB_TL_1.From           = 1F;
            animBorder2_ET_0_AC_0_SB_TL_1.To             = 0F;
            Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2");
            Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty);
            animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1);
            FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular");
            FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
        }
Esempio n. 11
0
        private void AnimateShift(double x, double y, bool isBlurEnabled)
        {
            // Blur

            double scrollDirection    = (x - ShiftTransform.X > 0) ? 1 : -1;
            double absDeltaX          = Math.Abs(this.ShiftTransform.X - x);
            int    numberOfItemsDelta = Math.Max((int)absDeltaX / (int)avgItemWidth, 1);
            double blurAmount         = 0.02; // the default DirectionalBlurEffect amount

            if (isBlurEnabled)
            {
                if (this.Effect == null || !(this.filmStripBlurEffect is DirectionalBlurEffect))
                {
                    this.filmStripBlurEffect       = new DirectionalBlurEffect();
                    this.filmStripBlurEffect.Angle = 0;
                    this.Effect = filmStripBlurEffect;
                }


                if (absDeltaX > (avgItemWidth * 3))
                {
                    // The amount of blur is relative to the number of items being scrolled within the film strip
                    // with the maximum blur amount of blurAmount. The blur direction must also match direction of the
                    // FilmStripPanel.SetHorizontalOffset's horizontal animation to prevent jittering
                    blurAmount *= scrollDirection;
                    this.filmStripMultiItemBlurEffectAnimation.From              = blurAmount * ((numberOfItemsDelta <= 0.0 ? 1.0 : numberOfItemsDelta) / (this.ActualWidth <= 0.0 ? 1.0 : (this.ActualWidth / avgItemWidth)));
                    this.filmStripMultiItemBlurEffectAnimation.To                = 0;
                    this.filmStripMultiItemBlurEffectAnimation.Duration          = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));
                    this.filmStripMultiItemBlurEffectAnimation.AccelerationRatio = 0;
                    this.filmStripMultiItemBlurEffectAnimation.DecelerationRatio = 1;
                    this.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripMultiItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
                else if (absDeltaX > 0)
                {
                    if (this.filmStripOneItemBlurEffectAnimation.From == null)
                    {
                        this.filmStripOneItemBlurEffectAnimation.From = 0;
                    }

                    // The amount of blur should slowly accumulate when moving between many items sequentially
                    // such as holding down the arrow key. The HandoffBehavior.SnapshotAndReplace behavior will ensure
                    // the a smooth transition to the next animation.
                    this.filmStripOneItemBlurEffectAnimation.From             += blurAmount * 0.001 * scrollDirection; // accumulate blur in small increments
                    this.filmStripOneItemBlurEffectAnimation.To                = 0;
                    this.filmStripOneItemBlurEffectAnimation.Duration          = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));
                    this.filmStripOneItemBlurEffectAnimation.AccelerationRatio = 0;
                    this.filmStripOneItemBlurEffectAnimation.DecelerationRatio = 1;
                    this.filmStripOneItemBlurEffectAnimation.Completed        += new EventHandler(this.FilmStripOneItemBlurEffectAnimationCompleted);
                    this.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripOneItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
            }

            // Translate

            DoubleAnimation transformAnimation = new DoubleAnimation();

            // animate horizontally so that current item is positioned at the center of the viewport
            //transformAnimation.From = centerRelativeOffset - this.offset.X;

            double from = ShiftTransform.X;

            transformAnimation.To = x;

            // this duration must match FilmStripControl.BringCurrentItemIntoView's Effect animation duration
            numberOfItemsDelta          = (int)Math.Abs((int)(from - transformAnimation.To) / (int)avgItemWidth);
            transformAnimation.Duration = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));

            transformAnimation.AccelerationRatio = 0;
            transformAnimation.DecelerationRatio = 1;
            ShiftTransform.BeginAnimation(TranslateTransform.XProperty, transformAnimation);
        }
        private ICanvasImage CreateDirectionalBlur(CanvasBitmap source)
        {
            var blurEffect = new DirectionalBlurEffect
            {
                Source = source
            };

            return blurEffect;
        }
        private void AnimateShift(double x, double y, bool isBlurEnabled)
        {
            // Blur

            double scrollDirection = (x - ShiftTransform.X > 0) ? 1 : -1;
            double absDeltaX = Math.Abs(this.ShiftTransform.X - x);
            int numberOfItemsDelta = Math.Max((int)absDeltaX / (int)avgItemWidth, 1);
            double blurAmount = 0.02; // the default DirectionalBlurEffect amount

            if (isBlurEnabled)
            {
                if (this.Effect == null || !(this.filmStripBlurEffect is DirectionalBlurEffect))
                {
                    this.filmStripBlurEffect = new DirectionalBlurEffect();
                    this.filmStripBlurEffect.Angle = 0;
                    this.Effect = filmStripBlurEffect;
                }

                if (absDeltaX > (avgItemWidth * 3))
                {
                    // The amount of blur is relative to the number of items being scrolled within the film strip
                    // with the maximum blur amount of blurAmount. The blur direction must also match direction of the
                    // FilmStripPanel.SetHorizontalOffset's horizontal animation to prevent jittering
                    blurAmount *= scrollDirection;
                    this.filmStripMultiItemBlurEffectAnimation.From = blurAmount * ((numberOfItemsDelta <= 0.0 ? 1.0 : numberOfItemsDelta) / (this.ActualWidth <= 0.0 ? 1.0 : (this.ActualWidth / avgItemWidth)));
                    this.filmStripMultiItemBlurEffectAnimation.To = 0;
                    this.filmStripMultiItemBlurEffectAnimation.Duration = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));
                    this.filmStripMultiItemBlurEffectAnimation.AccelerationRatio = 0;
                    this.filmStripMultiItemBlurEffectAnimation.DecelerationRatio = 1;
                    this.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripMultiItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
                else if (absDeltaX > 0)
                {
                    if (this.filmStripOneItemBlurEffectAnimation.From == null)
                    {
                        this.filmStripOneItemBlurEffectAnimation.From = 0;
                    }

                    // The amount of blur should slowly accumulate when moving between many items sequentially
                    // such as holding down the arrow key. The HandoffBehavior.SnapshotAndReplace behavior will ensure
                    // the a smooth transition to the next animation.
                    this.filmStripOneItemBlurEffectAnimation.From += blurAmount * 0.001 * scrollDirection; // accumulate blur in small increments
                    this.filmStripOneItemBlurEffectAnimation.To = 0;
                    this.filmStripOneItemBlurEffectAnimation.Duration = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));
                    this.filmStripOneItemBlurEffectAnimation.AccelerationRatio = 0;
                    this.filmStripOneItemBlurEffectAnimation.DecelerationRatio = 1;
                    this.filmStripOneItemBlurEffectAnimation.Completed += new EventHandler(this.FilmStripOneItemBlurEffectAnimationCompleted);
                    this.Effect.BeginAnimation(DirectionalBlurEffect.BlurAmountProperty, this.filmStripOneItemBlurEffectAnimation, HandoffBehavior.SnapshotAndReplace);
                }
            }

            // Translate

            DoubleAnimation transformAnimation = new DoubleAnimation();

            // animate horizontally so that current item is positioned at the center of the viewport
            //transformAnimation.From = centerRelativeOffset - this.offset.X;

            double from = ShiftTransform.X;
            transformAnimation.To = x;

            // this duration must match FilmStripControl.BringCurrentItemIntoView's Effect animation duration
            numberOfItemsDelta = (int)Math.Abs((int)(from - transformAnimation.To) / (int)avgItemWidth);
            transformAnimation.Duration = standardSlideFilmStripDuration + new Duration(new TimeSpan(numberOfItemsDelta * perItemSlideFilmStripTime));

            transformAnimation.AccelerationRatio = 0;
            transformAnimation.DecelerationRatio = 1;
            ShiftTransform.BeginAnimation(TranslateTransform.XProperty, transformAnimation);
        }