Example #1
0
    public override void Init(Transform trans, ITrajectoryData data)
    {
        base.Init(trans, data);
        if (data is EllipseData)
        {
            _data = data as EllipseData;
        }
        else
        {
            Debug.LogError("当前传入椭圆形路径的数据类型错误,类型为:" + data);
            return;
        }

        _data.Center = new Vector2(0, (GameUtil.GetCameraMax().y - GameUtil.GetCameraMin().y) * (float)_data.YRatioInScreen);

        float offsetY = _data.Center.y + (float)_data.YRadius;

        _enter.InitByOffsetY(_trans, 0, offsetY, EnterPath.MoveDirection.UP_TO_DOWN);

        Vector2 startPos = new Vector2(_trans.position.x, offsetY);

        _data.StartPos = startPos;

        _trajectory = new EllipseTrajectory();
        _trajectory.Init(_data);
    }
 public void StartMove(EllipseData ellipseData)
 {
     this.wayPositions       = ellipseHelper.GetEllipsePositions(ellipseData);
     this.startPositionAtWay = UnityEngine.Random.Range(0, wayPositions.Length);
     previousPointAtWay      = startPositionAtWay;
     currentPointAtWay       = AddPointAtWay(wayPositions, startPositionAtWay);
     transform.position      = wayPositions[startPositionAtWay];
     Play();
 }
Example #3
0
    private void InitTrajectory(float width)
    {
        EllipseData data = new EllipseData();

        data.XRadius = width / 2;
        data.YRadius = 0.3f;
        var pos = transform.position;

        pos.y      -= (float)data.YRadius;
        _centerX    = pos.x;
        data.Center = pos;

        _trajectory = new EllipseTrajectory();
        _trajectory.Init(data);
    }
        private void DeleteComment(EllipseData ed)
        {
            if (_ellipses.Contains(ed))
            {
                _ellipses.Remove(ed);
                EyeCanvas.Children.Remove(ed.Figure);
            }

            if (!_commentBinding.Contains(ed.Text))
            {
                return;
            }
            _programSelect = true;
            _commentBinding.Remove(ed.Text);
            _programSelect = false;
        }
Example #5
0
    public void Init(ITrajectoryData data)
    {
        if (data is EllipseData)
        {
            _data = data as EllipseData;
        }
        else
        {
            Debug.LogError("当前数据不是EllipseData类型,类型为:" + data);
            return;
        }

        _xRadius = (float)_data.XRadius;
        _yRadius = (float)_data.YRadius;
        InitPos(_data);
        _middleIndex = _posList.Length / 2;
        _curIndex    = GetStartIndex(_posList, _data.StartPos);
    }
        private void SelectEllipseCond(EllipseData ellipseData, bool select)
        {
            Point relativePoint = ellipseData.Figure.TransformToAncestor(EyeCanvas)
                                  .Transform(new Point(0, 0));
            // Если выделение, то эллипс в 2 раза больше и красный
            int   dims   = select ? 40 : 20;
            int   offset = select ? -10 : 10;
            Brush cl     = select ? Brushes.Red : Brushes.Orange;

            ellipseData.Figure.Width  = dims;
            ellipseData.Figure.Height = dims;
            if (ellipseData.Figure.Stroke != cl)
            {
                Canvas.SetLeft(ellipseData.Figure, relativePoint.X + offset);
                Canvas.SetTop(ellipseData.Figure, relativePoint.Y + offset);
            }
            ellipseData.Figure.Stroke = cl;
        }
        public Tuple <double[], double[], string[]> GetComments()
        {
            double[] xses  = new double[_ellipses.Count];
            double[] yses  = new double[_ellipses.Count];
            string[] texts = new string[_ellipses.Count];


            for (int i = 0; i < _ellipses.Count; i++)
            {
                EllipseData ed            = _ellipses[i];
                Point       relativePoint = ed.Figure.TransformToAncestor(EyeCanvas)
                                            .Transform(new Point(0, 0));
                xses[i]  = relativePoint.X / EyeCanvas.Width * 100;
                yses[i]  = relativePoint.Y / EyeCanvas.Height * 100;
                texts[i] = ed.Text;
            }

            return(Tuple.Create(xses, yses, texts));
        }
        private void ImageMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!_isPlacing)
            {
                return;
            }
            _lastPos = Mouse.GetPosition(EyeCanvas);
            TextHelperForm t = new TextHelperForm();

            if (t.ShowDialog() != true)
            {
                _isPlacing = false;
                return;
            }

            string text = t.Text;

            Ellipse ell = new Ellipse
            {
                Width           = 20,
                Height          = 20,
                Stroke          = Brushes.Orange,
                Fill            = Brushes.Transparent,
                StrokeThickness = 4
            };

            EllipseData ed = new EllipseData
            {
                Text   = text,
                Figure = ell
            };

            ell.MouseRightButtonDown += (ssender, args) => DeleteComment(ed);
            _ellipses.Add(ed);

            Canvas.SetLeft(ell, _lastPos.X - 5);
            Canvas.SetTop(ell, _lastPos.Y - 5);
            EyeCanvas.Children.Add(ell);
            _commentBinding.Add(text);
            _isPlacing           = false;
            AddComment.IsEnabled = true;
        }
Example #9
0
        public void DrawEllipse()
        {
            var request = new EllipseData();

            request.PinX   = 5;
            request.PinY   = 5;
            request.Width  = 1;
            request.Height = 1;
            request.Text   = "test draw ellipse";
            var shapeStyleData = new ShapeStyleData();

            shapeStyleData.FillBackGroundColor = "#FF0000";
            var textStyleData = new TextStyleData();

            textStyleData.FontSize = 0.25;
            textStyleData.FontName = "Times New Roman";
            request.ShapeStyleData = shapeStyleData;
            request.TextStyleData  = textStyleData;

            var response = diagramApi.PutDrawEllipse(fileName, pageName, request, StorageTestFOLDER);

            Assert.IsTrue(response.IsSuccess);
        }
Example #10
0
    private void InitPos(EllipseData data)
    {
        int   count = GetVailCount(data.Precision);
        float xLeft = data.Center.x - _xRadius;

        //x轴上的坐标分成多少份,举例,顶点为4个,x轴上坐标要被分成2份
        int   partCount   = count / 2;
        int   xPointCount = partCount + 1;
        float x           = xLeft;

        float[] y;
        _posList = new Vector3[count];
        float xOffset = _xRadius * 2 / partCount;

        for (int i = 0; i < xPointCount; i++)
        {
            y = GetY(x, Vector2.zero);

            if (Mathf.Abs(y[0] - _data.Center.y) < 0.01f)
            {
                _posList[i] = new Vector3(x, y[0]);
            }
            else if (y[0] > _data.Center.y)
            {
                _posList[i] = new Vector3(x, y[0]);
                _posList[_posList.Length - i] = new Vector3(x, y[1]);
            }
            else if (y[0] < _data.Center.y)
            {
                _posList[i] = new Vector3(x, y[1]);
                _posList[_posList.Length - i] = new Vector3(x, y[0]);
            }

            x += xOffset;
        }
    }