Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
Added the PropertyChanged Fody weaver.
Browse files Browse the repository at this point in the history
Removed NotifyPropertyChangedEx.
  • Loading branch information
Wibble199 committed May 6, 2020
1 parent ef9d66d commit b748be0
Show file tree
Hide file tree
Showing 24 changed files with 211 additions and 341 deletions.
2 changes: 2 additions & 0 deletions Project-Aurora/Project-Aurora/ConfigUI.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using PropertyChanged;

namespace Aurora
{
[DoNotNotify]
partial class ConfigUI : Window, INotifyPropertyChanged
{
Control_Settings settingsControl = new Control_Settings();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Aurora.Profiles;
using Aurora.Utils;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -14,6 +15,7 @@

namespace Aurora.Controls {

[DoNotNotify]
public partial class GameStateParameterPicker : UserControl, INotifyPropertyChanged {

public event EventHandler<SelectedPathChangedEventArgs> SelectedPathChanged;
Expand Down
3 changes: 3 additions & 0 deletions Project-Aurora/Project-Aurora/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
64 changes: 64 additions & 0 deletions Project-Aurora/Project-Aurora/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
43 changes: 8 additions & 35 deletions Project-Aurora/Project-Aurora/Profiles/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
using Newtonsoft.Json.Serialization;
using System.Collections.ObjectModel;
using Aurora.Settings;
using System.ComponentModel;

namespace Aurora.Profiles
{
public class LightEventConfig : NotifyPropertyChangedEx
public class LightEventConfig : INotifyPropertyChanged
{
//TODO: Add NotifyPropertyChanged to properties
public string[] ProcessNames { get; set; }

/// <summary>One or more REGULAR EXPRESSIONS that can be used to match the title of an application</summary>
Expand Down Expand Up @@ -50,24 +50,15 @@ public class LightEventConfig : NotifyPropertyChangedEx

public HashSet<string> ExtraAvailableLayers { get; set; } = new HashSet<string>();

protected LightEventType? type = LightEventType.Normal;
public LightEventType? Type
{
get { return type; }
set
{
object old = type;
object newVal = value;
type = value;
InvokePropertyChanged(old, newVal);
}
}
public LightEventType? Type { get; set; } = LightEventType.Normal;

public bool EnableByDefault { get; set; } = true;
public bool EnableOverlaysByDefault { get; set; } = true;

public event PropertyChangedEventHandler PropertyChanged;
}

public class Application : ObjectSettings<ApplicationSettings>, IInit, ILightEvent, IDisposable
public class Application : ObjectSettings<ApplicationSettings>, IInit, ILightEvent, INotifyPropertyChanged, IDisposable
{
#region Public Properties
public bool Initialized { get; protected set; } = false;
Expand All @@ -83,19 +74,7 @@ public class Application : ObjectSettings<ApplicationSettings>, IInit, ILightEve
public Type GameStateType { get { return Config.GameStateType; } }
public bool IsEnabled { get { return Settings.IsEnabled; } }
public bool IsOverlayEnabled { get { return Settings.IsOverlayEnabled; } }
public event PropertyChangedExEventHandler PropertyChanged;
protected LightEventType type;
public LightEventType Type
{
get { return type; }
protected set
{
object old = type;
object newVal = value;
type = value;
InvokePropertyChanged(old, newVal);
}
}
public LightEventType Type { get; set; }
#endregion

#region Internal Properties
Expand All @@ -108,8 +87,7 @@ protected set
internal Dictionary<string, IEffectScript> EffectScripts { get; set; }
#endregion

#region Private Fields/Properties
#endregion
public event PropertyChangedEventHandler PropertyChanged;

public Application(LightEventConfig config)
{
Expand Down Expand Up @@ -147,11 +125,6 @@ protected override void SettingsCreateHook() {
Settings.IsOverlayEnabled = Config.EnableOverlaysByDefault;
}

protected void InvokePropertyChanged(object oldValue, object newValue, [CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedExEventArgs(propertyName, oldValue, newValue));
}

public void SwitchToProfile(ApplicationProfile newProfileSettings)
{
if (Disposed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ namespace Aurora.Profiles.EliteDangerous
{
public class EliteDangerousSettings : FirstTimeApplicationSettings
{
private string gamePath = "";

public string GamePath { get { return gamePath; } set { gamePath = value; InvokePropertyChanged(); } }
public string GamePath { get; set; } = "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ namespace Aurora.Profiles.Generic_Application
{
public class GenericApplicationSettings : ApplicationSettings
{
#region Private Properties
private string applicationName = "New Application Profile";
#endregion

#region Public Properties
public string ApplicationName { get { return applicationName; } set { applicationName = value; InvokePropertyChanged(); } }
#endregion
public string ApplicationName { get; set; } = "New Application Profile";

public GenericApplicationSettings()
{
Expand All @@ -24,8 +18,7 @@ public GenericApplicationSettings()

public GenericApplicationSettings(string appname) : base()
{
applicationName = appname;
ApplicationName = appname;
}

}
}
13 changes: 3 additions & 10 deletions Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Windows;
using System.Windows.Data;
using System.Globalization;
using System.ComponentModel;

namespace Aurora.Profiles
{
Expand Down Expand Up @@ -307,19 +308,11 @@ private bool InsertLightEvent(ILightEvent lightEvent, LightEventType? old = null
return true;
}

private void LightEvent_PropertyChanged(object sender, PropertyChangedExEventArgs e)
private void LightEvent_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
ILightEvent lightEvent = (ILightEvent)sender;
if (e.PropertyName.Equals(nameof(LightEventConfig.Type)))
{
LightEventType old = (LightEventType)e.OldValue;
LightEventType newVal = (LightEventType)e.NewValue;

if (!old.Equals(newVal))
{
InsertLightEvent(lightEvent, old);
}
}
InsertLightEvent(lightEvent);
}

public bool RegisterEvent(ILightEvent @event)
Expand Down
9 changes: 8 additions & 1 deletion Project-Aurora/Project-Aurora/Project-Aurora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@
<Compile Include="Settings\Control_ScriptManager.xaml.cs">
<DependentUpon>Control_ScriptManager.xaml</DependentUpon>
</Compile>
<Compile Include="Settings\INotifyPropertyChangedEx.cs" />
<Compile Include="Settings\Keybind.cs" />
<Compile Include="Settings\Layers\Control_GlitchLayer.xaml.cs">
<DependentUpon>Control_GlitchLayer.xaml</DependentUpon>
Expand Down Expand Up @@ -2527,6 +2526,11 @@
<PackageReference Include="DotNetZip">
<Version>1.13.7</Version>
</PackageReference>
<PackageReference Include="Fody">
<Version>6.1.1</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="hidlibrary">
<Version>3.2.46</Version>
</PackageReference>
Expand All @@ -2551,6 +2555,9 @@
<PackageReference Include="Octokit">
<Version>0.47.0</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.8</Version>
</PackageReference>
<PackageReference Include="RGB.NET.Devices.Asus">
<Version>0.1.32</Version>
</PackageReference>
Expand Down
Loading

0 comments on commit b748be0

Please sign in to comment.