Skip to content

Commit

Permalink
Merge pull request #9 from FaustVX/master
Browse files Browse the repository at this point in the history
Allow multiple `MonoGameContentControl`
  • Loading branch information
Gandifil authored May 20, 2024
2 parents f6e48f4 + 44d726b commit dea0c00
Show file tree
Hide file tree
Showing 18 changed files with 516 additions and 449 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -317,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -326,5 +326,5 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/
Binary file modified .template.config/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions .template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
".git/**",
"**/.idea/**",
"**/*.user"
]
],
"source": "./MonoGame.WpfCore/"
}]
}
}
3 changes: 1 addition & 2 deletions MonoGame.WpfCore/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Application
<Application
x:Class="MonoGame.WpfCore.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
7 changes: 3 additions & 4 deletions MonoGame.WpfCore/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Windows;

namespace MonoGame.WpfCore
namespace MonoGame.WpfCore;

public partial class App : Application
{
public partial class App : Application
{
}
}
1 change: 0 additions & 1 deletion MonoGame.WpfCore/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:monogame-logo.png

Binary file added MonoGame.WpfCore/Icon.bmp
Binary file not shown.
Binary file added MonoGame.WpfCore/Icon.ico
Binary file not shown.
26 changes: 20 additions & 6 deletions MonoGame.WpfCore/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window
<Window
x:Class="MonoGame.WpfCore.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -7,13 +7,10 @@
xmlns:monoGameControls="clr-namespace:MonoGame.WpfCore.MonoGameControls"
xmlns:local="clr-namespace:MonoGame.WpfCore"
mc:Ignorable="d"
Title="MonoGame.WpfCore"
Title="MonoGame.WpfCore"
WindowStartupLocation="CenterScreen"
Width="800"
Height="480">
<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>

<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top">
Expand Down Expand Up @@ -42,6 +39,23 @@
</MenuItem>
</Menu>

<monoGameControls:MonoGameContentControl />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<monoGameControls:MonoGameContentControl Grid.Column="0">
<monoGameControls:MonoGameContentControl.DataContext>
<local:MainWindowViewModel />
</monoGameControls:MonoGameContentControl.DataContext>
</monoGameControls:MonoGameContentControl>

<monoGameControls:MonoGameContentControl Grid.Column="1">
<monoGameControls:MonoGameContentControl.DataContext>
<local:MainWindowViewModel />
</monoGameControls:MonoGameContentControl.DataContext>
</monoGameControls:MonoGameContentControl>
</Grid>
</DockPanel>
</Window>
11 changes: 5 additions & 6 deletions MonoGame.WpfCore/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Windows;

namespace MonoGame.WpfCore
namespace MonoGame.WpfCore;

public partial class MainWindow : Window
{
public partial class MainWindow : Window
public MainWindow()
{
public MainWindow()
{
InitializeComponent();
}
InitializeComponent();
}
}
57 changes: 28 additions & 29 deletions MonoGame.WpfCore/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@
using Microsoft.Xna.Framework.Graphics;
using MonoGame.WpfCore.MonoGameControls;

namespace MonoGame.WpfCore
namespace MonoGame.WpfCore;

public class MainWindowViewModel : MonoGameViewModel
{
public class MainWindowViewModel : MonoGameViewModel
{
private SpriteBatch _spriteBatch;
private Texture2D _texture;
private Vector2 _position;
private float _rotation;
private Vector2 _origin;
private Vector2 _scale;
private SpriteBatch _spriteBatch = default!;
private Texture2D _texture = default!;
private Vector2 _position;
private float _rotation;
private Vector2 _origin;
private Vector2 _scale;

public override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
_texture = Content.Load<Texture2D>("monogame-logo");
}
public override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
_texture = Content.Load<Texture2D>("monogame-logo");
}

public override void Update(GameTime gameTime)
{
_position = GraphicsDevice.Viewport.Bounds.Center.ToVector2();
_rotation = (float)Math.Sin(gameTime.TotalGameTime.TotalSeconds) / 4f;
_origin = _texture.Bounds.Center.ToVector2();
_scale = Vector2.One;
}
public override void Update(GameTime gameTime)
{
_position = GraphicsDevice.Viewport.Bounds.Center.ToVector2();
_rotation = (float)Math.Sin(gameTime.TotalGameTime.TotalSeconds) / 4f;
_origin = _texture.Bounds.Center.ToVector2();
_scale = Vector2.One;
}

public override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
public override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);

_spriteBatch.Begin();
_spriteBatch.Draw(_texture, _position, null, Color.White, _rotation, _origin, _scale, SpriteEffects.None, 0f);
_spriteBatch.End();
}
_spriteBatch.Begin();
_spriteBatch.Draw(_texture, _position, null, Color.White, _rotation, _origin, _scale, SpriteEffects.None, 0f);
_spriteBatch.End();
}
}
}
23 changes: 18 additions & 5 deletions MonoGame.WpfCore/MonoGame.WpfCore.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.7.1.189" />
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.8" />
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder" Version="3.7.0.9" />
<PackageReference Include="SharpDX" Version="4.2.0" />
</ItemGroup>

<ItemGroup>
<MonoGameContentReference Include="**\*.mgcb" />
</ItemGroup>

<ItemGroup>
<None Remove="Icon.ico" />
<None Remove="Icon.bmp" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Icon.ico" />
<EmbeddedResource Include="Icon.bmp" />
</ItemGroup>
</Project>
Loading

0 comments on commit dea0c00

Please sign in to comment.