public override void OnApplyTemplate() { base.OnApplyTemplate(); stopAnglePanel = (Ellipse)GetTemplateChild("StopAnglePanel"); stopColorPanel = (Rectangle)GetTemplateChild("StopColorPanel"); stopAngleArrow = (Line)GetTemplateChild("StopAngleArrow"); previewPanel = (Canvas)GetTemplateChild("PreviewPanel"); linearGradientBrush = (LinearGradientBrush)GetTemplateChild("LinearGradientBrush"); nA = (Numeric)GetTemplateChild("nA"); nL = (Numeric)GetTemplateChild("nL"); stopAnglePanel.MouseDown += new MouseButtonEventHandler(Ellipse_MouseDown); stopAnglePanel.MouseMove += new MouseEventHandler(Ellipse_MouseMove); previewPanel.MouseDown += new MouseButtonEventHandler(Canvas_MouseDown); stopColorPanel.MouseLeftButtonDown += new MouseButtonEventHandler(Rectangle_MouseLeftButtonDown); nA.ValueChanged += new RoutedEventHandler(Numeric_OpacityValueChanged); nL.ValueChanged += new RoutedEventHandler(Numeric_LocationValueChanged); GradientBrushEntity entity = new GradientBrushEntity(); entity.GradientStops.Add(new Arrow(Colors.White, 0)); entity.GradientStops.Add(new Arrow(Colors.Black, 1)); GradientBrush = entity; }
public GradientColorPicker() { DefaultStyleKey = typeof(GradientColorPicker); GradientBrush = new GradientBrushEntity(); DataContext = this; MenuItem editStopMenuItem = new MenuItem { Header = GisEditor.LanguageManager.GetStringResource("GradientColorPickerEditStopHeader") }; editStopMenuItem.Click += new RoutedEventHandler((s, e) => { SetCurrentStopColor(); }); MenuItem removeStopMenuItem = new MenuItem { Header = GisEditor.LanguageManager.GetStringResource("GradientColorPickerRemoveStopHeader") }; removeStopMenuItem.Click += new RoutedEventHandler((s, e) => { RemoveCurrentStop(); }); stopCtx = new ContextMenu(); stopCtx.Items.Add(editStopMenuItem); stopCtx.Items.Add(removeStopMenuItem); }