Esempio n. 1
0
        private void Canvas_OnMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (Condition == null)
            {
                return;
            }
            var ic = PointMatrixPick.CreateICFromPick(Condition);
            var p  = e.GetPosition(Canvas);
            var X  = _x + _scale * p.X / (Canvas.Width / (ic.Grid.CellGrid.GetLength(0)));

            if (X >= ic.Grid.CellGrid.GetLength(0))
            {
                return;
            }
            var Y = _y + _scale * p.Y / (Canvas.Height / (ic.Grid.CellGrid.GetLength(1)));

            if (Y >= ic.Grid.CellGrid.GetLength(1))
            {
                return;
            }
            _scale += Math.Sign(-e.Delta) * 0.1;
            if (_scale < 0.1)
            {
                _scale = 0.1;
            }
            if (_scale > 1)
            {
                _scale = 1;
            }

            var width   = ic.Grid.CellGrid.GetLength(0);
            var height  = ic.Grid.CellGrid.GetLength(1);
            var nwidth  = (int)(width * _scale);
            var nheight = (int)(height * _scale);
            var x       = (int)X - (nwidth / 2);
            var y       = (int)Y
                          - (nheight / 2);
            var xx = (int)X + (nwidth / 2);
            var yy = (int)Y + (nheight / 2);

            if (xx >= width)
            {
                x -= (xx - width) + 1;
            }
            if (yy >= height)
            {
                y -= (yy - height) + 1;
            }
            if (x < 0)
            {
                x = 0;
            }
            if (y < 0)
            {
                y = 0;
            }
            _x        = x;
            _y        = y;
            Condition = PointMatrixPick.CreatePickFromIC(ic, Condition);
        }
Esempio n. 2
0
        private void UpdateScreen()
        {
            Canvas.Children.Clear();
            var ic = PointMatrixPick.CreateICFromPick(Condition);

            Canvas.Children.Add(new Image
            {
                Source =
                    GenerateImage(_x, _y, (int)(ic.Grid.CellGrid.GetLength(0) * _scale),
                                  (int)(ic.Grid.CellGrid.GetLength(1) * _scale))
            });
        }
Esempio n. 3
0
        private void Canvas_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (Operation.None == _selectedOperation)
            {
                return;
            }

            if (_comboBox.SelectedIndex < 0)
            {
                return;
            }
            var p  = e.GetPosition(Canvas);
            var ic = PointMatrixPick.CreateICFromPick(Condition);
            var x  = _x + _scale * p.X / (Canvas.Width / (ic.Grid.CellGrid.GetLength(0)));

            if (x >= ic.Grid.CellGrid.GetLength(0))
            {
                return;
            }
            var y = _y + _scale * p.Y / (Canvas.Height / (ic.Grid.CellGrid.GetLength(1)));

            if (y >= ic.Grid.CellGrid.GetLength(1))
            {
                return;
            }
            if (Operation.Check == _selectedOperation)
            {
                ic.Grid.CellGrid[(int)x, (int)y].Value = InitialConditions.GetTransformation((int)MatrixCount)(_comboBox.SelectedIndex);
            }
            else
            {
                var k = ic.Grid.CellGrid[(int)x, (int)y].Value;
                for (var i = 0; i < ic.Grid.CellGrid.GetLength(0); i++)
                {
                    for (var j = 0; j < ic.Grid.CellGrid.GetLength(1); j++)
                    {
                        if (ic.Grid.CellGrid[i, j].Value == k)
                        {
                            ic.Grid.CellGrid[i, j].Value = InitialConditions.GetTransformation((int)MatrixCount)(_comboBox.SelectedIndex);
                        }
                    }
                }
            }
            Condition = PointMatrixPick.CreatePickFromIC(ic, Condition);
        }
Esempio n. 4
0
        private DrawingImage GenerateImage(int x, int y, int width, int height)
        {
            var ic = PointMatrixPick.CreateICFromPick(Condition);

            return(ic.Grid.GenerateImage(x, y, width, height, Canvas.Width, Canvas.Height));
        }