private void ColorBtn_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; SolidColorBrush brush = (SolidColorBrush)btn.Background; Debug.WriteLine("ColorBtn_Click"); ColorClicked?.Invoke(brush); }
public IssueRowViewModel(Issue issue, WorkLogCore workLog, CollectionEventAggregator colorClickedAggregator, IssueColors issueColors) { Issue = issue; Name = Issue.Name; TimeText = ProjectedObservableValue <string> .FromObservableValue(issue.TotalLoggedTime, time => time.ToString("h\\:mm")); Color = issueColors.GetColor(Issue); Background = ProjectedObservableValue <Brush> .FromObservableValue(workLog.Logger.RunningIssue, runningIssue => runningIssue == Issue?Brushes.LightGreen : Brushes.White); StartStopButtonText = ProjectedObservableValue <string> .FromObservableValue(workLog.Logger.RunningIssue, runningIssue => runningIssue == Issue? "Stop" : "Start"); StartStopButtonCommand = new DelegateCommand(() => workLog.Logger.StartStop(Issue)); RemoveButtonCommand = new DelegateCommand(() => { if (MessageBox.Show($"Do you want to delete '{Name}' issue and its logged time?", "Remove issue", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { workLog.Issues.Remove(Issue); issueColors.RemoveColor(Issue); } }); ColorClickedCommand = new DelegateCommand(() => ColorClicked?.Invoke(this, EventArgs.Empty)); colorClickedAggregator.ItemChanged += (sender, e) => IsColorChecked.Value = sender == this && IsColorChecked.Value == false; }
private void OnColorClicked(int index, MouseButtons buttons) { ColorClicked?.Invoke(this, new EventArgs <Pair <int, MouseButtons> >(Pair.Create(index, buttons))); }