Exemple #1
0
        public void PlayStep(Fixture fixture, RoutineStep step)
        {
            List <Point>          movementPoints  = step.GetPoints();
            List <AttributePoint> attributePoints = step.GetAttributePoints(movementPoints, fixture);
            double timePerPoint = step.Duration / movementPoints.Count;

            _playStep(fixture, step, movementPoints, attributePoints, timePerPoint);
        }
        public void PlayStep(Fixture fixture, RoutineStep step)
        {
            List<Point> movementPoints = step.GetPoints();
            List<AttributePoint> attributePoints = step.GetAttributePoints(movementPoints, fixture);
            double timePerPoint = step.Duration / movementPoints.Count;

            _playStep(fixture, step, movementPoints, attributePoints, timePerPoint);
        }
Exemple #3
0
 private void lbxSteps_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     RemoveCurrentShape();
     if (lbxSteps.SelectedItem != null)
     {
         ((RoutineStep)lbxSteps.SelectedItem).AddToCanvas(canvas1);
         _lastSelectedStep = ((RoutineStep)lbxSteps.SelectedItem);
     }
 }
        public void PreviewStep(Fixture fixture, RoutineStep step)
        {
            List<Point> movementPoints = step.GetPoints();
            List<AttributePoint> attributePoints = step.GetAttributePoints(movementPoints, fixture);
            double timePerPoint = step.Duration / movementPoints.Count;

            PlayStepAsynchCaller caller = new PlayStepAsynchCaller(_playStep);
            caller.BeginInvoke(fixture, step, movementPoints, attributePoints, timePerPoint, null, null);
        }
Exemple #5
0
        public void PreviewStep(Fixture fixture, RoutineStep step)
        {
            List <Point>          movementPoints  = step.GetPoints();
            List <AttributePoint> attributePoints = step.GetAttributePoints(movementPoints, fixture);
            double timePerPoint = step.Duration / movementPoints.Count;

            PlayStepAsynchCaller caller = new PlayStepAsynchCaller(_playStep);

            caller.BeginInvoke(fixture, step, movementPoints, attributePoints, timePerPoint, null, null);
        }
Exemple #6
0
        private void _playStep(Fixture fixture, RoutineStep step, List <Point> movementPoints, List <AttributePoint> attributePoints, double timePerPoint)
        {
            for (int i = 0; i < step.RepeatCount; i++)
            {
                for (int j = 0; j < movementPoints.Count; j++)
                {
                    // First set the attribute values at this point
                    foreach (AttributePointSetting setting in attributePoints[j].AttributePointSettings)
                    {
                        setting.Attribute.SetLevel(setting.Value);
                    }

                    // Then tell the light to move
                    fixture.MoveTo(movementPoints[j], timePerPoint);
                }
            }
        }
        private void _playStep(Fixture fixture, RoutineStep step, List<Point> movementPoints, List<AttributePoint> attributePoints, double timePerPoint)
        {
            for (int i = 0; i < step.RepeatCount; i++)
            {
                for (int j = 0; j < movementPoints.Count; j++)
                {
                    // First set the attribute values at this point
                    foreach (AttributePointSetting setting in attributePoints[j].AttributePointSettings)
                    {
                        setting.Attribute.SetLevel(setting.Value);
                    }

                    // Then tell the light to move
                    fixture.MoveTo(movementPoints[j], timePerPoint);
                }
            }
        }
