Esempio n. 1
0
        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            Grid grid     = new Grid();
            int  rowIndex = 0;

            CheckBox  distinctEdgesCheckBox = new CheckBox();
            TextBlock textBlock             = new TextBlock {
                Text = AppResources.DistinctEdges
            };

            distinctEdgesCheckBox.Content    = textBlock;
            distinctEdgesCheckBox.IsChecked  = _cartoonFilter.DistinctEdges;
            distinctEdgesCheckBox.Checked   += distinctEdgesCheckBox_Checked;
            distinctEdgesCheckBox.Unchecked += distinctEdgesCheckBox_Unchecked;
            Grid.SetRow(distinctEdgesCheckBox, rowIndex++);

            for (int i = 0; i < rowIndex; ++i)
            {
                RowDefinition rd = new RowDefinition();
                grid.RowDefinitions.Add(rd);
            }

            grid.Children.Add(distinctEdgesCheckBox);

            control.ControlsContainer.Children.Add(grid);

            return(true);
        }
        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            Grid grid     = new Grid();
            int  rowIndex = 0;

            TextBlock sketchModeText = new TextBlock {
                Text = AppResources.SketchMode
            };

            Grid.SetRow(sketchModeText, rowIndex++);

            RadioButton grayRadioButton = new RadioButton {
                GroupName = SketchModeGroup
            };
            TextBlock textBlock = new TextBlock {
                Text = AppResources.Gray
            };

            grayRadioButton.Content  = textBlock;
            grayRadioButton.Checked += grayRadioButton_Checked;
            Grid.SetRow(grayRadioButton, rowIndex++);

            RadioButton colorRadioButton = new RadioButton {
                GroupName = SketchModeGroup
            };

            textBlock = new TextBlock {
                Text = AppResources.Color
            };
            colorRadioButton.Content  = textBlock;
            colorRadioButton.Checked += colorRadioButton_Checked;
            Grid.SetRow(colorRadioButton, rowIndex++);

            if (_sketchFilter.SketchMode == SketchMode.Gray)
            {
                grayRadioButton.IsChecked = true;
            }
            else
            {
                colorRadioButton.IsChecked = true;
            }

            for (int i = 0; i < rowIndex; ++i)
            {
                RowDefinition rd = new RowDefinition();
                grid.RowDefinitions.Add(rd);
            }

            grid.Children.Add(sketchModeText);
            grid.Children.Add(grayRadioButton);
            grid.Children.Add(colorRadioButton);

            control.ControlsContainer.Children.Add(grid);

            return(true);
        }
        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            _hdrControl = new HdrControl
            {
                NoiseSuppression = _hdrEffect.NoiseSuppression,
                Strength         = _hdrEffect.Strength,
                Saturation       = _hdrEffect.Saturation
            };

            control.ControlsContainer.Children.Add(_hdrControl);
            _hdrControl.ValueChanged += HdrValueChanged;

            return(true);
        }
        public override bool AttachControl(FilterPropertiesControl control)
        {
            Control = control;

            Grid grid     = new Grid();
            int  rowIndex = 0;

            TextBlock brightnessText = new TextBlock {
                Text = AppResources.Brightness
            };

            Grid.SetRow(brightnessText, rowIndex++);

            Slider brightnessSlider = new Slider {
                Minimum = 0.0, Maximum = 1.0, Value = _lomoFilter.Brightness
            };

            brightnessSlider.ValueChanged += brightnessSlider_ValueChanged;
            Grid.SetRow(brightnessSlider, rowIndex++);

            TextBlock saturationText = new TextBlock {
                Text = AppResources.Saturation
            };

            Grid.SetRow(saturationText, rowIndex++);

            Slider saturationSlider = new Slider {
                Minimum = 0.0, Maximum = 1.0, Value = _lomoFilter.Saturation
            };

            saturationSlider.ValueChanged += saturationSlider_ValueChanged;
            Grid.SetRow(saturationSlider, rowIndex++);

            TextBlock lomoVignettingText = new TextBlock {
                Text = AppResources.LomoVignetting
            };

            Grid.SetRow(lomoVignettingText, rowIndex++);

            RadioButton highRadioButton = new RadioButton {
                GroupName = _lomoVignettingGroup
            };
            TextBlock textBlock = new TextBlock {
                Text = AppResources.High
            };

            highRadioButton.Content  = textBlock;
            highRadioButton.Checked += highRadioButton_Checked;
            Grid.SetRow(highRadioButton, rowIndex++);

            RadioButton medRadioButton = new RadioButton {
                GroupName = _lomoVignettingGroup
            };

            textBlock = new TextBlock {
                Text = AppResources.Medium
            };
            medRadioButton.Content  = textBlock;
            medRadioButton.Checked += medRadioButton_Checked;
            Grid.SetRow(medRadioButton, rowIndex++);

            RadioButton lowRadioButton = new RadioButton {
                GroupName = _lomoVignettingGroup
            };

            textBlock = new TextBlock {
                Text = AppResources.Low
            };
            lowRadioButton.Content  = textBlock;
            lowRadioButton.Checked += lowRadioButton_Checked;
            Grid.SetRow(lowRadioButton, rowIndex++);

            switch (_lomoFilter.LomoVignetting)
            {
            case LomoVignetting.Low: lowRadioButton.IsChecked = true; break;

            case LomoVignetting.Medium: medRadioButton.IsChecked = true; break;

            case LomoVignetting.High: highRadioButton.IsChecked = true; break;
            }

            for (int i = 0; i < rowIndex; ++i)
            {
                RowDefinition rd = new RowDefinition();
                grid.RowDefinitions.Add(rd);
            }

            grid.Children.Add(brightnessText);
            grid.Children.Add(brightnessSlider);
            grid.Children.Add(saturationText);
            grid.Children.Add(saturationSlider);
            grid.Children.Add(lomoVignettingText);
            grid.Children.Add(lowRadioButton);
            grid.Children.Add(medRadioButton);
            grid.Children.Add(highRadioButton);

            control.ControlsContainer.Children.Add(grid);

            return(true);
        }
