Ejemplo n.º 1
0
        public void Move(Figure selected, Point pos)
        {
            switch (selected.Type)
            {
            case Figure.FigureType.Rect:
                _moved = true;
                MoveRect((RectFigure)selected, pos);
                break;

            case Figure.FigureType.Ellipse:
                _moved = true;
                MoveEllipse((EllipseFigure)selected, pos);
                break;

            case Figure.FigureType.Line:
                _moved = true;
                MoveLine((LineFigure)selected, pos);
                break;

            case Figure.FigureType.Text:
                _moved = true;
                MoveText((TextFigure)selected, pos);
                break;
            }

            if ((_nowMoving != null) && ((_nowMoving.Iterations != -1) || (StepManager.FinalStep != null)))
            {
                StepManager.RefreshToCurrentStep();
            }
        }
Ejemplo n.º 2
0
 private void textBox5_TextChanged(object sender, EventArgs e)
 {
     if (_ignoreTextChanged)
     {
         return;
     }
     if (StepManager.CurrentStep is DrawStep)
     {
         var ds = (DrawStep) StepManager.CurrentStep;
         if (ds.StepType == DrawStep.DrawStepType.DrawRect)
         {
             ((DrawRectStep) ds).Figure.FigureColor.Parse(textBox5.Text);
         }
         else if (ds.StepType == DrawStep.DrawStepType.DrawLine)
         {
             ((DrawLineStep) ds).Figure.FigureColor.Parse(textBox5.Text);
         }
         else if (ds.StepType == DrawStep.DrawStepType.DrawText)
         {
             ((DrawTextStep) ds).Figure.FigureColor.Parse(textBox5.Text);
         }
     }
     if ((StepManager.CurrentStep.Iterations != -1) || (StepManager.FinalStep != null))
     {
         StepManager.RefreshToCurrentStep();
     }
     else
     {
         MainForm.RedrawNeeded?.Invoke();
     }
 }
Ejemplo n.º 3
0
        public void Start(Point pos)
        {
            _startPos = pos;

            switch (DrawStepType)
            {
            case DrawStep.DrawStepType.DrawRect:
                _nowDrawing = StartDrawRect();
                break;

            case DrawStep.DrawStepType.DrawEllipse:
                _nowDrawing = StartDrawEllipse();
                break;

            case DrawStep.DrawStepType.DrawLine:
                _nowDrawing = StartDrawLine();
                break;

            case DrawStep.DrawStepType.DrawText:
                _nowDrawing = StartDrawText();
                break;
            }

            StepManager.InsertNext(_nowDrawing);

            if (_nowDrawing.Iterations != -1)
            {
                StepManager.RefreshToCurrentStep();
            }
        }
Ejemplo n.º 4
0
        public void Move(Point pos)
        {
            if (_nowDrawing != null)
            {
                switch (DrawStepType)
                {
                case DrawStep.DrawStepType.DrawRect:
                    ResizeDrawnRect(pos);
                    break;

                case DrawStep.DrawStepType.DrawEllipse:
                    ResizeDrawnEllipse(pos);
                    break;

                case DrawStep.DrawStepType.DrawLine:
                    ResizeDrawnLine(pos);
                    break;

                case DrawStep.DrawStepType.DrawText:
                    ResizeDrawnText(pos);
                    break;
                }
                if ((_nowDrawing.Iterations != -1) || (StepManager.FinalStep != null))
                {
                    StepManager.RefreshToCurrentStep();
                }
            }
        }
Ejemplo n.º 5
0
 private void guideLabel_Click(object sender, EventArgs e)
 {
     if (_selected != null)
     {
         _selected.IsGuide    = !_selected.IsGuide;
         guideLabel.ForeColor = _selected.IsGuide ? SystemColors.ControlText : SystemColors.ControlDark;
         StepManager.RefreshToCurrentStep();
     }
 }
