Skip to content

Commit

Permalink
V2.0.0 - reworked event management
Browse files Browse the repository at this point in the history
* now events are user configurable from the setting window. posibility to have active (on the main window) a subset of all defined events
* new database structure. the old database will be overwritten with a new empty one
* added 50m pistol target
  • Loading branch information
AzmodanRO committed Aug 1, 2021
1 parent c6bc618 commit d377970
Show file tree
Hide file tree
Showing 26 changed files with 2,153 additions and 728 deletions.
5 changes: 1 addition & 4 deletions Software/C#/freETarget/App.config
Expand Up @@ -23,7 +23,7 @@
<value>True</value>
</setting>
<setting name="defaultTarget" serializeAs="String">
<value>Air Pistol Practice</value>
<value>Pistol Practice</value>
</setting>
<setting name="targetColor" serializeAs="String">
<value>Moccasin</value>
Expand All @@ -37,9 +37,6 @@
<setting name="calibrationY" serializeAs="String">
<value>0</value>
</setting>
<setting name="MatchShots" serializeAs="String">
<value>60</value>
</setting>
<setting name="OnlySeries" serializeAs="String">
<value>False</value>
</setting>
Expand Down
67 changes: 67 additions & 0 deletions Software/C#/freETarget/Event.cs
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace freETarget {
public class Event {

public enum EventType {
Practice,
Match,
Final
}

public long ID { get; }

public string Name { get; set; }

public bool DecimalScoring { get; set; }

public EventType Type { get; set; }

public int NumberOfShots { get; set; }

public targets.aTarget Target { get; set; }

public int Minutes { get; set; }

public decimal ProjectileCaliber { get; set; }

public int Final_NumberOfShotPerSeries { get; set; } //5

public int Final_SeriesSeconds { get; set; } //250

public int Final_NumberOfShotsBeforeSingleShotSeries { get; set; } //10 for air pistol/rifle

public int Final_NumberOfShotsInSingleShotSeries { get; set; } //2 for air pistol/rifle

public int Final_SingleShotSeconds { get; set; } //50

public Color TabColor { get; set; }

public Event(long id, string name, bool decimalScoring, EventType type, int numberOfShots, targets.aTarget target, int minutes, decimal caliber,
int final_seriesShots, int seriesSeconds, int shotsInSeries, int shotsInSingle, int singleSeconds, Color tabColor ) {
this.ID = id;
this.Name = name;
this.DecimalScoring = decimalScoring;
this.Type = type;
this.NumberOfShots = numberOfShots;
this.Target = target;
this.Minutes = minutes;
this.ProjectileCaliber = caliber;
this.Final_NumberOfShotPerSeries = final_seriesShots;
this.Final_SeriesSeconds = seriesSeconds;
this.Final_NumberOfShotsBeforeSingleShotSeries = shotsInSeries;
this.Final_NumberOfShotsInSingleShotSeries = shotsInSingle;
this.Final_SingleShotSeconds = singleSeconds;
this.TabColor = tabColor;
}

public override string ToString() {
return this.Name;
}
}
}
107 changes: 107 additions & 0 deletions Software/C#/freETarget/EventManager.cs
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace freETarget {

public class EventManager {

private List<Event> eventList = new List<Event>();
private List<Event> activeEventList = new List<Event>();

StorageController storage;

public EventManager(StorageController storage) {
this.storage = storage;
}

/*
* no events in the DB. create the default events
*/
public void initializeEvents() {

//air pistol practice
Event evAPP = new Event(-1, "Pistol Practice", false, Event.EventType.Practice, -1, new targets.AirPistol(4.5m), -1, 4.5m, -1, -1, -1, -1, -1, Color.Gold);
storage.storeEvent(evAPP);

//air pistol match
Event evAPM = new Event(-1, "Pistol Match", false, Event.EventType.Match, 60, new targets.AirPistol(4.5m), 75, 4.5m, -1, -1, -1, -1, -1, Color.Orange);
storage.storeEvent(evAPM);

//air pistol final
Event evAPF = new Event(-1, "Pistol Final", true, Event.EventType.Final, 24, new targets.AirPistol(4.5m), 75, 4.5m, 5, 250, 10, 2, 50, Color.Red);
storage.storeEvent(evAPF);

//air rifle practice
Event evARP = new Event(-1, "Rifle Practice", true, Event.EventType.Practice, -1, new targets.AirRifle(4.5m), -1, 4.5m, -1, -1, -1, -1, -1, Color.LimeGreen);
storage.storeEvent(evARP);

//air rifle match
Event evARM = new Event(-1, "Rifle Match", true, Event.EventType.Match, 60, new targets.AirRifle(4.5m), 75, 4.5m, -1, -1, -1, -1, -1, Color.Turquoise);
storage.storeEvent(evARM);

//air rfile final
Event evARF = new Event(-1, "Rifle Final", true, Event.EventType.Final, 24, new targets.AirRifle(4.5m), 75, 4.5m, 5, 250, 10, 2, 50, Color.DodgerBlue);
storage.storeEvent(evARF);

//reload events to get autogenerated IDs
List<Event> evs = storage.loadEvents();

storage.updateActiveEvents(evs);
}

public void setEventsList(List<Event> list) {
this.eventList = list;
}

public List<Event> getEventsList() {
return this.eventList;
}

public void setActiveEventsList(List<long> idList) {

if (eventList.Count == 0) {
Console.WriteLine("Event list empty");
return;
}

this.activeEventList.Clear();
foreach (Event ev in eventList) {
if (idList.Contains(ev.ID)) {
this.activeEventList.Add(ev);
}
}


}

public List<Event> getActiveEventsList() {
return this.activeEventList;
}

public Event findEventByID(long id) {
Event ret = null;
foreach(Event e in eventList) {
if(e.ID == id) {
ret = e;
break;
}
}
return ret;
}

public Event findEventByName(string name) {
Event ret = null;
foreach (Event e in eventList) {
if (e.Name == name) {
ret = e;
break;
}
}
return ret;
}
}
}
78 changes: 0 additions & 78 deletions Software/C#/freETarget/EventType.cs

