void ReleaseDesignerOutlets() { if (ButtonOAuth != null) { ButtonOAuth.Dispose(); ButtonOAuth = null; } if (ButtonRemove != null) { ButtonRemove.Dispose(); ButtonRemove = null; } if (LabelIdentity != null) { LabelIdentity.Dispose(); LabelIdentity = null; } if (LabelIdentityText != null) { LabelIdentityText.Dispose(); LabelIdentityText = null; } if (LabelRefresh != null) { LabelRefresh.Dispose(); LabelRefresh = null; } if (LabelRefreshText != null) { LabelRefreshText.Dispose(); LabelRefreshText = null; } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { // Initialize controls CheckBoxRandom.IsChecked = false; ComboBoxColorSpace.Items.Add(Cmy.FriendlyName); ComboBoxColorSpace.Items.Add(Cmyk.FriendlyName); ComboBoxColorSpace.Items.Add(Hsl.FriendlyName); ComboBoxColorSpace.Items.Add(Hsv.FriendlyName); ComboBoxColorSpace.Items.Add(HunterLab.FriendlyName); ComboBoxColorSpace.Items.Add(Lab.FriendlyName); ComboBoxColorSpace.Items.Add(Lch.FriendlyName); ComboBoxColorSpace.Items.Add(Luv.FriendlyName); ComboBoxColorSpace.Items.Add(Rgb.FriendlyName); ComboBoxColorSpace.Items.Add(Rgba.FriendlyName); ComboBoxColorSpace.Items.Add(Xyz.FriendlyName); ComboBoxColorSpace.Items.Add(Yxy.FriendlyName); ComboBoxColorSpace.SelectedValue = Rgba.FriendlyName; ListBoxColorSet.ItemsSource = Colors; // Configure bindings (enable / disable) var binding = new Binding("SelectedItems.Count") { Source = ListBoxColorSet, Converter = new PositiveIntegerToBoolConverter() }; ButtonRemove.SetBinding(IsEnabledProperty, binding); // Configure bindings (Random = true) binding = new Binding("IsChecked") { Source = CheckBoxRandom, Converter = new BooleanToVisibilityConverter() }; TextBlockLabelA2.SetBinding(VisibilityProperty, binding); TextBlockLabelAMin.SetBinding(VisibilityProperty, binding); TextBlockLabelAMax.SetBinding(VisibilityProperty, binding); TextBoxValueA2.SetBinding(VisibilityProperty, binding); SliderA2.SetBinding(VisibilityProperty, binding); TextBlockLabelB2.SetBinding(VisibilityProperty, binding); TextBlockLabelBMin.SetBinding(VisibilityProperty, binding); TextBlockLabelBMax.SetBinding(VisibilityProperty, binding); TextBoxValueB2.SetBinding(VisibilityProperty, binding); SliderB2.SetBinding(VisibilityProperty, binding); TextBlockLabelC2.SetBinding(VisibilityProperty, binding); TextBlockLabelCMin.SetBinding(VisibilityProperty, binding); TextBlockLabelCMax.SetBinding(VisibilityProperty, binding); TextBoxValueC2.SetBinding(VisibilityProperty, binding); SliderC2.SetBinding(VisibilityProperty, binding); CheckBoxIncrement.SetBinding(VisibilityProperty, binding); ButtonRandomize.SetBinding(VisibilityProperty, binding); // Configure bindings (ColorSpace = CMYK) binding = new Binding("SelectedValue") { Source = ComboBoxColorSpace, Converter = new ColorSpaceToVisibilityConverter() }; TextBlockLabelD1.SetBinding(VisibilityProperty, binding); TextBoxValueD1.SetBinding(VisibilityProperty, binding); SliderD1.SetBinding(VisibilityProperty, binding); // Configure bindings (Random = true && ColorSpace = CMYK) var bindings = new[] { new Binding("SelectedValue") { Source = ComboBoxColorSpace }, new Binding("IsChecked") { Source = CheckBoxRandom } }; var multiBinding = new MultiBinding() { Converter = new ColorSpaceToVisibilityMultiConverter() }; foreach (var bindingPart in bindings) { multiBinding.Bindings.Add(bindingPart); } TextBlockLabelD2.SetBinding(VisibilityProperty, multiBinding); TextBlockLabelDMin.SetBinding(VisibilityProperty, multiBinding); TextBlockLabelDMax.SetBinding(VisibilityProperty, multiBinding); TextBoxValueD2.SetBinding(VisibilityProperty, multiBinding); SliderD2.SetBinding(VisibilityProperty, multiBinding); // Configure bindings (Current color rectangles) _currentColor1Binding = new Binding("CurrentColor1") { Source = this, Converter = new ColorSpaceToSolidColorBrushConverter() }; RectangleCurrentColor1.SetBinding(Shape.FillProperty, _currentColor1Binding); _currentColor2Binding = new Binding("CurrentColor2") { Source = this, Converter = new ColorSpaceToSolidColorBrushConverter() }; RectangleCurrentColor2.SetBinding(Shape.FillProperty, _currentColor2Binding); _randomColorBinding = new Binding("RandomColor") { Source = this, Converter = new ColorSpaceToSolidColorBrushConverter() }; RectangleRandomColor1.SetBinding(Shape.FillProperty, _currentColor1Binding); RectangleRandomColor2.SetBinding(Shape.FillProperty, _currentColor2Binding); }
private void ButtonRemove_GotFocus(object sender, RoutedEventArgs e) { ButtonRemove.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); }