Exemple #1
0
        /// <summary>
        /// 在派生类中重写后,每当应用程序代码或内部进程调用 <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>,都将调用此方法。
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //初始化控件部件
            shadeCanvas    = this.Template.FindName("PART_ColorShadeCanvas", this) as Canvas;
            shadeSelector  = this.Template.FindName("PART_ColorShadeSelector", this) as FrameworkElement;
            spectrumSlider = this.Template.FindName("PART_ColorSpectrumSlider", this) as ColorSpectrumSlider;
            tbA            = this.Template.FindName("PART_TextBoxA", this) as TextBox;
            tbR            = this.Template.FindName("PART_TextBoxR", this) as TextBox;
            tbG            = this.Template.FindName("PART_TextBoxG", this) as TextBox;
            tbB            = this.Template.FindName("PART_TextBoxB", this) as TextBox;
            tbHexString    = this.Template.FindName("PART_TextBoxHexString", this) as TextBox;

            //为控件部件添加事件处理程序
            shadeCanvas.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(shadeCanvas_PreviewMouseLeftButtonDown);
            shadeCanvas.MouseMove         += new MouseEventHandler(shadeCanvas_MouseMove);
            shadeCanvas.MouseLeftButtonUp += new MouseButtonEventHandler(shadeCanvas_MouseLeftButtonUp);
            spectrumSlider.ValueChanged   += new RoutedPropertyChangedEventHandler <double>(spectrumSlider_ValueChanged);

            //更新颜色
            UpdateColor(Color, null);
        }
Exemple #2
0
		/// <summary>
		/// 在派生类中重写后,每当应用程序代码或内部进程调用 <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>,都将调用此方法。
		/// </summary>
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			//初始化控件部件
			shadeCanvas = this.Template.FindName("PART_ColorShadeCanvas", this) as Canvas;
			shadeSelector = this.Template.FindName("PART_ColorShadeSelector", this) as FrameworkElement;
			spectrumSlider = this.Template.FindName("PART_ColorSpectrumSlider", this) as ColorSpectrumSlider;
			tbA = this.Template.FindName("PART_TextBoxA", this) as TextBox;
			tbR = this.Template.FindName("PART_TextBoxR", this) as TextBox;
			tbG = this.Template.FindName("PART_TextBoxG", this) as TextBox;
			tbB = this.Template.FindName("PART_TextBoxB", this) as TextBox;
			tbHexString = this.Template.FindName("PART_TextBoxHexString", this) as TextBox;
			
			//为控件部件添加事件处理程序
			shadeCanvas.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(shadeCanvas_PreviewMouseLeftButtonDown);
			shadeCanvas.MouseMove += new MouseEventHandler(shadeCanvas_MouseMove);
			shadeCanvas.MouseLeftButtonUp += new MouseButtonEventHandler(shadeCanvas_MouseLeftButtonUp);
			spectrumSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(spectrumSlider_ValueChanged);

			//更新颜色
			UpdateColor(Color, null);
		}