コード例 #1
0
ファイル: Canvas.cs プロジェクト: xubingyue/Gleed2D-1
        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" ) ;
        }