Exemple #8
0
        /*
         * CANVAS/DRAWING
         */
        private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //Must have left the canvas while drawing and now they clicking to stop darwing?
            if (_drawing)
            {
                return;
            }

            if (_makingPathStep2)
            {
                _makingPathStep2 = false;
                _makingPath      = false;
                return;
            }

            Point p = e.GetPosition((UIElement)sender);

            HitTestResult result = VisualTreeHelper.HitTest(canvas1, p);

            //Check to make sure there is a Fixture selected in the Timeline
            if (lbxTimeline.SelectedItem == null || !(lbxTimeline.SelectedItem is RoutineFixture))
            {
                if (_activeTool == null)
                {
                    return;
                }
                if (lbxTimeline.Items.Count > 0)
                {
                    MessageBox.Show("You must select a fixture to add the step to.");
                }
                else
                {
                    MessageBox.Show("You must add a fixture first.");
                }
                return;
            }

            //Move an attribute point after it has already been placed.
            if (result.VisualHit.GetType() == typeof(Ellipse))
            {
                if (((Ellipse)result.VisualHit).Name.Contains("_attrPoint"))
                {
                    _attrPoint            = GetAttributePointEllipseParent((Ellipse)result.VisualHit);
                    _movingAttributePoint = true;
                    return;
                }
            }

            //The move tool. :) For moving a shape.
            if (_activeTool == btnToolbarMove)
            {
                Shape     closestShape = (Shape)GetClosestCanvasChild(p);
                StepShape stepShape    = GetShapeParent(closestShape);
                _movingShape = true;
                _stepShape   = stepShape;
                _stepShape.Select();
                foreach (UIElement element in canvas1.Children)
                {
                    if (element.GetType() == typeof(Shape))
                    {
                        if (((Shape)element).Name.Contains("_stepShape"))
                        {
                            StepShape parent = GetShapeParent((Shape)element);
                            parent.Deselect();
                        }
                    }
                }
            }

            if (_stepShape == null || result.VisualHit != _stepShape.Shape)
            {
                //This probably shouldn't get here. I don't know where it should go yet
                if (_stepShape != null)
                {
                    _stepShape.Deselect();
                }

                //If user has selected a shape tool.
                if (_activeTool != null && (_activeTool == btnToolbarCircle || _activeTool == btnToolbarDot || _activeTool == btnToolbarLine ||
                                            _activeTool == btnToolbarPolyline || _activeTool == btnToolbarRectangle || _activeTool == btnToolbarArc))
                {
                    _drawing = true;
                    RemoveCurrentShape();
                    if (_activeTool == btnToolbarCircle)
                    {
                        Ellipse ell = (Ellipse)StepEllipse.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        ell.Name += "_stepShape";
                        canvas1.Children.Add(ell);
                        _stepShape = new StepEllipse(ell);
                    }
                    else if (_activeTool == btnToolbarRectangle)
                    {
                        Rectangle rect = StepRectangle.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        rect.Name += "_stepShape";
                        canvas1.Children.Add(rect);
                        _stepShape = new StepRectangle(rect);
                    }
                    else if (_activeTool == btnToolbarLine)
                    {
                        Line line = StepLine.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        line.Name += "_stepShape";
                        canvas1.Children.Add(line);
                        _stepShape = new StepLine(line);
                    }
                    else if (_activeTool == btnToolbarArc)
                    {
                        _stepShape             = new StepPath(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        _stepShape.Shape.Name += "_stepShape";
                        canvas1.Children.Add(_stepShape.Shape);
                        _makingPath = true;
                    }
                    else if (_activeTool == btnToolbarPolyline)
                    {
                        _stepShape             = new StepFreeForm(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        _stepShape.Shape.Name += "_stepShape";
                        canvas1.Children.Add(_stepShape.Shape);
                    }
                    _last_mouse_location = e.GetPosition(canvas1);
                    //Create new list item for the step shape & add to list.
                    RoutineStep rs = new RoutineStep("New Step", _stepShape, _routine);
                    ((RoutineFixture)lbxTimeline.SelectedItem).RoutineSteps.Add(rs);
                    _lastSelectedStep = rs;

                    /*Horrible way to refresh the listbox.  Need to figure this out.
                     * Currently it removes the row that allows you to add more fixutres. Can't do that!
                     */
                    //lbxSteps.ItemsSource = null;
                    //lbxSteps.Items.Clear();
                    //lbxSteps.ItemsSource = ((RoutineFixture)lbxTimeline.SelectedItem).RoutineSteps;
                }
                //Not drawing something, making a reference point?
                else if (_activeTool == btnToolbarReferencePoint)
                {
                    _movingReferencePoint = true;
                    _refPoint             = new RoutineFixtureReferencePoint((RoutineFixture)lbxTimeline.SelectedItem, e.GetPosition(canvas1));
                    canvas1.Children.Add(_refPoint.Ellipse);
                    canvas1.Children.Add(_refPoint.Label);
                    _refPoint.MoveFixtureTo();
                    ((RoutineFixture)lbxTimeline.SelectedItem).Fixture.On();
                }
                //Not a referencePoint, is it an Attribute Point?
                else if (_activeTool == btnToolbarAttrPoint)
                {
                    _movingAttributePoint = true;

                    Shape closestShape = (Shape)GetClosestCanvasChild(p);
                    Point closestPoint = GetClosestPointOnShape(closestShape, p);

                    _attrPoint = new AttributePoint(closestPoint, ((RoutineFixture)lbxTimeline.SelectedItem).Fixture);
                    canvas1.Children.Add(_attrPoint.Ellipse);
                    Canvas.SetLeft(_attrPoint.Ellipse, closestPoint.X - 450);
                    Canvas.SetTop(_attrPoint.Ellipse, closestPoint.Y - 450);
                    _lastSelectedStep.AddAttributePoint(_attrPoint);

                    //Live Preview
                    if (LivePreview)
                    {
                        ((RoutineFixture)lbxTimeline.SelectedItem).Fixture.MoveTo(closestPoint, 0);
                    }
                }
            }
        }
 private void lbxSteps_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     RemoveCurrentShape();
     if (lbxSteps.SelectedItem != null)
     {
         ((RoutineStep)lbxSteps.SelectedItem).AddToCanvas(canvas1);
         _lastSelectedStep = ((RoutineStep)lbxSteps.SelectedItem);
     }
 }
        /*
         * CANVAS/DRAWING
         */
        private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //Must have left the canvas while drawing and now they clicking to stop darwing?
            if (_drawing)
                return;

            if (_makingPathStep2)
            {
                _makingPathStep2 = false;
                _makingPath = false;
                return;
            }

            Point p = e.GetPosition((UIElement)sender);

            HitTestResult result = VisualTreeHelper.HitTest(canvas1, p);

            //Check to make sure there is a Fixture selected in the Timeline
            if (lbxTimeline.SelectedItem == null || !(lbxTimeline.SelectedItem is RoutineFixture))
            {
                if (_activeTool == null) return;
                if(lbxTimeline.Items.Count > 0)
                    MessageBox.Show("You must select a fixture to add the step to.");
                else
                    MessageBox.Show("You must add a fixture first.");
                return;
            }

            //Move an attribute point after it has already been placed.
            if (result.VisualHit.GetType() == typeof(Ellipse))
            {
                if (((Ellipse)result.VisualHit).Name.Contains("_attrPoint"))
                {
                    _attrPoint = GetAttributePointEllipseParent((Ellipse)result.VisualHit);
                    _movingAttributePoint = true;
                    return;
                }
            }

            //The move tool. :) For moving a shape.
            if (_activeTool == btnToolbarMove)
            {
                Shape closestShape = (Shape)GetClosestCanvasChild(p);
                StepShape stepShape = GetShapeParent(closestShape);
                _movingShape = true;
                _stepShape = stepShape;
                _stepShape.Select();
                foreach (UIElement element in canvas1.Children)
                {
                    if (element.GetType() == typeof(Shape))
                    {
                        if (((Shape)element).Name.Contains("_stepShape"))
                        {
                            StepShape parent = GetShapeParent((Shape)element);
                            parent.Deselect();
                        }
                    }
                }
            }

            if (_stepShape == null || result.VisualHit != _stepShape.Shape)
            {
                //This probably shouldn't get here. I don't know where it should go yet
                if(_stepShape != null) _stepShape.Deselect();

                //If user has selected a shape tool.
                if (_activeTool != null && (_activeTool == btnToolbarCircle || _activeTool == btnToolbarDot || _activeTool == btnToolbarLine
                    || _activeTool == btnToolbarPolyline || _activeTool == btnToolbarRectangle || _activeTool == btnToolbarArc))
                {
                    _drawing = true;
                    RemoveCurrentShape();
                    if (_activeTool == btnToolbarCircle)
                    {
                        Ellipse ell = (Ellipse)StepEllipse.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        ell.Name += "_stepShape";
                        canvas1.Children.Add(ell);
                        _stepShape = new StepEllipse(ell);
                    }
                    else if (_activeTool == btnToolbarRectangle)
                    {
                        Rectangle rect = StepRectangle.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        rect.Name += "_stepShape";
                        canvas1.Children.Add(rect);
                        _stepShape = new StepRectangle(rect);
                    }
                    else if (_activeTool == btnToolbarLine)
                    {
                        Line line = StepLine.Draw(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        line.Name += "_stepShape";
                        canvas1.Children.Add(line);
                        _stepShape = new StepLine(line);
                    }
                    else if (_activeTool == btnToolbarArc)
                    {
                        _stepShape = new StepPath(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        _stepShape.Shape.Name += "_stepShape";
                        canvas1.Children.Add(_stepShape.Shape);
                        _makingPath = true;
                    }
                    else if (_activeTool == btnToolbarPolyline)
                    {
                        _stepShape = new StepFreeForm(e.GetPosition(canvas1).X, e.GetPosition(canvas1).Y);
                        _stepShape.Shape.Name += "_stepShape";
                        canvas1.Children.Add(_stepShape.Shape);
                    }
                    _last_mouse_location = e.GetPosition(canvas1);
                    //Create new list item for the step shape & add to list.
                    RoutineStep rs = new RoutineStep("New Step", _stepShape, _routine);
                    ((RoutineFixture)lbxTimeline.SelectedItem).RoutineSteps.Add(rs);
                    _lastSelectedStep = rs;
                    /*Horrible way to refresh the listbox.  Need to figure this out.
                     * Currently it removes the row that allows you to add more fixutres. Can't do that!
                     */
                    //lbxSteps.ItemsSource = null;
                    //lbxSteps.Items.Clear();
                    //lbxSteps.ItemsSource = ((RoutineFixture)lbxTimeline.SelectedItem).RoutineSteps;
                }
                //Not drawing something, making a reference point?
                else if(_activeTool == btnToolbarReferencePoint)
                {
                    _movingReferencePoint = true;
                    _refPoint = new RoutineFixtureReferencePoint((RoutineFixture)lbxTimeline.SelectedItem, e.GetPosition(canvas1));
                    canvas1.Children.Add(_refPoint.Ellipse);
                    canvas1.Children.Add(_refPoint.Label);
                    _refPoint.MoveFixtureTo();
                    ((RoutineFixture)lbxTimeline.SelectedItem).Fixture.On();
                }
                //Not a referencePoint, is it an Attribute Point?
                else if (_activeTool == btnToolbarAttrPoint)
                {
                    _movingAttributePoint = true;

                    Shape closestShape = (Shape)GetClosestCanvasChild(p);
                    Point closestPoint = GetClosestPointOnShape(closestShape, p);

                    _attrPoint = new AttributePoint(closestPoint, ((RoutineFixture)lbxTimeline.SelectedItem).Fixture);
                    canvas1.Children.Add(_attrPoint.Ellipse);
                    Canvas.SetLeft(_attrPoint.Ellipse, closestPoint.X -450);
                    Canvas.SetTop(_attrPoint.Ellipse, closestPoint.Y -450);
                    _lastSelectedStep.AddAttributePoint(_attrPoint);

                    //Live Preview
                    if (LivePreview)
                    {
                        ((RoutineFixture)lbxTimeline.SelectedItem).Fixture.MoveTo(closestPoint, 0);
                    }
                }
            }
        }