Ejemplo n.º 6
0
 private void MainGraphicsOnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
 {
     Drawer.SetHostRectSize(_mainGraphics.ActualWidth, _mainGraphics.ActualHeight);
     if (StepManager.CurrentStep == null)
     {
         _mainGraphics.InvalidateVisual();
     }
     else
     {
         StepManager.RefreshToCurrentStep();
     }
 }
Ejemplo n.º 7
0
        private void canvasLabel_Click(object sender, EventArgs e)
        {
            var frm = new SetCanvasSizeForm();

            frm.SetInitialVales(Drawer.CanvasWidth, Drawer.CanvasHeight);
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                Drawer.SetCanvasSize(frm.InputWidth, frm.InputHeight);
                DataStorage.GetScalarExpression("canvas.height").SetRawExpression(Drawer.CanvasHeight.ToString());
                DataStorage.GetScalarExpression("canvas.width").SetRawExpression(Drawer.CanvasWidth.ToString());
                AddCanvasMagnets();
                StepManager.RefreshToCurrentStep();
            }
            frm.Dispose();
        }
Ejemplo n.º 8
0
 private void ValueTextBoxTextChanged(object sender, EventArgs eventArgs)
 {
     if (!_ignoreTextChange && !string.IsNullOrWhiteSpace(textBox2.Text))
     {
         if (Expr == null)
         {
             Expr = DataStorage.Add(new ScalarExpression("data", textBox1.Text, textBox2.Text));
             Expr.ValueChanged += ExprValueChanged;
         }
         else
         {
             Expr.SetRawExpression(textBox2.Text);
         }
         StepManager.RefreshToCurrentStep();
     }
 }
Ejemplo n.º 9
0
 private void markAsFinalLabel_Click(object sender, EventArgs e)
 {
     if (StepManager.CurrentStep == null)
     {
         return;
     }
     if (StepManager.FinalStep == null)
     {
         if (StepManager.CurrentStep.Iterations == -1)
         {
             StepManager.FinalStep = StepManager.CurrentStep;
             markAsFinalLabel.Text = "reset final";
         }
     }
     else
     {
         StepManager.FinalStep = null;
         markAsFinalLabel.Text = "mark as final";
     }
     StepManager.RefreshToCurrentStep();
 }
Ejemplo n.º 10
0
        public void CurrentSelectionToIterableGroup()
        {
            if (MarkedControls.Count == 0)
            {
                return;
            }
            var min = _stepControls.Count;
            var max = -1;

            for (var i = 0; i < MarkedControls.Count; ++i)
            {
                if (MarkedControls[i].Index < min)
                {
                    min = MarkedControls[i].Index;
                }
                if (MarkedControls[i].Index > max)
                {
                    max = MarkedControls[i].Index;
                }
                MarkedControls[i]
                .Step.MakeIterable(ArrayExpressionEditor.Items.Count > 1
                        ? ArrayExpressionEditor.Len
                        : 2);
                MarkedControls[i].RespectIterable();
            }
            if (max + 1 == StepManager.Steps.Count)
            {
                StepManager.Insert(new EmptyStep(), max + 1, false, null, false, true);
            }
            StepManager.IterableGroups.Add(new IterableStepGroup(ArrayExpressionEditor.Items.Count > 1
                ? string.Format("len({0})", ArrayExpressionEditor.Items[0].Expr.FullName)
                : "2")
            {
                StartIndex = min,
                Length     = max - min + 1
            });
            ClearMarked();
            ConstructList();
            StepManager.RefreshToCurrentStep();
        }
