protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { if (!this.IsEnabled) { return; } base.OnMouseLeftButtonDown(e); string backcolor = "#55000000"; ColorAnimation colorChangeAnimation = new ColorAnimation { To = CColor.ChangeColorBrightness((Color)ColorConverter.ConvertFromString(backcolor), (float)-0.1), Duration = new Duration(new TimeSpan(0, 0, 0, 0, 100)) }; PropertyPath colorTargetPath = new PropertyPath("(Background).(SolidColorBrush.Color)"); Storyboard CellBackgroundChangeStory = new Storyboard(); Storyboard.SetTarget(colorChangeAnimation, this); Storyboard.SetTargetProperty(colorChangeAnimation, colorTargetPath); CellBackgroundChangeStory.Children.Add(colorChangeAnimation); CellBackgroundChangeStory.Begin(); }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); string backcolor = ""; if (C_ButtonType == ButtonType.close) { backcolor = "#FFE81123"; } else if (C_ButtonType == ButtonType.minimize || C_ButtonType == ButtonType.maximize) { backcolor = "#22FFFFFF"; } ColorAnimation colorChangeAnimation = new ColorAnimation { To = CColor.ChangeColorBrightness((Color)ColorConverter.ConvertFromString(backcolor), (float)-0.1), Duration = new Duration(new TimeSpan(0, 0, 0, 0, 100)) }; PropertyPath colorTargetPath = new PropertyPath("(Background).(SolidColorBrush.Color)"); Storyboard CellBackgroundChangeStory = new Storyboard(); Storyboard.SetTarget(colorChangeAnimation, this); Storyboard.SetTargetProperty(colorChangeAnimation, colorTargetPath); CellBackgroundChangeStory.Children.Add(colorChangeAnimation); CellBackgroundChangeStory.Begin(); }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnMouseLeftButtonUp(e); ColorAnimation colorChangeAnimation = new ColorAnimation { To = CColor.ChangeColorBrightness((Color)ColorConverter.ConvertFromString("#00000000"), (float)0.15), Duration = new Duration(new TimeSpan(0, 0, 0, 0, 100)) }; PropertyPath colorTargetPath = new PropertyPath("(Background).(SolidColorBrush.Color)"); Storyboard CellBackgroundChangeStory = new Storyboard(); Storyboard.SetTarget(colorChangeAnimation, this); Storyboard.SetTargetProperty(colorChangeAnimation, colorTargetPath); CellBackgroundChangeStory.Children.Add(colorChangeAnimation); CellBackgroundChangeStory.Begin(); }