Пример #1
0
        private void EditComplete(ScaleStates undoState, ScaleStates doState)
        {
            var selectedItem = this.selectedItem;

            if (selectedItem == null)
            {
                return;
            }

            // make copies of the scale states as they will be save into the undo redo stack
            doState        = new ScaleStates(doState);
            doState.Matrix = selectedItem.Matrix;
            undoState      = new ScaleStates(undoState);

            var undoBuffer = context.Scene.UndoBuffer;

            undoBuffer.Add(new UndoRedoActions(async() =>
            {
                SetItem(selectedItem, undoState);
                await selectedItem.Rebuild();
                // we set the matrix again after as the rebuild might move the object
                selectedItem.Matrix = undoState.Matrix;
                selectedItem.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues));
            },
                                               async() =>
            {
                SetItem(selectedItem, doState);
                await selectedItem.Rebuild();
                // we set the matrix again after as the rebuild might move the object
                selectedItem.Matrix = doState.Matrix;
                selectedItem.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues));
            }));
        }
Пример #2
0
        private void SetInitialState(IObject3DControlContext context)
        {
            if (getWidth != null)
            {
                InitialState.Width = getWidth();
            }

            if (getDepth != null)
            {
                InitialState.Depth = getDepth.Invoke();
            }

            if (getHeight != null)
            {
                InitialState.Height = getHeight();
            }

            if (getDiameters != null)
            {
                for (int i = 0; i < getDiameters.Count; i++)
                {
                    InitialState.Diameters[i] = getDiameters[i]();
                }
            }

            if (selectedItem != null)
            {
                InitialState.Matrix = selectedItem.Matrix;
            }

            FinalState = new ScaleStates(InitialState);
        }
Пример #3
0
            public ScaleStates(ScaleStates initialState)
            {
                this.Depth  = initialState.Depth;
                this.Height = initialState.Height;
                this.Width  = initialState.Width;
                this.Matrix = initialState.Matrix;

                for (int i = 0; i < initialState.Diameters.Count; i++)
                {
                    this.Diameters.Add(initialState.Diameters[i]);
                }
            }
Пример #4
0
        private void ChangeScaleState(float scaleValue, ScaleStates scaleState, int minDuration, int maxDuration, Action trigger)
        {
            this.scaleState = scaleState;

            int delay = Functions.GetRandomInt(minDuration, maxDuration);

            Vector2 scale = Scale;

            scale.X = scaleValue;
            Scale   = scale;

            timer = new Timer(delay, trigger, false);
        }
Пример #5
0
        private void SetItem(IObject3D item, ScaleStates states)
        {
            setWidth?.Invoke(states.Width);
            setDepth?.Invoke(states.Depth);

            setHeight?.Invoke(states.Height);

            if (setDiameters != null)
            {
                for (int i = 0; i < setDiameters.Count; i++)
                {
                    setDiameters[i](states.Diameters[i]);
                }
            }

            item.Matrix = states.Matrix;

            item.Invalidate(new InvalidateArgs(item, InvalidateType.DisplayValues));
        }
Пример #6
0
    void Update()
    {
        switch (state)
        {
        default:
        case (ScaleStates.scalingUp):
            ScaleUp();
            if (Timer > 1.0)
            {
                Timer = 0;
                state = ScaleStates.scalingDown;
            }
            break;

        case (ScaleStates.scalingDown):
            ScaleDown();
            if (Timer > 1.0)
            {
                Timer = 0;
                state = ScaleStates.scalingUp;
            }
            break;
        }
    }