This file was deleted.

5 changes: 3 additions & 2 deletions Software/C#/freETarget/ISSF.cs
Expand Up @@ -7,13 +7,14 @@
namespace freETarget {
class ISSF {

public const int finalSeriesTime = 250; //seconds
/* public const int finalSeriesTime = 250; //seconds
public const int singleShotTime = 50; //seconds
public const int finalNoOfShots = 24;
public const int match60NoOfShots = 60;
public const int match60Time = 75;//seconds
public const int match40NoOfShots = 40;
public const int match40Time = 50;//seconds
public const int match40Time = 50;//seconds*/




Expand Down
4 changes: 2 additions & 2 deletions Software/C#/freETarget/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.17.0.0")]
[assembly: AssemblyFileVersion("1.17.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
14 changes: 1 addition & 13 deletions Software/C#/freETarget/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Software/C#/freETarget/Properties/Settings.settings
Expand Up @@ -15,7 +15,7 @@
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="defaultTarget" Type="System.String" Scope="User">
<Value Profile="(Default)">Air Pistol Practice</Value>
<Value Profile="(Default)">Pistol Practice</Value>
</Setting>
<Setting Name="targetColor" Type="System.Drawing.Color" Scope="User">
<Value Profile="(Default)">Moccasin</Value>
Expand All @@ -29,9 +29,6 @@
<Setting Name="calibrationY" Type="System.Decimal" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="MatchShots" Type="System.Int32" Scope="User">
<Value Profile="(Default)">60</Value>
</Setting>
<Setting Name="OnlySeries" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
Expand Down

0 comments on commit d377970

Please sign in to comment.