Ejemplo n.º 11
0
 private bool TryChangeData(string data)
 {
     _ignoreTextChange = true;
     if (Expr == null)
     {
         if ((ArrayExpressionEditor.Len == -1) || data.Contains(";"))
         {
             var items = data.Split(';');
             for (var i = 0; i < items.Length; ++i)
             {
                 items[i] = items[i].Trim();
                 if (items[i].Length == 0)
                 {
                     _ignoreTextChange = false;
                     return(false);
                 }
             }
             _definedAsConstVector = true;
             Expr = DataStorage.Add(new ArrayExpression("data", textBox1.Text, items));
             if ((ArrayExpressionEditor.Len != -1) &&
                 (items.Length != ArrayExpressionEditor.Len))
             {
                 ArrayExpressionEditor.Len = items.Length;
                 ArrayExpressionEditor.LenChanged(this);
             }
         }
         else
         {
             _definedAsConstVector = false;
             Expr =
                 DataStorage.Add(new ArrayExpression("data", textBox1.Text, data,
                                                     ArrayExpressionEditor.Len));
         }
         Expr.ValueChanged += ExprValueChanged;
     }
     else
     {
         if (data.Contains(";"))
         {
             var items = data.Split(';');
             for (var i = 0; i < items.Length; ++i)
             {
                 items[i] = items[i].Trim();
                 if (items[i].Length == 0)
                 {
                     _ignoreTextChange = false;
                     return(false);
                 }
             }
             _definedAsConstVector = true;
             Expr.SetRawExpressions(items);
             if ((ArrayExpressionEditor.Len != -1) &&
                 (items.Length != ArrayExpressionEditor.Len))
             {
                 ArrayExpressionEditor.Len = items.Length;
                 ArrayExpressionEditor.LenChanged(this);
             }
         }
         else
         {
             _definedAsConstVector = false;
             Expr.SetRawExpression(data, ArrayExpressionEditor.Len);
         }
     }
     ArrayExpressionEditor.Len = Expr.Exprs.Length;
     StepManager.RefreshToCurrentStep();
     _ignoreTextChange = false;
     return(true);
 }
Ejemplo n.º 12
0
 private void textBox2_TextChanged(object sender, EventArgs e)
 {
     if (_ignoreTextChanged)
     {
         return;
     }
     if (StepManager.CurrentStep is DrawStep)
     {
         var ds = (DrawStep) StepManager.CurrentStep;
         if (ds.StepType == DrawStep.DrawStepType.DrawRect)
         {
             ((DrawRectStep) ds).ReInitY(textBox2.Text);
         }
         else if (ds.StepType == DrawStep.DrawStepType.DrawEllipse)
         {
             ((DrawEllipseStep) ds).ReInitY(textBox2.Text);
         }
         else if (ds.StepType == DrawStep.DrawStepType.DrawLine)
         {
             ((DrawLineStep) ds).ReInitY(textBox2.Text);
         }
         else if (ds.StepType == DrawStep.DrawStepType.DrawText)
         {
             ((DrawTextStep) ds).ReInitY(textBox2.Text);
         }
     }
     else if (StepManager.CurrentStep is MoveStep)
     {
         var ms = (MoveStep) StepManager.CurrentStep;
         if (ms.StepType == MoveStep.MoveStepType.MoveRect)
         {
             ((MoveRectStep) ms).MoveY(textBox2.Text);
         }
         else if (ms.StepType == MoveStep.MoveStepType.MoveEllipse)
         {
             ((MoveEllipseStep) ms).MoveY(textBox2.Text);
         }
         else if (ms.StepType == MoveStep.MoveStepType.MoveLine)
         {
             ((MoveLineStep) ms).MoveY(textBox2.Text);
         }
         else if (ms.StepType == MoveStep.MoveStepType.MoveText)
         {
             ((MoveTextStep) ms).MoveY(textBox2.Text);
         }
     }
     else if (StepManager.CurrentStep is ResizeStep)
     {
         var rs = (ResizeStep) StepManager.CurrentStep;
         if (rs.StepType == ResizeStep.ResizeStepType.ResizeLine)
         {
             ((ResizeLineStep) rs).ResizeY(textBox2.Text);
         }
         if (rs.StepType == ResizeStep.ResizeStepType.ResizeRect)
         {
             ((ResizeTextStep) rs).ResizeY(textBox2.Text);
         }
     }
     if ((StepManager.CurrentStep.Iterations != -1) || (StepManager.FinalStep != null))
     {
         StepManager.RefreshToCurrentStep();
     }
     else
     {
         MainForm.RedrawNeeded?.Invoke();
     }
 }