Skip to content

Commit

Permalink
Added mandatory "category" and "tag" fields to the Calculator class, c…
Browse files Browse the repository at this point in the history
…loses #40.
  • Loading branch information
gbmhunter committed Jan 16, 2016
1 parent caf5ff3 commit 76010d5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.3.6
------

- Added mandatory "category" and "tag" fields to the Calculator class, closes #40.

v0.3.5
------

Expand Down
5 changes: 3 additions & 2 deletions src/Calculators/Electronics/Basic/OhmsLaw/OhmsLaw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public OhmsLawCalculator()
"Ohm's Law",
"The hammer in any electrical engineers toolbox. Calculate voltage, resistance and current using Ohm's law.",
"pack://application:,,,/Calculators/Electronics/Basic/OhmsLaw/icon.png",
new string[]{ "Electronics", "Basic" },
new string[]{"ohm, resistor, resistance, voltage, current, law, vir"},
new OhmsLawView()) {

var view = (OhmsLawView)this.View;
Expand All @@ -46,8 +48,7 @@ public OhmsLawCalculator()
"voltage",
view.TextBoxVoltageValue,
view.VoltageUnits,
view.RadioButtonVoltage,
//this.CalcVars,
view.RadioButtonVoltage,
() => {
var current = this.Current.RawVal;
var resistance = this.Resistance.RawVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public ResistorDividerCalc()
"Resistor Divider",
"Resistor dividers are a simple, widely-used circuit primitive for reducing a voltage based on a fixed ratio.",
"pack://application:,,,/Calculators/Electronics/Basic/ResistorDivider/grid-icon.png",
new string[] { "Electronics", "Basic" },
new string[] { "resistor, resistance, voltage, divider, reduce" },
new ResistorDividerCalcView()) {

// Re-cast the view so we can access it's unique properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public TrackCurrentIpc2221ACalculator()
"Track Current (IPC-2221A)",
"PCB track current carrying capability calculator, using the IPC-2221A standard.",
"pack://application:,,,/Calculators/Electronics/Pcb/TrackCurrentIpc2221A/grid-icon.png",
new string[] { "Electronics", "PCB" },
new string[] { "pcb, track, current, trace, width, carry, heat, temperature, ipc, ipc2221a, ipc-2221a" },
new TrackCurrentIpc2221AView()) {

// Re-cast the view so we can access it's unique properties
Expand Down
39 changes: 36 additions & 3 deletions src/Core/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace NinjaCalc.Core {
/// <summary>
/// Base calculator class. Designed to be inherited by actual calculator implementations.
/// Base calculator class. Designed to be inherited by actual calculator implementations, which then define their own variables.
/// </summary>
public abstract class Calculator {

Expand All @@ -32,6 +32,20 @@ public Uri IconImagePath {
set;
}

public string[] CategoryTree {
get;
set;
}

public string[] Tags {
get;
set;
}

/// <summary>
/// This holds the "view" of the calculator, the WPF UserControl object which represents what
/// the user can see and interact with.
/// </summary>
public UserControl View {
get;
set;
Expand All @@ -52,11 +66,26 @@ public List<CalcVarBase> CalcVars {
/// </summary>
/// <param name="name"></param>
/// <param name="description"></param>
public Calculator(string name, string description, string iconImagePath, UserControl view) {
public Calculator(
string name,
string description,
string iconImagePath,
string[] categoryTree,
string[] tags,
UserControl view) {

this.Name = name;
this.Description = description;


//========== CATEGORY ==========//

this.CategoryTree = categoryTree;

//========== TAGS ==========//

this.Tags = tags;

//========== SELECTION GRID ICON ==========//

// The following is implemented to that unit tests work, as constructing a calculator outside
// of this project (i.e. inside Unit Test project instead) causes the URI pack scheme to fail
Expand All @@ -70,9 +99,13 @@ public Calculator(string name, string description, string iconImagePath, UserCon
}
//this.IconImagePath = iconImagePath;

//========== VIEW ==========//

// Internally save reference to the view
this.View = view;

//========== MISC. ==========//

// Initialise empty dictionary for the calculator variables
// (these are not passed into the constructor for clarity reasons)
this.CalcVars = new List<CalcVarBase>();
Expand Down

0 comments on commit 76010d5

Please sign in to comment.