Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 25 additions & 0 deletions Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**Describe the bug**
A clear and concise description of what the bug is.

**To reproduce in an app**
Steps to reproduce the behavior:
1. Add API '...'
2. Run app.
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

** App (please complete the following information):**
- Platform: [e.g. Windows, Android, iOS]
- Device: [e.g. Surface Pro 4, Samsung S7]
- Platform version: [e.g. Fall Creators Update, Android 24, iOS 8.1]
- MADE version: [e.g. 1.0.0.0]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
[version]: http://contributor-covenant.org/version/1/4/
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<img src="ProjectBanner.png" alt="MADE App Components" />

# Contributing to MADE App Components

These guidelines are designed to help you as a contributor to bring your code and skills to the project to make it better.
Expand Down Expand Up @@ -28,5 +30,4 @@ Even better, if you know how to fix it, follow up your issue with a pull request

We're including Unit Tests and UI tests for the project. While we will aim to have the best coverage as possible across the entire project, it could always be improved on. If you find an area that is missing tests or could have more tests for, feel free to raise an issue or help out by writing some tests!

As well as testing, we aim to document the entire project in terms of both developer guidelines such as these and our own API documentation. If you find something that is wrong or is missing, again, feel free to raise an issue or contribute towards the documentation.

As well as testing, we aim to document the entire project in terms of both developer guidelines such as these and our own API documentation. If you find something that is wrong or is missing, again, feel free to raise an issue or contribute towards the documentation.
11 changes: 11 additions & 0 deletions Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1,092 changes: 0 additions & 1,092 deletions MADE App Components - Light.sln

This file was deleted.

1,588 changes: 0 additions & 1,588 deletions MADE App Components.sln

This file was deleted.

9 changes: 9 additions & 0 deletions MADE.App.Mvvm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
116 changes: 116 additions & 0 deletions MADE.App.Mvvm/Bindable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Bindable.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// Defines an abstract class for creating bindable objects.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Mvvm
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;

/// <summary>
/// Defines an abstract class for creating bindable objects.
/// </summary>
public abstract class Bindable : INotifyPropertyChanged
{
/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Raises the property changed event for the given property value.
/// </summary>
/// <param name="propertyExpression">
/// The expression containing the property to raise as changed.
/// </param>
/// <typeparam name="T">
/// The type of property.
/// </typeparam>
public virtual void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
{
PropertyChangedEventHandler handler = this.PropertyChanged;

if (handler == null)
{
return;
}

string propertyName = GetPropertyName(propertyExpression);

if (!string.IsNullOrEmpty(propertyName))
{
this.RaisePropertyChanged(propertyName);
}
}

/// <summary>
/// Sets the value of the given property value and raises the property changed event if the value is different to the previously set value.
/// </summary>
/// <param name="propertyExpression">
/// The expression containing the property to raise as changed.
/// </param>
/// <param name="field">
/// The reference field for the property.
/// </param>
/// <param name="value">
/// The value to update the property with.
/// </param>
/// <typeparam name="T">
/// The type of property.
/// </typeparam>
/// <returns>
/// Returns true if the property was updated; otherwise, false.
/// </returns>
protected bool Set<T>(Expression<Func<T>> propertyExpression, ref T field, T value)
{
if (EqualityComparer<T>.Default.Equals(field, value))
{
return false;
}

field = value;
this.RaisePropertyChanged(propertyExpression);
return true;
}

/// <summary>
/// Raises the property changed event for the given property name.
/// </summary>
/// <param name="propertyName">
/// The name of the property to raise as changed.
/// </param>
protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

private static string GetPropertyName<T>(Expression<Func<T>> propertyExpression)
{
if (object.Equals(propertyExpression, null))
{
throw new ArgumentNullException(nameof(propertyExpression));
}

if (!(propertyExpression.Body is MemberExpression body))
{
throw new ArgumentException("Invalid argument", nameof(propertyExpression));
}

if (!(body.Member is PropertyInfo property))
{
throw new ArgumentException("Argument is not a property", nameof(propertyExpression));
}

return property.Name;
}
}
}
39 changes: 39 additions & 0 deletions MADE.App.Mvvm/MADE.App.Mvvm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard2.0\MADE.App.Mvvm.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netstandard2.0\MADE.App.Mvvm.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Remove="api\**" />
<Compile Remove="articles\**" />
<Compile Remove="_site\**" />
<EmbeddedResource Remove="api\**" />
<EmbeddedResource Remove="articles\**" />
<EmbeddedResource Remove="_site\**" />
<None Remove="api\**" />
<None Remove="articles\**" />
<None Remove="_site\**" />
</ItemGroup>

<ItemGroup>
<None Remove=".gitignore" />
<None Remove="docfx.json" />
<None Remove="index.md" />
<None Remove="log.txt" />
<None Remove="toc.yml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="docfx.console" Version="2.36.0" PrivateAssets="All" />
</ItemGroup>

</Project>
106 changes: 106 additions & 0 deletions MADE.App.Mvvm/RelayCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RelayCommand.cs" company="MADE Apps">
// Copyright (c) MADE Apps.
// </copyright>
// <summary>
// Defines an implementation of the ICommand for running an action on execution.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace MADE.App.Mvvm
{
using System;
using System.Windows.Input;

/// <summary>
/// Defines an implementation of the <see cref="ICommand"/> for running an action on execution.
/// </summary>
public class RelayCommand : ICommand
{
private readonly Action executeAction;

private readonly Func<bool> canExecute;

/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand"/> class with an action.
/// </summary>
/// <param name="executeAction">
/// The action to execute when the command is fired.
/// </param>
public RelayCommand(Action executeAction)
: this(executeAction, null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand"/> class with an action and a function to check whether the action can execute.
/// </summary>
/// <param name="executeAction">
/// The action to execute when the command is fired.
/// </param>
/// <param name="canExecute">
/// The function to check whether the action can be executed.
/// </param>
public RelayCommand(Action executeAction, Func<bool> canExecute)
{
this.executeAction = executeAction ?? throw new ArgumentNullException(nameof(executeAction));
this.canExecute = canExecute ?? (() => true);
}

/// <summary>
/// Occurs when changes occur that affect whether or not the command should execute.
/// </summary>
public event EventHandler CanExecuteChanged;

/// <summary>
/// Defines the method that determines whether the command can execute in its current state.
/// </summary>
/// <returns>
/// Returns true if this command can be executed; otherwise, false.
/// </returns>
public bool CanExecute()
{
return this.CanExecute(null);
}

/// <summary>
/// Defines the method that determines whether the command can execute in its current state.
/// </summary>
/// <param name="parameter">
/// Data used by the command.
/// If the command does not require data to be passed, this object can be set to null.
/// </param>
/// <returns>
/// Returns true if this command can be executed; otherwise, false.
/// </returns>
public bool CanExecute(object parameter)
{
return this.canExecute();
}

/// <summary>
/// Defines the method to be called when the command is invoked.
/// </summary>
public void Execute()
{
this.Execute(null);
}

/// <summary>
/// Defines the method to be called when the command is invoked.
/// </summary>
/// <param name="parameter">
/// Data used by the command.
/// If the command does not require data to be passed, this object can be set to null.
/// </param>
public void Execute(object parameter)
{
if (!this.CanExecute(parameter))
{
return;
}

this.executeAction();
}
}
}
Loading