Esempio n. 5
0
 /// <summary>
 /// Attaches a UI controls for adjusting filter properties.
 /// </summary>
 /// <param name="control"></param>
 /// <returns>True if the control was populated, false otherwise.</returns>
 public virtual bool AttachControl(FilterPropertiesControl control)
 {
     return(false);
 }
 /// <summary>
 /// Completes the actions when HideControlsAnimation has finished.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void HideControlsAnimation_Completed(object sender, EventArgs e)
 {
     HideControlsAnimation.Completed -= HideControlsAnimation_Completed;
     _controlToHide.Visibility = Visibility.Collapsed;
     _controlToHide.Opacity = 0;
     _controlToHide = null;
 }
        /// <summary>
        /// Shows the filter property controls.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        //void ShowPropertiesControls(object sender, System.Windows.Input.GestureEventArgs e)
        void ShowPropertiesControls(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (sender is Grid)
            {
                Grid grid = (Grid)sender;

                foreach (UIElement element in grid.Children)
                {
                    if (element is FilterPropertiesControl)
                    {
                        if (element.Visibility == Visibility.Collapsed
                            || element.Opacity < 1)
                        {
                            Debug.WriteLine(DebugTag + "ShowPropertiesControls()");

                            if (HintText.Visibility == Visibility.Visible)
                            {
                                HintText.Visibility = Visibility.Collapsed;
                            }

                            HideControlsAnimation.Completed -= HideControlsAnimation_Completed;
                            HideControlsAnimationStoryBoard.Stop();

                            if (_timer != null)
                            {
                                _timer.Tick -= HidePropertiesControls;
                                _timer.Stop();
                                _timer = null;
                            }

                            _controlToHide = (FilterPropertiesControl)element;
                            _controlToHide.Visibility = Visibility.Visible;

                            try
                            {
                                Storyboard.SetTargetName(ShowControlsAnimation, _controlToHide.Name);
                                ShowControlsAnimation.From = _controlToHide.Opacity;
                                ShowControlsAnimationStoryBoard.Completed += ShowControlsAnimationStoryBoard_Completed;
                                ShowControlsAnimationStoryBoard.Begin();
                            }
                            catch (InvalidOperationException ex)
                            {
                                Debug.WriteLine(ex.ToString());
                            }

                            _timer = new DispatcherTimer();
                            _timer.Interval = new TimeSpan(0, 0, 0, HideControlsDelay);
                            _timer.Tick += HidePropertiesControls;
                            _timer.Start();
                        }
                        else if (e.OriginalSource is Image)
                        {
                            HidePropertiesControls(null, null);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Severes the connections related to showing and hiding the filter
        /// property controls and hides the controls if visible.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void FilterPreviewPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Debug.WriteLine(DebugTag + "FilterPreviewPivot_SelectionChanged()");

            if (!_hintTextShown && FilterPreviewPivot.SelectedIndex != 0)
            {
                HintText.Visibility = Visibility.Visible;
                _hintTextShown = true;
            }
            else if (_hintTextShown
                     && HintText.Visibility == Visibility.Visible
                     && FilterPreviewPivot.SelectedIndex == 0)
            {
                HintText.Visibility = Visibility.Collapsed;
                _hintTextShown = false;
            }

            ShowControlsAnimationStoryBoard.Completed -= ShowControlsAnimationStoryBoard_Completed;
            HideControlsAnimation.Completed -= HideControlsAnimation_Completed;
            ShowControlsAnimationStoryBoard.Stop();
            HideControlsAnimationStoryBoard.Stop();

            if (_controlToHide != null)
            {
                _controlToHide.Visibility = Visibility.Collapsed;
                _controlToHide.Opacity = 0;
                _controlToHide = null;
            }

            //if (count % 2 == 0)
            //{

            //    if (askforReview)
            //    {
            //        //make sure we only ask once! 
            //        var returnvalue = MessageBox.Show("Please tell us how is the app as your reveiws matter alot to us.\nPlease  Rate 5 Stars", "Please Rate 5 Stars", MessageBoxButton.OK);
            //        if (returnvalue == MessageBoxResult.OK)
            //        {
            //            IsolatedStorageSettings.ApplicationSettings["done"] = true;
            //            askforReview = false;



            //            var marketplaceReviewTask = new MarketplaceReviewTask();
            //            marketplaceReviewTask.Show();
            //        }

            //    }
            //}
            if (count % 3 == 0)
            //{ NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative)); }
            {
                AdRequest adRequest = new AdRequest();
                adRequest.ForceTesting = true;
                interstitialAd.LoadAd(adRequest);
                interstitialAd.ReceivedAd += OnAdReceived;

            }

            if (count % 3 == 1)
            {
                if (p == true)
                {


                    p = false;

                    q = true;

                    interstitialAd.ShowAd();

                }
            }
            count++;
        }
        /// <summary>
        /// Constructs the filters and the pivot items.
        /// </summary>
        private void CreateComponents()
        {
            CreateFilters();

            DataContext dataContext = FilterEffects.DataContext.Instance;
            _previewImages = new List<Image>();
            int i = 0;

            // Create a pivot item with an image for each filter. The image
            // content is added later. In addition, create the preview bitmaps
            // and associate them with the images.
            foreach (AbstractFilter filter in _filters)
            {
                PivotItem pivotItem = new PivotItem();
                pivotItem.Header = filter.Name;

                if (filter.ShortDescription != null && filter.ShortDescription.Length > 0)
                {
                    pivotItem.Header += " (" + filter.ShortDescription + ")";
                }

                FilterPropertiesControl control = new FilterPropertiesControl();

                String name = FilterPropertyControlNamePrefix + filter.Name;
                control.Name = name;

                Grid grid = new Grid();

                name = PivotItemNamePrefix + filter.Name;
                grid.Name = name;

                _previewImages.Add(new Image());
                grid.Children.Add(_previewImages[i++]);

                if (filter.AttachControl(control))
                {
                    control.VerticalAlignment = VerticalAlignment.Bottom;
                    control.Opacity = 0;
                    control.Visibility = Visibility.Collapsed;
                    control.ControlBackground.Fill = AppUtils.ThemeBackgroundBrush;
                    grid.Children.Add(control);

                    grid.Tap += ShowPropertiesControls;
                    control.Manipulated += OnControlManipulated;
                }

                pivotItem.Content = grid;
                FilterPreviewPivot.Items.Add(pivotItem);
                filter.PreviewResolution = new Windows.Foundation.Size(
                    DefaultOutputResolutionWidth, DefaultOutputResolutionHeight);
            }

            HintTextBackground.Fill = AppUtils.ThemeBackgroundBrush;

            FilterPreviewPivot.SelectionChanged += FilterPreviewPivot_SelectionChanged;
        }
        /// <summary>
        /// Severes the connections related to showing and hiding the filter
        /// property controls and hides the controls if visible.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void FilterPreviewPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Debug.WriteLine(DebugTag + "FilterPreviewPivot_SelectionChanged()");

            if (!_hintTextShown && FilterPreviewPivot.SelectedIndex != 0)
            {
                HintText.Visibility = Visibility.Visible;
                _hintTextShown = true;
            }
            else if (_hintTextShown
                     && HintText.Visibility == Visibility.Visible
                     && FilterPreviewPivot.SelectedIndex == 0)
            {
                HintText.Visibility = Visibility.Collapsed;
                _hintTextShown = false;
            }

            ShowControlsAnimationStoryBoard.Completed -= ShowControlsAnimationStoryBoard_Completed;
            HideControlsAnimation.Completed -= HideControlsAnimation_Completed;
            ShowControlsAnimationStoryBoard.Stop();
            HideControlsAnimationStoryBoard.Stop();

            if (_controlToHide != null)
            {
                _controlToHide.Visibility = Visibility.Collapsed;
                _controlToHide.Opacity = 0;
                _controlToHide = null;
            }
        }