├── .gitattributes ├── .gitignore ├── DreamBit.Extension ├── Commands │ ├── BuildContentCommand.cs │ ├── Editor │ │ ├── CloseSceneCommand.cs │ │ ├── RedoCommand.cs │ │ ├── SaveSceneCommand.cs │ │ ├── UndoCommand.cs │ │ ├── ZoomInCommand.cs │ │ ├── ZoomOutCommand.cs │ │ ├── ZoomToFitScreenCommand.cs │ │ └── ZoomToOriginalSizeCommand.cs │ ├── Project │ │ ├── AddFontCommand.cs │ │ ├── AddSceneCommand.cs │ │ ├── AddScriptCommand.cs │ │ ├── EditFontCommand.cs │ │ └── EditSceneCommand.cs │ ├── SceneEditorWindowCommand.cs │ ├── SceneHierarchy │ │ ├── AddCameraObjectCommand.cs │ │ ├── AddGameObjectCommand.cs │ │ ├── CopyGameObjectCommand.cs │ │ ├── MoveGameObjectCommand.cs │ │ ├── PasteGameObjectCommand.cs │ │ └── RemoveGameObjectCommand.cs │ ├── SceneHierarchyWindowCommand.cs │ ├── SceneInspect │ │ ├── DropOnInspectCommand.cs │ │ └── RemoveGameComponentCommand.cs │ └── SceneInspectWindowCommand.cs ├── Components │ ├── HierarchyBridge.cs │ ├── PackageBridge.cs │ ├── SolutionMonitor.cs │ ├── ToolCommand.cs │ └── ToolWindow.cs ├── Controls │ ├── Containers │ │ └── ExpansionPanel.cs │ ├── DialogView.cs │ ├── DragAndDrop │ │ ├── AdornedTreeViewDroppableBehavior.cs │ │ ├── TreeViewItemAdorner.cs │ │ └── TreeViewLastItemAdorner.cs │ ├── Input │ │ ├── CheckBox.xaml │ │ ├── CheckBox.xaml.cs │ │ ├── ColorPicker.xaml │ │ ├── ColorPicker.xaml.cs │ │ ├── ColorPickerChangedEventArgs.cs │ │ ├── ContentSelector.xaml │ │ ├── ContentSelector.xaml.cs │ │ ├── FloatBox.xaml │ │ ├── FloatBox.xaml.cs │ │ ├── GameObjectSelector.xaml │ │ ├── GameObjectSelector.xaml.cs │ │ ├── IconButton.cs │ │ ├── IntBox.xaml │ │ ├── IntBox.xaml.cs │ │ ├── TextBox.xaml │ │ └── TextBox.xaml.cs │ ├── Objects │ │ └── Vector2Proxy.cs │ └── WindowView.cs ├── Converters │ ├── IconSourceConverter.cs │ ├── MultiTreeViewMarginConverter.cs │ └── VisibleIfNotNullConverter.cs ├── DreamBit.Extension.csproj ├── DreamBitPackage.Guids.cs ├── DreamBitPackage.cs ├── DreamBitPackage.vsct ├── Helpers │ ├── ColorHelper.cs │ ├── ControlHelper.cs │ ├── DesignHelper.cs │ ├── ErrorHelper.cs │ ├── GameComponentCollectionHelper.cs │ ├── GameObjectCollectionHelper.cs │ ├── KeyHelper.cs │ ├── MarshalHelper.cs │ └── TreeViewItemHelper.cs ├── Management │ ├── Editor.cs │ └── ProjectManager.cs ├── Module │ ├── EditorCamera.cs │ ├── EditorGameModule.cs │ ├── EditorToolBox.cs │ ├── Handlers │ │ ├── EditorHandler.cs │ │ ├── MoveHandler.cs │ │ ├── RotateHandler.cs │ │ ├── ScaleHandler.cs │ │ └── SelectHandler.cs │ ├── SelectionData.cs │ ├── SelectionObject.cs │ ├── TestGame.cs │ └── Tools │ │ ├── CameraTool.cs │ │ ├── EditorTool.cs │ │ ├── HandlerTool.cs │ │ └── SelectionTool.cs ├── Properties │ ├── AssemblyInfo.cs │ └── ExtensionInjectionModule.cs ├── Resources │ ├── Cursors │ │ ├── handClose.cur │ │ └── handOpen.cur │ ├── CustomCursors.cs │ ├── DreamBitPackage.ico │ ├── Icons │ │ └── 16 │ │ │ ├── cancel.png │ │ │ ├── close.png │ │ │ ├── copy.png │ │ │ ├── cursor.png │ │ │ ├── dragPanel.png │ │ │ ├── glyphDown.png │ │ │ ├── glyphDown.white.png │ │ │ ├── graphics3D.png │ │ │ ├── redo.png │ │ │ ├── save.png │ │ │ ├── undo.png │ │ │ ├── videoCamera.png │ │ │ ├── zoomIn.png │ │ │ ├── zoomOut.png │ │ │ ├── zoomToFit.png │ │ │ └── zoomToOriginalSize.png │ ├── Images │ │ └── DottedRepeat.png │ ├── Logo.ico │ └── Styles │ │ ├── Border.xaml │ │ ├── CheckBox.xaml │ │ ├── Colors.cs │ │ ├── Colors.xaml │ │ ├── ComboBox.xaml │ │ ├── DragAndDrop.xaml │ │ ├── ExpansionPanel.xaml │ │ ├── ExpansionPanel.xaml.cs │ │ ├── IconButton.xaml │ │ ├── TextBox.xaml │ │ ├── Theme.xaml │ │ ├── ToolBar.xaml │ │ ├── TreeView.xaml │ │ ├── TreeView.xaml.cs │ │ ├── VisualStudio.xaml │ │ └── WindowView.xaml ├── ViewModels │ ├── BaseViewModel.cs │ ├── Dialogs │ │ ├── BaseDialogViewModel.cs │ │ └── EditFontDialogViewModel.cs │ ├── SceneEditorViewModel.cs │ ├── SceneHierarchyViewModel.cs │ └── SceneInspectViewModel.cs ├── Windows │ ├── Dialogs │ │ ├── EditFontDialog.xaml │ │ ├── EditFontDialog.xaml.cs │ │ ├── FileNameDialog.xaml │ │ └── FileNameDialog.xaml.cs │ ├── SceneEditorView.xaml │ ├── SceneEditorView.xaml.cs │ ├── SceneEditorWindow.cs │ ├── SceneHierarchyView.xaml │ ├── SceneHierarchyView.xaml.cs │ ├── SceneHierarchyWindow.cs │ ├── SceneInspect │ │ ├── CameraInspect.xaml │ │ ├── CameraInspect.xaml.cs │ │ ├── ImageRendererInspect.xaml │ │ ├── ImageRendererInspect.xaml.cs │ │ ├── ObjectInspect.xaml │ │ ├── ObjectInspect.xaml.cs │ │ ├── SceneComponentInspect.cs │ │ ├── ScriptBehaviorInspect.xaml │ │ ├── ScriptBehaviorInspect.xaml.cs │ │ ├── TextRendererInspect.xaml │ │ ├── TextRendererInspect.xaml.cs │ │ ├── TransformInspect.xaml │ │ └── TransformInspect.xaml.cs │ ├── SceneInspectView.xaml │ ├── SceneInspectView.xaml.cs │ └── SceneInspectWindow.cs └── source.extension.vsixmanifest ├── DreamBit.Game ├── Content │ ├── ContentManager.cs │ ├── Font.cs │ ├── IContent.cs │ ├── IContentLoader.cs │ ├── IContentManager.cs │ └── Image.cs ├── Drawing │ ├── ContentDrawer.cs │ └── DrawBatch.cs ├── DreamBit.Game.csproj ├── Elements │ ├── Components │ │ ├── Camera.cs │ │ ├── ImageRenderer.cs │ │ ├── ScriptBehavior.cs │ │ ├── ScriptProperty.cs │ │ ├── ScriptPropertyType.cs │ │ └── TextRenderer.cs │ ├── GameComponent.cs │ ├── GameComponentCollection.cs │ ├── GameObject.cs │ ├── GameObjectCollection.cs │ ├── GameObjectHelper.cs │ ├── ITransform.cs │ ├── Scene.cs │ ├── Transform.cs │ └── TransformChange.cs ├── Files │ ├── SceneFile.cs │ └── ScriptFile.cs ├── Helpers │ └── GameHelper.cs ├── Properties │ ├── AssemblyInfo.cs │ └── GameInjectionModule.cs ├── Registrations │ ├── SceneFileRegistration.cs │ └── ScriptFileRegistration.cs └── Serialization │ ├── Converters │ ├── ColorConverter.cs │ ├── ContentConverter.cs │ ├── GameComponentConverter.cs │ ├── GameObjectConverter.cs │ ├── ProjectFileConverter.cs │ ├── SceneConverter.cs │ └── Vector2Converter.cs │ └── GameElementsParser.cs ├── DreamBit.General ├── DreamBit.General.csproj ├── Management │ └── FileManager.cs ├── Properties │ ├── AssemblyInfo.cs │ └── GeneralInjectionModule.cs └── State │ ├── CompositeStateCommand.cs │ ├── IStateUnit.cs │ ├── StateCommand.cs │ ├── StateHelper.cs │ ├── StateManager.cs │ ├── StateScope.cs │ ├── StateTransaction.cs │ └── ValueChangedEventArgs.cs ├── DreamBit.Pipeline ├── Contents.cs ├── DreamBit.Pipeline.csproj ├── Exceptions │ ├── ImportAlreadyExistsException.cs │ ├── ImportNotFoundException.cs │ ├── PipelineAlreadyLoadedException.cs │ └── PipelineNotLoadedException.cs ├── Files │ ├── FontFamily.cs │ ├── FontStyle.cs │ ├── PipelineFont.cs │ └── PipelineImage.cs ├── GlobalProperties.cs ├── Helpers │ └── ContentImportHelper.cs ├── Imports │ ├── BuildtAction.cs │ ├── ContentImport.cs │ ├── ContentImporter.cs │ ├── CopyImport.cs │ ├── FontImport.cs │ ├── TextureFormat.cs │ └── TextureImport.cs ├── MonoGame │ ├── PipelineBuilder.cs │ └── PipelineFile.cs ├── Pipeline.cs ├── Platform.cs ├── Profile.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── PipelineInjectionModule.cs │ └── PipelineMappingProfile.cs ├── Registrations │ ├── PipelineFontRegistration.cs │ └── PipelineImageRegistration.cs └── Translators │ ├── ContentsTranslator.cs │ ├── GlobalPropertiesTranslator.cs │ ├── IObjectTranslator.cs │ ├── ITranslator.cs │ ├── ImportTranslators │ ├── CopyImportTranslator.cs │ ├── FontImportTranslator.cs │ └── TextureImportTranslator.cs │ ├── ReferencesTranslator.cs │ └── Translations.cs ├── DreamBit.Project.Tests ├── DreamBit.Project.Tests.csproj ├── Mocks │ ├── FileManagerMock.cs │ ├── ProjectFileMock.cs │ ├── ProjectMock.cs │ ├── RegistrationMock.cs │ └── SerializerMock.cs ├── Properties │ └── AssemblyInfo.cs └── Tests │ ├── ProjectFileTest.cs │ └── ProjectTest.cs ├── DreamBit.Project ├── DreamBit.Project.csproj ├── Exceptions │ ├── FileIdAlreadyExistsException.cs │ ├── FileLocationAlreadyExistsException.cs │ ├── InvalidFileExtensionException.cs │ ├── ProjectAlreadyLoadedException.cs │ ├── ProjectFileNotFoundException.cs │ ├── ProjectNotLoadedException.cs │ ├── TypeAlreadyRegistredException.cs │ └── TypeNotRegisteredException.cs ├── Helpers │ ├── FileRegistrationHelper.cs │ └── ProjectFileHelper.cs ├── MovedEventArgs.cs ├── Project.cs ├── ProjectFile.cs ├── Properties │ ├── AssemblyInfo.cs │ └── ProjectInjectionModule.cs ├── Registrations │ ├── FileRegistrations.cs │ └── IFileRegistration.cs └── Serialization │ ├── Converters │ ├── ProjectConverter.cs │ └── ProjectItemConverter.cs │ └── Serializer.cs ├── DreamBit.sln ├── Game1.zip ├── Images ├── extension.png ├── overview.png └── solution-explorer.png ├── LICENSE ├── Libs └── MultiSelectTreeView │ └── MultiSelectTreeView.dll ├── Old.DreamBit.Game.Edition ├── Components │ ├── EditionGameScene.cs │ └── IEditionGameScene.cs ├── Elements │ └── Components │ │ ├── EditableCameraObject.cs │ │ ├── EditableImageRenderer.cs │ │ ├── EditableScriptBehavior.cs │ │ └── EditableTextRenderer.cs ├── Factory │ └── EditableGameObjectComponentFactory.cs ├── Files │ ├── SceneFile.cs │ └── ScriptFile.cs ├── Old.DreamBit.Game.Edition.csproj ├── Properties │ ├── AssemblyInfo.cs │ └── GameEditionInjectionModule.cs ├── Registrations │ ├── SceneFileRegistration.cs │ └── ScriptFileRegistration.cs └── Writing │ ├── DataWriter.cs │ ├── IDataWriter.cs │ ├── ISceneWriter.cs │ └── SceneWriter.cs ├── Old.DreamBit.Game.Tests ├── Components │ ├── CameraServiceTest.cs │ ├── SceneCameraTest.cs │ └── SceneManagerTest.cs ├── Content │ ├── ContentManagerServiceTest.cs │ ├── ContentReferenceManagerTest.cs │ └── SceneLoaderTest.cs ├── Drawing │ ├── DrawBatchDefinitionsTest.cs │ └── DrawBatchTest.cs ├── Elements │ ├── Components │ │ ├── CameraObjectTest.cs │ │ ├── GameObjectComponentTest.cs │ │ ├── ImageRendererTest.cs │ │ └── TextRendererTest.cs │ ├── GameObjectTest.cs │ ├── SceneTest.cs │ └── TransformTest.cs ├── Implementations │ └── Elements │ │ └── GameObjectComponentImplementation.cs ├── Mocks │ ├── Components │ │ ├── CameraMock.cs │ │ ├── CameraServiceMock.cs │ │ └── SceneCameraMock.cs │ ├── Content │ │ ├── ContentLoaderMock.cs │ │ ├── ContentManagerMock.cs │ │ ├── ContentReferenceManagerMock.cs │ │ ├── FontMock.cs │ │ └── ImageMock.cs │ ├── Data │ │ └── GameDataMock.cs │ ├── Drawing │ │ ├── DrawBatchMock.cs │ │ └── DrawBatchServiceMock.cs │ ├── Elements │ │ ├── GameObjectComponentMock.cs │ │ └── GameObjectMock.cs │ └── Reading │ │ └── DataReaderMock.cs ├── Old.DreamBit.Game.Tests.csproj └── Properties │ └── AssemblyInfo.cs ├── Old.DreamBit.Game ├── Components │ ├── BaseGame.cs │ ├── CameraService.cs │ ├── DeltaTime.cs │ ├── GameScene.cs │ ├── ICamera.cs │ ├── ICameraService.cs │ ├── IGameScene.cs │ ├── ISceneCamera.cs │ ├── ISceneManager.cs │ ├── SceneCamera.cs │ └── SceneManager.cs ├── Content │ ├── ContentManagerService.cs │ ├── ContentReferenceManager.cs │ ├── Font.cs │ ├── IContent.cs │ ├── IContentLoader.cs │ ├── IContentManager.cs │ ├── IContentManagerService.cs │ ├── IContentReferenceManager.cs │ ├── Image.cs │ └── Loaders │ │ ├── FontLoader.cs │ │ ├── ImageLoader.cs │ │ └── SceneLoader.cs ├── Data │ ├── DebugData.cs │ ├── GameContent.cs │ ├── GameData.cs │ ├── GameScript.cs │ ├── IDebugData.cs │ └── IGameData.cs ├── Drawing │ ├── DrawBatch.cs │ ├── DrawBatchDefinition.cs │ ├── DrawBatchDefinitionRequest.cs │ ├── DrawBatchService.cs │ ├── IDrawBatch.cs │ └── IDrawBatchService.cs ├── Elements │ ├── Components │ │ ├── CameraObject.cs │ │ ├── ComponentType.cs │ │ ├── GameObjectComponent.cs │ │ ├── ImageRenderer.cs │ │ ├── ScriptBehavior.cs │ │ └── TextRenderer.cs │ ├── GameObject.cs │ ├── Scene.cs │ ├── Transform.cs │ └── TransformChange.cs ├── Exceptions │ └── ContentNotRegisteredException.cs ├── Factory │ └── GameObjectComponentFactory.cs ├── Helpers │ ├── GameObjectHelper.cs │ ├── PropertyHelper.cs │ ├── PropertyInfoHelper.cs │ └── TypeHelper.cs ├── Old.DreamBit.Game.csproj ├── Properties │ ├── AssemblyInfo.cs │ └── GameInjectionModule.cs ├── Reading │ ├── Attributes │ │ └── ContentReferenceAttribute.cs │ ├── Converters │ │ ├── GameObjectComponentConverter.cs │ │ └── GameObjectConverter.cs │ ├── DataReader.cs │ └── IDataReader.cs ├── Singletons.cs └── Static │ ├── GameObject.cs │ └── GameObjectComponent.cs ├── README.md ├── ScrawlBit.MonoGame.Interop ├── Controls │ ├── DrawEventArgs.cs │ ├── DrawingSurface.cs │ ├── GameControl.cs │ ├── GameModule.cs │ ├── GameMouseButtonEventArgs.cs │ ├── GameMouseEventArgs.cs │ ├── GameMouseWheelEventArgs.cs │ ├── GraphicsDeviceEventArgs.cs │ └── RenderSizeChangedEventArgs.cs ├── Properties │ └── AssemblyInfo.cs ├── ScrawlBit.MonoGame.Interop.csproj ├── Services │ ├── DeviceService.cs │ └── GraphicsDeviceService.cs └── Util │ └── Disposer.cs ├── Scrawlbit.AutoMapper ├── Configuration │ ├── InclusionMappingSource.cs │ ├── MappingBuilder.cs │ ├── MappingDestination.cs │ ├── MappingMemberConfiguration.cs │ └── MappingSource.cs ├── Mapping.cs ├── MappingService.cs ├── MappingServiceBuilder.cs ├── MappingServiceProfile.cs ├── Properties │ └── AssemblyInfo.cs └── Scrawlbit.AutoMapper.csproj ├── Scrawlbit.Json ├── Converters │ ├── AbstractObjectConveter.cs │ └── DependencyInstanceConverter.cs ├── JsonHelper.cs ├── JsonParser.cs ├── Properties │ └── AssemblyInfo.cs └── Scrawlbit.Json.csproj ├── Scrawlbit.MonoGame.Tests ├── AssertionHelper.cs ├── Assertions │ ├── RectangleAssertions.cs │ └── Vector2Assertions.cs ├── Constants.cs ├── FloatAssertionsHelper.cs ├── Properties │ └── AssemblyInfo.cs └── Scrawlbit.MonoGame.Tests.csproj ├── Scrawlbit.MonoGame ├── Helpers │ ├── FloatHelper.cs │ ├── MathematicHelper.cs │ ├── MatrixHelper.cs │ ├── PointHelper.cs │ ├── RectangleHelper.cs │ ├── SpriteBatchHelper.cs │ ├── SpriteEffectsHelper.cs │ ├── TextureHelper.cs │ └── Vector2Helper.cs ├── Properties │ └── AssemblyInfo.cs └── Scrawlbit.MonoGame.csproj ├── Scrawlbit.Presentation ├── Attributes │ └── LocalizableDescriptionAttribute.cs ├── Behaviors │ ├── ListBoxDragAndDropBehavior.cs │ ├── RadioButtonListSelectedValueBehavior.cs │ ├── RegexInputValidationBehavior.cs │ └── TreeViewSelectedItemBehavior.cs ├── Bindings │ └── EnumCollectionBinding.cs ├── Collections │ └── Behaviors.cs ├── Commands │ ├── BaseCommand.cs │ ├── CommandMethod.cs │ ├── CommandParameter.cs │ └── DelegateCommand.cs ├── Converters │ ├── CollectionViewSourceConverter.cs │ ├── ConverterMarkupExtension.cs │ ├── EnumDisplayNameConverter.cs │ ├── EnumerableHasElementsConverter.cs │ ├── IntToFloatConverter.cs │ ├── InverseBooleanConverter.cs │ ├── IsNullConverter.cs │ ├── LocalizableDescriptionConverter.cs │ ├── NewArrayConverter.cs │ ├── OrConverter.cs │ ├── TypeConverter.cs │ ├── ValueConverterGroup.cs │ ├── ValueConverterGroupMarkup.cs │ └── VisibilityConverter.cs ├── Data │ ├── ComparisonBinding.cs │ ├── ContextMenuBinding.cs │ └── TypeTemplateSelector.cs ├── Dependency │ ├── ComponentObject.cs │ ├── DependencyObjectHelper.cs │ ├── DependencyProperty.cs │ ├── DependencyRegistry.cs │ ├── EventRegistry.cs │ └── RoutedEvent.cs ├── DragAndDrop │ ├── DraggableBehavior.cs │ ├── DropEventArgs.cs │ ├── DropType.cs │ ├── DroppableAdorner.cs │ ├── DroppableBehavior.cs │ ├── MultipleDataDraggableBehavior.cs │ ├── TreeViewDraggableBehavior.cs │ ├── TreeViewDropEventArgs.cs │ └── TreeViewDroppableBehavior.cs ├── Helpers │ ├── ApplicationHelper.cs │ ├── BindingHelper.cs │ ├── CommandHelper.cs │ ├── ComponentModelHelper.cs │ ├── ControlHelper.cs │ ├── InteractionHelper.cs │ ├── ItemContainerGeneratorHelper.cs │ ├── KeyboardHelper.cs │ └── TreeViewHelper.cs ├── Properties │ └── AssemblyInfo.cs └── Scrawlbit.Presentation.csproj ├── Scrawlbit.SimpleInjector ├── Configuration │ ├── Registration.cs │ ├── RegistrationBuilder.cs │ └── RegistrationSource.cs ├── ContainerBuilder.cs ├── Properties │ └── AssemblyInfo.cs ├── ResolverContainer.cs └── Scrawlbit.SimpleInjector.csproj └── Scrawlbit.Util ├── Collections ├── ExtendedObservableCollection.cs ├── IObservableCollection.cs ├── IReadOnlyObservableCollection.cs ├── ObservableCollectionHelper.cs ├── OrderedDictionary.cs └── ReadonlyObservableCollectionWrapper.cs ├── Comparison └── FuncEqualityComparer.cs ├── Helpers ├── ArrayHelper.cs ├── AttributeHelper.cs ├── ByteHelper.cs ├── CollectionHelper.cs ├── DictionaryHelper.cs ├── EnumHelper.cs ├── EnumerableHelper.cs ├── ExpressionHelper.cs ├── FloatHelper.cs ├── IntHelper.cs ├── LazyHelper.cs ├── ListHelper.cs ├── MemberHelper.cs ├── ObjectHelper.cs ├── StringHelper.cs ├── TypeHelper.cs └── Variable.cs ├── Injection ├── Configuration │ ├── IInjectionModule.cs │ ├── IRegistration.cs │ └── IRegistrationBuilder.cs └── IContainer.cs ├── Mapping ├── Configuration │ ├── IInclusionMappingSource.cs │ ├── IMappingBuilder.cs │ ├── IMappingDestination.cs │ ├── IMappingMemberConfiguration.cs │ ├── IMappingProfile.cs │ └── IMappingSource.cs ├── IMapping.cs └── IMappingService.cs ├── Notification ├── InternalPropertyChangedEventArgs.cs ├── InternalPropertyChangingEventArgs.cs ├── NotificationComponent.cs ├── NotificationHelper.cs ├── NotificationObject.cs ├── Notificator │ ├── ChainedNotificationConstructor.cs │ ├── ChainedNotificator.cs │ ├── Events.cs │ ├── NotificationConstruction.cs │ ├── NotificationConstructor.cs │ └── Notificator.cs └── State │ ├── ChangesStateManager.cs │ ├── ChangesTracker.cs │ ├── CollectionChangesTracker.cs │ ├── IChangesState.cs │ ├── NullChangesTracker.cs │ └── PropertyChangesTracker.cs ├── Properties └── AssemblyInfo.cs └── Scrawlbit.Util.csproj /DreamBit.Extension/Commands/BuildContentCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Pipeline; 3 | using DreamBit.Project; 4 | 5 | namespace DreamBit.Extension.Commands 6 | { 7 | internal interface IBuildContentCommand : IToolCommand 8 | { 9 | bool CanExecute(); 10 | 11 | void Execute(bool clean = false); 12 | } 13 | internal sealed class BuildContentCommand : ToolCommand, IBuildContentCommand 14 | { 15 | private readonly IPipeline _pipeline; 16 | 17 | public BuildContentCommand(IPipeline pipeline) 18 | { 19 | _pipeline = pipeline; 20 | } 21 | 22 | protected override int Id => DreamBitPackage.Guids.BuildContentCommand; 23 | 24 | public override bool CanExecute() 25 | { 26 | return _pipeline.Loaded; 27 | } 28 | 29 | public override void Execute() 30 | { 31 | Execute(true); 32 | } 33 | public void Execute(bool clean) 34 | { 35 | _pipeline.Build(_pipeline.BuiltContentFolder, clean); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/CloseSceneCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Management; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Windows.Input; 4 | 5 | namespace DreamBit.Extension.Commands.Editor 6 | { 7 | internal interface ICloseSceneCommand : ICommand { } 8 | internal class CloseSceneCommand : BaseCommand, ICloseSceneCommand 9 | { 10 | private readonly IEditor _editor; 11 | 12 | public CloseSceneCommand(IEditor editor) 13 | { 14 | _editor = editor; 15 | } 16 | 17 | public bool CanExecute() 18 | { 19 | return _editor.OpenedSceneFile != null; 20 | } 21 | public void Execute() 22 | { 23 | _editor.OpenedSceneFile = null; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/RedoCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.General.State; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Linq; 4 | using System.Windows.Input; 5 | 6 | namespace DreamBit.Extension.Commands.Editor 7 | { 8 | internal interface IRedoCommand : ICommand 9 | { 10 | bool CanExecute(); 11 | void Execute(); 12 | } 13 | 14 | internal sealed class RedoCommand : BaseCommand, IRedoCommand 15 | { 16 | private readonly IStateManager _state; 17 | 18 | public RedoCommand(IStateManager state) 19 | { 20 | _state = state; 21 | } 22 | 23 | public bool CanExecute() 24 | { 25 | return _state.Dos.Any(); 26 | } 27 | public void Execute() 28 | { 29 | _state.Do(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/SaveSceneCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Management; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Windows.Input; 4 | 5 | namespace DreamBit.Extension.Commands.Editor 6 | { 7 | internal interface ISaveSceneCommand : ICommand { } 8 | internal class SaveSceneCommand : BaseCommand, ISaveSceneCommand 9 | { 10 | private readonly IEditor _editor; 11 | 12 | public SaveSceneCommand(IEditor editor) 13 | { 14 | _editor = editor; 15 | } 16 | 17 | public bool CanExecute() 18 | { 19 | return _editor.OpenedSceneFile != null; 20 | } 21 | public void Execute() 22 | { 23 | _editor.OpenedSceneFile.Save(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/UndoCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.General.State; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Linq; 4 | using System.Windows.Input; 5 | 6 | namespace DreamBit.Extension.Commands.Editor 7 | { 8 | internal interface IUndoCommand : ICommand 9 | { 10 | bool CanExecute(); 11 | void Execute(); 12 | } 13 | 14 | internal sealed class UndoCommand : BaseCommand, IUndoCommand 15 | { 16 | private readonly IStateManager _state; 17 | 18 | public UndoCommand(IStateManager state) 19 | { 20 | _state = state; 21 | } 22 | 23 | public bool CanExecute() 24 | { 25 | return _state.Undos.Any(); 26 | } 27 | public void Execute() 28 | { 29 | _state.Undo(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/ZoomInCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Management; 2 | using DreamBit.Extension.Module; 3 | using Scrawlbit.Presentation.Commands; 4 | using System.Windows.Input; 5 | 6 | namespace DreamBit.Extension.Commands.Editor 7 | { 8 | internal interface IZoomInCommand : ICommand 9 | { 10 | bool CanExecute(); 11 | void Execute(); 12 | } 13 | 14 | internal class ZoomInCommand : BaseCommand, IZoomInCommand 15 | { 16 | private readonly IEditor _editor; 17 | 18 | public ZoomInCommand(IEditor editor) 19 | { 20 | _editor = editor; 21 | } 22 | 23 | public bool CanExecute() 24 | { 25 | return _editor.OpenedScene != null && _editor.Camera.Zoom < _editor.Camera.MaxZoom; 26 | } 27 | public void Execute() 28 | { 29 | _editor.Camera.ZoomIn(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/ZoomOutCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Management; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Windows.Input; 4 | 5 | namespace DreamBit.Extension.Commands.Editor 6 | { 7 | internal interface IZoomOutCommand : ICommand 8 | { 9 | bool CanExecute(); 10 | void Execute(); 11 | } 12 | 13 | internal class ZoomOutCommand : BaseCommand, IZoomOutCommand 14 | { 15 | private readonly IEditor _editor; 16 | 17 | public ZoomOutCommand(IEditor editor) 18 | { 19 | _editor = editor; 20 | } 21 | 22 | public bool CanExecute() 23 | { 24 | return _editor.OpenedScene != null && _editor.Camera.Zoom > _editor.Camera.MinZoom; 25 | } 26 | public void Execute() 27 | { 28 | _editor.Camera.ZoomOut(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Editor/ZoomToOriginalSizeCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Management; 2 | using Scrawlbit.Presentation.Commands; 3 | using System.Windows.Input; 4 | 5 | namespace DreamBit.Extension.Commands.Editor 6 | { 7 | internal interface IZoomToOriginalSizeCommand : ICommand 8 | { 9 | bool CanExecute(); 10 | void Execute(); 11 | } 12 | 13 | internal class ZoomToOriginalSizeCommand : BaseCommand, IZoomToOriginalSizeCommand 14 | { 15 | private readonly IEditor _editor; 16 | 17 | public ZoomToOriginalSizeCommand(IEditor editor) 18 | { 19 | _editor = editor; 20 | } 21 | 22 | public bool CanExecute() 23 | { 24 | return _editor.OpenedScene != null && _editor.Camera.Zoom != 1; 25 | } 26 | public void Execute() 27 | { 28 | _editor.Camera.Zoom = 1; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/Project/AddFontCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Management; 3 | using DreamBit.Extension.Windows.Dialogs; 4 | 5 | namespace DreamBit.Extension.Commands.Project 6 | { 7 | internal interface IAddFontCommand : IToolCommand { } 8 | internal sealed class AddFontCommand : ToolCommand, IAddFontCommand 9 | { 10 | private readonly IProjectManager _manager; 11 | private IHierarchyBridge _hierarchy; 12 | 13 | public AddFontCommand(IProjectManager manager) 14 | { 15 | _manager = manager; 16 | } 17 | 18 | protected override int Id => DreamBitPackage.Guids.AddFontCommand; 19 | 20 | public override void Execute() 21 | { 22 | var dialog = new EditFontDialog(); 23 | 24 | dialog.NewFont(_hierarchy); 25 | } 26 | protected override bool CanShow() 27 | { 28 | return _manager.IsSingleHierarchySelected(out _hierarchy); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/SceneEditorWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Windows; 3 | 4 | namespace DreamBit.Extension.Commands 5 | { 6 | internal interface ISceneEditorWindowCommand : IToolCommand { } 7 | internal sealed class SceneEditorWindowCommand : ToolCommand, ISceneEditorWindowCommand 8 | { 9 | private readonly IPackageBridge _package; 10 | 11 | public SceneEditorWindowCommand(IPackageBridge package) 12 | { 13 | _package = package; 14 | } 15 | 16 | protected override int Id => DreamBitPackage.Guids.SceneEditorWindowCommand; 17 | 18 | public override void Execute() 19 | { 20 | _package.ShowWindow(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/SceneHierarchyWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Windows; 3 | 4 | namespace DreamBit.Extension.Commands 5 | { 6 | internal interface ISceneHierarchyWindowCommand : IToolCommand { } 7 | internal sealed class SceneHierarchyWindowCommand : ToolCommand, ISceneHierarchyWindowCommand 8 | { 9 | private readonly IPackageBridge _package; 10 | 11 | public SceneHierarchyWindowCommand(IPackageBridge package) 12 | { 13 | _package = package; 14 | } 15 | 16 | protected override int Id => DreamBitPackage.Guids.SceneHierarchyWindowCommand; 17 | 18 | public override void Execute() 19 | { 20 | _package.ShowWindow(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DreamBit.Extension/Commands/SceneInspectWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Windows; 3 | 4 | namespace DreamBit.Extension.Commands 5 | { 6 | internal interface ISceneInspectWindowCommand : IToolCommand { } 7 | internal sealed class SceneInspectWindowCommand : ToolCommand, ISceneInspectWindowCommand 8 | { 9 | private readonly IPackageBridge _package; 10 | 11 | public SceneInspectWindowCommand(IPackageBridge package) 12 | { 13 | _package = package; 14 | } 15 | 16 | protected override int Id => DreamBitPackage.Guids.SceneInspectWindowCommand; 17 | 18 | public override void Execute() 19 | { 20 | _package.ShowWindow(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DreamBit.Extension/Components/ToolWindow.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Shell; 2 | 3 | namespace DreamBit.Extension.Components 4 | { 5 | public abstract class ToolWindow : ToolWindowPane 6 | { 7 | protected ToolWindow() 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/DialogView.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.ViewModels.Dialogs; 2 | using Microsoft.VisualStudio.PlatformUI; 3 | using StartupLocation = System.Windows.WindowStartupLocation; 4 | 5 | namespace DreamBit.Extension.Controls 6 | { 7 | public class DialogView : DialogWindow 8 | { 9 | public DialogView() 10 | { 11 | HasMaximizeButton = false; 12 | HasMinimizeButton = false; 13 | WindowStartupLocation = StartupLocation.CenterOwner; 14 | } 15 | 16 | protected T LoadViewModel() where T : BaseDialogViewModel 17 | { 18 | var viewModel = DreamBitPackage.Container.Resolve(); 19 | DataContext = viewModel; 20 | 21 | viewModel.Closed += Close; 22 | 23 | return viewModel; 24 | } 25 | protected void LoadViewModel(out T viewModel) where T : BaseDialogViewModel 26 | { 27 | viewModel = LoadViewModel(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/CheckBox.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/ColorPicker.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/ColorPickerChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.General.State; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace DreamBit.Extension.Controls.Input 5 | { 6 | public class ColorPickerChangedEventArgs : ValueChangedEventArgs 7 | { 8 | public ColorPickerChangedEventArgs(Color oldValue, Color newValue, string colorName) 9 | { 10 | OldValue = oldValue; 11 | NewValue = newValue; 12 | ColorName = colorName; 13 | } 14 | 15 | public string ColorName { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/ContentSelector.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/FloatBox.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/GameObjectSelector.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/IntBox.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/IntBox.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.General.State; 2 | using Scrawlbit.Presentation.Dependency; 3 | 4 | namespace DreamBit.Extension.Controls.Input 5 | { 6 | public partial class IntBox 7 | { 8 | public delegate void IntBoxEventHandler(IntBox sender, ValueChangedEventArgs e); 9 | public static readonly DependencyProperty ValueProperty; 10 | 11 | static IntBox() 12 | { 13 | var registry = new DependencyRegistry(); 14 | 15 | ValueProperty = registry.Property(p => p.Value); 16 | } 17 | public IntBox() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | public event IntBoxEventHandler Changed; 23 | public int Value 24 | { 25 | get => ValueProperty.Get(this); 26 | set => ValueProperty.Set(this, value); 27 | } 28 | public int Increment 29 | { 30 | get => (int)Input.Increment; 31 | set => Input.Increment = (int)value; 32 | } 33 | 34 | private void OnInputChanged(FloatBox sender, ValueChangedEventArgs e) 35 | { 36 | Changed?.Invoke(this, ((int)e.OldValue, (int)e.NewValue)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/Input/TextBox.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /DreamBit.Extension/Controls/WindowView.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.ViewModels; 2 | using System.Windows.Controls; 3 | 4 | namespace DreamBit.Extension.Controls 5 | { 6 | public class WindowView : UserControl 7 | { 8 | protected T LoadViewModel() where T : BaseViewModel 9 | { 10 | var viewModel = DreamBitPackage.Container.Resolve(); 11 | DataContext = viewModel; 12 | 13 | return viewModel; 14 | } 15 | protected void LoadViewModel(out T viewModel) where T : BaseViewModel 16 | { 17 | viewModel = LoadViewModel(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Converters/IconSourceConverter.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Presentation.Converters; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows.Media.Imaging; 5 | 6 | namespace DreamBit.Extension.Converters 7 | { 8 | public class IconSourceConverter : ConverterMarkupExtension 9 | { 10 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return new BitmapImage(DreamBitPackage.GetResourceUri($"Resources/Icons/{parameter}/{value}.png")); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DreamBit.Extension/Converters/MultiTreeViewMarginConverter.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Helpers; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Data; 7 | 8 | namespace DreamBit.Extension.Converters 9 | { 10 | public class MultiTreeViewMarginConverter : IValueConverter 11 | { 12 | public double Length { get; set; } 13 | 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (!(value is MultiSelectTreeViewItem item)) 17 | return new Thickness(0); 18 | 19 | return new Thickness(Length * item.GetDepth(), 0, 0, 0); 20 | } 21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 22 | { 23 | return DependencyProperty.UnsetValue; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Converters/VisibleIfNotNullConverter.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Presentation.Converters; 2 | 3 | namespace DreamBit.Extension.Converters 4 | { 5 | internal class VisibleIfNotNullConverter : ValueConverterGroupMarkup 6 | { 7 | public VisibleIfNotNullConverter() 8 | { 9 | Add(new IsNullConverter()); 10 | Add(new InverseBooleanConverter()); 11 | Add(new VisibilityConverter()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/ColorHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | using MonoGameColor = Microsoft.Xna.Framework.Color; 3 | 4 | namespace DreamBit.Extension.Helpers 5 | { 6 | public static class ColorHelper 7 | { 8 | public static bool AreEquals(this Color color, MonoGameColor xnaColor) 9 | { 10 | return color.R == xnaColor.R && 11 | color.G == xnaColor.G && 12 | color.B == xnaColor.B && 13 | color.A == xnaColor.A; 14 | } 15 | 16 | public static MonoGameColor ToMonoGameColor(this Color color) 17 | { 18 | return new MonoGameColor(color.R, color.G, color.B, color.A); 19 | } 20 | 21 | public static Color ToMediaColor(this MonoGameColor xnaColor) 22 | { 23 | return new Color 24 | { 25 | R = xnaColor.R, 26 | G = xnaColor.G, 27 | B = xnaColor.B, 28 | A = xnaColor.A 29 | }; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/DesignHelper.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | 4 | namespace DreamBit.Extension.Helpers 5 | { 6 | public static class DesignHelper 7 | { 8 | public static bool IsInDesignMode(this DependencyObject dependencyObject) 9 | { 10 | return (bool)dependencyObject.GetValue(DesignerProperties.IsInDesignModeProperty); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/ErrorHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio; 2 | 3 | namespace DreamBit.Extension.Helpers 4 | { 5 | public static class ErrorHelper 6 | { 7 | public static void ThrowOnFailure(this int result) 8 | { 9 | ErrorHandler.ThrowOnFailure(result); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/KeyHelper.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Helpers; 2 | using System.Windows.Input; 3 | 4 | namespace DreamBit.Extension.Helpers 5 | { 6 | public static class KeyHelper 7 | { 8 | public static bool IsShift(this Key key) 9 | { 10 | return key.In(Key.LeftShift, Key.RightShift); 11 | } 12 | public static bool IsControl(this Key key) 13 | { 14 | return key.In(Key.LeftCtrl, Key.RightCtrl); 15 | } 16 | public static bool IsControlOrShift(this Key key) 17 | { 18 | return key.IsControl() || key.IsShift(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/MarshalHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace DreamBit.Extension.Helpers 5 | { 6 | public static class MarshalHelper 7 | { 8 | public static void Release(this IntPtr pointer) 9 | { 10 | if (pointer != IntPtr.Zero) 11 | Marshal.Release(pointer); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Helpers/TreeViewItemHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | 7 | namespace DreamBit.Extension.Helpers 8 | { 9 | public static class TreeViewItemHelper 10 | { 11 | public static int GetDepth(this TreeViewItem item) 12 | { 13 | return item.GetAncestors().TakeWhile(e => !(e is TreeView)).OfType().Count(); 14 | } 15 | public static int GetDepth(this MultiSelectTreeViewItem item) 16 | { 17 | return item.GetAncestors().TakeWhile(e => !(e is MultiSelectTreeView)).OfType().Count(); 18 | } 19 | 20 | private static IEnumerable GetAncestors(this DependencyObject child) 21 | { 22 | var parent = VisualTreeHelper.GetParent(child); 23 | 24 | while (parent != null) 25 | { 26 | yield return parent; 27 | parent = VisualTreeHelper.GetParent(parent); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DreamBit.Extension/Module/SelectionData.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Extension.Module 4 | { 5 | public class SelectionData 6 | { 7 | public bool IsVisible { get; set; } 8 | public Vector2 Position { get; set; } 9 | public float Rotation { get; set; } 10 | public Vector2 Scale { get; set; } 11 | public Matrix Matrix { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DreamBit.Extension/Module/TestGame.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | using ScrawlBit.MonoGame.Interop.Controls; 4 | 5 | namespace DreamBit.Extension.Module 6 | { 7 | public class TestGame : GameModule 8 | { 9 | private Texture2D _pixel; 10 | 11 | public Vector2 Position { get; set; } 12 | 13 | protected override void Initialize() 14 | { 15 | _pixel = new Texture2D(GraphicsDevice, 1, 1); 16 | _pixel.SetData(new[] { Color.White }); 17 | } 18 | protected override void Draw() 19 | { 20 | GraphicsDevice.Clear(Color.Transparent); 21 | 22 | SpriteBatch.Begin(); 23 | SpriteBatch.Draw(_pixel, Position, new Rectangle((int)Position.X, (int)Position.Y, 40, 40), Color.Red * 0.5f); 24 | SpriteBatch.End(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Module/Tools/EditorTool.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Module.Handlers; 2 | using System.Windows.Input; 3 | 4 | namespace DreamBit.Extension.Module.Tools 5 | { 6 | public interface IEditorTool : IEditorHandler 7 | { 8 | string Icon { get; } 9 | Key ShortcutKey { get; } 10 | bool KeepShortcutPressed { get; } 11 | } 12 | 13 | internal abstract class EditorTool : EditorHandler, IEditorTool 14 | { 15 | public abstract string Icon { get; } 16 | public abstract Key ShortcutKey { get; } 17 | public virtual bool KeepShortcutPressed => false; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DreamBit.Extension/Module/Tools/SelectionTool.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Module.Handlers; 2 | using System.Windows.Input; 3 | 4 | namespace DreamBit.Extension.Module.Tools 5 | { 6 | internal interface ISelectionTool : IEditorTool { } 7 | internal class SelectionTool : HandlerTool, ISelectionTool 8 | { 9 | public SelectionTool(IMoveHandler moveHandler, IRotateHandler rotateHandler, IScaleHandler scaleHandler, ISelectHandler selectHandler) 10 | : base(moveHandler, rotateHandler, scaleHandler, selectHandler) 11 | { 12 | selectHandler.DrawOrder = 1; 13 | moveHandler.DrawOrder = 2; 14 | rotateHandler.DrawOrder = 3; 15 | scaleHandler.DrawOrder = 4; 16 | } 17 | 18 | public override string Icon => "cursor"; 19 | public override Key ShortcutKey => Key.V; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Cursors/handClose.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Cursors/handClose.cur -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Cursors/handOpen.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Cursors/handOpen.cur -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/CustomCursors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | using System.Windows.Resources; 5 | 6 | namespace DreamBit.Extension.Resources 7 | { 8 | public static class CustomCursors 9 | { 10 | private static Cursor _handOpen; 11 | private static Cursor _handClose; 12 | 13 | public static Cursor HandOpen => Get("handOpen", ref _handOpen); 14 | public static Cursor HandClose => Get("handClose", ref _handClose); 15 | 16 | private static Cursor Get(string name, ref Cursor cursor) 17 | { 18 | if (cursor == null) 19 | { 20 | Uri path = DreamBitPackage.GetResourceUri($"Resources/Cursors/{name}.cur"); 21 | StreamResourceInfo info = Application.GetResourceStream(path); 22 | 23 | cursor = new Cursor(info.Stream); 24 | } 25 | 26 | return cursor; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/DreamBitPackage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/DreamBitPackage.ico -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/cancel.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/close.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/copy.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/cursor.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/dragPanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/dragPanel.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/glyphDown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/glyphDown.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/glyphDown.white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/glyphDown.white.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/graphics3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/graphics3D.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/redo.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/save.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/undo.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/videoCamera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/videoCamera.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/zoomIn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/zoomIn.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/zoomOut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/zoomOut.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/zoomToFit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/zoomToFit.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Icons/16/zoomToOriginalSize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Icons/16/zoomToOriginalSize.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Images/DottedRepeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Images/DottedRepeat.png -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/DreamBit.Extension/Resources/Logo.ico -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/Border.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/CheckBox.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/Colors.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.PlatformUI; 2 | using Microsoft.VisualStudio.Shell; 3 | 4 | namespace DreamBit.Extension.Resources.Styles 5 | { 6 | public static class Colors 7 | { 8 | public static ThemeResourceKey ComboBoxBorderBrushKey => EnvironmentColors.ComboBoxBorderBrushKey; 9 | public static ThemeResourceKey ComboBoxBackgroundBrushKey => EnvironmentColors.ComboBoxBackgroundBrushKey; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/Colors.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/ComboBox.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 15 | 16 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/DragAndDrop.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/ExpansionPanel.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace DreamBit.Extension.Resources.Styles.SceneInspect 5 | { 6 | public partial class ExpansionPanelStyle 7 | { 8 | private void OnMenuButtonClick(object sender, RoutedEventArgs e) 9 | { 10 | var button = (Button)sender; 11 | 12 | button.ContextMenu.PlacementTarget = button; 13 | button.ContextMenu.IsOpen = true; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/TextBox.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/Theme.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/ToolBar.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /DreamBit.Extension/Resources/Styles/WindowView.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /DreamBit.Extension/ViewModels/BaseViewModel.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Notification; 2 | 3 | namespace DreamBit.Extension.ViewModels 4 | { 5 | public class BaseViewModel : NotificationObject 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Extension/ViewModels/Dialogs/BaseDialogViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Extension.ViewModels.Dialogs 4 | { 5 | public abstract class BaseDialogViewModel : BaseViewModel 6 | { 7 | public event Action Closed; 8 | 9 | protected virtual void Close() 10 | { 11 | Closed?.Invoke(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DreamBit.Extension/ViewModels/SceneInspectViewModel.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Commands.SceneInspect; 2 | using DreamBit.Extension.Management; 3 | using DreamBit.General.State; 4 | using System.Windows.Input; 5 | 6 | namespace DreamBit.Extension.ViewModels 7 | { 8 | public class SceneInspectViewModel : BaseViewModel 9 | { 10 | public SceneInspectViewModel( 11 | IEditor editor, 12 | IStateManager state, 13 | IDropOnInspectCommand dropOnInspectCommand, 14 | IRemoveGameComponentCommand removeGameComponentCommand) 15 | { 16 | Editor = editor; 17 | State = state; 18 | DropOnInspectCommand = dropOnInspectCommand; 19 | RemoveGameComponentCommand = removeGameComponentCommand; 20 | } 21 | 22 | public IEditor Editor { get; } 23 | public IStateManager State { get; } 24 | public ICommand DropOnInspectCommand { get; } 25 | public ICommand RemoveGameComponentCommand { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/Dialogs/EditFontDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Helpers; 3 | using DreamBit.Extension.ViewModels.Dialogs; 4 | using DreamBit.Pipeline.Files; 5 | 6 | namespace DreamBit.Extension.Windows.Dialogs 7 | { 8 | public partial class EditFontDialog 9 | { 10 | private readonly EditFontDialogViewModel _viewModel; 11 | 12 | public EditFontDialog() 13 | { 14 | InitializeComponent(); 15 | 16 | if (this.IsInDesignMode()) 17 | return; 18 | 19 | LoadViewModel(out _viewModel); 20 | } 21 | 22 | public void NewFont(IHierarchyBridge hierarchy) 23 | { 24 | _viewModel.Create(hierarchy); 25 | 26 | Title = "New Font"; 27 | ShowModal(); 28 | } 29 | public void EditFont(PipelineFont font) 30 | { 31 | _viewModel.Edit(font); 32 | 33 | Title = "Edit Font"; 34 | ShowModal(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/Dialogs/FileNameDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | using Scrawlbit.Helpers; 5 | 6 | namespace DreamBit.Extension.Windows.Dialogs 7 | { 8 | public partial class FileNameDialog 9 | { 10 | public FileNameDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | public event Action FileNameInformed; 16 | 17 | public void Open(string title) 18 | { 19 | Title = title; 20 | ShowModal(); 21 | } 22 | 23 | private void OnTextKeyUp(object sender, KeyEventArgs e) 24 | { 25 | if (e.Key == Key.Enter) 26 | NotifyFileNameInformed(); 27 | } 28 | private void OnOkClick(object sender, RoutedEventArgs e) 29 | { 30 | NotifyFileNameInformed(); 31 | } 32 | 33 | private void NotifyFileNameInformed() 34 | { 35 | if (!FileName.Text.HasValue()) 36 | return; 37 | 38 | string fileName = FileName.Text.Trim(); 39 | 40 | FileNameInformed?.Invoke(fileName); 41 | Close(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneEditorView.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Helpers; 2 | using DreamBit.Extension.ViewModels; 3 | 4 | namespace DreamBit.Extension.Windows 5 | { 6 | public partial class SceneEditorView 7 | { 8 | public SceneEditorView() 9 | { 10 | InitializeComponent(); 11 | 12 | if (this.IsInDesignMode()) 13 | return; 14 | 15 | LoadViewModel(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneEditorWindow.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using DreamBit.Extension.Helpers; 3 | using DreamBit.Extension.Management; 4 | using Scrawlbit.Notification; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace DreamBit.Extension.Windows 8 | { 9 | [Guid(DreamBitPackage.Guids.SceneEditorWindow)] 10 | public class SceneEditorWindow : ToolWindow 11 | { 12 | private readonly IEditor _editor; 13 | 14 | public SceneEditorWindow() 15 | { 16 | var view = new SceneEditorView(); 17 | 18 | Content = view; 19 | 20 | if (!view.IsInDesignMode()) 21 | { 22 | DreamBitPackage.Container.Inject(out _editor); 23 | 24 | _editor.Notify().On(e => e.OpenedSceneFile.Name).Changed(UpdateCaption); 25 | } 26 | 27 | UpdateCaption(); 28 | } 29 | 30 | private void UpdateCaption(string name = null) 31 | { 32 | Caption = name ?? "Scene Editor"; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneHierarchyWindow.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Components; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace DreamBit.Extension.Windows 5 | { 6 | [Guid(DreamBitPackage.Guids.SceneHierarchyWindow)] 7 | public class SceneHierarchyWindow : ToolWindow 8 | { 9 | public SceneHierarchyWindow() 10 | { 11 | Caption = "Scene Hierarchy"; 12 | Content = new SceneHierarchyView(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneInspect/ObjectInspect.xaml: -------------------------------------------------------------------------------- 1 |  13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneInspect/ObjectInspect.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Controls.Input; 2 | using DreamBit.Extension.Module; 3 | using DreamBit.General.State; 4 | using System.Windows; 5 | 6 | namespace DreamBit.Extension.Windows.SceneInspect 7 | { 8 | public partial class ObjectInspect 9 | { 10 | public ObjectInspect() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void OnIsVisibleChanged(CheckBox sender, ValueChangedEventArgs e) 16 | { 17 | ((ISelectionObject)sender.DataContext).ValidateChanges(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneInspect/TransformInspect.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Controls.Input; 2 | using DreamBit.Extension.Module; 3 | using DreamBit.General.State; 4 | 5 | namespace DreamBit.Extension.Windows.SceneInspect 6 | { 7 | public partial class TransformInspect 8 | { 9 | public TransformInspect() 10 | { 11 | InitializeComponent(); 12 | } 13 | 14 | private void OnTransformChanged(FloatBox sender, ValueChangedEventArgs e) 15 | { 16 | ((ISelectionObject)sender.DataContext).ValidateChanges(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneInspectView.xaml.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Extension.Helpers; 2 | using DreamBit.Extension.ViewModels; 3 | 4 | namespace DreamBit.Extension.Windows 5 | { 6 | public partial class SceneInspectView 7 | { 8 | public SceneInspectView() 9 | { 10 | InitializeComponent(); 11 | 12 | if (this.IsInDesignMode()) 13 | return; 14 | 15 | LoadViewModel(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DreamBit.Extension/Windows/SceneInspectWindow.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using DreamBit.Extension.Components; 3 | 4 | namespace DreamBit.Extension.Windows 5 | { 6 | [Guid(DreamBitPackage.Guids.SceneInspectWindow)] 7 | public class SceneInspectWindow : ToolWindow 8 | { 9 | public SceneInspectWindow() 10 | { 11 | Caption = "Scene Inspect"; 12 | Content = new SceneInspectView(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /DreamBit.Game/Content/IContent.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project; 2 | 3 | namespace DreamBit.Game.Content 4 | { 5 | public interface IContent 6 | { 7 | IProjectFile File { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /DreamBit.Game/Content/IContentLoader.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project; 2 | using MonoGameContentManager = Microsoft.Xna.Framework.Content.ContentManager; 3 | 4 | namespace DreamBit.Game.Content 5 | { 6 | public interface IContentLoader 7 | { 8 | MonoGameContentManager Manager { get; set; } 9 | 10 | T Load(IProjectFile file); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DreamBit.Game/Content/IContentManager.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Pipeline.Files; 2 | using DreamBit.Project; 3 | 4 | namespace DreamBit.Game.Content 5 | { 6 | public interface IContentManager 7 | { 8 | bool IsContent(IProjectFile file); 9 | 10 | IContent Load(IProjectFile file); 11 | IImage Load(IPipelineImage file); 12 | IFont Load(IPipelineFont file); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DreamBit.Game/Content/Image.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Pipeline.Files; 2 | using DreamBit.Project; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | using Scrawlbit.MonoGame.Helpers; 6 | 7 | namespace DreamBit.Game.Content 8 | { 9 | public interface IImage : IContent 10 | { 11 | new IPipelineImage File { get; } 12 | Texture2D Texture { get; } 13 | int Height { get; } 14 | int Width { get; } 15 | Vector2 Size { get; } 16 | } 17 | 18 | internal class Image : IImage 19 | { 20 | private readonly IContentLoader _loader; 21 | private Texture2D _texture; 22 | 23 | public Image(IPipelineImage file, IContentLoader loader) 24 | { 25 | _loader = loader; 26 | 27 | File = file; 28 | } 29 | 30 | public IPipelineImage File { get; } 31 | public Texture2D Texture 32 | { 33 | get => _texture ?? (_texture = _loader.Load(File)); 34 | } 35 | public int Height => Texture.Height; 36 | public int Width => Texture.Width; 37 | public Vector2 Size => Texture.Size(); 38 | IProjectFile IContent.File => File; 39 | } 40 | } -------------------------------------------------------------------------------- /DreamBit.Game/Elements/Components/ScriptPropertyType.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements.Components 2 | { 3 | public enum ScriptPropertyType 4 | { 5 | Unknown, 6 | Int, 7 | Bool, 8 | String, 9 | Float, 10 | Vector2, 11 | GameObject 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DreamBit.Game/Elements/GameComponent.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Drawing; 2 | using Microsoft.Xna.Framework; 3 | using Scrawlbit.Notification; 4 | 5 | namespace DreamBit.Game.Elements 6 | { 7 | public abstract partial class GameComponent : NotificationObject 8 | { 9 | public GameObject GameObject { get; internal set; } 10 | public bool Started { get; private set; } 11 | public abstract string Name { get; } 12 | 13 | internal void Initialize() 14 | { 15 | if (!Started) 16 | { 17 | Start(); 18 | Started = true; 19 | } 20 | } 21 | 22 | protected internal virtual void Start() { } 23 | protected internal virtual void Update(GameTime gameTime) { } 24 | protected internal virtual void PostUpdate(GameTime gameTime) { } 25 | protected internal virtual void Draw(IContentDrawer drawer) { } 26 | } 27 | } -------------------------------------------------------------------------------- /DreamBit.Game/Elements/GameObjectHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Scrawlbit.MonoGame.Helpers; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace DreamBit.Game.Elements 7 | { 8 | public static class GameObjectHelper 9 | { 10 | public static Rectangle TotalArea(this IEnumerable gameObjects) 11 | { 12 | return RectangleHelper.Union(gameObjects.Select(g => g.TotalArea())); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DreamBit.Game/Elements/ITransform.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Game.Elements 4 | { 5 | public interface ITransform 6 | { 7 | Vector2 Position { get; set; } 8 | float Rotation { get; set; } 9 | Vector2 Scale { get; set; } 10 | 11 | Matrix Matrix { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DreamBit.Game/Elements/Scene.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Drawing; 2 | using DreamBit.Game.Elements.Components; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace DreamBit.Game.Elements 7 | { 8 | public sealed class Scene 9 | { 10 | public Scene() 11 | { 12 | Objects = new GameObjectCollection(); 13 | } 14 | 15 | public IGameObjectCollection Objects { get; } 16 | 17 | public IEnumerable GetCameras() 18 | { 19 | return Objects.SelectMany(o => o.Components).OfType(); 20 | } 21 | 22 | public void Preview(IContentDrawer drawer) 23 | { 24 | for (int i = 0; i < Objects.Count; i++) 25 | Objects[i].Preview(drawer); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DreamBit.Game/Elements/TransformChange.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements 2 | { 3 | internal enum TransformChange 4 | { 5 | Relative = 1, 6 | Real 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Game/Helpers/GameHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using System; 3 | using System.Globalization; 4 | 5 | namespace DreamBit.Game.Helpers 6 | { 7 | public static class GameHelper 8 | { 9 | public static float EnsurePrecision(this float value) 10 | { 11 | return (float)Math.Round(value, 3); 12 | } 13 | public static Vector2 EnsurePrecision(this Vector2 value) 14 | { 15 | return new Vector2(value.X.EnsurePrecision(), value.Y.EnsurePrecision()); 16 | } 17 | 18 | public static string Text(this float value) 19 | { 20 | return value.ToString(CultureInfo.InvariantCulture); 21 | } 22 | public static string Text(this Vector2 value) 23 | { 24 | string x = value.X.Text(); 25 | string y = value.Y.Text(); 26 | 27 | return $"{x};{y}"; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DreamBit.Game/Registrations/SceneFileRegistration.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Files; 2 | using DreamBit.Game.Serialization; 3 | using DreamBit.Modularization.Management; 4 | using DreamBit.Pipeline; 5 | using DreamBit.Project; 6 | using DreamBit.Project.Registrations; 7 | using Scrawlbit.Json; 8 | using System; 9 | 10 | namespace DreamBit.Game.Registrations 11 | { 12 | internal interface ISceneFileRegistration : IFileRegistration { } 13 | internal class SceneFileRegistration : ISceneFileRegistration 14 | { 15 | private readonly IPipeline _pipeline; 16 | private readonly IFileManager _fileManager; 17 | private readonly IGameElementsParser _parser; 18 | 19 | public SceneFileRegistration(IPipeline pipeline, IFileManager fileManager, IGameElementsParser parser) 20 | { 21 | _pipeline = pipeline; 22 | _fileManager = fileManager; 23 | _parser = parser; 24 | } 25 | 26 | public string Type => "Scene"; 27 | public string Extension => ".scene"; 28 | public Type ObjectType => typeof(SceneFile); 29 | 30 | public bool ShouldIncludeFromExternalAction(string path) => true; 31 | public ProjectFile CreateInstance() => new SceneFile(_pipeline, _fileManager, _parser); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DreamBit.Game/Registrations/ScriptFileRegistration.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Files; 2 | using DreamBit.Modularization.Management; 3 | using DreamBit.Project; 4 | using DreamBit.Project.Registrations; 5 | using System; 6 | using System.Text.RegularExpressions; 7 | 8 | namespace DreamBit.Game.Registrations 9 | { 10 | internal interface IScriptFileRegistration : IFileRegistration { } 11 | internal class ScriptFileRegistration : IScriptFileRegistration 12 | { 13 | private readonly IFileManager _fileManager; 14 | private readonly IProject _project; 15 | 16 | public ScriptFileRegistration(IFileManager fileManager, IProject project) 17 | { 18 | _fileManager = fileManager; 19 | _project = project; 20 | } 21 | 22 | public string Type => "Script"; 23 | public string Extension => ".cs"; 24 | public Type ObjectType => typeof(ScriptFile); 25 | 26 | public bool ShouldIncludeFromExternalAction(string path) 27 | { 28 | string content = _fileManager.ReadAllText(path); 29 | 30 | return Regex.IsMatch(content, @"class (\w+) ?:.+ScriptBehavior"); 31 | } 32 | public ProjectFile CreateInstance() => new ScriptFile(_fileManager, _project); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /DreamBit.Game/Serialization/Converters/ColorConverter.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | using Scrawlbit.Util.Helpers; 5 | using System; 6 | 7 | namespace DreamBit.Game.Serialization.Converters 8 | { 9 | internal class ColorConverter : JsonConverter 10 | { 11 | public override Color ReadJson(JsonReader reader, Type objectType, Color existingValue, bool hasExistingValue, JsonSerializer serializer) 12 | { 13 | JToken token = JToken.Load(reader); 14 | string[] parts = token.ToString().Split(';'); 15 | byte r = parts[0].ToByte(); 16 | byte g = parts[1].ToByte(); 17 | byte b = parts[2].ToByte(); 18 | byte a = parts[3].ToByte(); 19 | 20 | return new Color(r, g, b, a); 21 | } 22 | public override void WriteJson(JsonWriter writer, Color value, JsonSerializer serializer) 23 | { 24 | string s = $"{value.R};{value.G};{value.B};{value.A}"; 25 | JToken token = JToken.FromObject(s, serializer); 26 | 27 | token.WriteTo(writer); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DreamBit.Game/Serialization/Converters/ProjectFileConverter.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project; 2 | using DreamBit.Project.Helpers; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | 7 | namespace DreamBit.Game.Serialization.Converters 8 | { 9 | internal class ProjectFileConverter : JsonConverter 10 | { 11 | private readonly IProject _project; 12 | 13 | public ProjectFileConverter(IProject project) 14 | { 15 | _project = project; 16 | } 17 | 18 | public override IProjectFile ReadJson(JsonReader reader, Type objectType, IProjectFile existingValue, bool hasExistingValue, JsonSerializer serializer) 19 | { 20 | JToken token = JToken.Load(reader); 21 | Guid? id = token.ToObject(); 22 | 23 | if (id != null) 24 | return _project.Files.GetById(id.Value); 25 | 26 | return null; 27 | } 28 | public override void WriteJson(JsonWriter writer, IProjectFile value, JsonSerializer serializer) 29 | { 30 | JToken token = JToken.FromObject(value.Id, serializer); 31 | 32 | token.WriteTo(writer); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DreamBit.Game/Serialization/Converters/SceneConverter.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Elements; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | using Scrawlbit.Json; 5 | using System; 6 | 7 | namespace DreamBit.Game.Serialization.Converters 8 | { 9 | internal class SceneConverter : JsonConverter 10 | { 11 | public override Scene ReadJson(JsonReader reader, Type objectType, Scene existingValue, bool hasExistingValue, JsonSerializer serializer) 12 | { 13 | JObject obj = JObject.Load(reader); 14 | Scene scene = new Scene(); 15 | 16 | scene.Objects.Add(obj[nameof(Scene.Objects)].ToObject(serializer)); 17 | 18 | return scene; 19 | } 20 | public override void WriteJson(JsonWriter writer, Scene value, JsonSerializer serializer) 21 | { 22 | JObject obj = new JObject(); 23 | 24 | obj.SetProperty(nameof(Scene.Objects), value.Objects, serializer); 25 | 26 | obj.WriteTo(writer); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DreamBit.Game/Serialization/Converters/Vector2Converter.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Helpers; 2 | using Microsoft.Xna.Framework; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using Scrawlbit.Helpers; 6 | using System; 7 | using System.Globalization; 8 | 9 | namespace DreamBit.Game.Serialization.Converters 10 | { 11 | internal class Vector2Converter : JsonConverter 12 | { 13 | public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer) 14 | { 15 | JToken token = JToken.Load(reader); 16 | string[] parts = token.ToString().Split(';'); 17 | float x = parts[0].ToFloat(CultureInfo.InvariantCulture); 18 | float y = parts[1].ToFloat(CultureInfo.InvariantCulture); 19 | 20 | return new Vector2(x, y); 21 | } 22 | public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer) 23 | { 24 | string text = value.Text(); 25 | JToken token = JToken.FromObject(text); 26 | 27 | token.WriteTo(writer); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DreamBit.General/Properties/GeneralInjectionModule.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.General.State; 2 | using DreamBit.Modularization.Management; 3 | using Scrawlbit.Injection.Configuration; 4 | using Scrawlbit.Json; 5 | 6 | namespace DreamBit.Modularization.Properties 7 | { 8 | public class GeneralInjectionModule : IInjectionModule 9 | { 10 | private IRegistrationBuilder _builder; 11 | 12 | public void Register(IRegistrationBuilder builder) 13 | { 14 | _builder = builder; 15 | 16 | Management(); 17 | State(); 18 | Other(); 19 | } 20 | 21 | private void Management() 22 | { 23 | _builder.Register().Singleton(); 24 | } 25 | private void State() 26 | { 27 | _builder.Register().Singleton(); 28 | } 29 | private void Other() 30 | { 31 | _builder.Register().Transient(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /DreamBit.General/State/CompositeStateCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace DreamBit.General.State 5 | { 6 | internal class CompositeStateCommand : IStateCommand 7 | { 8 | private readonly IStateCommand[] _commands; 9 | 10 | public CompositeStateCommand(IEnumerable commands, string description) 11 | { 12 | _commands = commands.ToArray(); 13 | 14 | Description = description; 15 | } 16 | 17 | public string Description { get; } 18 | 19 | public void Do() 20 | { 21 | foreach (var state in _commands) 22 | state.Do(); 23 | } 24 | public void Undo() 25 | { 26 | foreach (var state in _commands.Reverse()) 27 | state.Undo(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DreamBit.General/State/IStateUnit.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.General.State 2 | { 3 | public interface IStateUnit 4 | { 5 | string Description { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /DreamBit.General/State/StateCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.General.State 4 | { 5 | public interface IStateCommand : IStateUnit 6 | { 7 | void Do(); 8 | void Undo(); 9 | } 10 | 11 | public class StateCommand : IStateCommand 12 | { 13 | public StateCommand(string description = null, Action @do = null, Action undo = null) 14 | { 15 | Description = description; 16 | Do = @do; 17 | Undo = undo; 18 | } 19 | 20 | public string Description { get; set; } 21 | public Action Do { get; set; } 22 | public Action Undo { get; set; } 23 | 24 | void IStateCommand.Do() => Do?.Invoke(); 25 | void IStateCommand.Undo() => Undo?.Invoke(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /DreamBit.General/State/StateScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.General.State 4 | { 5 | public interface IStateScope : IDisposable 6 | { 7 | } 8 | 9 | internal class StateScope : IStateScope 10 | { 11 | private readonly IStateTransaction _transaction; 12 | 13 | public StateScope(IStateTransaction transaction = null) 14 | { 15 | _transaction = transaction; 16 | } 17 | 18 | public void Dispose() 19 | { 20 | _transaction?.End(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DreamBit.General/State/ValueChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace DreamBit.General.State 4 | { 5 | public class ValueChangedEventArgs : RoutedEventArgs 6 | { 7 | public ValueChangedEventArgs() 8 | { 9 | } 10 | public ValueChangedEventArgs(T oldValue, T newValue) 11 | { 12 | OldValue = oldValue; 13 | NewValue = newValue; 14 | } 15 | 16 | public T OldValue { get; set; } 17 | public T NewValue { get; set; } 18 | 19 | public static implicit operator ValueChangedEventArgs((T OldValue, T NewValue) e) 20 | { 21 | return new ValueChangedEventArgs(e.OldValue, e.NewValue); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DreamBit.Pipeline/Exceptions/ImportAlreadyExistsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Pipeline.Exceptions 4 | { 5 | public class ImportAlreadyExistsException : Exception 6 | { 7 | public ImportAlreadyExistsException(string path) : base($"There is already an import with the path \"{path}\"") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Exceptions/ImportNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Pipeline.Exceptions 4 | { 5 | public class ImportNotFoundException : Exception 6 | { 7 | public ImportNotFoundException(string path) : base($"There is no import with the path \"{path}\"") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Exceptions/PipelineAlreadyLoadedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Pipeline.Exceptions 4 | { 5 | public class PipelineAlreadyLoadedException : Exception 6 | { 7 | public PipelineAlreadyLoadedException() : base("The pipeline is already loaded") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Exceptions/PipelineNotLoadedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Pipeline.Exceptions 4 | { 5 | public class PipelineNotLoadedException : Exception 6 | { 7 | public PipelineNotLoadedException() : base("The pipeline is not loaded") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Files/FontFamily.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace DreamBit.Pipeline.Files 4 | { 5 | public enum FontFamily 6 | { 7 | Arial, 8 | [Display(Name = "Segoe UI")] 9 | SegoeUI 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Files/FontStyle.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Files 2 | { 3 | public enum FontStyle 4 | { 5 | Regular, 6 | Bold, 7 | Italic 8 | } 9 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Files/PipelineImage.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project; 2 | 3 | namespace DreamBit.Pipeline.Files 4 | { 5 | public interface IPipelineImage : IProjectFile 6 | { 7 | } 8 | 9 | public sealed class PipelineImage : ProjectFile, IPipelineImage 10 | { 11 | private readonly IPipeline _pipeline; 12 | 13 | internal PipelineImage(IPipeline pipeline) 14 | { 15 | _pipeline = pipeline; 16 | } 17 | 18 | protected override void OnAdded() 19 | { 20 | _pipeline.Contents.AddImport(this); 21 | } 22 | protected override void OnMoved(MovedEventArgs e) 23 | { 24 | _pipeline.Contents.Move(this, e.OldLocation); 25 | } 26 | protected override void OnRemoved() 27 | { 28 | _pipeline.Contents.Remove(this); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/GlobalProperties.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline 2 | { 3 | public interface IGlobalProperties 4 | { 5 | string OutputDir { get; set; } 6 | string IntermediateDir { get; set; } 7 | Platform Platform { get; set; } 8 | string Config { get; set; } 9 | Profile Profile { get; set; } 10 | bool Compress { get; set; } 11 | 12 | void Reset(); 13 | } 14 | 15 | internal class GlobalProperties : IGlobalProperties 16 | { 17 | internal GlobalProperties() 18 | { 19 | Reset(); 20 | } 21 | 22 | public string OutputDir { get; set; } 23 | public string IntermediateDir { get; set; } 24 | public Platform Platform { get; set; } 25 | public string Config { get; set; } 26 | public Profile Profile { get; set; } 27 | public bool Compress { get; set; } 28 | 29 | public void Reset() 30 | { 31 | OutputDir = "bin"; 32 | IntermediateDir = "obj"; 33 | Platform = Platform.Windows; 34 | Config = ""; 35 | Profile = Profile.Reach; 36 | Compress = false; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Helpers/ContentImportHelper.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project; 2 | using System.IO; 3 | 4 | namespace DreamBit.Pipeline.Helpers 5 | { 6 | public static class ContentImportHelper 7 | { 8 | public static string AsImportPath(this string path) 9 | { 10 | return path.Replace('\\', '/'); 11 | } 12 | public static string GetImportPath(this IProjectFile file) 13 | { 14 | return file.Location.AsImportPath(); 15 | } 16 | 17 | public static string AsContentPath(this string path) 18 | { 19 | string folder = Path.GetDirectoryName(path); 20 | string file = Path.GetFileNameWithoutExtension(path); 21 | 22 | return Path.Combine(folder, file).AsImportPath(); 23 | } 24 | public static string GetContentPath(this IProjectFile file) 25 | { 26 | return file.Location.AsContentPath(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DreamBit.Pipeline/Imports/BuildtAction.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Imports 2 | { 3 | public enum BuildtAction 4 | { 5 | Copy, 6 | Build 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Imports/ContentImport.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Imports 2 | { 3 | public interface IContentImport 4 | { 5 | string Path { get; } 6 | BuildtAction BuildtAction { get; } 7 | } 8 | 9 | internal class ContentImport : IContentImport 10 | { 11 | protected ContentImport(string path, BuildtAction buildtAction) 12 | { 13 | Path = path; 14 | BuildtAction = buildtAction; 15 | } 16 | 17 | public string Path { get; internal set; } 18 | public BuildtAction BuildtAction { get; } 19 | } 20 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Imports/CopyImport.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Imports 2 | { 3 | public interface ICopyImport : IContentImport 4 | { 5 | } 6 | 7 | internal class CopyImport : ContentImport, ICopyImport 8 | { 9 | internal CopyImport(string path) : base(path, BuildtAction.Copy) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Imports/FontImport.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Imports 2 | { 3 | public interface IFontImport : IContentImport 4 | { 5 | bool PremultiplyAlpha { get; set; } 6 | TextureFormat TextureFormat { get; set; } 7 | } 8 | 9 | internal class FontImport : ContentImport, IFontImport 10 | { 11 | internal FontImport(string path) : base(path, BuildtAction.Build) 12 | { 13 | PremultiplyAlpha = true; 14 | TextureFormat = TextureFormat.Compressed; 15 | } 16 | 17 | public bool PremultiplyAlpha { get; set; } 18 | public TextureFormat TextureFormat { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Imports/TextureFormat.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Imports 2 | { 3 | public enum TextureFormat 4 | { 5 | Color, 6 | DxtCompressed, 7 | NoChange, 8 | Compressed, 9 | Color16Bit, 10 | Etc1Compressed, 11 | PvrCompressed, 12 | AtcCompressed 13 | } 14 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Platform.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline 2 | { 3 | public enum Platform 4 | { 5 | Windows 6 | } 7 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Profile.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline 2 | { 3 | public enum Profile 4 | { 5 | Reach, 6 | HiDef 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Properties/PipelineMappingProfile.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Pipeline.Imports; 2 | using Scrawlbit.Mapping.Configuration; 3 | 4 | namespace DreamBit.Pipeline.Properties 5 | { 6 | public class PipelineMappingProfile : IMappingProfile 7 | { 8 | public void Register(IMappingBuilder builder) 9 | { 10 | builder.Map().ToSelf(); 11 | builder.Map().ToSelf(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Registrations/PipelineFontRegistration.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Modularization.Management; 2 | using DreamBit.Pipeline.Files; 3 | using DreamBit.Project; 4 | using DreamBit.Project.Registrations; 5 | using System; 6 | 7 | namespace DreamBit.Pipeline.Registrations 8 | { 9 | internal interface IPipelineFontRegistration : IFileRegistration 10 | { 11 | } 12 | 13 | internal class PipelineFontRegistration : IPipelineFontRegistration 14 | { 15 | private readonly IPipeline _pipeline; 16 | private readonly IFileManager _fileManager; 17 | 18 | public PipelineFontRegistration(IPipeline pipeline, IFileManager fileManager) 19 | { 20 | _pipeline = pipeline; 21 | _fileManager = fileManager; 22 | } 23 | 24 | public string Type => "Font"; 25 | public string Extension => ".spritefont"; 26 | public Type ObjectType => typeof(PipelineFont); 27 | 28 | public bool ShouldIncludeFromExternalAction(string path) => true; 29 | public ProjectFile CreateInstance() => new PipelineFont(_pipeline, _fileManager); 30 | } 31 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Registrations/PipelineImageRegistration.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Pipeline.Files; 2 | using DreamBit.Project; 3 | using DreamBit.Project.Registrations; 4 | using System; 5 | 6 | namespace DreamBit.Pipeline.Registrations 7 | { 8 | internal interface IPipelineImageRegistration : IFileRegistration 9 | { 10 | } 11 | 12 | internal class PipelineImageRegistration : IPipelineImageRegistration 13 | { 14 | private readonly IPipeline _pipeline; 15 | 16 | public PipelineImageRegistration(IPipeline pipeline) 17 | { 18 | _pipeline = pipeline; 19 | } 20 | 21 | public string Type => "Image"; 22 | public string Extension => ".png"; 23 | public Type ObjectType => typeof(PipelineImage); 24 | 25 | public bool ShouldIncludeFromExternalAction(string path) => true; 26 | public ProjectFile CreateInstance() => new PipelineImage(_pipeline); 27 | } 28 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Translators/IObjectTranslator.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Translators 2 | { 3 | internal interface IObjectTranslator 4 | { 5 | bool TryRead(string text, out object value); 6 | bool TryWrite(object value, out string text); 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Translators/ITranslator.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Pipeline.Translators 2 | { 3 | internal interface ITranslator 4 | { 5 | void Read(string text); 6 | string Write(); 7 | } 8 | } -------------------------------------------------------------------------------- /DreamBit.Pipeline/Translators/ReferencesTranslator.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace DreamBit.Pipeline.Translators 4 | { 5 | internal interface IReferencesTranslator : ITranslator { } 6 | 7 | internal class ReferencesTranslator : IReferencesTranslator 8 | { 9 | public void Read(string text) 10 | { 11 | } 12 | public string Write() 13 | { 14 | var builder = new StringBuilder(); 15 | 16 | builder.AppendLine("#-------------------------------- References --------------------------------#"); 17 | builder.AppendLine(); 18 | 19 | return builder.ToString(); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /DreamBit.Project.Tests/Mocks/ProjectFileMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Mocks 4 | { 5 | public class ProjectFileMock : ProjectFile 6 | { 7 | public ProjectFileMock(IProject project, Guid id, string type, string extension, string location) 8 | { 9 | Project = project; 10 | Id = id; 11 | Type = type; 12 | Extension = extension; 13 | Location = location; 14 | } 15 | public ProjectFileMock(IProject project, string type, string extension, string location) 16 | { 17 | Project = project; 18 | Type = type; 19 | Extension = extension; 20 | Location = location; 21 | } 22 | 23 | public override string Type { get; } 24 | public override string Extension { get; } 25 | 26 | public static ProjectFileMock Script(IProject project, Guid id, string location) 27 | { 28 | return new ProjectFileMock(project, id, "Script", "cs", location); 29 | } 30 | public static ProjectFileMock Script(IProject project, string location) 31 | { 32 | return new ProjectFileMock(project, "Script", "cs", location); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /DreamBit.Project.Tests/Mocks/RegistrationMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Project.Registrations; 3 | 4 | namespace DreamBit.Project.Mocks 5 | { 6 | public class RegistrationMock : IFileRegistration 7 | { 8 | public string Type { get; set; } 9 | public string Extension { get; set; } 10 | 11 | public ProjectFile CreateInstance() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /DreamBit.Project.Tests/Mocks/SerializerMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project.Serialization; 2 | 3 | namespace DreamBit.Project.Mocks 4 | { 5 | public class SerializerMock : ISerializer 6 | { 7 | public IProject Project { get; set; } 8 | public bool Loaded { get; set; } 9 | public bool Saved { get; set; } 10 | 11 | public void Load(IProject project) 12 | { 13 | Project = project; 14 | Loaded = true; 15 | } 16 | public void Save(IProject project) 17 | { 18 | Project = project; 19 | Saved = true; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /DreamBit.Project.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("DreamBit.Project.Tests")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("")] 8 | [assembly: AssemblyProduct("DreamBit.Project.Tests")] 9 | [assembly: AssemblyCopyright("Copyright © 2019")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: Guid("30418afe-dc84-422e-b5fd-fdc31ded2433")] 16 | 17 | // [assembly: AssemblyVersion("1.0.*")] 18 | [assembly: AssemblyVersion("1.0.0.0")] 19 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /DreamBit.Project.Tests/Tests/ProjectFileTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Project.Mocks; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace DreamBit.Project.Tests 7 | { 8 | [TestClass] 9 | public class ProjectFileTest 10 | { 11 | private ProjectMock _project; 12 | 13 | [TestInitialize] 14 | public void Initialize() 15 | { 16 | _project = new ProjectMock { Folder = @"C:\Projects\Test" }; 17 | } 18 | 19 | [TestMethod] 20 | public void GetName() 21 | { 22 | var file = ProjectFileMock.Script(_project, @"Bosses\Boss.cs"); 23 | 24 | file.Name.Should().Be("Boss.cs"); 25 | } 26 | 27 | [TestMethod] 28 | public void DeterminePathAndLocation() 29 | { 30 | var file = ProjectFileMock.Script(_project, @"Bosses\Boss.cs"); 31 | 32 | file.Location.Should().Be(@"Bosses\Boss.cs"); 33 | file.Path.Should().Be(@"C:\Projects\Test\Bosses\Boss.cs"); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/FileIdAlreadyExistsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class FileIdAlreadyExistsException : Exception 6 | { 7 | public FileIdAlreadyExistsException() : base("There is alredy a file with the same id in the project") { } 8 | } 9 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/FileLocationAlreadyExistsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class FileLocationAlreadyExistsException : Exception 6 | { 7 | public FileLocationAlreadyExistsException() : base("There is alredy a file with the same location in the project") { } 8 | } 9 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/InvalidFileExtensionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class InvalidFileExtensionException : Exception 6 | { 7 | public InvalidFileExtensionException(string path, string expectedExtension) : base( 8 | $"The path {path} is invalid for this file. The expected extension was {expectedExtension}.") 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/ProjectAlreadyLoadedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class ProjectAlreadyLoadedException : Exception 6 | { 7 | public ProjectAlreadyLoadedException() : base("The project is already loaded") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/ProjectFileNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class ProjectFileNotFoundException : Exception 6 | { 7 | public ProjectFileNotFoundException(string path) : base($"There is not a project file in the path {path}") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/ProjectNotLoadedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class ProjectNotLoadedException : Exception 6 | { 7 | public ProjectNotLoadedException() : base("The project is not loaded") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/TypeAlreadyRegistredException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class TypeAlreadyRegistredException : Exception 6 | { 7 | public TypeAlreadyRegistredException() : base("This type is already registred") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Project/Exceptions/TypeNotRegisteredException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Exceptions 4 | { 5 | public class TypeNotRegisteredException : Exception 6 | { 7 | public TypeNotRegisteredException(string type) : base($"The type {type} is not registred") 8 | { 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /DreamBit.Project/Helpers/FileRegistrationHelper.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project.Registrations; 2 | using Scrawlbit.Injection.Configuration; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | 7 | namespace DreamBit.Project.Helpers 8 | { 9 | public static class FileRegistrationHelper 10 | { 11 | public static IRegistration RegisterFile(this IRegistrationBuilder builder) where T : class, IFileRegistration 12 | { 13 | FileRegistrations.Types.Add(typeof(T)); 14 | 15 | return builder.Register(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DreamBit.Project/Helpers/ProjectFileHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace DreamBit.Project.Helpers 6 | { 7 | public static class ProjectFileHelper 8 | { 9 | internal static bool IsPathIncluded(this IEnumerable files, string path) 10 | { 11 | return files.Any(f => f.Path == path); 12 | } 13 | 14 | public static ProjectFile GetByPath(this IEnumerable files, string path) 15 | { 16 | return files.SingleOrDefault(f => f.Path == path); 17 | } 18 | public static ProjectFile GetById(this IEnumerable files, Guid id) 19 | { 20 | return files.SingleOrDefault(f => f.Id == id); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DreamBit.Project/MovedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Project 2 | { 3 | public class MovedEventArgs 4 | { 5 | public string OldPath { get; internal set; } 6 | public string OldLocation { get; internal set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /DreamBit.Project/Properties/ProjectInjectionModule.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Project.Registrations; 2 | using DreamBit.Project.Serialization; 3 | using Scrawlbit.Injection.Configuration; 4 | 5 | namespace DreamBit.Project.Properties 6 | { 7 | public class ProjectInjectionModule : IInjectionModule 8 | { 9 | public void Register(IRegistrationBuilder builder) 10 | { 11 | builder.Register().Singleton(); 12 | builder.Register().Resolve(); 13 | builder.Register().Resolve(); 14 | 15 | builder.Register().Transient(); 16 | 17 | builder.Register().Singleton(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /DreamBit.Project/Registrations/IFileRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Project.Registrations 4 | { 5 | public interface IFileRegistration 6 | { 7 | string Type { get; } 8 | string Extension { get; } 9 | Type ObjectType { get; } 10 | 11 | bool ShouldIncludeFromExternalAction(string path); 12 | ProjectFile CreateInstance(); 13 | } 14 | } -------------------------------------------------------------------------------- /Game1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/Game1.zip -------------------------------------------------------------------------------- /Images/extension.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/Images/extension.png -------------------------------------------------------------------------------- /Images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/Images/overview.png -------------------------------------------------------------------------------- /Images/solution-explorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/Images/solution-explorer.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Scrawlbit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Libs/MultiSelectTreeView/MultiSelectTreeView.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scrawlbit/dreambit/4ffa8f6c290ae58f1721e0640744808e90f6f98c/Libs/MultiSelectTreeView/MultiSelectTreeView.dll -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Components/IEditionGameScene.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Content; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace DreamBit.Game.Components 6 | { 7 | public interface IEditionGameScene 8 | { 9 | ContentManager ContentManager { get; set; } 10 | SpriteBatch SpriteBatch { get; set; } 11 | 12 | void LoadContent(); 13 | void Update(GameTime gameTime); 14 | void PostUpdate(GameTime gameTime); 15 | void Draw(GameTime gameTime); 16 | 17 | void OpenScene(string assetName); 18 | } 19 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Elements/Components/EditableCameraObject.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Game.Elements.Components 4 | { 5 | public class EditableCameraObject : GameObjectComponent 6 | { 7 | internal EditableCameraObject() 8 | { 9 | } 10 | 11 | public ComponentType Type => ComponentType.Camera; 12 | public Vector2 Size { get; set; } 13 | public bool IsActive { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Elements/Components/EditableImageRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Drawing; 3 | 4 | namespace DreamBit.Game.Elements.Components 5 | { 6 | internal class EditableImageRenderer : ImageRenderer 7 | { 8 | internal EditableImageRenderer(IDrawBatch drawBatch) : base(drawBatch) 9 | { 10 | } 11 | 12 | public ComponentType Type => ComponentType.ImageRenderer; 13 | public Guid FileId { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Elements/Components/EditableScriptBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace DreamBit.Game.Elements.Components 5 | { 6 | internal class EditableScriptBehavior : GameObjectComponent 7 | { 8 | internal EditableScriptBehavior(Guid fileId) 9 | { 10 | FileId = fileId; 11 | Properties = new Dictionary(); 12 | } 13 | 14 | public ComponentType Type => ComponentType.ScriptBehavior; 15 | public Guid FileId { get; } 16 | public Dictionary Properties { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Elements/Components/EditableTextRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Drawing; 3 | 4 | namespace DreamBit.Game.Elements.Components 5 | { 6 | internal class EditableTextRenderer : TextRenderer 7 | { 8 | internal EditableTextRenderer(IDrawBatch drawBatch) : base(drawBatch) 9 | { 10 | } 11 | 12 | public ComponentType Type => ComponentType.TextRenderer; 13 | public Guid FileId { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Factory/EditableGameObjectComponentFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Drawing; 3 | using DreamBit.Game.Elements.Components; 4 | using Scrawlbit.Injection; 5 | 6 | namespace DreamBit.Game.Factory 7 | { 8 | internal class EditableGameObjectComponentFactory : IGameObjectComponentFactory 9 | { 10 | private readonly IContainer _container; 11 | 12 | public EditableGameObjectComponentFactory(IContainer container) 13 | { 14 | _container = container; 15 | } 16 | 17 | public GameObjectComponent CreateImageRenderer() 18 | { 19 | return new EditableImageRenderer(_container.Resolve()); 20 | } 21 | public GameObjectComponent CreateTextRenderer() 22 | { 23 | return new EditableTextRenderer(_container.Resolve()); 24 | } 25 | public GameObjectComponent CreateCameraObject() 26 | { 27 | return new EditableCameraObject(); 28 | } 29 | public GameObjectComponent CreateScriptBehavior(string fileId) 30 | { 31 | return new EditableScriptBehavior(Guid.Parse(fileId)); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Registrations/SceneFileRegistration.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Files; 2 | using DreamBit.Modularization.Management; 3 | using DreamBit.Pipeline; 4 | using DreamBit.Project; 5 | using DreamBit.Project.Registrations; 6 | using Scrawlbit.Json; 7 | using System; 8 | 9 | namespace DreamBit.Game.Registrations 10 | { 11 | internal interface ISceneFileRegistration : IFileRegistration { } 12 | internal class SceneFileRegistration : ISceneFileRegistration 13 | { 14 | private readonly IPipeline _pipeline; 15 | private readonly IFileManager _fileManager; 16 | private readonly IJsonParser _jsonParser; 17 | 18 | public SceneFileRegistration(IPipeline pipeline, IFileManager fileManager, IJsonParser jsonParser) 19 | { 20 | _pipeline = pipeline; 21 | _fileManager = fileManager; 22 | _jsonParser = jsonParser; 23 | } 24 | 25 | public string Type => "Scene"; 26 | public string Extension => ".scene"; 27 | public Type ObjectType => typeof(SceneFile); 28 | 29 | public bool ShouldIncludeFromExternalAction(string path) => true; 30 | public ProjectFile CreateInstance() => new SceneFile(_pipeline, _fileManager, _jsonParser); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Writing/DataWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | using Scrawlbit.Json; 4 | 5 | namespace DreamBit.Game.Writing 6 | { 7 | internal class DataWriter : IDataWriter 8 | { 9 | private readonly IJsonParser _jsonParser; 10 | 11 | public DataWriter(IJsonParser jsonParser) 12 | { 13 | _jsonParser = jsonParser; 14 | } 15 | 16 | public void Save(T data, string assetName, string extension, Encoding encoding) 17 | { 18 | File.WriteAllText($"Content/{assetName}.{extension}", _jsonParser.ParseObject(data), encoding); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Writing/IDataWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | namespace DreamBit.Game.Writing 4 | { 5 | internal interface IDataWriter 6 | { 7 | void Save(T data, string assetName, string extension, Encoding encoding); 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Writing/ISceneWriter.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Elements; 2 | 3 | namespace DreamBit.Game.Writing 4 | { 5 | public interface ISceneWriter 6 | { 7 | void Save(Scene scene, string assetName); 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Edition/Writing/SceneWriter.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using DreamBit.Game.Elements; 3 | 4 | namespace DreamBit.Game.Writing 5 | { 6 | internal class SceneWriter : ISceneWriter 7 | { 8 | private readonly IDataWriter _dataWriter; 9 | private readonly UTF8Encoding _encoding; 10 | 11 | public SceneWriter(IDataWriter dataWriter) 12 | { 13 | _dataWriter = dataWriter; 14 | _encoding = new UTF8Encoding(false); 15 | } 16 | 17 | public void Save(Scene scene, string assetName) 18 | { 19 | _dataWriter.Save(scene, assetName, "scene", _encoding); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Content/SceneLoaderTest.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Content.Loaders; 2 | using DreamBit.Game.Tests.Mocks.Reading; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace DreamBit.Game.Tests.Content 7 | { 8 | [TestClass] 9 | public class SceneLoaderTest 10 | { 11 | [TestMethod] 12 | public void LoadScene() 13 | { 14 | var dataReader = new DataReaderMock(); 15 | var loader = new SceneLoader(); 16 | 17 | var content = loader.Load(null, "test", null, dataReader); 18 | 19 | content.Should().Be(dataReader.Content); 20 | dataReader.AssetRequested.Should().Be("test.scene"); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Elements/Components/GameObjectComponentTest.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Tests.Implementations.Elements; 2 | using DreamBit.Game.Tests.Mocks.Elements; 3 | using FluentAssertions; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace DreamBit.Game.Tests.Elements.Components 7 | { 8 | [TestClass] 9 | public class GameObjectComponentTest 10 | { 11 | [TestMethod] 12 | public void StartOnce() 13 | { 14 | var gameObject = new GameObjectMock(); 15 | var component = new GameObjectComponentImplementation(); 16 | 17 | component.Started.Should().BeFalse(); 18 | 19 | component.Initialize(gameObject); 20 | component.StartCount.Should().Be(1); 21 | component.Started.Should().BeTrue(); 22 | 23 | component.Initialize(gameObject); 24 | component.StartCount.Should().Be(1); 25 | component.Started.Should().BeTrue(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Implementations/Elements/GameObjectComponentImplementation.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Elements.Components; 2 | 3 | namespace DreamBit.Game.Tests.Implementations.Elements 4 | { 5 | public class GameObjectComponentImplementation : GameObjectComponent 6 | { 7 | public int StartCount; 8 | 9 | protected internal override void Start() 10 | { 11 | StartCount++; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Components/CameraMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Components; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace DreamBit.Game.Tests.Mocks.Components 5 | { 6 | public class CameraMock : ICamera 7 | { 8 | public bool IsActive { get; set; } 9 | public Vector2 Size { get; set; } 10 | public Vector2 Position { get; set; } 11 | public float Rotation { get; set; } 12 | public Vector2 Zoom { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Components/CameraServiceMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Components; 2 | 3 | namespace DreamBit.Game.Tests.Mocks.Components 4 | { 5 | internal class CameraServiceMock : ICameraService 6 | { 7 | public ICamera CurrentCamera { get; set; } 8 | 9 | public void UpdateSceneCamera() 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Components/SceneCameraMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Components; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace DreamBit.Game.Tests.Mocks.Components 5 | { 6 | public class SceneCameraMock : ISceneCamera 7 | { 8 | public Vector2 Size { get; set; } 9 | public Vector2 Position { get; set; } 10 | public float Rotation { get; set; } 11 | public Vector2 Zoom { get; set; } 12 | 13 | public Matrix TransformMatrix { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Content/ContentLoaderMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Content; 3 | using DreamBit.Game.Reading; 4 | using Microsoft.Xna.Framework.Content; 5 | 6 | namespace DreamBit.Game.Tests.Mocks.Content 7 | { 8 | internal class ContentLoaderMock : IContentLoader 9 | { 10 | public Type ContentType { get; set; } 11 | public IContent ContentToLoad { get; set; } 12 | public (Guid? fileId, string AssetName) Request { get; set; } 13 | 14 | public IContent Load(Guid? fileId, string assetName, ContentManager contentManager, IDataReader dataReader) 15 | { 16 | Request = (fileId, assetName); 17 | 18 | return ContentToLoad; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Content/ContentManagerMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Content; 3 | 4 | namespace DreamBit.Game.Tests.Mocks.Content 5 | { 6 | public class ContentManagerMock : IContentManager 7 | { 8 | public IContent ContentToLoad { get; set; } 9 | public (Type ContentType, Guid? FileId, string AssetName) Request { get; set; } 10 | public bool IsLoaded { get; set; } 11 | 12 | public IContent Load(Type contentType, Guid fileId) 13 | { 14 | Request = (contentType, fileId, null); 15 | 16 | return ContentToLoad; 17 | } 18 | public IContent Load(Type contentType, string assetName) 19 | { 20 | Request = (contentType, null, assetName); 21 | 22 | return ContentToLoad; 23 | } 24 | public T Load(Guid fileId) where T : IContent 25 | { 26 | return (T)Load(typeof(T), fileId); 27 | } 28 | public T Load(string assetName) where T : IContent 29 | { 30 | return (T)Load(typeof(T), assetName); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Content/ContentReferenceManagerMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using DreamBit.Game.Content; 4 | using DreamBit.Game.Elements.Components; 5 | 6 | namespace DreamBit.Game.Tests.Mocks.Content 7 | { 8 | public class ContentReferenceManagerMock : IContentReferenceManager 9 | { 10 | public void Prepare(GameObjectComponent component, PropertyInfo property, Guid fileId) 11 | { 12 | throw new NotImplementedException(); 13 | } 14 | public void Resolve(GameObjectComponent component) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Content/FontMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using DreamBit.Game.Content; 4 | using Microsoft.Xna.Framework; 5 | using Microsoft.Xna.Framework.Graphics; 6 | 7 | namespace DreamBit.Game.Tests.Mocks.Content 8 | { 9 | public class FontMock : IFont 10 | { 11 | public Guid? FileId { get; set; } 12 | public SpriteFont SpriteFont { get; set; } 13 | 14 | public Vector2 MeasureString(string text) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | public Vector2 MeasureString(StringBuilder text) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Content/ImageMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Content; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace DreamBit.Game.Tests.Mocks.Content 6 | { 7 | public class ImageMock : IImage 8 | { 9 | public Guid? FileId { get; set; } 10 | public Texture2D Texture { get; set; } 11 | public int Height { get; set; } 12 | public int Width { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Data/GameDataMock.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using DreamBit.Game.Data; 3 | 4 | namespace DreamBit.Game.Tests.Mocks.Data 5 | { 6 | internal class GameDataMock : IGameData 7 | { 8 | public GameDataMock() 9 | { 10 | ContentPaths = new List(); 11 | ScriptTypes = new List(); 12 | } 13 | 14 | public string StartScene { get; set; } 15 | public List ContentPaths { get; } 16 | public List ScriptTypes { get; } 17 | 18 | IReadOnlyList IGameData.ContentPaths => ContentPaths; 19 | IReadOnlyList IGameData.ScriptTypes => ScriptTypes; 20 | } 21 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Elements/GameObjectComponentMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Elements.Components; 2 | 3 | namespace DreamBit.Game.Tests.Mocks.Elements 4 | { 5 | public class GameObjectComponentMock : GameObjectComponent 6 | { 7 | public bool StartCalled { get; set; } 8 | public bool UpdateCalled { get; set; } 9 | public bool PostUpdateCalled { get; set; } 10 | public bool DrawCalled { get; set; } 11 | 12 | protected internal override void Start() 13 | { 14 | StartCalled = true; 15 | } 16 | protected internal override void Update() 17 | { 18 | UpdateCalled = true; 19 | } 20 | protected internal override void PostUpdate() 21 | { 22 | PostUpdateCalled = true; 23 | } 24 | protected internal override void Draw() 25 | { 26 | DrawCalled = true; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Mocks/Reading/DataReaderMock.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Reading; 2 | 3 | namespace DreamBit.Game.Tests.Mocks.Reading 4 | { 5 | public class DataReaderMock : IDataReader 6 | { 7 | public object Content { get; set; } 8 | public string AssetRequested { get; set; } 9 | 10 | public T Load(string assetName, string extension) 11 | { 12 | AssetRequested = $"{assetName}.{extension}"; 13 | 14 | return (T)Content; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("DreamBit.Game.Tests")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("DreamBit.Game.Tests")] 10 | [assembly: AssemblyCopyright("Copyright © 2019")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: Guid("1d60d34e-285f-4c61-b2a8-19d67075db44")] 17 | 18 | // [assembly: AssemblyVersion("1.0.*")] 19 | [assembly: AssemblyVersion("1.0.0.0")] 20 | [assembly: AssemblyFileVersion("1.0.0.0")] 21 | -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/CameraService.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Components 2 | { 3 | internal class CameraService : ICameraService 4 | { 5 | private readonly ISceneCamera _sceneCamera; 6 | private ICamera _currentCamera; 7 | 8 | public CameraService(ISceneCamera sceneCamera) 9 | { 10 | _sceneCamera = sceneCamera; 11 | } 12 | 13 | public ICamera CurrentCamera 14 | { 15 | get => _currentCamera; 16 | set 17 | { 18 | if (value == _currentCamera) return; 19 | 20 | if (_currentCamera != null) 21 | _currentCamera.IsActive = false; 22 | 23 | _currentCamera = value; 24 | _currentCamera.IsActive = true; 25 | } 26 | } 27 | 28 | public void UpdateSceneCamera() 29 | { 30 | if (CurrentCamera?.IsActive == true) 31 | { 32 | _sceneCamera.Size = CurrentCamera.Size; 33 | _sceneCamera.Position = CurrentCamera.Position; 34 | _sceneCamera.Rotation = CurrentCamera.Rotation; 35 | _sceneCamera.Zoom = CurrentCamera.Zoom; 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/DeltaTime.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace DreamBit.Game.Components 5 | { 6 | public static class DeltaTime 7 | { 8 | internal static GameTime GameTime { get; set; } 9 | 10 | public static TimeSpan ElapsedTime => GameTime.ElapsedGameTime; 11 | public static float ElapsedSeconds => (float)ElapsedTime.TotalSeconds; 12 | public static float ElapsedMilliseconds => (float)ElapsedTime.TotalMilliseconds; 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/GameScene.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Drawing; 2 | using Microsoft.Xna.Framework; 3 | 4 | namespace DreamBit.Game.Components 5 | { 6 | internal class GameScene : IGameScene 7 | { 8 | private readonly ISceneManager _sceneManager; 9 | private readonly IDrawBatch _drawBatch; 10 | private readonly ISceneCamera _sceneCamera; 11 | 12 | public GameScene(ISceneManager sceneManager, IDrawBatch drawBatch, ISceneCamera sceneCamera) 13 | { 14 | _sceneManager = sceneManager; 15 | _drawBatch = drawBatch; 16 | _sceneCamera = sceneCamera; 17 | } 18 | 19 | public void Update(GameTime gameTime) 20 | { 21 | DeltaTime.GameTime = gameTime; 22 | 23 | _sceneManager.OpenedScene.Update(); 24 | } 25 | public void PostUpdate(GameTime gameTime) 26 | { 27 | _sceneManager.OpenedScene.PostUpdate(); 28 | } 29 | public void Draw(GameTime gameTime) 30 | { 31 | _drawBatch.Begin(transformMatrix: _sceneCamera.TransformMatrix); 32 | _sceneManager.OpenedScene.Draw(); 33 | _drawBatch.End(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/ICamera.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Game.Components 4 | { 5 | internal interface ICamera 6 | { 7 | bool IsActive { get; set; } 8 | Vector2 Size { get; } 9 | Vector2 Position { get; } 10 | float Rotation { get; } 11 | Vector2 Zoom { get; } 12 | } 13 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/ICameraService.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Components 2 | { 3 | internal interface ICameraService 4 | { 5 | ICamera CurrentCamera { get; set; } 6 | 7 | void UpdateSceneCamera(); 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/IGameScene.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Game.Components 4 | { 5 | internal interface IGameScene 6 | { 7 | void Update(GameTime gameTime); 8 | void PostUpdate(GameTime gameTime); 9 | void Draw(GameTime gameTime); 10 | } 11 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/ISceneCamera.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace DreamBit.Game.Components 4 | { 5 | public interface ISceneCamera 6 | { 7 | Vector2 Size { get; set; } 8 | Vector2 Position { get; set; } 9 | float Rotation { get; set; } 10 | Vector2 Zoom { get; set; } 11 | 12 | Matrix TransformMatrix { get; } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Components/ISceneManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Elements; 3 | 4 | namespace DreamBit.Game.Components 5 | { 6 | public interface ISceneManager 7 | { 8 | Scene OpenedScene { get; } 9 | 10 | void Load(Guid fileId); 11 | void Load(string assetName); 12 | } 13 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/Font.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | 6 | namespace DreamBit.Game.Content 7 | { 8 | public interface IFont : IContent 9 | { 10 | Guid? FileId { get; } 11 | SpriteFont SpriteFont { get; } 12 | 13 | Vector2 MeasureString(string text); 14 | Vector2 MeasureString(StringBuilder text); 15 | } 16 | 17 | internal class Font : IFont 18 | { 19 | public Font(Guid? fileId, SpriteFont spriteFont) 20 | { 21 | FileId = fileId; 22 | SpriteFont = spriteFont; 23 | } 24 | 25 | public Guid? FileId { get; } 26 | public SpriteFont SpriteFont { get; } 27 | 28 | public Vector2 MeasureString(string text) 29 | { 30 | return SpriteFont.MeasureString(text); 31 | } 32 | public Vector2 MeasureString(StringBuilder text) 33 | { 34 | return SpriteFont.MeasureString(text); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/IContent.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Content 2 | { 3 | public interface IContent 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/IContentLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Reading; 3 | using Microsoft.Xna.Framework.Content; 4 | 5 | namespace DreamBit.Game.Content 6 | { 7 | internal interface IContentLoader 8 | { 9 | Type ContentType { get; } 10 | 11 | IContent Load(Guid? fileId, string assetName, ContentManager contentManager, IDataReader dataReader); 12 | } 13 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/IContentManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Content 4 | { 5 | public interface IContentManager 6 | { 7 | bool IsLoaded { get; } 8 | 9 | IContent Load(Type contentType, Guid fileId); 10 | IContent Load(Type contentType, string assetName); 11 | T Load(Guid fileId) where T : IContent; 12 | T Load(string assetName) where T : IContent; 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/IContentManagerService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework.Content; 2 | 3 | namespace DreamBit.Game.Content 4 | { 5 | internal interface IContentManagerService 6 | { 7 | ContentManager ContentManager { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/IContentReferenceManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using DreamBit.Game.Elements.Components; 4 | 5 | namespace DreamBit.Game.Content 6 | { 7 | internal interface IContentReferenceManager 8 | { 9 | void Prepare(GameObjectComponent component, PropertyInfo property, Guid fileId); 10 | void Resolve(GameObjectComponent component); 11 | } 12 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/Image.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace DreamBit.Game.Content 5 | { 6 | public interface IImage : IContent 7 | { 8 | Guid? FileId { get; } 9 | Texture2D Texture { get; } 10 | int Height { get; } 11 | int Width { get; } 12 | } 13 | 14 | internal class Image : IImage 15 | { 16 | public Image(Guid? fileId, Texture2D texture) 17 | { 18 | FileId = fileId; 19 | Texture = texture; 20 | } 21 | 22 | public Guid? FileId { get; } 23 | public Texture2D Texture { get; } 24 | public int Height => Texture.Height; 25 | public int Width => Texture.Width; 26 | } 27 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/Loaders/FontLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Reading; 3 | using Microsoft.Xna.Framework.Content; 4 | using Microsoft.Xna.Framework.Graphics; 5 | 6 | namespace DreamBit.Game.Content.Loaders 7 | { 8 | internal class FontLoader : IContentLoader 9 | { 10 | public Type ContentType => typeof(IFont); 11 | 12 | public IContent Load(Guid? fileId, string assetName, ContentManager contentManager, IDataReader dataReader) 13 | { 14 | return new Font(fileId, contentManager.Load(assetName)); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/Loaders/ImageLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Reading; 3 | using Microsoft.Xna.Framework.Content; 4 | using Microsoft.Xna.Framework.Graphics; 5 | 6 | namespace DreamBit.Game.Content.Loaders 7 | { 8 | internal class ImageLoader : IContentLoader 9 | { 10 | public Type ContentType => typeof(IImage); 11 | 12 | public IContent Load(Guid? fileId, string assetName, ContentManager contentManager, IDataReader dataReader) 13 | { 14 | return new Image(fileId, contentManager.Load(assetName)); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Content/Loaders/SceneLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DreamBit.Game.Elements; 3 | using DreamBit.Game.Reading; 4 | using Microsoft.Xna.Framework.Content; 5 | 6 | namespace DreamBit.Game.Content.Loaders 7 | { 8 | internal class SceneLoader : IContentLoader 9 | { 10 | public Type ContentType => typeof(Scene); 11 | 12 | public IContent Load(Guid? fileId, string assetName, ContentManager contentManager, IDataReader dataReader) 13 | { 14 | return dataReader.Load(assetName, "scene"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/DebugData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Data 4 | { 5 | public class DebugData : IDebugData 6 | { 7 | public Guid StartScene { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/GameContent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Data 4 | { 5 | internal class GameContent 6 | { 7 | public Guid FileId { get; set; } 8 | public string ContentPath { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/GameData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace DreamBit.Game.Data 5 | { 6 | internal class GameData : IGameData 7 | { 8 | public string StartScene { get; set; } 9 | [JsonProperty("ContentReferences")] 10 | public IReadOnlyList ContentPaths { get; set; } 11 | [JsonProperty("ScriptReferences")] 12 | public IReadOnlyList ScriptTypes { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/GameScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Data 4 | { 5 | internal class GameScript 6 | { 7 | private Type _type; 8 | 9 | public Guid FileId { get; set; } 10 | public string TypeName { get; set; } 11 | 12 | public Type Type 13 | { 14 | get 15 | { 16 | if (_type == null) 17 | _type = Type.GetType(TypeName); 18 | 19 | return _type; 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/IDebugData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Data 4 | { 5 | internal interface IDebugData 6 | { 7 | Guid StartScene { get; } 8 | } 9 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Data/IGameData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DreamBit.Game.Data 4 | { 5 | internal interface IGameData 6 | { 7 | string StartScene { get; } 8 | IReadOnlyList ContentPaths { get; } 9 | IReadOnlyList ScriptTypes { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Drawing/DrawBatchDefinitionRequest.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Drawing 2 | { 3 | internal class DrawBatchDefinitionRequest 4 | { 5 | public DrawBatchDefinitionRequest(DrawBatchDefinition definition) 6 | { 7 | Definition = definition; 8 | RequestCount = 1; 9 | } 10 | 11 | public DrawBatchDefinition Definition { get; } 12 | public int RequestCount { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Drawing/IDrawBatchService.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Content; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace DreamBit.Game.Drawing 6 | { 7 | internal interface IDrawBatchService 8 | { 9 | SpriteBatch SpriteBatch { get; set; } 10 | 11 | void Begin(DrawBatchDefinition definition); 12 | void End(); 13 | 14 | void Draw(IImage image, Rectangle rectangle, Color color); 15 | void Draw(IImage image, Vector2 position, Color color); 16 | void Draw(IImage image, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effect, float depth); 17 | void Draw(IImage image, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effect, float depth); 18 | 19 | void DrawString(IFont font, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effect, float depth); 20 | void DrawString(IFont font, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effect, float depth); 21 | } 22 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Elements/Components/ComponentType.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements.Components 2 | { 3 | public enum ComponentType 4 | { 5 | ImageRenderer, 6 | ScriptBehavior, 7 | Camera, 8 | TextRenderer 9 | } 10 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Elements/Components/GameObjectComponent.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements.Components 2 | { 3 | public abstract partial class GameObjectComponent 4 | { 5 | public bool Started { get; private set; } 6 | public IGameObject GameObject { get; private set; } 7 | 8 | internal virtual void Initialize(IGameObject gameObject) 9 | { 10 | if (!Started) 11 | { 12 | GameObject = gameObject; 13 | 14 | Start(); 15 | Started = true; 16 | } 17 | } 18 | 19 | protected internal virtual void Start() { } 20 | protected internal virtual void Update() { } 21 | protected internal virtual void PostUpdate() { } 22 | protected internal virtual void Draw() { } 23 | } 24 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Elements/Components/ScriptBehavior.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements.Components 2 | { 3 | public abstract class ScriptBehavior : GameObjectComponent 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Elements/TransformChange.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Elements 2 | { 3 | internal enum TransformChange 4 | { 5 | Relative = 1, 6 | Real 7 | } 8 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Exceptions/ContentNotRegisteredException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Exceptions 4 | { 5 | public class ContentNotRegisteredException : Exception 6 | { 7 | public ContentNotRegisteredException(Guid id) : base($"There is no content registered with id \"{id}\"") 8 | { 9 | 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Helpers/PropertyHelper.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Helpers 2 | { 3 | public static class PropertyHelper 4 | { 5 | public static bool SetTo(this T value, ref T variable) 6 | { 7 | if (!Equals(variable, value)) 8 | { 9 | variable = value; 10 | return true; 11 | } 12 | 13 | return false; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Helpers/PropertyInfoHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Reflection; 3 | 4 | namespace DreamBit.Game.Helpers 5 | { 6 | internal static class PropertyInfoHelper 7 | { 8 | public static bool IsStatic(this PropertyInfo property) 9 | { 10 | return property.GetMethod?.IsStatic ?? property.SetMethod.IsStatic; 11 | } 12 | public static bool HasParameters(this PropertyInfo property) 13 | { 14 | return property.GetIndexParameters().Any(); 15 | } 16 | public static bool HasPublicGetter(this PropertyInfo property) 17 | { 18 | return property.GetMethod?.IsPublic == true; 19 | } 20 | public static bool HasPublicSetter(this PropertyInfo property) 21 | { 22 | return property.SetMethod?.IsPublic == true; 23 | } 24 | 25 | public static void CopyValue(this PropertyInfo property, object obj, object from) 26 | { 27 | var value = property.GetValue(from); 28 | property.SetValue(obj, value); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Helpers/TypeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace DreamBit.Game.Helpers 6 | { 7 | internal static class TypeHelper 8 | { 9 | public static IEnumerable GetInstanceProperties(this Type type) 10 | { 11 | foreach (var property in type.GetProperties()) 12 | { 13 | if (property.IsStatic()) continue; 14 | if (property.HasParameters()) continue; 15 | 16 | yield return property; 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Reading/Attributes/ContentReferenceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DreamBit.Game.Reading.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Property)] 6 | internal class ContentReferenceAttribute : Attribute 7 | { 8 | public ContentReferenceAttribute(string propertyName) 9 | { 10 | PropertyName = propertyName; 11 | } 12 | 13 | public string PropertyName { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Reading/DataReader.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using DreamBit.Game.Reading.Converters; 3 | using Scrawlbit.Json; 4 | using Newtonsoft.Json.Converters; 5 | using Scrawlbit.Injection; 6 | 7 | namespace DreamBit.Game.Reading 8 | { 9 | internal class DataReader : IDataReader 10 | { 11 | private readonly IContainer _container; 12 | private IJsonParser _jsonParser; 13 | 14 | public DataReader(IContainer container) 15 | { 16 | _container = container; 17 | } 18 | 19 | public T Load(string assetName, string extension) 20 | { 21 | if (_jsonParser == null) 22 | { 23 | _jsonParser = _container.Resolve(); 24 | _jsonParser.Converters.Add(new StringEnumConverter()); 25 | _jsonParser.Converters.Add(_container.Resolve()); 26 | _jsonParser.Converters.Add(_container.Resolve()); 27 | } 28 | 29 | var json = File.ReadAllText($"Content/{assetName}.{extension}"); 30 | var obj = _jsonParser.ParseString(json); 31 | 32 | return obj; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Reading/IDataReader.cs: -------------------------------------------------------------------------------- 1 | namespace DreamBit.Game.Reading 2 | { 3 | internal interface IDataReader 4 | { 5 | T Load(string assetName, string extension); 6 | } 7 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Singletons.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Components; 2 | 3 | namespace DreamBit.Game 4 | { 5 | internal static class Singletons 6 | { 7 | private static ISceneManager _sceneManager; 8 | 9 | internal static ISceneManager SceneManager => Get(ref _sceneManager); 10 | 11 | private static T Get(ref T variable) where T : class 12 | { 13 | return variable ?? BaseGame.Container.Inject(out variable); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Static/GameObject.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Elements.Components; 2 | using DreamBit.Game.Helpers; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace DreamBit.Game.Elements 6 | { 7 | partial class GameObject 8 | { 9 | public static GameObject Copy(IGameObject gameObject) 10 | { 11 | var copy = new GameObject 12 | { 13 | Name = gameObject.Name, 14 | IsVisible = gameObject.IsVisible, 15 | Transform = 16 | { 17 | Position = gameObject.Transform.Position, 18 | Rotation = gameObject.Transform.Rotation, 19 | Scale = gameObject.Transform.Scale, 20 | } 21 | }; 22 | 23 | foreach (var child in gameObject.Children) 24 | copy.AddChild(Copy(child)); 25 | 26 | foreach (var component in gameObject.Components) 27 | copy.AddComponent(GameObjectComponent.Copy(component)); 28 | 29 | return copy; 30 | } 31 | public static IGameObject Find(string name) 32 | { 33 | return Singletons.SceneManager.OpenedScene.GameObjects.Find(name); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Old.DreamBit.Game/Static/GameObjectComponent.cs: -------------------------------------------------------------------------------- 1 | using DreamBit.Game.Components; 2 | using DreamBit.Game.Helpers; 3 | 4 | // ReSharper disable once CheckNamespace 5 | namespace DreamBit.Game.Elements.Components 6 | { 7 | partial class GameObjectComponent 8 | { 9 | internal static GameObjectComponent Copy(GameObjectComponent component) 10 | { 11 | var type = component.GetType(); 12 | var properties = type.GetProperties(); 13 | var copy = BaseGame.Container.Resolve(type); 14 | 15 | foreach (var property in properties) 16 | { 17 | if (property.HasPublicGetter() && property.HasPublicSetter()) 18 | property.CopyValue(copy, component); 19 | } 20 | 21 | return (GameObjectComponent)copy; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /ScrawlBit.MonoGame.Interop/Controls/DrawEventArgs.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework.Graphics; 2 | 3 | namespace ScrawlBit.MonoGame.Interop.Controls 4 | { 5 | /// 6 | /// Provides data for the Draw event. 7 | /// 8 | public sealed class DrawEventArgs : GraphicsDeviceEventArgs 9 | { 10 | private readonly DrawingSurface _drawingSurface; 11 | 12 | public DrawEventArgs(DrawingSurface drawingSurface, GraphicsDevice graphicsDevice) 13 | : base(graphicsDevice) 14 | { 15 | _drawingSurface = drawingSurface; 16 | } 17 | 18 | public void InvalidateSurface() 19 | { 20 | _drawingSurface.Invalidate(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /ScrawlBit.MonoGame.Interop/Controls/GameMouseButtonEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | 4 | namespace ScrawlBit.MonoGame.Interop.Controls 5 | { 6 | public class GameMouseButtonEventArgs : GameMouseEventArgs 7 | { 8 | private readonly MouseButtonEventArgs _args; 9 | 10 | internal GameMouseButtonEventArgs(MouseButtonEventArgs args, IInputElement inputElement) : base(args, inputElement) 11 | { 12 | _args = args; 13 | } 14 | 15 | public MouseButtonState ButtonState => _args.ButtonState; 16 | public MouseButton ChangedButton => _args.ChangedButton; 17 | public int ClickCount => _args.ClickCount; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ScrawlBit.MonoGame.Interop/Controls/GameMouseWheelEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Input; 3 | 4 | namespace ScrawlBit.MonoGame.Interop.Controls 5 | { 6 | public class GameMouseWheelEventArgs : GameMouseEventArgs 7 | { 8 | private readonly MouseWheelEventArgs _args; 9 | 10 | internal GameMouseWheelEventArgs(MouseWheelEventArgs args, IInputElement inputElement) : base(args, inputElement) 11 | { 12 | _args = args; 13 | } 14 | 15 | public int Delta => _args.Delta; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ScrawlBit.MonoGame.Interop/Controls/GraphicsDeviceEventArgs.cs: -------------------------------------------------------------------------------- 1 | #region File Description 2 | //----------------------------------------------------------------------------- 3 | // Copyright 2011, Nick Gravelyn. 4 | // Licensed under the terms of the Ms-PL: 5 | // http://www.microsoft.com/opensource/licenses.mspx#Ms-PL 6 | //----------------------------------------------------------------------------- 7 | #endregion 8 | 9 | using System; 10 | using Microsoft.Xna.Framework.Graphics; 11 | 12 | namespace ScrawlBit.MonoGame.Interop.Controls 13 | { 14 | /// 15 | /// Arguments used for Device related events. 16 | /// 17 | public class GraphicsDeviceEventArgs : EventArgs 18 | { 19 | /// 20 | /// Gets the GraphicsDevice. 21 | /// 22 | public GraphicsDevice GraphicsDevice { get; } 23 | 24 | /// 25 | /// Initializes a new GraphicsDeviceEventArgs. 26 | /// 27 | /// The GraphicsDevice associated with the event. 28 | public GraphicsDeviceEventArgs(GraphicsDevice graphicsDevice) 29 | { 30 | GraphicsDevice = graphicsDevice; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /ScrawlBit.MonoGame.Interop/Controls/RenderSizeChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace ScrawlBit.MonoGame.Interop.Controls 2 | { 3 | public class RenderSizeChangedEventArgs 4 | { 5 | internal RenderSizeChangedEventArgs(int width, int height) 6 | { 7 | Width = width; 8 | Height = height; 9 | } 10 | 11 | public int Width { get; } 12 | public int Height { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/Configuration/MappingBuilder.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace Scrawlbit.Mapping.Configuration 4 | { 5 | internal class MappingBuilder : IMappingBuilder 6 | { 7 | private readonly Profile _profile; 8 | private readonly IMappingService _mappingService; 9 | 10 | public MappingBuilder(Profile profile, IMappingService mappingService) 11 | { 12 | _profile = profile; 13 | _mappingService = mappingService; 14 | } 15 | 16 | public IMappingSource Map() 17 | { 18 | return new MappingSource(_profile, _mappingService); 19 | } 20 | 21 | public void RegisterProfile(IMappingProfile profile) 22 | { 23 | profile.Register(this); 24 | } 25 | public void RegisterProfile() where T : IMappingProfile, new() 26 | { 27 | RegisterProfile(new T()); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/Configuration/MappingSource.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace Scrawlbit.Mapping.Configuration 4 | { 5 | internal class MappingSource : IMappingSource 6 | { 7 | private readonly Profile _profile; 8 | private readonly IMappingService _mappingService; 9 | 10 | internal MappingSource(Profile profile, IMappingService mappingService) 11 | { 12 | _profile = profile; 13 | _mappingService = mappingService; 14 | } 15 | 16 | public IMappingDestination To() 17 | { 18 | return new MappingDestination(_profile, _mappingService); 19 | } 20 | public IMappingDestination ToSelf() 21 | { 22 | return To(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/Mapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AutoMapper; 3 | 4 | namespace Scrawlbit.Mapping 5 | { 6 | internal class Mapping : IMapping 7 | { 8 | private readonly IMapper _mapper; 9 | private readonly T _model; 10 | 11 | public Mapping(IMapper mapper, T model) 12 | { 13 | _mapper = mapper; 14 | _model = model; 15 | } 16 | 17 | public object To(Type destinationType) 18 | { 19 | return _mapper.Map(_model, typeof(T), destinationType); 20 | } 21 | public TDestination To() 22 | { 23 | return _mapper.Map(_model); 24 | } 25 | public TDestination To(TDestination destination) 26 | { 27 | return _mapper.Map(_model, destination); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/MappingService.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace Scrawlbit.Mapping 4 | { 5 | internal class MappingService : IMappingService 6 | { 7 | public IMapper Mapper { get; set; } 8 | 9 | public IMapping Map(T model) 10 | { 11 | return new Mapping(Mapper, model); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/MappingServiceBuilder.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Scrawlbit.Mapping.Configuration; 3 | 4 | namespace Scrawlbit.Mapping 5 | { 6 | public class MappingServiceBuilder 7 | { 8 | private readonly MappingServiceProfile _profile; 9 | private readonly MappingService _mappingService; 10 | 11 | public MappingServiceBuilder() 12 | { 13 | _mappingService = new MappingService(); 14 | _profile = new MappingServiceProfile(); 15 | 16 | MappingBuilder = new MappingBuilder(_profile, _mappingService); 17 | } 18 | 19 | public IMappingBuilder MappingBuilder { get; } 20 | 21 | public IMappingService Build() 22 | { 23 | var configuration = new MapperConfiguration(c => c.AddProfile(_profile)); 24 | var mapper = configuration.CreateMapper(); 25 | 26 | _mappingService.Mapper = mapper; 27 | 28 | return _mappingService; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Scrawlbit.AutoMapper/MappingServiceProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | 3 | namespace Scrawlbit.Mapping 4 | { 5 | internal class MappingServiceProfile : Profile 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /Scrawlbit.Json/Converters/AbstractObjectConveter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Linq; 4 | 5 | namespace Scrawlbit.Json.Converters 6 | { 7 | public abstract class AbstractObjectConveter : JsonConverter 8 | { 9 | public override bool CanWrite => false; 10 | 11 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 16 | { 17 | var jObject = JObject.Load(reader); 18 | var target = CreateInstance(jObject); 19 | 20 | serializer.Populate(jObject.CreateReader(), target); 21 | 22 | return target; 23 | } 24 | public override bool CanConvert(Type objectType) 25 | { 26 | return typeof(T).IsAssignableFrom(objectType); 27 | } 28 | 29 | protected abstract T CreateInstance(JObject jObject); 30 | } 31 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame.Tests/AssertionHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Scrawlbit.MonoGame.Tests.Assertions; 3 | 4 | namespace Scrawlbit.MonoGame.Tests 5 | { 6 | public static class AssertionHelper 7 | { 8 | public static Vector2Assertions Should(this Vector2 actualValue) 9 | { 10 | return new Vector2Assertions(actualValue); 11 | } 12 | public static RectangleAssertions Should(this Rectangle actualValue) 13 | { 14 | return new RectangleAssertions(actualValue); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame.Tests/Assertions/RectangleAssertions.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using FluentAssertions.Execution; 3 | using Microsoft.Xna.Framework; 4 | 5 | namespace Scrawlbit.MonoGame.Tests.Assertions 6 | { 7 | public class RectangleAssertions 8 | { 9 | public RectangleAssertions(Rectangle value) 10 | { 11 | Subject = value; 12 | } 13 | 14 | public Rectangle Subject { get; } 15 | 16 | public AndConstraint Be(Rectangle expectedValue, string because = "", params object[] becauseArgs) 17 | { 18 | Execute.Assertion 19 | .ForCondition(Subject == expectedValue) 20 | .BecauseOf(because, becauseArgs) 21 | .FailWith("Expected {context:value} to be {0}{reason}, but found {1}.", expectedValue, Subject); 22 | 23 | return new AndConstraint(this); 24 | } 25 | public AndConstraint Be(int expectedX, int expectedY, int expectedWidth, int expectedHeight, string because = "", params object[] becauseArgs) 26 | { 27 | return Be(new Rectangle(expectedX, expectedY, expectedWidth, expectedHeight), because, becauseArgs); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame.Tests/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.MonoGame.Tests 2 | { 3 | public static class Constants 4 | { 5 | public const float CommonPrecision = 0.0001f; 6 | } 7 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame.Tests/FloatAssertionsHelper.cs: -------------------------------------------------------------------------------- 1 | using FluentAssertions; 2 | using FluentAssertions.Numeric; 3 | 4 | namespace Scrawlbit.MonoGame.Tests 5 | { 6 | public static class FloatAssertionsHelper 7 | { 8 | public static AndConstraint> BeApproximately(this NumericAssertions assertions, float expectedValue, string because = "", params object[] becauseArgs) 9 | { 10 | return assertions.BeApproximately(expectedValue, Constants.CommonPrecision, because, becauseArgs); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame/Helpers/MathematicHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace Scrawlbit.MonoGame.Helpers 4 | { 5 | public static class MathematicHelper 6 | { 7 | public static float RoundAngle(float rotation, int fixedDegrees) 8 | { 9 | return MathHelper.ToRadians((int)(MathHelper.ToDegrees(rotation) / fixedDegrees) * fixedDegrees); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame/Helpers/PointHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | 3 | namespace Scrawlbit.MonoGame.Helpers 4 | { 5 | public static class PointHelper 6 | { 7 | public static readonly Point Zero = new Point(0, 0); 8 | 9 | public static bool IsEmpty(this Point point) 10 | { 11 | return point == Zero; 12 | } 13 | 14 | public static Point Transform(Point point, Matrix matrix) 15 | { 16 | return Vector2.Transform(point.ToVector2(), matrix).ToPoint(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame/Helpers/SpriteEffectsHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework.Graphics; 2 | 3 | namespace Scrawlbit.MonoGame.Helpers 4 | { 5 | public static class SpriteEffectsHelper 6 | { 7 | public static SpriteEffects GetEffects(bool flipHorizontally, bool flipVertically) 8 | { 9 | var effects = SpriteEffects.None; 10 | 11 | if (flipHorizontally) 12 | effects |= SpriteEffects.FlipHorizontally; 13 | 14 | if (flipVertically) 15 | effects |= SpriteEffects.FlipVertically; 16 | 17 | return effects; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Scrawlbit.MonoGame/Helpers/TextureHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace Scrawlbit.MonoGame.Helpers 5 | { 6 | public static class TextureHelper 7 | { 8 | public static Color GetPixel(this Color[] colors, int x, int y, int width) 9 | { 10 | return colors[x + (y * width)]; 11 | } 12 | 13 | public static bool IsTransparent(this Color[] colors, int x, int y, int width) 14 | { 15 | return colors.GetPixel(x, y, width) == Color.Transparent; 16 | } 17 | 18 | public static Color[] GetPixels(this Texture2D texture) 19 | { 20 | var colors = new Color[texture.Width * texture.Height]; 21 | texture.GetData(colors); 22 | return colors; 23 | } 24 | 25 | public static Vector2 Size(this Texture2D texture) 26 | { 27 | return new Vector2(texture.Width, texture.Height); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Bindings/EnumCollectionBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Scrawlbit.Presentation.Bindings 6 | { 7 | public class EnumCollectionBinding : Binding, IValueConverter 8 | { 9 | public EnumCollectionBinding() 10 | { 11 | Converter = this; 12 | } 13 | 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | var type = value as Type; 17 | if (type?.IsEnum == true) 18 | return Enum.GetValues(type); 19 | 20 | return null; 21 | } 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Collections/Behaviors.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xaml.Behaviors; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Scrawlbit.Presentation.Collections 5 | { 6 | public class Behaviors : Collection 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Commands/CommandParameter.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Helpers; 2 | using System; 3 | using System.Reflection; 4 | 5 | namespace Scrawlbit.Presentation.Commands 6 | { 7 | internal class CommandParameter 8 | { 9 | private readonly ParameterInfo _info; 10 | private bool? _isNullable; 11 | 12 | public CommandParameter(ParameterInfo info) 13 | { 14 | _info = info; 15 | } 16 | 17 | private Type Type => _info.ParameterType; 18 | private bool IsNullable 19 | { 20 | get 21 | { 22 | if (_isNullable == null) 23 | _isNullable = Type.IsClass || Type.IsInterface || Type.IsNullable(); 24 | 25 | return _isNullable.Value; 26 | } 27 | } 28 | 29 | public bool IsAssignable(object value) 30 | { 31 | if (value == null && IsNullable) 32 | return true; 33 | 34 | return value?.GetType().IsAssignableTo(Type) == true; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/CollectionViewSourceConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Scrawlbit.Presentation.Converters 6 | { 7 | public class CollectionViewSourceConverter : IValueConverter 8 | { 9 | private readonly CollectionViewSource _viewSource; 10 | 11 | public CollectionViewSourceConverter() 12 | { 13 | _viewSource = new CollectionViewSource(); 14 | } 15 | 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | _viewSource.Source = value; 19 | 20 | return _viewSource.View; 21 | } 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | 27 | public event FilterEventHandler Filter 28 | { 29 | add { _viewSource.Filter += value; } 30 | remove { _viewSource.Filter -= value; } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/ConverterMarkupExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Scrawlbit.Presentation.Converters 7 | { 8 | public abstract class ConverterMarkupExtension : MarkupExtension, IValueConverter, IMultiValueConverter 9 | { 10 | public sealed override object ProvideValue(IServiceProvider serviceProvider) 11 | { 12 | return this; 13 | } 14 | 15 | public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | throw new NotSupportedException(); 18 | } 19 | public virtual object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotSupportedException(); 22 | } 23 | public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | throw new NotSupportedException(); 26 | } 27 | public virtual object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 28 | { 29 | throw new NotSupportedException(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/EnumDisplayNameConverter.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Presentation.Helpers; 2 | using System; 3 | using System.Globalization; 4 | 5 | namespace Scrawlbit.Presentation.Converters 6 | { 7 | public class EnumDisplayNameConverter : ConverterMarkupExtension 8 | { 9 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return (value as Enum)?.DisplayName(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/EnumerableHasElementsConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | 6 | namespace Scrawlbit.Presentation.Converters 7 | { 8 | public class EnumerableHasElementsConverter : ConverterMarkupExtension 9 | { 10 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return ((IEnumerable)value).Any(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/IntToFloatConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Scrawlbit.Presentation.Converters 5 | { 6 | public class IntToFloatConverter : ConverterMarkupExtension 7 | { 8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 9 | { 10 | int? intValue = value as int?; 11 | 12 | if (intValue != null) 13 | return (float)intValue; 14 | 15 | return null; 16 | } 17 | public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | float? floatValue = value as float?; 20 | 21 | if (floatValue != null) 22 | return (int)floatValue; 23 | 24 | return null; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Scrawlbit.Presentation.Converters 5 | { 6 | public class InverseBooleanConverter : ConverterMarkupExtension 7 | { 8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 9 | { 10 | return !(bool)value; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/IsNullConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Scrawlbit.Presentation.Converters 5 | { 6 | public class IsNullConverter : ConverterMarkupExtension 7 | { 8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 9 | { 10 | return value == null; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/LocalizableDescriptionConverter.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Presentation.Attributes; 2 | using System; 3 | using System.Globalization; 4 | using System.Reflection; 5 | using System.Windows.Data; 6 | 7 | namespace Scrawlbit.Presentation.Converters 8 | { 9 | [ValueConversion(typeof(object), typeof(string))] 10 | public class LocalizableDescriptionConverter : ConverterMarkupExtension 11 | { 12 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (value != null) 15 | { 16 | var fi = value.GetType().GetField(value.ToString()); 17 | 18 | if (fi != null) 19 | { 20 | var attribute = fi.GetCustomAttribute(); 21 | if (attribute != null) 22 | return attribute.Description; 23 | } 24 | 25 | return value.ToString(); 26 | } 27 | 28 | return string.Empty; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/NewArrayConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Presentation.Converters 6 | { 7 | public class NewArrayConverter : ConverterMarkupExtension 8 | { 9 | public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return values.ToArray(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/OrConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Presentation.Converters 6 | { 7 | public class OrConverter : ConverterMarkupExtension 8 | { 9 | public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var result = values?.Any(v => Equals(v, true)) ?? false; 12 | return result; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/TypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | 4 | namespace Scrawlbit.Presentation.Converters 5 | { 6 | public class TypeConverter : ConverterMarkupExtension 7 | { 8 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 9 | { 10 | return value.GetType(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Converters/VisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | 5 | namespace Scrawlbit.Presentation.Converters 6 | { 7 | public class VisibilityConverter : ConverterMarkupExtension 8 | { 9 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | return Equals(value, true) ? Visibility.Visible : Visibility.Collapsed; 12 | } 13 | public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | return Equals(value, Visibility.Visible); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Data/ComparisonBinding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Scrawlbit.Presentation.Data 6 | { 7 | public class ComparisonBinding : MultiBinding 8 | { 9 | public ComparisonBinding() 10 | { 11 | Converter = new EqualConverter(); 12 | } 13 | 14 | private class EqualConverter : IMultiValueConverter 15 | { 16 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | for (int i = 0; i < values.Length; i++) 19 | { 20 | for (int j = 0; j < values.Length; j++) 21 | { 22 | if (i != j && !Equals(values[i], values[j])) 23 | return false; 24 | } 25 | } 26 | 27 | return true; 28 | } 29 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 30 | { 31 | throw new NotSupportedException(); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Data/ContextMenuBinding.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Data; 4 | 5 | namespace Scrawlbit.Presentation.Data 6 | { 7 | public class ContextMenuBinding : Binding 8 | { 9 | private const string PlacementTargetTag = "PlacementTarget.Tag"; 10 | 11 | public ContextMenuBinding() 12 | : base(PlacementTargetTag) 13 | { 14 | Initialize(); 15 | } 16 | public ContextMenuBinding(string path) 17 | : base(PlacementTargetTag + "." + path) 18 | { 19 | Initialize(); 20 | } 21 | 22 | public new PropertyPath Path 23 | { 24 | get { return base.Path; } 25 | set 26 | { 27 | value.Path = PlacementTargetTag + "." + value.Path; 28 | base.Path = value; 29 | } 30 | } 31 | 32 | private void Initialize() 33 | { 34 | RelativeSource = new RelativeSource 35 | { 36 | Mode = RelativeSourceMode.FindAncestor, 37 | AncestorType = typeof(ContextMenu) 38 | }; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Data/TypeTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace Scrawlbit.Presentation.Data 6 | { 7 | public sealed class TypeTemplateSelector : DataTemplateSelector 8 | { 9 | public override DataTemplate SelectTemplate(object item, DependencyObject container) 10 | { 11 | DataTemplate template = null; 12 | 13 | if (item != null && container is FrameworkElement element) 14 | { 15 | Type type = item as Type ?? item.GetType(); 16 | DataTemplateKey key = new DataTemplateKey(type); 17 | 18 | template = element.TryFindResource(key) as DataTemplate; 19 | } 20 | 21 | return template ?? base.SelectTemplate(item, container); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Dependency/EventRegistry.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Scrawlbit.Presentation.Dependency 4 | { 5 | public class EventRegistry where TOwner : UIElement 6 | { 7 | public RoutedEvent Routed(string name) 8 | { 9 | var routedEvent = EventManager.RegisterRoutedEvent(name, RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TOwner)); 10 | 11 | return new RoutedEvent(routedEvent); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Dependency/RoutedEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Scrawlbit.Presentation.Dependency 4 | { 5 | public class RoutedEvent where TOwner : UIElement 6 | { 7 | private readonly RoutedEvent _routedEvent; 8 | 9 | internal RoutedEvent(RoutedEvent routedEvent) 10 | { 11 | _routedEvent = routedEvent; 12 | } 13 | 14 | public void Add(TOwner owner, RoutedEventHandler handler) 15 | { 16 | owner.AddHandler(_routedEvent, handler); 17 | } 18 | public void Remove(TOwner owner, RoutedEventHandler handler) 19 | { 20 | owner.RemoveHandler(_routedEvent, handler); 21 | } 22 | 23 | public void Raise(TOwner owner) 24 | { 25 | owner.RaiseEvent(new RoutedEventArgs(_routedEvent)); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/DragAndDrop/DropEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace Scrawlbit.Presentation.DragAndDrop 5 | { 6 | public class DropEventArgs 7 | { 8 | public object[] Data { get; set; } 9 | public object Target { get; set; } 10 | public DropType DropType { get; set; } 11 | public bool IsFiles { get; set; } 12 | 13 | public bool HasMultipleData => Data?.Length > 1; 14 | public object SingleData => Data?[0]; 15 | public IEnumerable Files => Data.Cast(); 16 | } 17 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/DragAndDrop/DropType.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Presentation.DragAndDrop 2 | { 3 | public enum DropType 4 | { 5 | Above = 1, 6 | Inside, 7 | InsideOnTop, 8 | Below 9 | } 10 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/DragAndDrop/DroppableAdorner.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Documents; 3 | 4 | namespace Scrawlbit.Presentation.DragAndDrop 5 | { 6 | public abstract class DroppableAdorner : Adorner 7 | { 8 | private AdornerLayer _layer; 9 | 10 | protected DroppableAdorner(UIElement adornedElement) : base(adornedElement) 11 | { 12 | IsHitTestVisible = false; 13 | } 14 | 15 | public virtual void Update(DropType dropType, object[] data, object target) 16 | { 17 | if (_layer == null) 18 | { 19 | _layer = AdornerLayer.GetAdornerLayer(AdornedElement); 20 | _layer.Add(this); 21 | } 22 | 23 | _layer.Update(AdornedElement); 24 | Visibility = Visibility.Visible; 25 | } 26 | public virtual void Remove() 27 | { 28 | Visibility = Visibility.Collapsed; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/DragAndDrop/MultipleDataDraggableBehavior.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Windows; 3 | using Microsoft.Xaml.Behaviors; 4 | using Scrawlbit.Presentation.Dependency; 5 | 6 | namespace Scrawlbit.Presentation.DragAndDrop 7 | { 8 | public class MultipleDataDraggableBehavior : Behavior 9 | { 10 | public static readonly DependencyProperty ItemsProperty; 11 | 12 | static MultipleDataDraggableBehavior() 13 | { 14 | var dependency = new DependencyRegistry(); 15 | 16 | ItemsProperty = dependency.Property(b => b.Items); 17 | } 18 | 19 | public IEnumerable Items 20 | { 21 | get => ItemsProperty.Get(this); 22 | set => ItemsProperty.Set(this, value); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/DragAndDrop/TreeViewDropEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Presentation.DragAndDrop 6 | { 7 | public class TreeViewDropEventArgs : DropEventArgs 8 | { 9 | public TreeViewDropEventArgs() 10 | { 11 | Sources = new Dictionary(); 12 | } 13 | 14 | public object OriginalTarget { get; set; } 15 | public IDictionary Sources { get; } 16 | public IEnumerable To { get; set; } 17 | public int ToIndex { get; set; } 18 | 19 | public SourceData SingleSource => Sources.Single().Value; 20 | 21 | public class SourceData 22 | { 23 | public object Data { get; set; } 24 | public IEnumerable From { get; set; } 25 | public int FromIndex { get; set; } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Helpers/ApplicationHelper.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Windows; 3 | 4 | namespace Scrawlbit.Presentation.Helpers 5 | { 6 | public static class ApplicationHelper 7 | { 8 | public static bool IsInDesignMode() 9 | { 10 | return (bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue; 11 | } 12 | 13 | public static T FindResource(string name) 14 | { 15 | return (T)Application.Current.FindResource(name); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Helpers/BindingHelper.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Helpers; 2 | using System; 3 | using System.Linq.Expressions; 4 | using System.Windows.Data; 5 | 6 | namespace Scrawlbit.Presentation.Helpers 7 | { 8 | public static class BindingHelper 9 | { 10 | public static Binding SourcePath(T source, Expression> path) 11 | { 12 | return new Binding(path.GetExpressionText()) { Source = source }; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Helpers/CommandHelper.cs: -------------------------------------------------------------------------------- 1 | using Scrawlbit.Presentation.Commands; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Input; 5 | 6 | namespace Scrawlbit.Presentation.Helpers 7 | { 8 | public static class CommandHelper 9 | { 10 | internal static bool IsParameterValid(object parameter, bool allowNullValues) 11 | { 12 | return parameter != DependencyProperty.UnsetValue && (allowNullValues || parameter != null); 13 | } 14 | 15 | public static void TryExecute(this ICommand command, object value) 16 | { 17 | if (command?.CanExecute(value) == true) 18 | command.Execute(value); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Helpers/ComponentModelHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.Reflection; 4 | 5 | namespace Scrawlbit.Presentation.Helpers 6 | { 7 | public static class ComponentModelHelper 8 | { 9 | public static string DisplayName(this Enum value) 10 | { 11 | var field = value.GetType().GetField(value.ToString()); 12 | var attribute = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute)); 13 | 14 | return attribute?.Name ?? value.ToString(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Scrawlbit.Presentation/Helpers/ItemContainerGeneratorHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Scrawlbit.Presentation.Helpers 5 | { 6 | public static class ItemContainerGeneratorHelper 7 | { 8 | public static DependencyObject SafeContainerFromIndex(this ItemContainerGenerator itemContainerGenerator, int index) 9 | { 10 | if (index < 0 || index == itemContainerGenerator.Items.Count) 11 | return null; 12 | 13 | return itemContainerGenerator.ContainerFromIndex(index); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Scrawlbit.SimpleInjector/Configuration/RegistrationSource.cs: -------------------------------------------------------------------------------- 1 | using SimpleInjector; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Scrawlbit.Injection.Configuration 7 | { 8 | internal class RegistrationSource 9 | { 10 | private readonly Container _container; 11 | private readonly List _registrations; 12 | 13 | public RegistrationSource(Container container) 14 | { 15 | _container = container; 16 | _registrations = new List(); 17 | } 18 | 19 | public Registration Get(Lifestyle lifeStyle, Func creator = null) where TImplementation : class 20 | { 21 | var registration = _registrations.SingleOrDefault(r => r.ImplementationType == typeof(TImplementation)); 22 | if (registration == null) 23 | { 24 | registration = creator != null 25 | ? lifeStyle.CreateRegistration(creator, _container) 26 | : lifeStyle.CreateRegistration(_container); 27 | 28 | _registrations.Add(registration); 29 | } 30 | 31 | return registration; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Scrawlbit.SimpleInjector/ResolverContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SimpleInjector; 3 | 4 | namespace Scrawlbit.Injection 5 | { 6 | internal class ResolverContainer : IContainer 7 | { 8 | private readonly Container _container; 9 | 10 | public ResolverContainer(Container container) 11 | { 12 | _container = container; 13 | } 14 | 15 | public object GetService(Type serviceType) 16 | { 17 | return Resolve(serviceType); 18 | } 19 | public object Resolve(Type serviceType) 20 | { 21 | return _container.GetInstance(serviceType); 22 | } 23 | public TService Resolve(Type serviceType) where TService : class 24 | { 25 | return (TService)Resolve(serviceType); 26 | } 27 | public TService Resolve() where TService : class 28 | { 29 | return _container.GetInstance(); 30 | } 31 | public TService Inject(out TService variable) where TService : class 32 | { 33 | return variable = Resolve(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Collections/ExtendedObservableCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Scrawlbit.Collections 5 | { 6 | public class ExtendedObservableCollection : ObservableCollection, IObservableCollection, IReadOnlyObservableCollection 7 | { 8 | public ExtendedObservableCollection() { } 9 | public ExtendedObservableCollection(List list) : base(list) { } 10 | public ExtendedObservableCollection(IEnumerable collection) : base(collection) { } 11 | 12 | object IObservableCollection.this[int index] => this[index]; 13 | void IObservableCollection.Insert(int index, object item) 14 | { 15 | Insert(index, (T)item); 16 | } 17 | void IObservableCollection.Add(object item) 18 | { 19 | Add((T)item); 20 | } 21 | bool IObservableCollection.Remove(object item) 22 | { 23 | return Remove((T)item); 24 | } 25 | int IObservableCollection.IndexOf(object item) 26 | { 27 | return IndexOf((T)item); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Collections/IObservableCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Collections.Specialized; 4 | using System.ComponentModel; 5 | 6 | namespace Scrawlbit.Collections 7 | { 8 | public interface IObservableCollection : IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged 9 | { 10 | object this[int index] { get; } 11 | int Count { get; } 12 | 13 | void Insert(int index, object item); 14 | void Add(object item); 15 | bool Remove(object item); 16 | void Move(int oldIndex, int newIndex); 17 | 18 | int IndexOf(object item); 19 | 20 | void Clear(); 21 | } 22 | 23 | public interface IObservableCollection : IObservableCollection, IList, IReadOnlyObservableCollection 24 | { 25 | new int Count { get; } 26 | new T this[int index] { get; } 27 | 28 | new void Clear(); 29 | } 30 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Collections/IReadOnlyObservableCollection.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.Specialized; 3 | using System.ComponentModel; 4 | 5 | namespace Scrawlbit.Collections 6 | { 7 | public interface IReadOnlyObservableCollection : IReadOnlyCollection, INotifyCollectionChanged, INotifyPropertyChanged 8 | { 9 | T this[int index] { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Comparison/FuncEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Scrawlbit.Comparison 5 | { 6 | internal class FuncEqualityComparer : IEqualityComparer 7 | { 8 | private readonly Func _comparer; 9 | 10 | public FuncEqualityComparer(Func comparer) 11 | { 12 | _comparer = comparer; 13 | } 14 | 15 | public bool Equals(T x, T y) 16 | { 17 | return Equals(_comparer(x), _comparer(y)); 18 | } 19 | public int GetHashCode(T obj) 20 | { 21 | return _comparer(obj).GetHashCode(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/ArrayHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class ArrayHelper 6 | { 7 | public static int IndexOf(this T[] array, T value) 8 | { 9 | return Array.IndexOf(array, value); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/AttributeHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | 5 | namespace Scrawlbit.Helpers 6 | { 7 | public static class AttributeHelper 8 | { 9 | public static bool HasAttribute(this ICustomAttributeProvider provider, bool inherit = true) where T : Attribute 10 | { 11 | return provider.GetCustomAttributes(typeof(T), inherit).Any(); 12 | } 13 | public static T Attribute(this ICustomAttributeProvider provider, bool inherit = true) where T : Attribute 14 | { 15 | return (T)provider.GetCustomAttributes(typeof(T), inherit).FirstOrDefault(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/ByteHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Util.Helpers 4 | { 5 | public static class ByteHelper 6 | { 7 | public static byte ToByte(this string value) 8 | { 9 | return Convert.ToByte(value); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/DictionaryHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Helpers 6 | { 7 | public static class DictionaryHelper 8 | { 9 | public static IEnumerable Keys(this IDictionary dictionary, Func, bool> predicate) 10 | { 11 | return dictionary.Where(predicate).Select(d => d.Key); 12 | } 13 | 14 | public static void ForEach(this IDictionary source, Action action) 15 | { 16 | foreach (var item in source) 17 | action(item.Key, item.Value); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/EnumHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Helpers 6 | { 7 | public static class EnumHelper 8 | { 9 | public static IEnumerable Enumerable() 10 | { 11 | return Enum.GetValues(typeof(T)).Cast(); 12 | } 13 | 14 | public static T Parse(string value, bool ignoreCase = false) 15 | { 16 | return (T)Enum.Parse(typeof(T), value, ignoreCase); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/ExpressionHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq.Expressions; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class ExpressionHelper 6 | { 7 | public static string GetExpressionText(this LambdaExpression expression) 8 | { 9 | var text = string.Empty; 10 | 11 | var member = expression.Body as MemberExpression; 12 | while (member != null) 13 | { 14 | if (text != string.Empty) 15 | text = "." + text; 16 | 17 | text = member.Member.Name + text; 18 | 19 | member = member.Expression as MemberExpression; 20 | } 21 | 22 | 23 | return text; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/FloatHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class FloatHelper 6 | { 7 | public static float ToFloat(this string text) 8 | { 9 | return float.Parse(text); 10 | } 11 | public static float ToFloat(this string text, CultureInfo culture) 12 | { 13 | return float.Parse(text, culture); 14 | } 15 | 16 | public static float Truncate(this float value) 17 | { 18 | return (int)value; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/IntHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class IntHelper 6 | { 7 | public static bool BetweenMargin(this int number, int numberCompare, int margin) 8 | { 9 | return number.Between(numberCompare - margin, numberCompare + margin); 10 | } 11 | 12 | public static bool Between(this int num, int lower, int upper, bool inclusive = false) 13 | { 14 | return inclusive 15 | ? lower <= num && num <= upper 16 | : lower < num && num < upper; 17 | } 18 | 19 | public static int ToInt(this string value) 20 | { 21 | return Convert.ToInt32(value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/LazyHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class LazyHelper 6 | { 7 | public static Lazy New(Func factory) 8 | { 9 | return new Lazy(factory); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/ListHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Scrawlbit.Helpers 6 | { 7 | public static class ListHelper 8 | { 9 | public static void InsertOrdered(this IList collection, T item, Func, IOrderedEnumerable> ordering) 10 | { 11 | var items = ordering(collection.Union(item)); 12 | var index = items.IndexOf(item); 13 | 14 | collection.Insert(index, item); 15 | } 16 | public static void InsertOrdered(this IList collection, T item, Func orderBy, params Func[] thenBy) 17 | { 18 | collection.InsertOrdered(item, c => 19 | { 20 | var items = c.OrderBy(orderBy); 21 | 22 | foreach (var t in thenBy) 23 | items = items.ThenBy(t); 24 | 25 | return items; 26 | }); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/MemberHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Scrawlbit.Util.Helpers 4 | { 5 | public static class MemberHelper 6 | { 7 | public static void SetProperty(this object obj, PropertyInfo property, object value) 8 | { 9 | property.SetValue(obj, value); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/ObjectHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace Scrawlbit.Helpers 4 | { 5 | public static class ObjectHelper 6 | { 7 | public static bool EqualsAny(this T value, params T[] values) 8 | { 9 | return values.Any(v => Equals(v, value)); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/StringHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Helpers 2 | { 3 | public static class StringHelper 4 | { 5 | public static bool HasValue(this string s) 6 | { 7 | return !string.IsNullOrWhiteSpace(s); 8 | } 9 | 10 | public static string Remove(this string source, string part) 11 | { 12 | return source.Replace(part, string.Empty); 13 | } 14 | 15 | public static string FormatWith(this string format, params object[] args) 16 | { 17 | return string.Format(format, args); 18 | } 19 | 20 | public static string IfEmptyThenNull(this string value) 21 | { 22 | return string.IsNullOrWhiteSpace(value) ? null : value; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Helpers/Variable.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Util.Helpers 2 | { 3 | public static class Variable 4 | { 5 | public static bool Set(ref T variable, T value) 6 | { 7 | if (!Equals(value, variable)) 8 | { 9 | variable = value; 10 | return true; 11 | } 12 | 13 | return false; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Scrawlbit.Util/Injection/Configuration/IInjectionModule.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Injection.Configuration 2 | { 3 | public interface IInjectionModule 4 | { 5 | void Register(IRegistrationBuilder builder); 6 | } 7 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Injection/Configuration/IRegistration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Injection.Configuration 4 | { 5 | public interface IRegistration where TService : class 6 | { 7 | bool Registered { get; } 8 | 9 | void Resolve() where TImplementation : class, TService; 10 | 11 | void Transient() where TImplementation : class, TService; 12 | void Transient(Func creator) where TImplementation : class, TService; 13 | void Transient(Func creator) where TImplementation : class, TService; 14 | 15 | void Singleton(); 16 | void Singleton() where TImplementation : class, TService; 17 | void Singleton(TImplementation instance) where TImplementation : class, TService; 18 | void Singleton(Func creator) where TImplementation : class, TService; 19 | void Singleton(Func creator) where TImplementation : class, TService; 20 | } 21 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Injection/Configuration/IRegistrationBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Injection.Configuration 2 | { 3 | public interface IRegistrationBuilder 4 | { 5 | IRegistration Register() where TService : class; 6 | 7 | void RegisterModule(IInjectionModule module); 8 | void RegisterModule() where T : IInjectionModule, new(); 9 | } 10 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Injection/IContainer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Injection 4 | { 5 | public interface IContainer : IServiceProvider 6 | { 7 | object Resolve(Type serviceType); 8 | TService Resolve(Type serviceType) where TService : class; 9 | TService Resolve() where TService : class; 10 | TService Inject(out TService variable) where TService : class; 11 | } 12 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/Configuration/IInclusionMappingSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Mapping.Configuration 4 | { 5 | public interface IInclusionMappingSource where TDerivedSource : TSource 6 | { 7 | IMappingDestination To(Action> include = null) where TDerivedDestination : TDestination; 8 | } 9 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/Configuration/IMappingBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Mapping.Configuration 2 | { 3 | public interface IMappingBuilder 4 | { 5 | IMappingSource Map(); 6 | 7 | void RegisterProfile(IMappingProfile profile); 8 | void RegisterProfile() where T : IMappingProfile, new(); 9 | } 10 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/Configuration/IMappingMemberConfiguration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace Scrawlbit.Mapping.Configuration 5 | { 6 | public interface IMappingMemberConfiguration 7 | { 8 | IMappingDestination Ignore(); 9 | IMappingDestination Skip(); 10 | IMappingDestination As(Expression> sourceMember); 11 | IMappingDestination Resolving(Func resolver); 12 | IMappingDestination Resolving(Func resolver); 13 | IMappingDestination Resolving(Func resolver); 14 | } 15 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/Configuration/IMappingProfile.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Mapping.Configuration 2 | { 3 | public interface IMappingProfile 4 | { 5 | void Register(IMappingBuilder builder); 6 | } 7 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/Configuration/IMappingSource.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Mapping.Configuration 2 | { 3 | public interface IMappingSource 4 | { 5 | IMappingDestination ToSelf(); 6 | IMappingDestination To(); 7 | } 8 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/IMapping.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Mapping 4 | { 5 | public interface IMapping 6 | { 7 | object To(Type destinationType); 8 | TDestination To(); 9 | TDestination To(TDestination destination); 10 | } 11 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Mapping/IMappingService.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Mapping 2 | { 3 | public interface IMappingService 4 | { 5 | IMapping Map(T model); 6 | } 7 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/InternalPropertyChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Notification 2 | { 3 | public class InternalPropertyChangedEventArgs : System.ComponentModel.PropertyChangedEventArgs 4 | { 5 | public InternalPropertyChangedEventArgs(string propertyName, object oldValue, object newValue) : base(propertyName) 6 | { 7 | OldValue = oldValue; 8 | NewValue = newValue; 9 | } 10 | 11 | public object OldValue { get; set; } 12 | public object NewValue { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/InternalPropertyChangingEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Notification 2 | { 3 | internal class InternalPropertyChangingEventArgs : System.ComponentModel.PropertyChangingEventArgs 4 | { 5 | public InternalPropertyChangingEventArgs(string propertyName, object oldValue, object newValue) : base(propertyName) 6 | { 7 | OldValue = oldValue; 8 | NewValue = newValue; 9 | } 10 | 11 | public object OldValue { get; set; } 12 | public object NewValue { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/Notificator/Events.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable once CheckNamespace 2 | namespace Scrawlbit.Notification.Notificator 3 | { 4 | public delegate void OnPropertyChanging(T oldValue, T newValue); 5 | public delegate void OnPropertyChanged(T oldValue, T newValue); 6 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/ChangesStateManager.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Notification.State 2 | { 3 | public class ChangesStateManager : NotificationObject, IChangesStateManager 4 | { 5 | private bool _hasChanges; 6 | 7 | public bool HasChanges 8 | { 9 | get { return _hasChanges; } 10 | private set 11 | { 12 | if (value == _hasChanges) return; 13 | _hasChanges = value; 14 | OnPropertyChanged(); 15 | } 16 | } 17 | 18 | public void NotifyChange() 19 | { 20 | HasChanges = true; 21 | } 22 | public void Clear() 23 | { 24 | HasChanges = false; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/ChangesTracker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Scrawlbit.Notification.State 4 | { 5 | public abstract class ChangesTracker 6 | { 7 | protected readonly Action ChangeNotified; 8 | 9 | protected ChangesTracker(Action changeNotified) 10 | { 11 | ChangeNotified = changeNotified; 12 | } 13 | 14 | public abstract void Track(T oldValue, T newValue); 15 | } 16 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/CollectionChangesTracker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | 4 | namespace Scrawlbit.Notification.State 5 | { 6 | public class CollectionChangesTracker : ChangesTracker 7 | { 8 | public CollectionChangesTracker(Action changeNotified) : base(changeNotified) { } 9 | 10 | public override void Track(T oldValue, T newValue) 11 | { 12 | var oldCollection = (INotifyCollectionChanged)oldValue; 13 | if (oldCollection != null) 14 | oldCollection.CollectionChanged -= OnCollectionChanged; 15 | 16 | var newCollection = (INotifyCollectionChanged)newValue; 17 | if (newCollection != null) 18 | newCollection.CollectionChanged += OnCollectionChanged; 19 | } 20 | 21 | private void OnCollectionChanged(object s, NotifyCollectionChangedEventArgs e) 22 | { 23 | ChangeNotified(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/IChangesState.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace Scrawlbit.Notification.State 4 | { 5 | public interface IChangesState : INotifyPropertyChanged 6 | { 7 | bool HasChanges { get; } 8 | } 9 | 10 | public interface IChangesStateNotifier : IChangesState 11 | { 12 | void NotifyChange(); 13 | } 14 | 15 | public interface IChangesStateManager : IChangesStateNotifier 16 | { 17 | void Clear(); 18 | } 19 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/NullChangesTracker.cs: -------------------------------------------------------------------------------- 1 | namespace Scrawlbit.Notification.State 2 | { 3 | public class NullChangesTracker : ChangesTracker 4 | { 5 | public NullChangesTracker() : base(null) 6 | { 7 | } 8 | 9 | public override void Track(T oldValue, T newValue) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Scrawlbit.Util/Notification/State/PropertyChangesTracker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace Scrawlbit.Notification.State 5 | { 6 | public class PropertyChangesTracker : ChangesTracker 7 | { 8 | public PropertyChangesTracker(Action changeNotified) : base(changeNotified) { } 9 | 10 | public override void Track(T oldValue, T newValue) 11 | { 12 | var oldObject = (INotifyPropertyChanged)oldValue; 13 | if (oldObject != null) 14 | oldObject.PropertyChanged -= OnPropertyChanged; 15 | 16 | var newObject = (INotifyPropertyChanged)newValue; 17 | if (newObject != null) 18 | newObject.PropertyChanged += OnPropertyChanged; 19 | } 20 | 21 | private void OnPropertyChanged(object s, PropertyChangedEventArgs e) 22 | { 23 | ChangeNotified(); 24 | } 25 | } 26 | } --------------------------------------------------------------------------------