Skip to content
Merged

sync #497

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c10b62a
Merge pull request #487 from joecare99/GenFreeWin
joecare99 Dec 30, 2024
52c0851
Merge pull request #488 from joecare99/master
joecare99 Dec 30, 2024
ef8fad0
Merge pull request #489 from joecare99/master
joecare99 Dec 30, 2024
ac7e9b0
AppWithPlugin
joecare99 Dec 30, 2024
e8cc39e
ctlClockLib
joecare99 Dec 30, 2024
e7bc34d
DynamicSample
joecare99 Dec 30, 2024
0d259d4
HelloPlugin
joecare99 Dec 30, 2024
8758513
PluginBase
joecare99 Dec 30, 2024
f947c89
TestClockApp
joecare99 Dec 30, 2024
38f63ed
TestNamespaces
joecare99 Dec 30, 2024
5553e63
TestStatements
joecare99 Dec 30, 2024
d505387
TestStatementsTest
joecare99 Dec 30, 2024
d15dea1
Tutorials
joecare99 Dec 30, 2024
7c0ebc1
TestStatements
joecare99 Dec 30, 2024
57f8264
AppWithPlugin
joecare99 Dec 30, 2024
899ead1
Properties
joecare99 Dec 30, 2024
430b328
AboutEx_Minor_Update
joecare99 Dec 30, 2024
e671352
Calc64BaseTests_Minor_Update
joecare99 Dec 30, 2024
173289e
Calc64WF_Minor_Update
joecare99 Dec 30, 2024
6233e83
Calc64_Wpf_Minor_Update
joecare99 Dec 30, 2024
775b2f0
Werner_Flaschbier_Minor_Update
joecare99 Dec 30, 2024
96ecd8b
BaseLib_Minor_Update
joecare99 Dec 30, 2024
8ef437e
BaseLibTests_Minor_Update
joecare99 Dec 30, 2024
76dd73d
MVVM_BaseLib_Minor_Update
joecare99 Dec 30, 2024
0be8c5e
MVVM_BaseLibTests_Minor_Update
joecare99 Dec 30, 2024
704b3bd
MVVM_19_FilterListsTests_Minor_Update
joecare99 Dec 30, 2024
75f466f
WPF_ControlsAndLayoutTests_Minor_Update
joecare99 Dec 30, 2024
5d8c5d0
WPF_StickyNotesDemo_Minor_Update
joecare99 Dec 30, 2024
1ab884b
Ignore
joecare99 Dec 30, 2024
662cc28
Ignore
joecare99 Dec 30, 2024
ff78118
Merge pull request #490 from joecare99/master
joecare99 Dec 30, 2024
62ca2c5
Merge pull request #491 from joecare99/CSharpBible
joecare99 Dec 30, 2024
a7a38c0
Merge branch 'master' into TestStatements
joecare99 Dec 30, 2024
75fea4b
Merge pull request #492 from joecare99/TestStatements
joecare99 Dec 30, 2024
7773dec
Merge branch 'master' into JC-AMS
joecare99 Dec 30, 2024
f9d804d
Merge pull request #493 from joecare99/JC-AMS
joecare99 Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@
/CSharpBible/Games/Sokoban_Base/*.svn
/CSharpBible/MVVM_Tutorial/UWP_00_Test/AppPackages
/TestStatements/TestStatements/Version.inc
obj.net
obj.net
/JC-AMS/Core/Resource/Version.inc
/TestStatements/*.snk
/CSharpBible/Libraries/*.snk
24 changes: 12 additions & 12 deletions CSharpBible/Calc/Calc64BaseTests/Calc64ModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ public void Calc64ModelTest()
}

[TestMethod()]
[DataRow(Calc64Model.EOpMode.CalcResult)]
[DataRow(Calc64Model.EOpMode.MemRetrieve)]
[DataRow(Calc64Model.EOpMode.BinaryNot)]
[DataRow(Calc64Model.EOpMode.Power)]
public void OperationModeTest(Calc64Model.EOpMode eVal)
[DataRow(EOpMode.CalcResult)]
[DataRow(EOpMode.MemRetrieve)]
[DataRow(EOpMode.BinaryNot)]
[DataRow(EOpMode.Power)]
public void OperationModeTest(EOpMode eVal)
{
Assert.AreEqual(Calc64Model.EOpMode.NoMode, testModel.OperationMode);
Assert.AreEqual(EOpMode.NoMode, testModel.OperationMode);
testModel.OperationMode = eVal;
Assert.AreEqual(eVal, testModel.OperationMode);
Assert.AreEqual($"COpChg(Calc64Base.Calc64Model,OperationMode,NoMode => {eVal})\r\n", DebugLog);
}

[TestMethod()]
[DataRow(Calc64Model.EOpMode.NoMode, "")]
[DataRow(Calc64Model.EOpMode.CalcResult,"=")]
[DataRow(Calc64Model.EOpMode.MemRetrieve,"MR")]
[DataRow(Calc64Model.EOpMode.BinaryNot,"~")]
[DataRow(Calc64Model.EOpMode.Power,"^")]
public void GetShortDescTest(Calc64Model.EOpMode eVal,string sExp)
[DataRow(EOpMode.NoMode, "")]
[DataRow(EOpMode.CalcResult,"=")]
[DataRow(EOpMode.MemRetrieve,"MR")]
[DataRow(EOpMode.BinaryNot,"~")]
[DataRow(EOpMode.Power,"^")]
public void GetShortDescTest(EOpMode eVal,string sExp)
{
Assert.AreEqual(sExp, Calc64Model.GetShortDesc(eVal));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class OperationModeToShortString : IValueConverter
/// <returns>System.Object.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value switch
{
Calc64Model.EOpMode opMode when targetType == typeof(string)
EOpMode opMode when targetType == typeof(string)
=> Properties.Resources.ResourceManager.GetString($"OPMode_{opMode}", Properties.Resources.Culture) ?? "",
_ => "",
};
Expand Down
2 changes: 1 addition & 1 deletion CSharpBible/Calc/Calc64_Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

var BaseServices = new ServiceCollection()
IServiceCollection BaseServices = new ServiceCollection()
.AddSingleton<ICalculator, Calc64Model>();

var serviceProvider = BaseServices.BuildServiceProvider();
Expand Down
49 changes: 37 additions & 12 deletions CSharpBible/Games/Werner_Flaschbier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,71 @@
// <summary></summary>
// ***********************************************************************

using BaseLib.Helper;
using ConsoleDisplay.View;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Security.Authentication.ExtendedProtection;
using System.Threading;
using Werner_Flaschbier_Base.Model;
using Werner_Flaschbier_Base.View;
using Werner_Flaschbier_Base.ViewModel;
using Werner_Flaschbier_Base.ViewModels;

namespace Werner_Flaschbier_Base
{
/// <summary>
/// Class Programm.
/// </summary>
public static class Programm
public class Programm
{
/// <summary>
/// The game
/// </summary>
static Game game;
private IWernerGame game;
private IVisual visual;

/// <summary>
/// Initializes static members of the <see cref="Programm" /> class.
/// </summary>
static Programm()
private static void OnStartUp()
{
game = new Game();
Visual.SetGame(game);
var sc = new ServiceCollection()
.AddSingleton<IWernerGame, WernerGame>()
.AddTransient<IWernerViewModel, WernerViewModel>()
.AddSingleton<IVisual, Visual>()
.AddSingleton<IConsole, MyConsole>();
var sp = sc.BuildServiceProvider();

IoC.Configure(sp);
}

/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
public static void Main(params string[] args)
{
var program = new Programm();
program.Initialize(args);
program.Run();
// program.OnExit();
}

public void Run()
{
while (game.isRunning)
{
UserAction action;
Visual.CheckUserAction(out action);
game.HandleUserAction(action);
var delay=game.GameStep();
visual.CheckUserAction();
var delay = game.GameStep();
Thread.Sleep(delay);
}
}

public void Initialize(string[] args)
{
OnStartUp();

game = IoC.GetRequiredService<IWernerGame>();
visual = IoC.GetRequiredService<IVisual>();
}
}

}
2 changes: 1 addition & 1 deletion CSharpBible/Games/Werner_Flaschbier/View/VTileDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// <summary></summary>
// ***********************************************************************
using System;
using Werner_Flaschbier_Base.ViewModel;
using Werner_Flaschbier_Base.Model;

namespace Werner_Flaschbier_Base.View
{
Expand Down
101 changes: 54 additions & 47 deletions CSharpBible/Games/Werner_Flaschbier/View/Visual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,32 @@
using ConsoleDisplay.View;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using Werner_Flaschbier_Base.ViewModel;
using Werner_Flaschbier_Base.Model;
using Werner_Flaschbier_Base.ViewModels;

namespace Werner_Flaschbier_Base.View
{
/// <summary>
/// Class Visual.
/// </summary>
public static class Visual {
public class Visual : IVisual {

#region Properties
/// <summary>
/// The buffer
/// </summary>
private static Tiles[] _buffer = new Tiles[12 * 20];
private Tiles[] _buffer = new Tiles[12 * 20];
/// <summary>
/// The game
/// </summary>
private static Game? _game;
private IWernerViewModel? _game;

/// <summary>
/// My console
/// </summary>
public static MyConsoleBase myConsole = new MyConsole();
private IConsole _console ;

/// <summary>
/// The key action
Expand All @@ -59,24 +61,28 @@ public static class Visual {
#endregion

#region Methods
/// <summary>
/// Sets the game.
/// </summary>
/// <param name="g">The g.</param>
public static void SetGame(Game g)
public Visual(IWernerViewModel viewModel,IConsole console)
{
_game = viewModel;
_game.PropertyChanged += OnPropertyChanged;
_console = console;
FullRedraw();
}

private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
_game = g;
g.visUpdate += G_visUpdate;
g.visFullRedraw += FullRedraw;
FullRedraw();
if (e.PropertyName == "Tiles")
G_visUpdate(sender, _game.HalfStep);
else if (e.PropertyName == "Level")
FullRedraw();
}

/// <summary>
/// Determines whether the specified e is enemy.
/// </summary>
/// <param name="e">The e.</param>
/// <returns><c>true</c> if the specified e is enemy; otherwise, <c>false</c>.</returns>
private static bool IsEnemy(Tiles e) => e == Tiles.Enemy_Dwn
/// <summary>
/// Determines whether the specified e is enemy.
/// </summary>
/// <param name="e">The e.</param>
/// <returns><c>true</c> if the specified e is enemy; otherwise, <c>false</c>.</returns>
private bool IsEnemy(Tiles e) => e == Tiles.Enemy_Dwn
|| e == Tiles.Enemy_Up
|| e == Tiles.Enemy_Left
|| e == Tiles.Enemy_Right;
Expand All @@ -86,7 +92,7 @@ private static bool IsEnemy(Tiles e) => e == Tiles.Enemy_Dwn
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">if set to <c>true</c> [e].</param>
private static void G_visUpdate(object? sender, bool e)
private void G_visUpdate(object? sender, bool e)
{
List<(Point, Tiles, Point)> diffFields = new();
var p = new Point();
Expand All @@ -95,15 +101,15 @@ private static void G_visUpdate(object? sender, bool e)
for (p.Y = 0; p.Y < _game.size.Height; p.Y++)
for (p.X = 0; p.X < _game.size.Width; p.X++)
{
var td = _game[p];
if (td != _buffer[p.X + p.Y * _game.size.Width] || (IsEnemy(td) && _game.OldPos(p)!=p))
var td = _game.Tiles[p];
if ((Tiles)td != _buffer[p.X + p.Y * _game.size.Width] || (IsEnemy((Tiles)td) && _game.OldPos(p)!=p))
{
Point pp = new Point(p.X,p.Y);
#pragma warning disable CS8604 // Mögliches Nullverweisargument.
diffFields.Add((pp, td, _game.OldPos(p)));
diffFields.Add((pp, (Tiles)td, _game.OldPos(p)));
#pragma warning restore CS8604 // Mögliches Nullverweisargument.
if (!e)
_buffer[p.X + p.Y * _game.size.Width] = td;
_buffer[p.X + p.Y * _game.size.Width] = (Tiles)td;
}
}
if (e)
Expand All @@ -126,9 +132,9 @@ private static void G_visUpdate(object? sender, bool e)
if (f.Item1.X != f.Item3.X && f.Item1.Y != f.Item3.Y)
{
var p1 = new Point(f.Item1.X, f.Item3.Y);
WriteTile(p1, _game[p1]);
WriteTile(p1, (Tiles)_game.Tiles[p1]);
var p2 = new Point(f.Item3.X, f.Item1.Y);
WriteTile(p2, _game[p2]);
WriteTile(p2, (Tiles)_game.Tiles[p2]);
}
WriteTile(f.Item1, f.Item2);
}
Expand All @@ -141,7 +147,7 @@ private static void G_visUpdate(object? sender, bool e)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
public static void FullRedraw(object? sender=null,EventArgs? e=null)
public void FullRedraw(object? sender=null,EventArgs? e=null)
{
// basic Checks
if (_game == null) return;
Expand All @@ -150,7 +156,7 @@ public static void FullRedraw(object? sender=null,EventArgs? e=null)
Point p = new Point();
for (p.Y = 0; p.Y < _game.size.Height; p.Y++)
for (p.X = 0; p.X < _game.size.Width; p.X++)
WriteTile(p, _buffer[p.X + p.Y * _game.size.Width] = _game[p]);
WriteTile(p, _buffer[p.X + p.Y * _game.size.Width] = (Tiles)_game.Tiles[p]);

// Draw statistics
ShowStatistics();
Expand All @@ -159,50 +165,50 @@ public static void FullRedraw(object? sender=null,EventArgs? e=null)
/// <summary>
/// Shows the statistics.
/// </summary>
private static void ShowStatistics()
private void ShowStatistics()
{
if (_game == null) return;
myConsole.SetCursorPosition(0, 24);
myConsole.BackgroundColor = ConsoleColor.Black;
myConsole.ForegroundColor = ConsoleColor.Yellow;
myConsole.Write($"\t{_game.level + 1}\t\t{_game.Score}\t\t{_game.Lives}/{Game.MaxLives} \t\t{Math.Floor(_game.TimeLeft)}\t\x08");
_console.SetCursorPosition(0, 24);
_console.BackgroundColor = ConsoleColor.Black;
_console.ForegroundColor = ConsoleColor.Yellow;
_console.Write($"\t{_game.Level + 1}\t\t{_game.Score}\t\t{_game.Lives}/{_game.MaxLives} \t\t{Math.Floor(_game.TimeLeft)}\t\x08");
}

/// <summary>
/// Writes the tile.
/// </summary>
/// <param name="p">The p.</param>
/// <param name="tile">The tile.</param>
public static void WriteTile(PointF p, Tiles tile)
public void WriteTile(PointF p, Tiles tile)
{
Size s = new Size(4, 2);
var colors = VTileDef.GetTileColors(tile);
var sTileStr = VTileDef.GetTileStr(tile);
for (int i = 0; i < sTileStr.Length; i++)
for (int x = 0; x < sTileStr[i].Length; x++)
{
myConsole.ForegroundColor = colors[x + i * s.Width].foreGround;
myConsole.BackgroundColor = colors[x + i * s.Width].backGround;
myConsole.SetCursorPosition((int)(p.X * s.Width) + x, (int)(p.Y * s.Height) + i);
myConsole.Write(sTileStr[i][x]);
_console.ForegroundColor = colors[x + i * s.Width].foreGround;
_console.BackgroundColor = colors[x + i * s.Width].backGround;
_console.SetCursorPosition((int)(p.X * s.Width) + x, (int)(p.Y * s.Height) + i);
_console.Write(sTileStr[i][x]);
}
}

/// <summary>
/// Sounds the specified gs.
/// </summary>
/// <param name="gs">The gs.</param>
public static void Sound(GameSound gs)
public void Sound(GameSound gs)
{
switch (gs)
{
case GameSound.NoSound:
break;
case GameSound.Tick:
myConsole.Beep(1000, 10);
_console.Beep(1000, 10);
break;
case GameSound.DeepBoom:
myConsole.Beep(300, 20);
_console.Beep(300, 20);
break;
default:
break;
Expand All @@ -214,13 +220,13 @@ public static void Sound(GameSound gs)
/// </summary>
/// <param name="action">The action.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool CheckUserAction(out UserAction action)
public bool CheckUserAction()
{
bool result = false;
action = UserAction.Nop;
if (myConsole.KeyAvailable)
UserAction action = UserAction.Nop;
if (_console.KeyAvailable)
{
var ch = myConsole.ReadKey()?.KeyChar ?? '\x00';
var ch = _console.ReadKey()?.KeyChar ?? '\x00';

ch = Char.ToUpper(ch);
if (keyAction.ContainsKey(ch))
Expand All @@ -229,7 +235,8 @@ public static bool CheckUserAction(out UserAction action)
result = true;
}
}
return result;
_game?.HandleUserAction(action);
return result;
}

#endregion
Expand Down
Loading
Loading