예제 #1
0
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            LabelX.Content = "X = " + e.GetPosition(CanvasMain).X;
            LabelY.Content = "Y = " + e.GetPosition(CanvasMain).Y;
            var point = e.GetPosition(CanvasMain);

            if (_isDraw && !_isMove && (e.LeftButton == MouseButtonState.Pressed))
            {
                _x2 = point.X;
                _y2 = point.Y;
                ChangingObjects();

                PrintFigure(_figures[_tag]);
                if (_isConnected)
                {
                    UdpHelper.SendFigure(Command.Point, _figures[_tag], _client, _isOneFigure);
                }

                _figures.Clear();
            }
            else if (_isMove && e.LeftButton == MouseButtonState.Pressed)
            {
                _figure.FirstPoint.X  = _oldPointFirst.X + (point.X - _x1);
                _figure.SecondPoint.X = _oldPointSecond.X + (point.X - _x1);
                _figure.FirstPoint.Y  = _oldPointFirst.Y + (point.Y - _y1);
                _figure.SecondPoint.Y = _oldPointSecond.Y + (point.Y - _y1);

                if (_isConnected)
                {
                    UdpHelper.SendFigure(Command.Move, _figure, _client, _isOneFigure);
                }

                if (_isOneFigure)
                {
                    CanvasMain.Children.Remove(_chousenShape);
                }
                else
                {
                    CanvasMain.Children.RemoveAt(CanvasMain.Children.Count - 1);
                }

                _isOneFigure = false;
                _figure.SetColor();
                _figure.Draw(CanvasMain);
                _figure.Tag = CanvasMain.Children.IndexOf(CanvasMain.Children[CanvasMain.Children.Count - 1]);
                _shape.Figures.Add(_figure);
                SetEventOnLastFigure();
            }
        }
예제 #2
0
        private void Canvas_MouseDown(object sender, MouseEventArgs e)
        {
            var point = e.GetPosition(CanvasMain);

            _x1          = point.X;
            _y1          = point.Y;
            _isDraw      = true;
            _isOneFigure = _isMove;
            if (_isConnected)
            {
                if (!_isMove)
                {
                    UdpHelper.SendFigure(Command.BeginPaint, new Line(), _client, _isOneFigure);
                }
            }
        }