public override bool AttachControl(FilterPropertiesControl control) { _control = control; Grid grid = new Grid(); int rowIndex = 0; CheckBox distinctEdgesCheckBox = new CheckBox(); TextBlock textBlock = new TextBlock(); 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; }
/// <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; }
public override bool AttachControl(FilterPropertiesControl control) { _control = control; Grid grid = new Grid(); int rowIndex = 0; CheckBox distinctEdgesCheckBox = new CheckBox(); TextBlock textBlock = new TextBlock(); 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); }
/// <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; } }
/// <summary> /// Shows the filter property controls. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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 { Interval = new TimeSpan(0, 0, 0, HideControlsDelay) }; _timer.Tick += HidePropertiesControls; _timer.Start(); } else if (e.OriginalSource is Image) { HidePropertiesControls(null, null); } } } } }
/// <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 { 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; }
public override bool AttachControl(FilterPropertiesControl control) { _control = control; Grid grid = new Grid(); int rowIndex = 0; TextBlock sketchModeText = new TextBlock(); sketchModeText.Text = AppResources.SketchMode; Grid.SetRow(sketchModeText, rowIndex++); RadioButton grayRadioButton = new RadioButton(); grayRadioButton.GroupName = SketchModeGroup; TextBlock textBlock = new TextBlock(); textBlock.Text = AppResources.Gray; grayRadioButton.Content = textBlock; grayRadioButton.Checked += grayRadioButton_Checked; Grid.SetRow(grayRadioButton, rowIndex++); RadioButton colorRadioButton = new RadioButton(); colorRadioButton.GroupName = SketchModeGroup; textBlock = new TextBlock(); 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; Grid grid = new Grid(); int rowIndex = 0; TextBlock sketchModeText = new TextBlock(); sketchModeText.Text = AppResources.SketchMode; Grid.SetRow(sketchModeText, rowIndex++); RadioButton grayRadioButton = new RadioButton(); grayRadioButton.GroupName = SketchModeGroup; TextBlock textBlock = new TextBlock(); textBlock.Text = AppResources.Gray; grayRadioButton.Content = textBlock; grayRadioButton.Checked += grayRadioButton_Checked; Grid.SetRow(grayRadioButton, rowIndex++); RadioButton colorRadioButton = new RadioButton(); colorRadioButton.GroupName = SketchModeGroup; textBlock = new TextBlock(); 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; }
/// <summary> /// Constructs the filters and the pivot items. /// </summary> private void CreateComponents() { CreateFilters(); DataContext dataContext = FilterEffects.DataContext.Singleton; // 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; FilterPropertiesControl control = new FilterPropertiesControl(); String name = FilterPropertyControlNamePrefix + filter.Name; control.Name = name; Grid grid = new Grid(); name = PivotItemNamePrefix + filter.Name; grid.Name = name; grid.Children.Add(filter.PreviewImage); if (filter.AttachControl(control)) { control.VerticalAlignment = VerticalAlignment.Bottom; control.Opacity = 0; control.Visibility = Visibility.Collapsed; control.ControlBackground.Fill = dataContext.ThemeBackgroundBrush(); grid.Children.Add(control); grid.Tap += ShowPropertiesControls; control.Manipulated += OnControlManipulated; } pivotItem.Content = grid; FilterPreviewPivot.Items.Add(pivotItem); filter.Resolution = new Size(DefaultOutputResolutionWidth, DefaultOutputResolutionHeight); } HintTextBackground.Fill = FilterEffects.DataContext.Singleton.ThemeBackgroundBrush(); FilterPreviewPivot.SelectionChanged += FilterPreviewPivot_SelectionChanged; }
public override bool AttachControl(FilterPropertiesControl control) { _control = control; Grid grid = new Grid(); int rowIndex = 0; TextBlock brightnessText = new TextBlock(); brightnessText.Text = AppResources.Brightness; Grid.SetRow(brightnessText, rowIndex++); Slider brightnessSlider = new Slider(); brightnessSlider.Minimum = 0.0; brightnessSlider.Maximum = 1.0; brightnessSlider.Value = _lomoFilter.Brightness; brightnessSlider.ValueChanged += brightnessSlider_ValueChanged; Grid.SetRow(brightnessSlider, rowIndex++); TextBlock saturationText = new TextBlock(); saturationText.Text = AppResources.Saturation; Grid.SetRow(saturationText, rowIndex++); Slider saturationSlider = new Slider(); saturationSlider.Minimum = 0.0; saturationSlider.Maximum = 1.0; saturationSlider.Value = _lomoFilter.Saturation; saturationSlider.ValueChanged += saturationSlider_ValueChanged; Grid.SetRow(saturationSlider, rowIndex++); TextBlock lomoVignettingText = new TextBlock(); lomoVignettingText.Text = AppResources.LomoVignetting; Grid.SetRow(lomoVignettingText, rowIndex++); RadioButton highRadioButton = new RadioButton(); highRadioButton.GroupName = _lomoVignettingGroup; TextBlock textBlock = new TextBlock(); textBlock.Text = AppResources.High; highRadioButton.Content = textBlock; highRadioButton.Checked += highRadioButton_Checked; Grid.SetRow(highRadioButton, rowIndex++); RadioButton medRadioButton = new RadioButton(); medRadioButton.GroupName = _lomoVignettingGroup; textBlock = new TextBlock(); textBlock.Text = AppResources.Medium; medRadioButton.Content = textBlock; medRadioButton.Checked += medRadioButton_Checked; Grid.SetRow(medRadioButton, rowIndex++); RadioButton lowRadioButton = new RadioButton(); lowRadioButton.GroupName = _lomoVignettingGroup; textBlock = new TextBlock(); 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; }
public override bool AttachControl(FilterPropertiesControl control) { return false; }
/// <summary> /// Shows the filter property controls. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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> /// Associates the given control with this filter and creates the /// control UI components. /// </summary> /// <param name="control">The control to attach.</param> /// <returns>True if the filter supports a control. False otherwise.</returns> public abstract bool AttachControl(FilterPropertiesControl control);
public override bool AttachControl(FilterPropertiesControl control) { _control = control; Grid grid = new Grid(); int rowIndex = 0; TextBlock brightnessText = new TextBlock(); brightnessText.Text = AppResources.Brightness; Grid.SetRow(brightnessText, rowIndex++); Slider brightnessSlider = new Slider(); brightnessSlider.Minimum = 0.0; brightnessSlider.Maximum = 1.0; brightnessSlider.Value = _lomoFilter.Brightness; brightnessSlider.ValueChanged += brightnessSlider_ValueChanged; Grid.SetRow(brightnessSlider, rowIndex++); TextBlock saturationText = new TextBlock(); saturationText.Text = AppResources.Saturation; Grid.SetRow(saturationText, rowIndex++); Slider saturationSlider = new Slider(); saturationSlider.Minimum = 0.0; saturationSlider.Maximum = 1.0; saturationSlider.Value = _lomoFilter.Saturation; saturationSlider.ValueChanged += saturationSlider_ValueChanged; Grid.SetRow(saturationSlider, rowIndex++); TextBlock lomoVignettingText = new TextBlock(); lomoVignettingText.Text = AppResources.LomoVignetting; Grid.SetRow(lomoVignettingText, rowIndex++); RadioButton highRadioButton = new RadioButton(); highRadioButton.GroupName = _lomoVignettingGroup; TextBlock textBlock = new TextBlock(); textBlock.Text = AppResources.High; highRadioButton.Content = textBlock; highRadioButton.Checked += highRadioButton_Checked; Grid.SetRow(highRadioButton, rowIndex++); RadioButton medRadioButton = new RadioButton(); medRadioButton.GroupName = _lomoVignettingGroup; textBlock = new TextBlock(); textBlock.Text = AppResources.Medium; medRadioButton.Content = textBlock; medRadioButton.Checked += medRadioButton_Checked; Grid.SetRow(medRadioButton, rowIndex++); RadioButton lowRadioButton = new RadioButton(); lowRadioButton.GroupName = _lomoVignettingGroup; textBlock = new TextBlock(); 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); }
public override bool AttachControl(FilterPropertiesControl control) { return(false); }