private void StatusLabel_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Label source = (Label)e.Source; string idStr = source.Name.Split('_')[1]; int id = idStr == "A" ? -1 : int.Parse(idStr); if (id == -1) { return; } EditStatus window = new EditStatus(_statusList, _statusList[id]); window.ShowDialog(); bool succeeded = _statusList.Find(_statusList[id].DisplayColor) >= 0 && _statusList.Find(_statusList[id].Description) >= 0; while (!succeeded) { MessageBox.Show("The description or color of the new status is duplicated!"); window = new EditStatus(_statusList, _statusList[id]); window.ShowDialog(); succeeded = _statusList.Find(_statusList[id].DisplayColor) >= 0 && _statusList.Find(_statusList[id].Description) >= 0; } RefreshStatusPanel(); }
private void Cell_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e) { // Show status panel Rectangle cell = (Rectangle)e.Source; int index0 = 0, index1 = 0; //MessageBox.Show(cell.Name); //MessageBox.Show(cell.Name); PresentationSource source = PresentationSource.FromVisual(this); double dpiX = 0; double dpiY = 0; if (source?.CompositionTarget != null) { dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11; dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22; } var mousePosition = PointToScreen(e.GetPosition(this)); if (cell.Name != "ResultCell") { index0 = int.Parse(cell.Name.Split('_')[1]); index1 = int.Parse(cell.Name.Split('_')[2]); } StatusWindow statusWindow = new StatusWindow(_statusList, cell, true) { Left = mousePosition.X * 96.0 / dpiX, Top = mousePosition.Y * 96.0 / dpiY }; statusWindow.ShowDialog(); if (cell.Name == "ResultCell") { _rule.Result = _statusList.Find(((SolidColorBrush)cell.Fill).Color); } else { _rule[index0 - _rule.Left, index1 - _rule.Top] = _statusList.Find(((SolidColorBrush)cell.Fill).Color); for (int i = 0; i < 8; ++i) { RefreshRuleRotateCanvas(i); } } }
private void ResetButton_Click(object sender, MouseButtonEventArgs e) { //MessageBox.Show(cell.Name); Rectangle newCell = new Rectangle(); newCell.Fill = Brushes.Black; PresentationSource source = PresentationSource.FromVisual(this); double dpiX = 0; double dpiY = 0; if (source?.CompositionTarget != null) { dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11; dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22; } var mousePosition = this.PointToScreen(e.GetPosition(this)); StatusWindow statusWindow = new StatusWindow(_status, newCell, false) { Left = mousePosition.X * 96.0 / dpiX, Top = mousePosition.Y * 96.0 / dpiY }; statusWindow.ShowDialog(); for (int i = 0; i < _map.Width; ++i) { for (int j = 0; j < _map.Height; ++j) { _map[i, j] = _status.Find(((SolidColorBrush)newCell.Fill).Color); } } for (int i = 0; i < _map.Width; ++i) { for (int j = 0; j < _map.Height; ++j) { _cells[i, j].Fill = new SolidColorBrush(_status[_map[i, j]].DisplayColor); } } }