public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();


            FillRadioButton = GetTemplateChild("FillRadioButton") as RadioButton;
            if (FillRadioButton != null)
                FillRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);

            BorderRadioButton = GetTemplateChild("BorderRadioButton") as RadioButton;
            if(BorderRadioButton != null)
                BorderRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);

            ColorPickerSection = GetTemplateChild("ColorPickerSection") as ContentControl;

            FillColorPicker = GetTemplateChild("FillColorPicker") as ColorPicker;
            if(FillColorPicker != null)
                FillColorPicker.ColorChanged += new EventHandler(FillColorPicker_ColorChanged);

            PreDefinedColorRampControl = GetTemplateChild("PreDefinedColorRampControl") as PreDefinedColorRampControl;
            if (PreDefinedColorRampControl != null)
                PreDefinedColorRampControl.GradientBrushChanged += new EventHandler<GradientBrushChangedEventArgs>(onGradientBrushChanged);

            BorderColorPicker = GetTemplateChild("BorderColorPicker") as ColorPicker;
            if(BorderColorPicker != null)
                BorderColorPicker.ColorChanged += new EventHandler(BorderColorPicker_ColorChanged);

            FillOpacityPanel = GetTemplateChild("FillOpacityPanel") as ContentControl;

            FillOpacitySlider = GetTemplateChild("FillOpacitySlider") as Slider;
            if (FillOpacitySlider != null)
                FillOpacitySlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(FillSlider_ValueChanged);                

            BorderOpacityPanel = GetTemplateChild("BorderOpacityPanel") as ContentControl;

            BorderOpacitySlider = GetTemplateChild("BorderOpacitySlider") as Slider;
            if(BorderOpacitySlider != null)
                BorderOpacitySlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(BorderSlider_ValueChanged);

            BorderWidthPanel = GetTemplateChild("BorderWidthPanel") as ContentControl;
            BorderWidthTextBox = GetTemplateChild("BorderWidthTextBox") as TextBox;
            if (BorderWidthTextBox != null)
            {
                BorderWidthTextBox.SetBinding(TextBox.TextProperty, new Binding() { 
                    Source = DataContext,
                    Mode = BindingMode.TwoWay,
                    Path = new PropertyPath("BorderThickness"),
                });
            }

            Initialize();
            if (PreDefinedColorRampControl != null)
                PreDefinedColorRampControl.Initialize();
        }        
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ColorPicker = GetTemplateChild("ColorPicker") as ColorPicker;
            PreDefinedColorRampControl = GetTemplateChild("PreDefinedColorRampControl") as PreDefinedColorRampControl;
            OpacitySlider = GetTemplateChild("OpacitySlider") as Slider;
            WidthTextBox = GetTemplateChild("WidthTextBox") as TextBox;

            attachEventsAndBindings();

            Initialize();
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            BackgroundColorPicker = GetTemplateChild("BackgroundColorPicker") as ColorPicker;
            if (BackgroundColorPicker != null)
            {
                loadBackgroundColorPicker();
                BackgroundColorPicker.ColorChanged += new EventHandler(BackgroundColorPicker_ColorChanged);
            }

            ForegroundColorPicker = GetTemplateChild("ForegroundColorPicker") as ColorPicker;
            if (ForegroundColorPicker != null)
            {
                loadForegroundColorPicker();
                ForegroundColorPicker.ColorChanged += new EventHandler(ForegroundColorPicker_ColorChanged);
            }

            BackgroundRadioButton = GetTemplateChild("BackgroundRadioButton") as RadioButton;
            if (BackgroundRadioButton != null)
            {
                BackgroundRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);
                BackgroundRadioButton.Unchecked += new RoutedEventHandler(RadioButton_UnChecked);
            }

            ForegroundRadioButton = GetTemplateChild("ForegroundRadioButton") as RadioButton;
            if (ForegroundRadioButton != null)
            {
                ForegroundRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);
                ForegroundRadioButton.Unchecked += new RoutedEventHandler(RadioButton_UnChecked);
            }

            ToleranceTextBox = GetTemplateChild("ToleranceTextBox") as TextBox;
            if (ToleranceTextBox != null)
            {
                ToleranceTextBox.SetBinding(TextBox.TextProperty, new Binding() { 
                     Mode = System.Windows.Data.BindingMode.TwoWay,
                     Path = new PropertyPath("MaximumFlareCount"),
                     Source = DataContext
                });
            }

            OkButton = GetTemplateChild("OkButton") as Button;
            if (OkButton != null)
                OkButton.Click += new RoutedEventHandler(OkButton_Click);

            CancelButton = GetTemplateChild("CancelButton") as Button;
            if(CancelButton != null)
                CancelButton.Click += new RoutedEventHandler(CancelButton_Click);
        }
示例#4
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();


            FillRadioButton = GetTemplateChild("FillRadioButton") as RadioButton;
            if (FillRadioButton != null)
            {
                FillRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);
            }

            BorderRadioButton = GetTemplateChild("BorderRadioButton") as RadioButton;
            if (BorderRadioButton != null)
            {
                BorderRadioButton.Checked += new RoutedEventHandler(RadioButton_Checked);
            }

            ColorPickerSection = GetTemplateChild("ColorPickerSection") as ContentControl;

            FillColorPicker = GetTemplateChild("FillColorPicker") as ColorPicker;
            if (FillColorPicker != null)
            {
                FillColorPicker.ColorChanged += new EventHandler(FillColorPicker_ColorChanged);
            }

            PreDefinedColorRampControl = GetTemplateChild("PreDefinedColorRampControl") as PreDefinedColorRampControl;
            if (PreDefinedColorRampControl != null)
            {
                PreDefinedColorRampControl.GradientBrushChanged += new EventHandler <GradientBrushChangedEventArgs>(onGradientBrushChanged);
            }

            BorderColorPicker = GetTemplateChild("BorderColorPicker") as ColorPicker;
            if (BorderColorPicker != null)
            {
                BorderColorPicker.ColorChanged += new EventHandler(BorderColorPicker_ColorChanged);
            }

            FillOpacityPanel = GetTemplateChild("FillOpacityPanel") as ContentControl;

            FillOpacitySlider = GetTemplateChild("FillOpacitySlider") as Slider;
            if (FillOpacitySlider != null)
            {
                FillOpacitySlider.ValueChanged += new RoutedPropertyChangedEventHandler <double>(FillSlider_ValueChanged);
            }

            BorderOpacityPanel = GetTemplateChild("BorderOpacityPanel") as ContentControl;

            BorderOpacitySlider = GetTemplateChild("BorderOpacitySlider") as Slider;
            if (BorderOpacitySlider != null)
            {
                BorderOpacitySlider.ValueChanged += new RoutedPropertyChangedEventHandler <double>(BorderSlider_ValueChanged);
            }

            BorderWidthPanel   = GetTemplateChild("BorderWidthPanel") as ContentControl;
            BorderWidthTextBox = GetTemplateChild("BorderWidthTextBox") as TextBox;
            if (BorderWidthTextBox != null)
            {
                BorderWidthTextBox.SetBinding(TextBox.TextProperty, new Binding()
                {
                    Source = DataContext,
                    Mode   = BindingMode.TwoWay,
                    Path   = new PropertyPath("BorderThickness"),
                });
            }

            Initialize();
            if (PreDefinedColorRampControl != null)
            {
                PreDefinedColorRampControl.Initialize();
            }
        }