예제 #1
0
        public Canvas(IMainForm mainForm, IModel model)
        {
            _inputHandlerForWhenEditorIdle                 = new InputHandlerForWhenEditorIdle(this);
            _inputHandlerForWhenMovingOrCopyingItems       = new InputHandlerForWhenMovingOrCopyingItems(this);
            _inputHandlerWhenRotatingItems                 = new InputHandlerWhenRotatingItems(this);
            _inputHandlerWhenScalingItems                  = new InputHandlerWhenScalingItems(this);
            _inputHandlerWhenCreatingTheSelectionRectangle = new InputHandlerWhenCreatingTheSelectionRectangle(this);

            _mainForm = mainForm;

            _model = model;

            _model.NewModelLoaded += newModelLoaded;

            _entityCreation = new EntityCreation(whenEntityReadyToBeAdded: () =>
            {
                addTheEntityCurrentlyBeingCreated( );
                _entityCreation.ClearCurrentEditor( );
                _entityCreation.StartedCreating = false;
            });

            _inputActionLookup = new Dictionary <UserActionInEditor, Action>
            {
                {
                    UserActionInEditor.Idle, _inputHandlerForWhenEditorIdle.Update
                },
                {
                    UserActionInEditor.MovingItems, _inputHandlerForWhenMovingOrCopyingItems.Update
                },
                {
                    UserActionInEditor.CopyingItems, _inputHandlerForWhenMovingOrCopyingItems.Update
                },
                {
                    UserActionInEditor.RotatingItems, _inputHandlerWhenRotatingItems.Update
                },
                {
                    UserActionInEditor.ScalingItems, _inputHandlerWhenScalingItems.Update
                },
                {
                    UserActionInEditor.MovingTheCamera, handleUpdateWhenMovingTheCamera
                },
                {
                    UserActionInEditor.CreatingSelectionBoxByDragging, _inputHandlerWhenCreatingTheSelectionRectangle.Update
                },
                {
                    UserActionInEditor.AddingAnItem, handleInputWhenAddingAnEntity
                },
            };

            _userActionInEditor = UserActionInEditor.Idle;

            _positionsBeforeUserInteraction = new List <Vector2>( );

            _rotationsBeforeUserInteraction = new List <float>( );

            _scalesBeforeUserInteraction = new List <Vector2>( );

            Stream stream = safeGetManifestResourceStream(@"GLEED2D.Resources.cursors.dragcopy.cur");

            new Cursor(stream);

            stream        = safeGetManifestResourceStream(@"GLEED2D.Resources.cursors.rotate.cur");
            _cursorRotate = new Cursor(stream);

            stream       = safeGetManifestResourceStream(@"GLEED2D.Resources.cursors.scale.cur");
            _cursorScale = new Cursor(stream);

            Constants.TryToLoadOtherwiseSetDefaults(@"settings.xml");
        }
예제 #2
0
파일: Canvas.cs 프로젝트: mtgattie/Gleed2D
        public Canvas( IMainForm mainForm, IModel model )
        {
            _inputHandlerForWhenEditorIdle = new InputHandlerForWhenEditorIdle( this );
            _inputHandlerForWhenMovingOrCopyingItems = new InputHandlerForWhenMovingOrCopyingItems( this );
            _inputHandlerWhenRotatingItems = new InputHandlerWhenRotatingItems( this );
            _inputHandlerWhenScalingItems = new InputHandlerWhenScalingItems( this );
            _inputHandlerWhenCreatingTheSelectionRectangle = new InputHandlerWhenCreatingTheSelectionRectangle( this );

            _mainForm = mainForm ;

            _model = model ;

            _model.NewModelLoaded += newModelLoaded ;

            _entityCreation = new EntityCreation( whenEntityReadyToBeAdded: ( ) =>
                    {
                        addTheEntityCurrentlyBeingCreated( ) ;
                        _entityCreation.ClearCurrentEditor( ) ;
                        _entityCreation.StartedCreating = false ;
                    } ) ;

            _inputActionLookup = new Dictionary<UserActionInEditor, Action>
                {
                    {
                        UserActionInEditor.Idle, _inputHandlerForWhenEditorIdle.Update
                        },
                    {
                        UserActionInEditor.MovingItems, _inputHandlerForWhenMovingOrCopyingItems.Update
                        },
                    {
                        UserActionInEditor.CopyingItems, _inputHandlerForWhenMovingOrCopyingItems.Update
                        },
                    {
                        UserActionInEditor.RotatingItems, _inputHandlerWhenRotatingItems.Update
                        },
                    {
                        UserActionInEditor.ScalingItems, _inputHandlerWhenScalingItems.Update
                        },
                    {
                        UserActionInEditor.MovingTheCamera, handleUpdateWhenMovingTheCamera
                        },
                    {
                        UserActionInEditor.CreatingSelectionBoxByDragging, _inputHandlerWhenCreatingTheSelectionRectangle.Update
                        },
                    {
                        UserActionInEditor.AddingAnItem, handleInputWhenAddingAnEntity
                        },
                } ;

            _userActionInEditor = UserActionInEditor.Idle ;

            _positionsBeforeUserInteraction = new List<Vector2>( ) ;

            _rotationsBeforeUserInteraction = new List<float>( ) ;

            _scalesBeforeUserInteraction = new List<Vector2>( ) ;

            Stream stream = safeGetManifestResourceStream( @"GLEED2D.Resources.cursors.dragcopy.cur" ) ;

            new Cursor( stream ) ;

            stream = safeGetManifestResourceStream( @"GLEED2D.Resources.cursors.rotate.cur" ) ;
            _cursorRotate = new Cursor( stream ) ;

            stream = safeGetManifestResourceStream( @"GLEED2D.Resources.cursors.scale.cur" ) ;
            _cursorScale = new Cursor( stream ) ;

            Constants.TryToLoadOtherwiseSetDefaults( @"settings.xml" ) ;
        }