Example #1
0
        private void Cell_OnMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            // ShowDialog status panel
            Rectangle cell   = (Rectangle)e.Source;
            int       index0 = int.Parse(cell.Name.Split('_')[1]);
            int       index1 = int.Parse(cell.Name.Split('_')[2]);

            //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 = MainCanvas.PointToScreen(e.GetPosition(MainCanvas));

            StatusWindow statusWindow = new StatusWindow(_status, cell, false)
            {
                Left = mousePosition.X * 96.0 / dpiX,
                Top  = mousePosition.Y * 96.0 / dpiY
            };

            statusWindow.ShowDialog();

            _map[index0, index1] = _status.Find(((SolidColorBrush)cell.Fill).Color);
        }
        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);
                }
            }
        }
Example #3
0
        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);
                }
            }
        }