diff --git a/.gitattributes b/.gitattributes index 0eb88a3b..412eeda7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ # Auto detect text files and perform LF normalization * text=auto + # Custom for Visual Studio *.cs diff=csharp *.sln merge=union @@ -7,6 +8,7 @@ *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union + # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain @@ -17,4 +19,4 @@ *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain -*.RTF diff=astextplain \ No newline at end of file +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 2911d25b..413e875f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,16 @@ +.idea/ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. - # User-specific files *.suo *.user *.sln.docstates - # Build results - [Dd]ebug*/ [Rr]elease*/ [Bb]uild*/ [Tt]est[Rr]esult [Bb]uild[Ll]og.* - *_i.c *_p.c *.ilk @@ -31,39 +28,32 @@ *.tli *.tlh *.tmp +.vs/ *.vspscc *.vssscc .builds *.pidb *.log *.scc - # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf - # Visual Studio profiler *.psess *.vsp - # Guidance Automation Toolkit *.gpState - # ReSharper is a .NET coding add-in _ReSharper*/ - *.[Rr]e[Ss]harper - # NCrunch *.ncrunch* .*crunch*.local.xml - # Installshield output folder [Ee]xpress - # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT @@ -73,13 +63,10 @@ DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html - # Click-Once directory publish - # Publish Web Output *.Publish.xml - # Others [Bb]in [Oo]bj @@ -91,27 +78,22 @@ ClientBin [Ss]tyle[Cc]op.* ~$* *.dbmdl - *.[Pp]ublish.xml - Generated_Code #added for RIA/Silverlight projects - # Backup & report files from converting an old project file to a newer # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML - # Allow plugins !FFXIVAPP.Plugin.*/ - ############ ## Windows ############ - # Windows image file caches Thumbs.db - # Folder config file Desktop.ini -FFXIVAPP.Client/FFXIVAPP.Client.csproj \ No newline at end of file +packages/ +distribution/ +published/ diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config index 3343d682..8751237f 100644 --- a/.nuget/NuGet.Config +++ b/.nuget/NuGet.Config @@ -1,7 +1,13 @@  - - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/.vs/FFXIVAPP/v15/sqlite3/storage.ide b/.vs/FFXIVAPP/v15/sqlite3/storage.ide deleted file mode 100644 index 1ee10049..00000000 Binary files a/.vs/FFXIVAPP/v15/sqlite3/storage.ide and /dev/null differ diff --git a/FFXIVAPP.Client/App.cs b/FFXIVAPP.Client/App.cs index 064be6cd..2194a7bc 100644 --- a/FFXIVAPP.Client/App.cs +++ b/FFXIVAPP.Client/App.cs @@ -1,50 +1,51 @@ -// FFXIVAPP.Client ~ App.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.ComponentModel; -using System.Configuration; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.NetworkInformation; -using System.Windows; -using System.Windows.Threading; -using System.Xml; -using System.Xml.Linq; -using FFXIVAPP.Client.Helpers; -using FFXIVAPP.Client.Properties; -using FFXIVAPP.Common.Helpers; -using FFXIVAPP.Common.Models; -using FFXIVAPP.Common.Utilities; -using NAudio.Wave; -using NLog; -using NLog.Config; - -namespace FFXIVAPP.Client -{ - internal partial class App - { - private App() - { - Startup += ApplicationStartup; - StartupUri = new Uri("ShellView.xaml", UriKind.Relative); +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// App.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client { + using System; + using System.CodeDom.Compiler; + using System.Collections.Generic; + using System.ComponentModel; + using System.Configuration; + using System.Diagnostics; + using System.IO; + using System.Linq; + using System.Net.NetworkInformation; + using System.Windows; + using System.Windows.Resources; + using System.Windows.Threading; + using System.Xml; + using System.Xml.Linq; + + using FFXIVAPP.Client.Helpers; + using FFXIVAPP.Client.Models; + using FFXIVAPP.Client.Properties; + using FFXIVAPP.Common.Helpers; + using FFXIVAPP.Common.Models; + using FFXIVAPP.Common.Utilities; + + using NAudio.Wave; + + using NLog; + using NLog.Config; + + internal partial class App { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + private static List _availableAudioDevices; + + private static IEnumerable _availableNetworkInterfaces; + + private App() { + this.Startup += ApplicationStartup; + this.StartupUri = new Uri("ShellView.xaml", UriKind.Relative); ConfigureNLog(); Settings.Default.PropertyChanged += SettingsPropertyChanged; @@ -55,8 +56,28 @@ private App() LoadComponent(this, resourceLocater); - Dispatcher.UnhandledException += OnDispatcherUnhandledException; - Dispatcher.UnhandledExceptionFilter += OnUnhandledExceptionFilter; + this.Dispatcher.UnhandledException += OnDispatcherUnhandledException; + this.Dispatcher.UnhandledExceptionFilter += this.OnUnhandledExceptionFilter; + } + + public static string[] MArgs { get; private set; } + + internal static IEnumerable AvailableAudioDevices { + get { + return _availableAudioDevices ?? (_availableAudioDevices = new List(DirectSoundOut.Devices.Where(d => d.Guid != Guid.Empty))); + } + } + + internal static IEnumerable AvailableNetworkInterfaces { + get { + return _availableNetworkInterfaces ?? (_availableNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces()); + } + } + + internal static PluginHost Plugins { + get { + return PluginHost.Instance; + } } /// @@ -66,8 +87,7 @@ private App() [DebuggerNonUserCode] [GeneratedCode("PresentationBuildTasks", "4.0.0.0")] [LoaderOptimization(LoaderOptimization.MultiDomainHost)] - public static void Main() - { + public static void Main() { var app = new App(); app.Run(); } @@ -76,62 +96,52 @@ public static void Main() /// /// /// - private static void ApplicationStartup(object sender, StartupEventArgs e) - { - if (e.Args.Length > 0) - { + private static void ApplicationStartup(object sender, StartupEventArgs e) { + if (e.Args.Length > 0) { MArgs = e.Args; } } - private static void CheckSettings() - { + private static void CheckSettings() { Common.Constants.EnableNLog = Settings.Default.EnableNLog; - try - { - if (!Settings.Default.Application_UpgradeRequired) - { + try { + if (!Settings.Default.Application_UpgradeRequired) { Settings.Default.Reload(); return; } + Settings.Default.Upgrade(); Settings.Default.Reload(); Settings.Default.Application_UpgradeRequired = false; } - catch (Exception) - { + catch (Exception) { SettingsHelper.Default(); } } /// /// - private static void ConfigureNLog() - { + private static void ConfigureNLog() { var hasLocal = false; const string fileName = "./FFXIVAPP.Client.exe.nlog"; - if (File.Exists(fileName)) - { + if (File.Exists(fileName)) { hasLocal = true; } - var resource = ResourceHelper.StreamResource(Constants.AppPack + "Resources/FFXIVAPP.Client.exe.nlog"); - if (resource == null) - { + + StreamResourceInfo resource = ResourceHelper.StreamResource(Constants.AppPack + "Resources/FFXIVAPP.Client.exe.nlog"); + if (resource == null) { return; } + StringReader stringReader; - if (hasLocal) - { - stringReader = new StringReader(XElement.Load(fileName) - .ToString()); + if (hasLocal) { + stringReader = new StringReader(XElement.Load(fileName).ToString()); } - else - { - stringReader = new StringReader(XElement.Load(resource.Stream) - .ToString()); + else { + stringReader = new StringReader(XElement.Load(resource.Stream).ToString()); } - using (var xmlReader = XmlReader.Create(stringReader)) - { + + using (XmlReader xmlReader = XmlReader.Create(stringReader)) { LogManager.Configuration = new XmlLoggingConfiguration(xmlReader, null); } } @@ -140,21 +150,9 @@ private static void ConfigureNLog() /// /// /// - private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) - { + private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; - var ex = e.Exception; - Logging.Log(Logger, new LogItem(ex, true)); - } - - /// - /// - /// - /// - private void OnUnhandledExceptionFilter(object sender, DispatcherUnhandledExceptionFilterEventArgs e) - { - e.RequestCatch = true; - var ex = e.Exception; + Exception ex = e.Exception; Logging.Log(Logger, new LogItem(ex, true)); } @@ -162,13 +160,10 @@ private void OnUnhandledExceptionFilter(object sender, DispatcherUnhandledExcept /// /// /// - private static void SettingsPropertyChanged(object sender, PropertyChangedEventArgs e) - { + private static void SettingsPropertyChanged(object sender, PropertyChangedEventArgs e) { Logging.Log(Logger, $"PropertyChanged : {e.PropertyName}"); - try - { - switch (e.PropertyName) - { + try { + switch (e.PropertyName) { case "CharacterName": Constants.CharacterName = Settings.Default.CharacterName; break; @@ -176,12 +171,12 @@ private static void SettingsPropertyChanged(object sender, PropertyChangedEventA Constants.GameLanguage = Settings.Default.GameLanguage; break; case "UILanguage": - if (AppViewModel.Instance.UILanguages.Any(ui => ui.Language == Settings.Default.UILanguage)) - { - var uiLanguage = AppViewModel.Instance.UILanguages.First(ui => ui.Language == Settings.Default.UILanguage); + if (AppViewModel.Instance.UILanguages.Any(ui => ui.Language == Settings.Default.UILanguage)) { + UILanguage uiLanguage = AppViewModel.Instance.UILanguages.First(ui => ui.Language == Settings.Default.UILanguage); Constants.CultureInfo = Settings.Default.Culture = uiLanguage.CultureInfo; LocaleHelper.Update(Settings.Default.Culture); } + break; case "ServerName": Constants.ServerName = Settings.Default.ServerName; @@ -191,23 +186,21 @@ private static void SettingsPropertyChanged(object sender, PropertyChangedEventA break; case "EnableNetworkReading": Common.Constants.EnableNetworkReading = Constants.EnableNetworkReading = Settings.Default.EnableNetworkReading; - if (Settings.Default.EnableNetworkReading) - { - if (!Initializer.NetworkWorking && Constants.IsOpen) - { + if (Settings.Default.EnableNetworkReading) { + if (!Initializer.NetworkWorking && Constants.IsOpen) { Initializer.StartNetworkWorker(); } } - else - { + else { Initializer.StopNetworkWorker(); } + break; case "NetworkUseWinPCap": - if (Initializer.NetworkWorking) - { + if (Initializer.NetworkWorking) { Initializer.RefreshNetworkWorker(); } + break; case "EnableHelpLabels": Constants.EnableHelpLabels = Settings.Default.EnableHelpLabels; @@ -219,31 +212,27 @@ private static void SettingsPropertyChanged(object sender, PropertyChangedEventA Constants.UIScale = Settings.Default.UIScale; break; case "TopMost": - if (ShellView.View != null) - { + if (ShellView.View != null) { ShellView.View.Topmost = Settings.Default.TopMost; } + break; case "DefaultAudioDevice": - if (Settings.Default.DefaultAudioDevice == "System Default") - { + if (Settings.Default.DefaultAudioDevice == "System Default") { Common.Constants.DefaultAudioDevice = Guid.Empty; } - else - { - foreach (var audioDevice in AvailableAudioDevices.Where(device => device.Guid != Guid.Empty)) - { - if (audioDevice.Description == Settings.Default.DefaultAudioDevice) - { + else { + foreach (DirectSoundDeviceInfo audioDevice in AvailableAudioDevices.Where(device => device.Guid != Guid.Empty)) { + if (audioDevice.Description == Settings.Default.DefaultAudioDevice) { Common.Constants.DefaultAudioDevice = audioDevice.Guid; } } } + break; } } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } @@ -252,38 +241,18 @@ private static void SettingsPropertyChanged(object sender, PropertyChangedEventA /// /// /// - private static void SettingsSettingChanging(object sender, SettingChangingEventArgs e) - { + private static void SettingsSettingChanging(object sender, SettingChangingEventArgs e) { Logging.Log(Logger, $"SettingChanging : [{e.SettingKey},{e.NewValue}]"); } - #region Logger - - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private static List _availableAudioDevices; - private static IEnumerable _availableNetworkInterfaces; - - #endregion - - #region Property Bindings - - internal static PluginHost Plugins - { - get { return PluginHost.Instance; } - } - - internal static IEnumerable AvailableAudioDevices - { - get { return _availableAudioDevices ?? (_availableAudioDevices = new List(DirectSoundOut.Devices.Where(d => d.Guid != Guid.Empty))); } - } - - internal static IEnumerable AvailableNetworkInterfaces - { - get { return _availableNetworkInterfaces ?? (_availableNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces()); } + /// + /// + /// + /// + private void OnUnhandledExceptionFilter(object sender, DispatcherUnhandledExceptionFilterEventArgs e) { + e.RequestCatch = true; + Exception ex = e.Exception; + Logging.Log(Logger, new LogItem(ex, true)); } - - public static string[] MArgs { get; private set; } - - #endregion } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/App.xaml b/FFXIVAPP.Client/App.xaml index 3b6b105b..97d21e2a 100644 --- a/FFXIVAPP.Client/App.xaml +++ b/FFXIVAPP.Client/App.xaml @@ -18,4 +18,4 @@ - + \ No newline at end of file diff --git a/FFXIVAPP.Client/App.xaml.cs b/FFXIVAPP.Client/App.xaml.cs index cd3e460b..f89e229e 100644 --- a/FFXIVAPP.Client/App.xaml.cs +++ b/FFXIVAPP.Client/App.xaml.cs @@ -1,26 +1,16 @@ -// FFXIVAPP.Client ~ App.xaml.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// App.xaml.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- -namespace FFXIVAPP.Client -{ +namespace FFXIVAPP.Client { /// /// Interaction logic for App.xaml /// - internal partial class App - { - } -} + internal partial class App { } +} \ No newline at end of file diff --git a/FFXIVAPP.Client/AppBootstrapper.cs b/FFXIVAPP.Client/AppBootstrapper.cs index 8e8741c9..a6101a85 100644 --- a/FFXIVAPP.Client/AppBootstrapper.cs +++ b/FFXIVAPP.Client/AppBootstrapper.cs @@ -1,40 +1,32 @@ -// FFXIVAPP.Client ~ AppBootstrapper.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Globalization; -using System.Runtime.CompilerServices; -using FFXIVAPP.Client.Models; -using FFXIVAPP.Common.Utilities; -using FFXIVAPP.ResourceFiles; -using NLog; -using Sharlayan.Models; - -namespace FFXIVAPP.Client -{ - internal class AppBootstrapper : INotifyPropertyChanged - { - #region Logger - +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AppBootstrapper.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client { + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Globalization; + using System.Runtime.CompilerServices; + + using FFXIVAPP.Client.Models; + using FFXIVAPP.Common.Utilities; + using FFXIVAPP.ResourceFiles; + + using NLog; + + using Sharlayan.Models; + + internal class AppBootstrapper : INotifyPropertyChanged { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - #endregion + private static Lazy _instance = new Lazy(() => new AppBootstrapper()); /*main entry to app * used for: @@ -42,23 +34,20 @@ internal class AppBootstrapper : INotifyPropertyChanged * configuring collections * setting up dependencies */ - - private AppBootstrapper() - { - if (App.MArgs != null) - { - foreach (var argument in App.MArgs) - { + private AppBootstrapper() { + if (App.MArgs != null) { + foreach (var argument in App.MArgs) { Logging.Log(Logger, $"ArgumentProvided : {argument}"); } } + Constants.IsOpen = false; Constants.ProcessModel = new ProcessModel(); - //initialize application data + + // initialize application data AppViewModel.Instance.ConfigurationsPath = Common.Constants.ConfigurationsPath; AppViewModel.Instance.LogsPath = Common.Constants.LogsPath; - AppViewModel.Instance.SavedLogsDirectoryList = new List - { + AppViewModel.Instance.SavedLogsDirectoryList = new List { "Say", "Shout", "Party", @@ -79,61 +68,57 @@ private AppBootstrapper() AppViewModel.Instance.SettingsPath = Common.Constants.SettingsPath; AppViewModel.Instance.PluginsSettingsPath = Common.Constants.PluginsSettingsPath; - #region Culture BootStrapping - - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "English", - ImageURI = Theme.GetImagePackURI("en"), - Title = "English", - CultureInfo = new CultureInfo("en") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "Japanese", - ImageURI = Theme.GetImagePackURI("ja"), - Title = "日本語", - CultureInfo = new CultureInfo("ja") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "French", - ImageURI = Theme.GetImagePackURI("fr"), - Title = "Français", - CultureInfo = new CultureInfo("fr") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "German", - ImageURI = Theme.GetImagePackURI("de"), - Title = "Deutsch", - CultureInfo = new CultureInfo("de") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "Chinese", - ImageURI = Theme.GetImagePackURI("cn"), - Title = "中國", - CultureInfo = new CultureInfo("zh") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "Korean", - ImageURI = Theme.GetImagePackURI("ko"), - Title = "한국어", - CultureInfo = new CultureInfo("ko") - }); - AppViewModel.Instance.UILanguages.Add(new UILanguage - { - Language = "Russian", - ImageURI = Theme.GetImagePackURI("ru"), - Title = "Русский", - CultureInfo = new CultureInfo("ru") - }); - - #endregion - - #region Initial BootStrapping + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "English", + ImageURI = Theme.GetImagePackURI("en"), + Title = "English", + CultureInfo = new CultureInfo("en") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "Japanese", + ImageURI = Theme.GetImagePackURI("ja"), + Title = "日本語", + CultureInfo = new CultureInfo("ja") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "French", + ImageURI = Theme.GetImagePackURI("fr"), + Title = "Français", + CultureInfo = new CultureInfo("fr") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "German", + ImageURI = Theme.GetImagePackURI("de"), + Title = "Deutsch", + CultureInfo = new CultureInfo("de") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "Chinese", + ImageURI = Theme.GetImagePackURI("cn"), + Title = "中國", + CultureInfo = new CultureInfo("zh") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "Korean", + ImageURI = Theme.GetImagePackURI("ko"), + Title = "한국어", + CultureInfo = new CultureInfo("ko") + }); + AppViewModel.Instance.UILanguages.Add( + new UILanguage { + Language = "Russian", + ImageURI = Theme.GetImagePackURI("ru"), + Title = "Русский", + CultureInfo = new CultureInfo("ru") + }); + + Initializer.SetupCurrentUICulture(); Initializer.LoadChatCodes(); @@ -145,45 +130,19 @@ private AppBootstrapper() Initializer.LoadSoundsIntoCache(); Initializer.LoadPlugins(); - #endregion + } - #region Property Bindings - - private static Lazy _instance = new Lazy(() => new AppBootstrapper()); - - public static AppBootstrapper Instance - { - get { return _instance.Value; } - } - - #endregion - - #region Declarations - - #endregion - - #region Loading Functions - - #endregion - - #region Utility Functions - - #endregion - - #region Command Bindings - - #endregion - - #region Implementation of INotifyPropertyChanged - public event PropertyChangedEventHandler PropertyChanged = delegate { }; - private void RaisePropertyChanged([CallerMemberName] string caller = "") - { - PropertyChanged(this, new PropertyChangedEventArgs(caller)); + public static AppBootstrapper Instance { + get { + return _instance.Value; + } } - #endregion + private void RaisePropertyChanged([CallerMemberName] string caller = "") { + this.PropertyChanged(this, new PropertyChangedEventArgs(caller)); + } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/AppException.cs b/FFXIVAPP.Client/AppException.cs index 755e0d62..45568b1b 100644 --- a/FFXIVAPP.Client/AppException.cs +++ b/FFXIVAPP.Client/AppException.cs @@ -1,42 +1,28 @@ -// FFXIVAPP.Client ~ AppException.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AppException.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- -using System; -using System.Runtime.Serialization; +namespace FFXIVAPP.Client { + using System; + using System.Runtime.Serialization; -namespace FFXIVAPP.Client -{ [Serializable] - internal class AppException : Exception - { - public AppException() - { - } + internal class AppException : Exception { + public AppException() { } - public AppException(string message) : base(message) - { - } + public AppException(string message) + : base(message) { } - public AppException(string message, Exception inner) : base(message, inner) - { - } + public AppException(string message, Exception inner) + : base(message, inner) { } - protected AppException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } + protected AppException(SerializationInfo info, StreamingContext context) + : base(info, context) { } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/AppViewModel.cs b/FFXIVAPP.Client/AppViewModel.cs index 295a740b..ee627519 100644 --- a/FFXIVAPP.Client/AppViewModel.cs +++ b/FFXIVAPP.Client/AppViewModel.cs @@ -1,437 +1,442 @@ -// FFXIVAPP.Client ~ AppViewModel.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.ComponentModel.Composition; -using System.Drawing; -using System.IO; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Forms; -using System.Windows.Threading; -using FFXIVAPP.Client.Models; -using FFXIVAPP.Client.Properties; -using FFXIVAPP.Common.Helpers; -using Sharlayan.Core; -using Sharlayan.Models; -using ContextMenu = System.Windows.Forms.ContextMenu; - -namespace FFXIVAPP.Client -{ - [Export(typeof(AppViewModel))] - internal sealed class AppViewModel : INotifyPropertyChanged - { - #region Property Bindings +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AppViewModel.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client { + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.ComponentModel; + using System.ComponentModel.Composition; + using System.Drawing; + using System.IO; + using System.Reflection; + using System.Runtime.CompilerServices; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Forms; + using System.Windows.Threading; + + using FFXIVAPP.Client.Models; + using FFXIVAPP.Client.Properties; + using FFXIVAPP.Common.Helpers; + + using Sharlayan.Core; + using Sharlayan.Models; + + using ContextMenu = System.Windows.Forms.ContextMenu; + [Export(typeof(AppViewModel))] + internal sealed class AppViewModel : INotifyPropertyChanged { private static bool _hasPlugins; + + private static Lazy _instance = new Lazy(() => new AppViewModel()); + private string _appTitle; - private List _chatHistory; + + private List _chatHistory; + private string _configurationsPath; + private string _currentVersion; + private string _downloadUri; + private bool _hasNewPluginUpdate; + private bool _hasNewVersion; + private string _latestVersion; + private Dictionary _locale; + private string _logsPath; + private NotifyIcon _notifyIcon; - private ObservableCollection _pluginTabItems; + private string _pluginsSettingsPath; + + private ObservableCollection _pluginTabItems; + private List _savedLogsDirectoryList; + private string _screenShotsPath; + private string _selected; + private string _settingsPath; + private List _signatures; + private string _soundsPath; + private Style _tabControlCollapsedHeader; + + private ObservableCollection _uiLanguages; + private string _updateNotes; - #region UILanguages + public event PropertyChangedEventHandler PropertyChanged = delegate { }; - private ObservableCollection _uiLanguages; + public static AppViewModel Instance { + get { + return _instance.Value; + } + } - public ObservableCollection UILanguages - { - get { return _uiLanguages ?? (_uiLanguages = new ObservableCollection()); } - set - { - _uiLanguages = value; - RaisePropertyChanged(); + public string AppTitle { + get { + return this._appTitle; + } + + set { + var tempvalue = Constants.IsOpen + ? value + : $"{value} : OFFLINE"; + this._appTitle = string.IsNullOrWhiteSpace(tempvalue) + ? "FFXIVAPP" + : $"FFXIVAPP ~ {tempvalue}"; + this.RaisePropertyChanged(); } } - #endregion + public List ChatHistory { + get { + return this._chatHistory ?? (this._chatHistory = new List()); + } - private static Lazy _instance = new Lazy(() => new AppViewModel()); + set { + this._chatHistory = value; + this.RaisePropertyChanged(); + } + } + + public string ConfigurationsPath { + get { + return this._configurationsPath; + } + + set { + this._configurationsPath = value; + if (!Directory.Exists(this._configurationsPath)) { + Directory.CreateDirectory(this._configurationsPath); + } - public static AppViewModel Instance - { - get { return _instance.Value; } + this.RaisePropertyChanged(); + } } - public Dictionary Locale - { - get { return _locale ?? (_locale = new Dictionary()); } - set - { - _locale = value; - RaisePropertyChanged(); + public string Copyright { + get { + object[] att = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + return att.Length == 0 + ? string.Empty + : ((AssemblyCopyrightAttribute) att[0]).Copyright; } } - public NotifyIcon NotifyIcon - { - get - { - if (_notifyIcon == null) - { - using (var iconStream = ResourceHelper.StreamResource(Constants.AppPack + "FFXIVAPP.ico") - .Stream) - { - _notifyIcon = new NotifyIcon - { - Icon = new Icon(iconStream), - Visible = true - }; - iconStream.Dispose(); - _notifyIcon.Text = "FFXIVAPP"; - var contextMenu = new ContextMenu(); - contextMenu.MenuItems.Add("&Restore Application") - .Enabled = false; - contextMenu.MenuItems.Add("&Exit"); - contextMenu.MenuItems[0] - .Click += NotifyIconOnRestoreClick; - contextMenu.MenuItems[1] - .Click += NotifyIconOnExitClick; - _notifyIcon.ContextMenu = contextMenu; - _notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick; - } - } - return _notifyIcon; + public string CurrentVersion { + get { + return this._currentVersion; + } + + set { + this._currentVersion = value; + this.RaisePropertyChanged(); } } - public string AppTitle - { - get { return _appTitle; } - set - { - var tempvalue = Constants.IsOpen ? value : $"{value} : OFFLINE"; - _appTitle = String.IsNullOrWhiteSpace(tempvalue) ? "FFXIVAPP" : $"FFXIVAPP ~ {tempvalue}"; - RaisePropertyChanged(); + public string DownloadUri { + get { + return this._downloadUri; + } + + set { + this._downloadUri = value; + this.RaisePropertyChanged(); } } - public ObservableCollection PluginTabItems - { - get { return _pluginTabItems ?? (_pluginTabItems = new ObservableCollection()); } - set - { - _pluginTabItems = value; - RaisePropertyChanged(); + public bool HasNewPluginUpdate { + get { + return this._hasNewPluginUpdate; + } + + set { + this._hasNewPluginUpdate = value; + this.RaisePropertyChanged(); } } - public bool HasPlugins - { - get { return _hasPlugins; } - set - { - _hasPlugins = value; - RaisePropertyChanged(); + public bool HasNewVersion { + get { + return this._hasNewVersion; + } + + set { + this._hasNewVersion = value; + this.RaisePropertyChanged(); } } - public string Selected - { - get { return _selected; } - set - { - _selected = value; - RaisePropertyChanged(); + public bool HasPlugins { + get { + return _hasPlugins; + } + + set { + _hasPlugins = value; + this.RaisePropertyChanged(); } } - public Style TabControlCollapsedHeader - { - get - { - if (_tabControlCollapsedHeader == null) - { - var s = new Style(); - s.Setters.Add(new Setter(UIElement.VisibilityProperty, Visibility.Collapsed)); - _tabControlCollapsedHeader = s; - } - return _tabControlCollapsedHeader; + public string LatestVersion { + get { + return this._latestVersion; } - set - { - _tabControlCollapsedHeader = value; - RaisePropertyChanged(); + + set { + this._latestVersion = value; + this.RaisePropertyChanged(); } } - public string ConfigurationsPath - { - get { return _configurationsPath; } - set - { - _configurationsPath = value; - if (!Directory.Exists(_configurationsPath)) - { - Directory.CreateDirectory(_configurationsPath); - } - RaisePropertyChanged(); + public Dictionary Locale { + get { + return this._locale ?? (this._locale = new Dictionary()); + } + + set { + this._locale = value; + this.RaisePropertyChanged(); } } - public string LogsPath - { - get { return _logsPath; } - set - { - _logsPath = value; - if (!Directory.Exists(_logsPath)) - { - Directory.CreateDirectory(_logsPath); + public string LogsPath { + get { + return this._logsPath; + } + + set { + this._logsPath = value; + if (!Directory.Exists(this._logsPath)) { + Directory.CreateDirectory(this._logsPath); } - RaisePropertyChanged(); + + this.RaisePropertyChanged(); } } - public List SavedLogsDirectoryList - { - get { return _savedLogsDirectoryList ?? (_savedLogsDirectoryList = new List()); } - set - { - foreach (var directoryPath in value) - { - var path = Path.Combine(LogsPath, directoryPath); - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); + public NotifyIcon NotifyIcon { + get { + if (this._notifyIcon == null) { + using (Stream iconStream = ResourceHelper.StreamResource(Constants.AppPack + "FFXIVAPP.ico").Stream) { + this._notifyIcon = new NotifyIcon { + Icon = new Icon(iconStream), + Visible = true + }; + iconStream.Dispose(); + this._notifyIcon.Text = "FFXIVAPP"; + var contextMenu = new ContextMenu(); + contextMenu.MenuItems.Add("&Restore Application").Enabled = false; + contextMenu.MenuItems.Add("&Exit"); + contextMenu.MenuItems[0].Click += NotifyIconOnRestoreClick; + contextMenu.MenuItems[1].Click += NotifyIconOnExitClick; + this._notifyIcon.ContextMenu = contextMenu; + this._notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick; } } - _savedLogsDirectoryList = value; - RaisePropertyChanged(); + + return this._notifyIcon; } } - public string ScreenShotsPath - { - get { return _screenShotsPath; } - set - { - _screenShotsPath = value; - if (!Directory.Exists(_screenShotsPath)) - { - Directory.CreateDirectory(_screenShotsPath); + public string PluginsSettingsPath { + get { + return this._pluginsSettingsPath; + } + + set { + this._pluginsSettingsPath = value; + if (!Directory.Exists(this._pluginsSettingsPath)) { + Directory.CreateDirectory(this._pluginsSettingsPath); } - RaisePropertyChanged(); + + this.RaisePropertyChanged(); } } - public string SoundsPath - { - get { return _soundsPath; } - set - { - _soundsPath = value; - if (!Directory.Exists(_soundsPath)) - { - Directory.CreateDirectory(_soundsPath); - } - RaisePropertyChanged(); + public ObservableCollection PluginTabItems { + get { + return this._pluginTabItems ?? (this._pluginTabItems = new ObservableCollection()); + } + + set { + this._pluginTabItems = value; + this.RaisePropertyChanged(); } } - public string SettingsPath - { - get { return _settingsPath; } - set - { - _settingsPath = value; - if (!Directory.Exists(_settingsPath)) - { - Directory.CreateDirectory(_settingsPath); + public List SavedLogsDirectoryList { + get { + return this._savedLogsDirectoryList ?? (this._savedLogsDirectoryList = new List()); + } + + set { + foreach (var directoryPath in value) { + var path = Path.Combine(this.LogsPath, directoryPath); + if (!Directory.Exists(path)) { + Directory.CreateDirectory(path); + } } - RaisePropertyChanged(); + + this._savedLogsDirectoryList = value; + this.RaisePropertyChanged(); } } - public string PluginsSettingsPath - { - get { return _pluginsSettingsPath; } - set - { - _pluginsSettingsPath = value; - if (!Directory.Exists(_pluginsSettingsPath)) - { - Directory.CreateDirectory(_pluginsSettingsPath); + public string ScreenShotsPath { + get { + return this._screenShotsPath; + } + + set { + this._screenShotsPath = value; + if (!Directory.Exists(this._screenShotsPath)) { + Directory.CreateDirectory(this._screenShotsPath); } - RaisePropertyChanged(); + + this.RaisePropertyChanged(); } } - public List ChatHistory - { - get { return _chatHistory ?? (_chatHistory = new List()); } - set - { - _chatHistory = value; - RaisePropertyChanged(); + public string Selected { + get { + return this._selected; } - } - public bool HasNewVersion - { - get { return _hasNewVersion; } - set - { - _hasNewVersion = value; - RaisePropertyChanged(); + set { + this._selected = value; + this.RaisePropertyChanged(); } } - public bool HasNewPluginUpdate - { - get { return _hasNewPluginUpdate; } - set - { - _hasNewPluginUpdate = value; - RaisePropertyChanged(); + public string SettingsPath { + get { + return this._settingsPath; } - } - public string DownloadUri - { - get { return _downloadUri; } - set - { - _downloadUri = value; - RaisePropertyChanged(); + set { + this._settingsPath = value; + if (!Directory.Exists(this._settingsPath)) { + Directory.CreateDirectory(this._settingsPath); + } + + this.RaisePropertyChanged(); } } - public string LatestVersion - { - get { return _latestVersion; } - set - { - _latestVersion = value; - RaisePropertyChanged(); + public List Signatures { + get { + return this._signatures ?? (this._signatures = new List()); } - } - public string UpdateNotes - { - get { return _updateNotes; } - set - { - _updateNotes = value; - RaisePropertyChanged(); + set { + this._signatures = value; + this.RaisePropertyChanged(); } } - public string CurrentVersion - { - get { return _currentVersion; } - set - { - _currentVersion = value; - RaisePropertyChanged(); + public string SoundsPath { + get { + return this._soundsPath; } - } - public string Copyright - { - get - { - var att = Assembly.GetExecutingAssembly() - .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); - return att.Length == 0 ? string.Empty : ((AssemblyCopyrightAttribute) att[0]).Copyright; + set { + this._soundsPath = value; + if (!Directory.Exists(this._soundsPath)) { + Directory.CreateDirectory(this._soundsPath); + } + + this.RaisePropertyChanged(); } } - public List Signatures - { - get { return _signatures ?? (_signatures = new List()); } - set - { - _signatures = value; - RaisePropertyChanged(); + public Style TabControlCollapsedHeader { + get { + if (this._tabControlCollapsedHeader == null) { + var s = new Style(); + s.Setters.Add(new Setter(UIElement.VisibilityProperty, Visibility.Collapsed)); + this._tabControlCollapsedHeader = s; + } + + return this._tabControlCollapsedHeader; + } + + set { + this._tabControlCollapsedHeader = value; + this.RaisePropertyChanged(); } } - #endregion + public ObservableCollection UILanguages { + get { + return this._uiLanguages ?? (this._uiLanguages = new ObservableCollection()); + } - #region Loading Functions + set { + this._uiLanguages = value; + this.RaisePropertyChanged(); + } + } - #endregion + public string UpdateNotes { + get { + return this._updateNotes; + } - #region Private Functions + set { + this._updateNotes = value; + this.RaisePropertyChanged(); + } + } /// /// /// /// - private static void NotifyIconOnRestoreClick(object sender, EventArgs eventArgs) - { - ShellView.View.WindowState = WindowState.Normal; - ShellView.View.Topmost = true; - ShellView.View.Topmost = Settings.Default.TopMost; + private static void NotifyIconOnExitClick(object sender, EventArgs eventArgs) { + DispatcherHelper.Invoke(() => ShellView.CloseApplication(), DispatcherPriority.Send); } /// /// /// - /// - private static void NotifyIconOnExitClick(object sender, EventArgs eventArgs) - { - DispatcherHelper.Invoke(() => ShellView.CloseApplication(), DispatcherPriority.Send); + /// + private static void NotifyIconOnMouseDoubleClick(object sender, MouseEventArgs mouseEventArgs) { + ShellView.View.WindowState = WindowState.Normal; + ShellView.View.Topmost = true; + ShellView.View.Topmost = Settings.Default.TopMost; } /// /// /// - /// - private static void NotifyIconOnMouseDoubleClick(object sender, MouseEventArgs mouseEventArgs) - { + /// + private static void NotifyIconOnRestoreClick(object sender, EventArgs eventArgs) { ShellView.View.WindowState = WindowState.Normal; ShellView.View.Topmost = true; ShellView.View.Topmost = Settings.Default.TopMost; } - #endregion - - #region Implementation of INotifyPropertyChanged - - public event PropertyChangedEventHandler PropertyChanged = delegate { }; - - private void RaisePropertyChanged([CallerMemberName] string caller = "") - { - PropertyChanged(this, new PropertyChangedEventArgs(caller)); + private void RaisePropertyChanged([CallerMemberName] string caller = "") { + this.PropertyChanged(this, new PropertyChangedEventArgs(caller)); } - - #endregion } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Constants.cs b/FFXIVAPP.Client/Constants.cs index 34480744..10acc664 100644 --- a/FFXIVAPP.Client/Constants.cs +++ b/FFXIVAPP.Client/Constants.cs @@ -1,303 +1,330 @@ -// FFXIVAPP.Client ~ Constants.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Xml.Linq; -using FFXIVAPP.Client.Helpers; -using FFXIVAPP.Common.Core.Constant; -using FFXIVAPP.Common.Helpers; -using Sharlayan.Models; - -namespace FFXIVAPP.Client -{ - internal static class Constants - { - #region Declarations - +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// Constants.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client { + using System; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Xml.Linq; + + using FFXIVAPP.Client.Helpers; + using FFXIVAPP.Common.Helpers; + + using Sharlayan.Models; + + internal static class Constants { public const string AppPack = "pack://application:,,,/FFXIVAPP.Client;component/"; - public static readonly string[] Supported = - { - "ja", "fr", "en", "de", "zh", "ru", "ko" + public static readonly string[] Supported = { + "ja", + "fr", + "en", + "de", + "zh", + "ru", + "ko" }; - public static StringComparison InvariantComparer = StringComparison.InvariantCultureIgnoreCase; public static StringComparison CultureComparer = StringComparison.CurrentCultureIgnoreCase; - #endregion - - #region Property Bindings + public static StringComparison InvariantComparer = StringComparison.InvariantCultureIgnoreCase; - private static XDocument _xSettings; - private static List _settings; - private static XDocument _xAutoTranslate; - private static XDocument _xChatCodes; - private static XDocument _xColors; private static Dictionary _autoTranslate; + + private static string _characterName; + private static Dictionary _chatCodes; + private static Dictionary _colors; + private static CultureInfo _cultureInfo; - private static string _characterName; - private static string _serverName; - private static string _gameLanguage; - private static bool _enableNLog; - private static bool _enableNetworkReading; + private static bool _enableHelpLabels; + + private static bool _enableNetworkReading; + + private static bool _enableNLog; + + private static string _gameLanguage; + + private static string _serverName; + + private static List _settings; + private static string _theme; + private static string _uiScale; - public static XDocument XSettings - { - get - { - var settingsFile = Path.Combine(AppViewModel.Instance.SettingsPath, "ApplicationSettings.xml"); - if (_xSettings != null) - { - return _xSettings; - } - try - { - var found = File.Exists(settingsFile); - _xSettings = found ? XDocument.Load(settingsFile) : ResourceHelper.XDocResource(Constants.AppPack + "/Defaults/Settings.xml"); - } - catch (Exception) - { - _xSettings = ResourceHelper.XDocResource(Constants.AppPack + "/Defaults/Settings.xml"); - } - return _xSettings; - } - set { _xSettings = value; } - } + private static XDocument _xAutoTranslate; - public static List Settings - { - get { return _settings ?? (_settings = new List()); } - set { _settings = value; } - } + private static XDocument _xChatCodes; - public static XDocument XAutoTranslate - { - get - { - var file = Path.Combine(Common.Constants.CachePath, "Configurations", "AutoTranslate.xml"); - if (_xAutoTranslate != null) - { - return _xAutoTranslate; - } - try - { - var found = File.Exists(file); - _xAutoTranslate = found ? XDocument.Load(file) : ResourceHelper.XDocResource(Constants.AppPack + "Defaults/AutoTranslate.xml"); - } - catch (Exception) - { - _xAutoTranslate = ResourceHelper.XDocResource(Constants.AppPack + "Defaults/AutoTranslate.xml"); - } - return _xAutoTranslate; + private static XDocument _xColors; + + private static XDocument _xSettings; + + public static Dictionary AutoTranslate { + get { + return _autoTranslate ?? (_autoTranslate = new Dictionary()); } - set { _xAutoTranslate = value; } - } - public static XDocument XChatCodes - { - get - { - var file = Path.Combine(Common.Constants.CachePath, "Configurations", "ChatCodes.xml"); - if (_xChatCodes != null) - { - return _xChatCodes; - } - try - { - var found = File.Exists(file); - _xChatCodes = found ? XDocument.Load(file) : ResourceHelper.XDocResource(Constants.AppPack + "Resources/ChatCodes.xml"); - } - catch (Exception) - { - _xChatCodes = ResourceHelper.XDocResource(Constants.AppPack + "Resources/ChatCodes.xml"); - } - return _xChatCodes; + set { + _autoTranslate = value; + ConstantsHelper.UpdatePluginConstants(); } - set { _xChatCodes = value; } } - public static XDocument XColors - { - get - { - var file = Path.Combine(Common.Constants.CachePath, "Configurations", "Colors.xml"); - if (_xColors != null) - { - return _xColors; - } - try - { - var found = File.Exists(file); - _xColors = found ? XDocument.Load(file) : ResourceHelper.XDocResource(Constants.AppPack + "Defaults/Colors.xml"); - } - catch (Exception) - { - _xColors = ResourceHelper.XDocResource(Constants.AppPack + "Defaults/Colors.xml"); - } - return _xColors; + public static string CharacterName { + get { + return _characterName; } - set { _xColors = value; } - } - public static Dictionary AutoTranslate - { - get { return _autoTranslate ?? (_autoTranslate = new Dictionary()); } - set - { - _autoTranslate = value; + set { + _characterName = value; ConstantsHelper.UpdatePluginConstants(); } } - public static Dictionary ChatCodes - { - get { return _chatCodes ?? (_chatCodes = new Dictionary()); } - set - { + public static Dictionary ChatCodes { + get { + return _chatCodes ?? (_chatCodes = new Dictionary()); + } + + set { _chatCodes = value; ConstantsHelper.UpdatePluginConstants(); } } - public static string ChatCodesXML - { - get { return XChatCodes.ToString(); } + public static string ChatCodesXML { + get { + return XChatCodes.ToString(); + } } - public static Dictionary Colors - { - get { return _colors ?? (_colors = new Dictionary()); } - set - { + public static Dictionary Colors { + get { + return _colors ?? (_colors = new Dictionary()); + } + + set { _colors = value; ConstantsHelper.UpdatePluginConstants(); } } - public static CultureInfo CultureInfo - { - get { return _cultureInfo ?? (_cultureInfo = new CultureInfo("en")); } - set - { + public static CultureInfo CultureInfo { + get { + return _cultureInfo ?? (_cultureInfo = new CultureInfo("en")); + } + + set { _cultureInfo = value; ConstantsHelper.UpdatePluginConstants(); } } - public static string CharacterName - { - get { return _characterName; } - set - { - _characterName = value; - ConstantsHelper.UpdatePluginConstants(); + public static bool EnableHelpLabels { + get { + return _enableHelpLabels; } - } - public static string ServerName - { - get { return _serverName; } - set - { - _serverName = value; + set { + _enableHelpLabels = value; ConstantsHelper.UpdatePluginConstants(); } } - public static string GameLanguage - { - get { return _gameLanguage; } - set - { - _gameLanguage = value; + public static bool EnableNetworkReading { + get { + return _enableNetworkReading; + } + + set { + _enableNetworkReading = value; ConstantsHelper.UpdatePluginConstants(); } } - public static bool EnableNLog - { - get { return _enableNLog; } - set - { + public static bool EnableNLog { + get { + return _enableNLog; + } + + set { _enableNLog = value; ConstantsHelper.UpdatePluginConstants(); } } - public static bool EnableNetworkReading - { - get { return _enableNetworkReading; } - set - { - _enableNetworkReading = value; + public static string GameLanguage { + get { + return _gameLanguage; + } + + set { + _gameLanguage = value; ConstantsHelper.UpdatePluginConstants(); } } - public static bool EnableHelpLabels - { - get { return _enableHelpLabels; } - set - { - _enableHelpLabels = value; + public static bool IsOpen { get; set; } + + public static IntPtr ProcessHandle { get; set; } + + public static ProcessModel ProcessModel { get; set; } + + public static List ProcessModels { get; set; } + + public static string ServerName { + get { + return _serverName; + } + + set { + _serverName = value; ConstantsHelper.UpdatePluginConstants(); } } - public static string Theme - { - get { return _theme; } - set - { + public static List Settings { + get { + return _settings ?? (_settings = new List()); + } + + set { + _settings = value; + } + } + + public static string Theme { + get { + return _theme; + } + + set { _theme = value; ConstantsHelper.UpdatePluginConstants(); } } - public static string UIScale - { - get { return _uiScale; } - set - { + public static string UIScale { + get { + return _uiScale; + } + + set { _uiScale = value; ConstantsHelper.UpdatePluginConstants(); } } - #endregion + public static XDocument XAutoTranslate { + get { + var file = Path.Combine(Common.Constants.CachePath, "Configurations", "AutoTranslate.xml"); + if (_xAutoTranslate != null) { + return _xAutoTranslate; + } - #region Auto-Properties + try { + var found = File.Exists(file); + _xAutoTranslate = found + ? XDocument.Load(file) + : ResourceHelper.XDocResource(AppPack + "Defaults/AutoTranslate.xml"); + } + catch (Exception) { + _xAutoTranslate = ResourceHelper.XDocResource(AppPack + "Defaults/AutoTranslate.xml"); + } - public static IntPtr ProcessHandle { get; set; } + return _xAutoTranslate; + } - public static ProcessModel ProcessModel { get; set; } + set { + _xAutoTranslate = value; + } + } - public static bool IsOpen { get; set; } + public static XDocument XChatCodes { + get { + var file = Path.Combine(Common.Constants.CachePath, "Configurations", "ChatCodes.xml"); + if (_xChatCodes != null) { + return _xChatCodes; + } - public static List ProcessModels { get; set; } + try { + var found = File.Exists(file); + _xChatCodes = found + ? XDocument.Load(file) + : ResourceHelper.XDocResource(AppPack + "Resources/ChatCodes.xml"); + } + catch (Exception) { + _xChatCodes = ResourceHelper.XDocResource(AppPack + "Resources/ChatCodes.xml"); + } + + return _xChatCodes; + } + + set { + _xChatCodes = value; + } + } + + public static XDocument XColors { + get { + var file = Path.Combine(Common.Constants.CachePath, "Configurations", "Colors.xml"); + if (_xColors != null) { + return _xColors; + } + + try { + var found = File.Exists(file); + _xColors = found + ? XDocument.Load(file) + : ResourceHelper.XDocResource(AppPack + "Defaults/Colors.xml"); + } + catch (Exception) { + _xColors = ResourceHelper.XDocResource(AppPack + "Defaults/Colors.xml"); + } + + return _xColors; + } - #endregion + set { + _xColors = value; + } + } + + public static XDocument XSettings { + get { + var settingsFile = Path.Combine(AppViewModel.Instance.SettingsPath, "ApplicationSettings.xml"); + if (_xSettings != null) { + return _xSettings; + } + + try { + var found = File.Exists(settingsFile); + _xSettings = found + ? XDocument.Load(settingsFile) + : ResourceHelper.XDocResource(AppPack + "/Defaults/Settings.xml"); + } + catch (Exception) { + _xSettings = ResourceHelper.XDocResource(AppPack + "/Defaults/Settings.xml"); + } + + return _xSettings; + } + + set { + _xSettings = value; + } + } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Converters/NameMultiValueConverter.cs b/FFXIVAPP.Client/Converters/NameMultiValueConverter.cs index 23378481..0725ecef 100644 --- a/FFXIVAPP.Client/Converters/NameMultiValueConverter.cs +++ b/FFXIVAPP.Client/Converters/NameMultiValueConverter.cs @@ -1,36 +1,25 @@ -// FFXIVAPP.Client ~ NameMultiValueConverter.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// NameMultiValueConverter.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- -using System; -using System.Globalization; -using System.Windows.Data; +namespace FFXIVAPP.Client.Converters { + using System; + using System.Globalization; + using System.Windows.Data; -namespace FFXIVAPP.Client.Converters -{ - internal class NameMultiValueConverter : IMultiValueConverter - { - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - { + internal class NameMultiValueConverter : IMultiValueConverter { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return $"{values[0]} ({values[1]})"; } - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) - { + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Defaults/AutoTranslate.xml b/FFXIVAPP.Client/Defaults/AutoTranslate.xml index db831b00..fc0bd12d 100644 --- a/FFXIVAPP.Client/Defaults/AutoTranslate.xml +++ b/FFXIVAPP.Client/Defaults/AutoTranslate.xml @@ -1,2 +1,3 @@ - + + \ No newline at end of file diff --git a/FFXIVAPP.Client/Defaults/ChatHistory.xml b/FFXIVAPP.Client/Defaults/ChatHistory.xml index 9f066af9..67d9a950 100644 --- a/FFXIVAPP.Client/Defaults/ChatHistory.xml +++ b/FFXIVAPP.Client/Defaults/ChatHistory.xml @@ -1,2 +1,3 @@ - + + \ No newline at end of file diff --git a/FFXIVAPP.Client/Defaults/Colors.xml b/FFXIVAPP.Client/Defaults/Colors.xml index edab4fdb..4a694f3e 100644 --- a/FFXIVAPP.Client/Defaults/Colors.xml +++ b/FFXIVAPP.Client/Defaults/Colors.xml @@ -1,4 +1,5 @@ - + + FFFFFF diff --git a/FFXIVAPP.Client/Defaults/Settings.xml b/FFXIVAPP.Client/Defaults/Settings.xml index 814b6f15..c321ff0e 100644 --- a/FFXIVAPP.Client/Defaults/Settings.xml +++ b/FFXIVAPP.Client/Defaults/Settings.xml @@ -1,2 +1,3 @@ - + + \ No newline at end of file diff --git a/FFXIVAPP.Client/FFXIVAPP.Client.csproj b/FFXIVAPP.Client/FFXIVAPP.Client.csproj index 72a9302c..4d1b982a 100644 --- a/FFXIVAPP.Client/FFXIVAPP.Client.csproj +++ b/FFXIVAPP.Client/FFXIVAPP.Client.csproj @@ -1,10 +1,13 @@  + + + + - Debug @@ -14,7 +17,7 @@ Properties FFXIVAPP.Client FFXIVAPP.Client - v4.6.1 + v4.6.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -46,53 +49,57 @@ app.manifest - - ..\packages\FFXIVAPP.Common.4.0.4\lib\NET461\FFXIVAPP.Common.dll + + ..\packages\Costura.Fody.3.1.0\lib\net46\Costura.dll True - - ..\packages\FFXIVAPP.IPluginInterface.4.0.3\lib\NET461\FFXIVAPP.IPluginInterface.dll - True + + ..\packages\FFXIVAPP.Common.5.0.0\lib\net462\FFXIVAPP.Common.dll - - ..\packages\FFXIVAPP.ResourceFiles.1.0.3\lib\NET461\FFXIVAPP.ResourceFiles.dll + + ..\packages\FFXIVAPP.IPluginInterface.5.0.0\lib\net462\FFXIVAPP.IPluginInterface.dll True + + ..\packages\FFXIVAPP.ResourceFiles.2.0.0\lib\net462\FFXIVAPP.ResourceFiles.dll + + + ..\packages\HtmlAgilityPack.1.8.4\lib\Net45\HtmlAgilityPack.dll + ..\packages\Machina.1.0.3\lib\NET461\Machina.dll True - - ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll - ..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll - - ..\packages\MahApps.Metro.IconPacks.1.9.0\lib\net46\MahApps.Metro.IconPacks.dll + + ..\packages\MahApps.Metro.IconPacks.1.9.1\lib\net46\MahApps.Metro.IconPacks.dll - - ..\packages\NAudio.1.8.0\lib\net35\NAudio.dll + + ..\packages\NAudio.1.8.4\lib\net35\NAudio.dll - - ..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\NLog.4.4.11\lib\net45\NLog.dll + ..\packages\NLog.4.5.6\lib\net45\NLog.dll - - ..\packages\Sharlayan.4.0.1\lib\net461\Sharlayan.dll + + ..\packages\Sharlayan.5.0.0\lib\net462\Sharlayan.dll + + + + + - - ..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll - @@ -267,7 +274,6 @@ Designer - Designer @@ -309,11 +315,35 @@ false - + + + + + + + + + + + + %25SYSTEMROOT%25\System32\WindowsPowerShell\v1.0\powershell.exe –NonInteractive –ExecutionPolicy Unrestricted –command "& { &'$(SolutionDir)RestorePackages.ps1' '$(SolutionDir).nuget/nuget.exe' }" + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + - - - - - - - - - - - - - - - - diff --git a/FFXIVAPP.Client/NLog.xsd b/FFXIVAPP.Client/NLog.xsd index 6b260423..1bd61d8b 100644 --- a/FFXIVAPP.Client/NLog.xsd +++ b/FFXIVAPP.Client/NLog.xsd @@ -70,6 +70,11 @@ Use InvariantCulture as default culture instead of CurrentCulture. Default value is: false. + + + Perform mesage template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. + + @@ -164,6 +169,7 @@ + @@ -325,16 +331,11 @@ - + - - - Name of the target. - - Delay the flush until the LogEvent has been confirmed as written @@ -345,6 +346,11 @@ Condition expression. Log events who meet this condition will cause a flush on the wrapped target. + + + Name of the target. + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -360,6 +366,7 @@ + @@ -378,6 +385,11 @@ Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + Action to take if the buffer overflows. + + Indicates whether to use sliding timeout. @@ -391,6 +403,12 @@ + + + + + + @@ -402,21 +420,25 @@ - + - + - - + + + + + + + - - + @@ -454,9 +476,9 @@ Action that should be taken if the will be more connections than . - + - Action that should be taken if the message is larger than maxMessageSize. + Maximum queue size. @@ -479,19 +501,19 @@ Network address. - + - Maximum queue size. + Action that should be taken if the message is larger than maxMessageSize. - + - Indicates whether to include stack contents. + NDLC item separator. - + - Indicates whether to include source info (file name and line number) in the information sent over the network. + NDC item separator. @@ -499,6 +521,26 @@ Indicates whether to include NLog-specific extensions to log4j schema. + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + Indicates whether to include contents of the stack. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + Indicates whether to include dictionary contents. @@ -509,19 +551,19 @@ Indicates whether to include call site (class and method name) in the information sent over the network. - + - AppInfo field. By default it's the friendly name of the current AppDomain. + Option to include all properties from the log events - + - NDC item separator. + AppInfo field. By default it's the friendly name of the current AppDomain. - + - Indicates whether to include dictionary contents. + Renderer for log4j:event logger-xml-attribute (Default ${logger}) @@ -570,12 +612,12 @@ - - - + + + @@ -598,11 +640,6 @@ Footer. - - - Indicates whether to use default row highlighting rules. - - Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) @@ -618,6 +655,11 @@ Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + Indicates whether to use default row highlighting rules. + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -671,14 +713,19 @@ + - + + + Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. + + Indicates whether to ignore case when comparing texts. @@ -699,11 +746,6 @@ Indicates whether to match whole words only. - - - Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. - - Background color. @@ -723,9 +765,9 @@ - + @@ -748,11 +790,6 @@ Footer. - - - Indicates whether to send the log messages to the standard error instead of the standard output. - - Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) @@ -763,6 +800,11 @@ The encoding for writing messages to the . + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -1007,14 +1049,14 @@ + - - - + + @@ -1032,6 +1074,11 @@ Layout that renders event Category. + + + Optional entrytype. When not set, or when not convertable to then determined by + + Layout that renders event ID. @@ -1047,29 +1094,24 @@ Name of the machine on which Event Log service is running. - - - Value to be used as the event Source. - - - + - Action to take if the message is larger than the option. + Maximum Event log size in kilobytes. If null, the value won't be set. Default is 512 Kilobytes as specified by Eventlog API - + - Optional entrytype. When not set, or when not convertable to then determined by + Message length limit to write to the Event Log. - + - Maximum Event log size in kilobytes. If null, the value won't be set. Default is 512 Kilobytes as specified by Eventlog API + Value to be used as the event Source. - + - Message length limit to write to the Event Log. + Action to take if the message is larger than the option. @@ -1123,38 +1165,39 @@ + + - - - - - - - + + - - + + + + + + - - + + - + @@ -1186,6 +1229,11 @@ Line ending mode. + + + Indicates whether to compress archive files into the zip archive format. + + Way file archives are numbered. @@ -1196,6 +1244,11 @@ Name of the file to be used for an archive. + + + Is the an absolute or relative path? + + Indicates whether to automatically archive log files every time the specified time passes. @@ -1206,89 +1259,84 @@ Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: - - - Indicates whether to compress archive files into the zip archive format. - - Maximum number of archive files that should be kept. - + - Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. + Indicates whether the footer should be written only when the file is archived. - + - Is the an absolute or relative path? + Maximum number of log filenames that should be stored as existing. - + - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. + Name of the file to write to. - + - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write + Value specifying the date format to use when archiving files. - + - Is the an absolute or relative path? + Indicates whether to archive old log file on startup. - + - Value indicationg whether file creation calls should be synchronized by a system global mutex. + Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - + - Indicates whether the footer should be written only when the file is archived. + Indicates whether to create directories if they do not exist. - + - Name of the file to write to. + Indicates whether to delete old log file on startup. - + - Value specifying the date format to use when archiving files. + File attributes (Windows only). - + - Indicates whether to archive old log file on startup. + Indicates whether to write BOM (byte order mark) in created files - + - Indicates whether to create directories if they do not exist. + Indicates whether to enable log file(s) to be deleted. - + - Indicates whether to enable log file(s) to be deleted. + Indicates whether to replace file contents on each write instead of appending log message at the end. - + - File attributes (Windows only). + Value indicationg whether file creation calls should be synchronized by a system global mutex. - + - Indicates whether to delete old log file on startup. + Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - + - Indicates whether to replace file contents on each write instead of appending log message at the end. + Is the an absolute or relative path? @@ -1296,14 +1344,14 @@ Indicates whether concurrent writes to the log file by multiple processes on the same host. - + - Indicates whether to keep log file open instead of opening and closing it on each logging event. + Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - + - Maximum number of log filenames that should be stored as existing. + Delay in milliseconds to wait before attempting to write to the file again. @@ -1336,14 +1384,14 @@ Indicates whether to automatically flush the file buffers after each log message. - + - Delay in milliseconds to wait before attempting to write to the file again. + Number of times the write is appended on the file before NLog discards the log message. - + - Number of times the write is appended on the file before NLog discards the log message. + Indicates whether to keep log file open instead of opening and closing it on each logging event. @@ -1357,6 +1405,13 @@ + + + + + + + @@ -1374,13 +1429,6 @@ - - - - - - - @@ -1516,16 +1564,11 @@ - + - - - Name of the target. - - Interval in which messages will be written up to the number of messages. @@ -1536,6 +1579,11 @@ Maximum allowed number of messages written per . + + + Name of the target. + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -1637,19 +1685,19 @@ - + + - - - + + + + - - - - + + @@ -1680,9 +1728,14 @@ Footer. - + - Indicates whether to send message as HTML instead of plain text. + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. @@ -1690,9 +1743,9 @@ Encoding to be used for sending e-mail. - + - Indicates whether to add new lines between log entries. + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1700,24 +1753,14 @@ CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - - - + - Mail message body (repeated for each log message send in one mail). + Indicates whether to add new lines between log entries. - + - Mail subject. + Indicates whether to send message as HTML instead of plain text. @@ -1725,19 +1768,19 @@ Sender's email address (e.g. joe@domain.com). - + - Indicates the SMTP client timeout. + Mail message body (repeated for each log message send in one mail). - + - Priority used for sending mails. + Mail subject. - + - Indicates whether NewLine characters in the body should be replaced with tags. + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1745,6 +1788,11 @@ Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + + Indicates the SMTP client timeout. + + SMTP Server to be used for sending. @@ -1833,74 +1881,6 @@ - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Encoding to be used when writing text to the queue. - - - - - Indicates whether to use the XML format when serializing message. This will also disable creating queues. - - - - - Indicates whether to check if a queue exists before writing to it. - - - - - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit - - - - - Indicates whether to create the queue if it doesn't exists. - - - - - Label to associate with each message. - - - - - Name of the queue to write to. - - - - - Indicates whether to use recoverable messages (with guaranteed delivery). - - - - - @@ -1944,13 +1924,13 @@ - - + + @@ -1983,16 +1963,6 @@ Indicates whether to append newline at the end of log message. - - - Action that should be taken if the will be more connections than . - - - - - Action that should be taken if the message is larger than maxMessageSize. - - Network address. @@ -2018,6 +1988,16 @@ Maximum queue size. + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -2037,21 +2017,25 @@ - + - + - - + + + + + + + - - + @@ -2089,9 +2073,9 @@ Action that should be taken if the will be more connections than . - + - Action that should be taken if the message is larger than maxMessageSize. + Maximum queue size. @@ -2114,19 +2098,19 @@ Network address. - + - Maximum queue size. + Action that should be taken if the message is larger than maxMessageSize. - + - Indicates whether to include stack contents. + NDLC item separator. - + - Indicates whether to include source info (file name and line number) in the information sent over the network. + NDC item separator. @@ -2134,6 +2118,26 @@ Indicates whether to include NLog-specific extensions to log4j schema. + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + Indicates whether to include contents of the stack. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include dictionary contents. + + Indicates whether to include dictionary contents. @@ -2144,19 +2148,19 @@ Indicates whether to include call site (class and method name) in the information sent over the network. - + - AppInfo field. By default it's the friendly name of the current AppDomain. + Option to include all properties from the log events - + - NDC item separator. + AppInfo field. By default it's the friendly name of the current AppDomain. - + - Indicates whether to include dictionary contents. + Renderer for log4j:event logger-xml-attribute (Default ${logger}) @@ -2486,6 +2490,7 @@ + @@ -2498,6 +2503,11 @@ Layout used to format log messages. + + + Always use independent of + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit @@ -2511,67 +2521,81 @@ - - - - + + + + + + + + Name of the target. + + + Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Web service method name. Only used with Soap. - + - Encoding. + Web service namespace. Only used with Soap. - + - Value whether escaping be done according to the old NLog style (Very non-standard) + Protocol to be used when calling web service. - + - Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) + Custom proxy address, include port separated by a colon - + - Web service method name. Only used with Soap. + Encoding. - + - Web service namespace. Only used with Soap. + Web service URL. - + - Protocol to be used when calling web service. + Value whether escaping be done according to the old NLog style (Very non-standard) - + - Web service URL. + Value whether escaping be done according to Rfc3986 (Supports Internationalized Resource Identifiers - IRIs) + + + + + Indicates whether to pre-authenticate the HttpWebRequest (Requires 'Authorization' in parameters) @@ -2584,6 +2608,11 @@ (optional) root namespace of the XML document, if POST of XML document chosen. (see and ). + + + Proxy configuration when calling web service + + @@ -2597,6 +2626,14 @@ + + + + + + + + @@ -2708,9 +2745,10 @@ + - + @@ -2719,7 +2757,7 @@ - Option to include all properties from the log events + Option to include all properties from the log event (as JSON) @@ -2727,6 +2765,11 @@ Indicates whether to include contents of the dictionary. + + + Indicates whether to include contents of the dictionary. + + Option to render the empty object value {} @@ -2737,9 +2780,9 @@ Option to suppress the extra spaces in the output json - + - Indicates whether to include contents of the dictionary. + How far should the JSON serializer follow object references before backing off @@ -2747,11 +2790,22 @@ - - + + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + Determines wether or not this attribute will be Json encoded. @@ -2762,14 +2816,9 @@ Indicates whether to escape non-ascii characters - - - Layout that will be rendered as the attribute's value. - - - + - Name of the attribute. + Whether an attribute with empty value should be included in the output @@ -2806,6 +2855,8 @@ + + @@ -2822,6 +2873,16 @@ Indicates whether to include contents of the dictionary. + + + Indicates whether to include contents of the stack. + + + + + Indicates whether to include contents of the stack. + + @@ -2996,6 +3057,80 @@ + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Default number of unique filter values to expect, will automatically increase if needed + + + + + Applies the configured action to the initial logevent that starts the timeout period. Used to configure that it should ignore all events until timeout. + + + + + Layout to be used to filter log messages. + + + + + Max number of unique filter values to expect simultaneously + + + + + Max length of filter values, will truncate if above limit + + + + + How long before a filter expires, and logging is accepted again + + + + + Default buffer size for the internal buffers + + + + + Reuse internal buffers, and doesn't have to constantly allocate new buffers + + + + + Append FilterCount to the when an event is no longer filtered + + + + + Insert FilterCount value into when an event is no longer filtered + + + + + diff --git a/FFXIVAPP.Client/PluginHost.cs b/FFXIVAPP.Client/PluginHost.cs index 734abca5..5bf655a4 100644 --- a/FFXIVAPP.Client/PluginHost.cs +++ b/FFXIVAPP.Client/PluginHost.cs @@ -1,460 +1,353 @@ -// FFXIVAPP.Client ~ PluginHost.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Windows; -using System.Xml.Linq; -using FFXIVAPP.Client.Helpers; -using FFXIVAPP.Client.Models; -using FFXIVAPP.Client.Reflection; -using FFXIVAPP.Common.Core.Constant; -using FFXIVAPP.Common.Core.Network; -using FFXIVAPP.Common.Models; -using FFXIVAPP.Common.Utilities; -using FFXIVAPP.IPluginInterface; -using FFXIVAPP.IPluginInterface.Events; -using NLog; -using Sharlayan.Core; - -namespace FFXIVAPP.Client -{ - internal class PluginHost : MarshalByRefObject, IPluginHost - { - #region Logger - +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// PluginHost.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client { + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Reflection; + using System.Windows; + using System.Xml.Linq; + + using FFXIVAPP.Client.Helpers; + using FFXIVAPP.Client.Models; + using FFXIVAPP.Client.Reflection; + using FFXIVAPP.Common.Core.Constant; + using FFXIVAPP.Common.Core.Network; + using FFXIVAPP.Common.Models; + using FFXIVAPP.Common.Utilities; + using FFXIVAPP.IPluginInterface; + using FFXIVAPP.IPluginInterface.Events; + + using NLog; + + using Sharlayan.Core; + + internal class PluginHost : MarshalByRefObject, IPluginHost { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - #endregion - - #region Declarations + private static Lazy _instance = new Lazy(() => new PluginHost()); public AssemblyReflectionManager AssemblyReflectionManager = new AssemblyReflectionManager(); - #endregion + private PluginCollectionHelper _loaded; - /// - /// - /// - public void LoadPlugins(string path) - { - if (String.IsNullOrWhiteSpace(path)) - { - return; + public event EventHandler ActionContainersUpdated = delegate { }; + + public event EventHandler ChatLogItemReceived = delegate { }; + + public event EventHandler ConstantsUpdated = delegate { }; + + public event EventHandler CurrentPlayerUpdated = delegate { }; + + public event EventHandler InventoryContainersUpdated = delegate { }; + + public event EventHandler MonsterItemsAdded = delegate { }; + + public event EventHandler MonsterItemsRemoved = delegate { }; + + public event EventHandler MonsterItemsUpdated = delegate { }; + + public event EventHandler NetworkPacketReceived = delegate { }; + + public event EventHandler NPCItemsAdded = delegate { }; + + public event EventHandler NPCItemsRemoved = delegate { }; + + public event EventHandler NPCItemsUpdated = delegate { }; + + public event EventHandler PartyMembersAdded = delegate { }; + + public event EventHandler PartyMembersRemoved = delegate { }; + + public event EventHandler PartyMembersUpdated = delegate { }; + + public event EventHandler PCItemsAdded = delegate { }; + + public event EventHandler PCItemsRemoved = delegate { }; + + public event EventHandler PCItemsUpdated = delegate { }; + + public event EventHandler TargetInfoUpdated = delegate { }; + + public static PluginHost Instance { + get { + return _instance.Value; } - try - { - if (Directory.Exists(path)) - { - var directories = Directory.GetDirectories(path); - foreach (var directory in directories) - { - LoadPlugin(directory); - } - } + } + + public PluginCollectionHelper Loaded { + get { + return this._loaded ?? (this._loaded = new PluginCollectionHelper()); } - catch (Exception ex) - { - Logging.Log(Logger, new LogItem(ex, true)); + + set { + if (this._loaded == null) { + this._loaded = new PluginCollectionHelper(); + } + + this._loaded = value; } } /// /// /// - public void LoadPlugin(string path) - { - if (String.IsNullOrWhiteSpace(path)) - { + public void LoadPlugin(string path) { + if (string.IsNullOrWhiteSpace(path)) { return; } - try - { - path = Directory.Exists(path) ? path : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); + + try { + path = Directory.Exists(path) + ? path + : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path); var settings = $@"{path}\PluginInfo.xml"; - if (!File.Exists(settings)) - { + if (!File.Exists(settings)) { return; } - var xDoc = XDocument.Load(settings); - foreach (var xElement in xDoc.Descendants() - .Elements("Main")) - { + + XDocument xDoc = XDocument.Load(settings); + foreach (XElement xElement in xDoc.Descendants().Elements("Main")) { var xKey = (string) xElement.Attribute("Key"); var xValue = (string) xElement.Element("Value"); - if (String.IsNullOrWhiteSpace(xKey) || String.IsNullOrWhiteSpace(xValue)) - { + if (string.IsNullOrWhiteSpace(xKey) || string.IsNullOrWhiteSpace(xValue)) { return; } - switch (xKey) - { + + switch (xKey) { case "FileName": - VerifyPlugin($@"{path}\{xValue}"); + this.VerifyPlugin($@"{path}\{xValue}"); break; } } } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } /// /// - public void UnloadPlugins() - { - foreach (var pluginInstance in Loaded.Cast() - .Where(pluginInstance => pluginInstance.Instance != null)) - { - pluginInstance.Instance.Dispose(); - } - Loaded.Clear(); - } - - /// - /// - public void UnloadPlugin(string name) - { - var plugin = Loaded.Find(name); - if (plugin != null) - { - plugin.Instance.Dispose(); - Loaded.Remove(plugin); + /// + public void LoadPlugins(string path) { + if (string.IsNullOrWhiteSpace(path)) { + return; } - } - /// - /// - /// - private void VerifyPlugin(string assemblyPath) - { - try - { - var bytes = File.ReadAllBytes(assemblyPath); - var pAssembly = Assembly.Load(bytes); - var pType = pAssembly.GetType(pAssembly.GetName() - .Name + ".Plugin"); - var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType); - if (!implementsIPlugin) - { - Logging.Log(Logger, $"*IPlugin Not Implemented* :: {pAssembly.GetName() .Name}"); - return; + try { + if (Directory.Exists(path)) { + string[] directories = Directory.GetDirectories(path); + foreach (var directory in directories) { + this.LoadPlugin(directory); + } } - var plugin = new PluginInstance - { - Instance = (IPlugin) Activator.CreateInstance(pType), - AssemblyPath = assemblyPath - }; - plugin.Instance.Initialize(Instance); - plugin.Loaded = true; - Loaded.Add(plugin); } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } - #region Property Bindings - - private PluginCollectionHelper _loaded; - - public PluginCollectionHelper Loaded - { - get { return _loaded ?? (_loaded = new PluginCollectionHelper()); } - set - { - if (_loaded == null) - { - _loaded = new PluginCollectionHelper(); - } - _loaded = value; - } - } - - private static Lazy _instance = new Lazy(() => new PluginHost()); - - public static PluginHost Instance - { - get { return _instance.Value; } - } - - #endregion - - #region Implementaion of IPluginHost - /// /// /// /// - public void PopupMessage(string pluginName, PopupContent popupContent) - { - if (popupContent == null) - { + public void PopupMessage(string pluginName, PopupContent popupContent) { + if (popupContent == null) { return; } - var pluginInstance = App.Plugins.Loaded.Find(popupContent.PluginName); - if (pluginInstance == null) - { + + PluginInstance pluginInstance = App.Plugins.Loaded.Find(popupContent.PluginName); + if (pluginInstance == null) { return; } + var title = $"[{pluginName}] {popupContent.Title}"; var message = popupContent.Message; Action cancelAction = null; - if (popupContent.CanCancel) - { - cancelAction = delegate { pluginInstance.Instance.PopupResult = MessageBoxResult.Cancel; }; + if (popupContent.CanCancel) { + cancelAction = delegate { + pluginInstance.Instance.PopupResult = MessageBoxResult.Cancel; + }; } - MessageBoxHelper.ShowMessageAsync(title, message, delegate { pluginInstance.Instance.PopupResult = MessageBoxResult.OK; }, cancelAction); - } - - public event EventHandler NewConstantsEntity = delegate { }; - - public event EventHandler NewChatLogEntry = delegate { }; - - public event EventHandler NewMonsterEntriesAdded = delegate { }; - - public event EventHandler NewMonsterEntries = delegate { }; - - public event EventHandler NewNPCEntriesRemoved = delegate { }; - - public event EventHandler NewNPCEntriesAdded = delegate { }; - - public event EventHandler NewNPCEntries = delegate { }; - - public event EventHandler NewMonsterEntriesRemoved = delegate { }; - public event EventHandler NewPCEntriesAdded = delegate { }; - - public event EventHandler NewPCEntries = delegate { }; - - public event EventHandler NewPCEntriesRemoved = delegate { }; - - public event EventHandler NewPlayerEntity = delegate { }; - - public event EventHandler NewTargetEntity = delegate { }; - - public event EventHandler NewPartyEntriesAdded = delegate { }; - - public event EventHandler NewPartyEntries = delegate { }; - - public event EventHandler NewPartyEntriesRemoved = delegate { }; + MessageBoxHelper.ShowMessageAsync( + title, + message, + delegate { + pluginInstance.Instance.PopupResult = MessageBoxResult.OK; + }, + cancelAction); + } - public event EventHandler NewInventoryEntries = delegate { }; + public virtual void RaiseActionContainersUpdated(List actionContainers) { + var raised = new ActionContainersEvent(this, actionContainers); + EventHandler handler = this.ActionContainersUpdated; + handler?.Invoke(this, raised); + } - public event EventHandler NewNetworkPacket = delegate { }; + public virtual void RaiseChatLogItemReceived(ChatLogItem chatLogItem) { + var raised = new ChatLogItemEvent(this, chatLogItem); + EventHandler handler = this.ChatLogItemReceived; + handler?.Invoke(this, raised); + } - public event EventHandler NewActionEntity = delegate { }; + public virtual void RaiseConstantsUpdated(ConstantsEntity constantsEntity) { + var raised = new ConstantsEntityEvent(this, constantsEntity); + EventHandler handler = this.ConstantsUpdated; + handler?.Invoke(this, raised); + } - public virtual void RaiseNewConstantsEntity(ConstantsEntity e) - { - var constantsEntityEvent = new ConstantsEntityEvent(this, e); - var handler = NewConstantsEntity; - if (handler != null) - { - handler(this, constantsEntityEvent); - } + public virtual void RaiseCurrentPlayerUpdated(CurrentPlayer currentPlayer) { + var raised = new CurrentPlayerEvent(this, currentPlayer); + EventHandler handler = this.CurrentPlayerUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewChatLogEntry(ChatLogEntry e) - { - var chatLogEntryEvent = new ChatLogEntryEvent(this, e); - var handler = NewChatLogEntry; - if (handler != null) - { - handler(this, chatLogEntryEvent); - } + public virtual void RaiseInventoryContainersUpdated(List inventoryContainers) { + var raised = new InventoryContainersEvent(this, inventoryContainers); + EventHandler handler = this.InventoryContainersUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewMonsterAddedEntries(List e) - { - var actorEntitiesAddedEvent = new ActorEntitiesAddedEvent(this, e); - var handler = NewMonsterEntriesAdded; - if (handler != null) - { - handler(this, actorEntitiesAddedEvent); - } + public virtual void RaiseMonsterItemsAdded(ConcurrentDictionary actorItems) { + var raised = new ActorItemsAddedEvent(this, actorItems); + EventHandler handler = this.MonsterItemsAdded; + handler?.Invoke(this, raised); } - public virtual void RaiseNewMonsterEntries(ConcurrentDictionary e) - { - var actorEntitiesEvent = new ActorEntitiesEvent(this, e); - var handler = NewMonsterEntries; - if (handler != null) - { - handler(this, actorEntitiesEvent); - } + public virtual void RaiseMonsterItemsRemoved(ConcurrentDictionary actorItems) { + var raised = new ActorItemsRemovedEvent(this, actorItems); + EventHandler handler = this.MonsterItemsRemoved; + handler?.Invoke(this, raised); } - public virtual void RaiseNewMonsterRemovedEntries(List e) - { - var actorEntitiesRemovedEvent = new ActorEntitiesRemovedEvent(this, e); - var handler = NewMonsterEntriesRemoved; - if (handler != null) - { - handler(this, actorEntitiesRemovedEvent); - } + public virtual void RaiseMonsterItemsUpdated(ConcurrentDictionary actorItems) { + var raised = new ActorItemsEvent(this, actorItems); + EventHandler handler = this.MonsterItemsUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewNPCAddedEntries(List e) - { - var actorEntitiesAddedEvent = new ActorEntitiesAddedEvent(this, e); - var handler = NewNPCEntriesAdded; - if (handler != null) - { - handler(this, actorEntitiesAddedEvent); - } + public virtual void RaiseNetworkPacketReceived(NetworkPacket networkPacket) { + var raised = new NetworkPacketEvent(this, networkPacket); + EventHandler handler = this.NetworkPacketReceived; + handler?.Invoke(this, raised); } - public virtual void RaiseNewNPCEntries(ConcurrentDictionary e) - { - var actorEntitiesEvent = new ActorEntitiesEvent(this, e); - var handler = NewNPCEntries; - if (handler != null) - { - handler(this, actorEntitiesEvent); - } + public virtual void RaiseNPCItemsAdded(ConcurrentDictionary actorItems) { + var raised = new ActorItemsAddedEvent(this, actorItems); + EventHandler handler = this.NPCItemsAdded; + handler?.Invoke(this, raised); } - public virtual void RaiseNewNPCRemovedEntries(List e) - { - var actorEntitiesRemovedEvent = new ActorEntitiesRemovedEvent(this, e); - var handler = NewNPCEntriesRemoved; - if (handler != null) - { - handler(this, actorEntitiesRemovedEvent); - } + public virtual void RaiseNPCItemsRemoved(ConcurrentDictionary actorItems) { + var raised = new ActorItemsRemovedEvent(this, actorItems); + EventHandler handler = this.NPCItemsRemoved; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPCAddedEntries(List e) - { - var actorEntitiesAddedEvent = new ActorEntitiesAddedEvent(this, e); - var handler = NewPCEntriesAdded; - if (handler != null) - { - handler(this, actorEntitiesAddedEvent); - } + public virtual void RaiseNPCItemsUpdated(ConcurrentDictionary actorItems) { + var raised = new ActorItemsEvent(this, actorItems); + EventHandler handler = this.NPCItemsUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPCEntries(ConcurrentDictionary e) - { - var actorEntitiesEvent = new ActorEntitiesEvent(this, e); - var handler = NewPCEntries; - if (handler != null) - { - handler(this, actorEntitiesEvent); - } + public virtual void RaisePartyMembersAdded(ConcurrentDictionary partyMembers) { + var raised = new PartyMembersAddedEvent(this, partyMembers); + EventHandler handler = this.PartyMembersAdded; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPCRemovedEntries(List e) - { - var actorEntitiesRemovedEvent = new ActorEntitiesRemovedEvent(this, e); - var handler = NewPCEntriesRemoved; - if (handler != null) - { - handler(this, actorEntitiesRemovedEvent); - } + public virtual void RaisePartyMembersRemoved(ConcurrentDictionary partyMembers) { + var raised = new PartyMembersRemovedEvent(this, partyMembers); + EventHandler handler = this.PartyMembersRemoved; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPlayerEntity(PlayerEntity e) - { - var playerEntityEvent = new PlayerEntityEvent(this, e); - var handler = NewPlayerEntity; - if (handler != null) - { - handler(this, playerEntityEvent); - } + public virtual void RaisePartyMembersUpdated(ConcurrentDictionary partyMembers) { + var raised = new PartyMembersEvent(this, partyMembers); + EventHandler handler = this.PartyMembersUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewTargetEntity(TargetEntity e) - { - var targetEntityEvent = new TargetEntityEvent(this, e); - var handler = NewTargetEntity; - if (handler != null) - { - handler(this, targetEntityEvent); - } + public virtual void RaisePCItemsAdded(ConcurrentDictionary actorItems) { + var raised = new ActorItemsAddedEvent(this, actorItems); + EventHandler handler = this.PCItemsAdded; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPartyAddedEntries(List e) - { - var partyEntitiesAddedEvent = new PartyEntitiesAddedEvent(this, e); - var handler = NewPartyEntriesAdded; - if (handler != null) - { - handler(this, partyEntitiesAddedEvent); - } + public virtual void RaisePCItemsRemoved(ConcurrentDictionary actorItems) { + var raised = new ActorItemsRemovedEvent(this, actorItems); + EventHandler handler = this.PCItemsRemoved; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPartyEntries(ConcurrentDictionary e) - { - var partyEntitiesEvent = new PartyEntitiesEvent(this, e); - var handler = NewPartyEntries; - if (handler != null) - { - handler(this, partyEntitiesEvent); - } + public virtual void RaisePCItemsUpdated(ConcurrentDictionary actorItems) { + var raised = new ActorItemsEvent(this, actorItems); + EventHandler handler = this.PCItemsUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewPartyRemovedEntries(List e) - { - var partyEntitiesRemovedEvent = new PartyEntitiesRemovedEvent(this, e); - var handler = NewPartyEntriesRemoved; - if (handler != null) - { - handler(this, partyEntitiesRemovedEvent); - } + public virtual void RaiseTargetInfoUpdated(TargetInfo targetInfo) { + var raised = new TargetInfoEvent(this, targetInfo); + EventHandler handler = this.TargetInfoUpdated; + handler?.Invoke(this, raised); } - public virtual void RaiseNewInventoryEntries(List e) - { - var inventoryEntitiesEvent = new InventoryEntitiesEvent(this, e); - var handler = NewInventoryEntries; - if (handler != null) - { - handler(this, inventoryEntitiesEvent); + /// + /// + public void UnloadPlugin(string name) { + PluginInstance plugin = this.Loaded.Find(name); + if (plugin != null) { + plugin.Instance.Dispose(); + this.Loaded.Remove(plugin); } } - public virtual void RaiseNewNetworkPacket(NetworkPacket e) - { - var networkPacketEvent = new NetworkPacketEvent(this, e); - var handler = NewNetworkPacket; - if (handler != null) - { - handler(this, networkPacketEvent); + /// + /// + public void UnloadPlugins() { + foreach (PluginInstance pluginInstance in this.Loaded.Cast().Where(pluginInstance => pluginInstance.Instance != null)) { + pluginInstance.Instance.Dispose(); } + + this.Loaded.Clear(); } - public virtual void RaiseNewActionEntities(List e) - { - var actionEntityEvent = new ActionEntityEvent(this, e); - var handler = NewActionEntity; - if (handler != null) - { - handler(this, actionEntityEvent); + /// + /// + /// + private void VerifyPlugin(string assemblyPath) { + try { + byte[] bytes = File.ReadAllBytes(assemblyPath); + Assembly pAssembly = Assembly.Load(bytes); + Type pType = pAssembly.GetType(pAssembly.GetName().Name + ".Plugin"); + var implementsIPlugin = typeof(IPlugin).IsAssignableFrom(pType); + if (!implementsIPlugin) { + Logging.Log(Logger, $"*IPlugin Not Implemented* :: {pAssembly.GetName().Name}"); + return; + } + + var plugin = new PluginInstance { + Instance = (IPlugin) Activator.CreateInstance(pType), + AssemblyPath = assemblyPath + }; + plugin.Instance.Initialize(Instance); + plugin.Loaded = true; + this.Loaded.Add(plugin); + } + catch (Exception ex) { + Logging.Log(Logger, new LogItem(ex, true)); } } - - #endregion } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/PluginInitializer.cs b/FFXIVAPP.Client/PluginInitializer.cs index 3af48494..7137c7e3 100644 --- a/FFXIVAPP.Client/PluginInitializer.cs +++ b/FFXIVAPP.Client/PluginInitializer.cs @@ -1,23 +1,13 @@ -// FFXIVAPP.Client ~ PluginInitializer.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// PluginInitializer.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- -namespace FFXIVAPP.Client -{ - internal static class PluginInitializer - { - } -} +namespace FFXIVAPP.Client { + internal static class PluginInitializer { } +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Properties/AssemblyInfo.cs b/FFXIVAPP.Client/Properties/AssemblyInfo.cs index 4708c0fb..66c69260 100644 --- a/FFXIVAPP.Client/Properties/AssemblyInfo.cs +++ b/FFXIVAPP.Client/Properties/AssemblyInfo.cs @@ -1,19 +1,12 @@ -// FFXIVAPP.Client ~ AssemblyInfo.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AssemblyInfo.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- using System.Reflection; using System.Runtime.InteropServices; @@ -22,7 +15,6 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. - [assembly: AssemblyTitle("FFXIVAPP.Client")] [assembly: AssemblyDescription("FFXIVAPP Client Host")] [assembly: AssemblyConfiguration("")] @@ -35,7 +27,6 @@ // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. - [assembly: ComVisible(false)] //In order to begin building localizable applications, set @@ -46,24 +37,21 @@ //the line below to match the UICulture setting in the project file. //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - -[assembly: ThemeInfo(ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located + // (used if a resource is not found in the page, // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, + ResourceDictionaryLocation.SourceAssembly // where the generic resource dictionary is located + // (used if a resource is not found in the page, // app, or any theme specific resource dictionaries) )] // Version information for an assembly consists of the following four values: -// // Major Version // Minor Version // Build Number // Revision -// // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("2.0.*")] - -[assembly: AssemblyVersion("3.0.*")] +[assembly: AssemblyVersion("3.0.*")] \ No newline at end of file diff --git a/FFXIVAPP.Client/Properties/Settings.Designer.cs b/FFXIVAPP.Client/Properties/Settings.Designer.cs index bd7a5902..bf352643 100644 --- a/FFXIVAPP.Client/Properties/Settings.Designer.cs +++ b/FFXIVAPP.Client/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace FFXIVAPP.Client.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/FFXIVAPP.Client/Properties/Settings.settings b/FFXIVAPP.Client/Properties/Settings.settings index 05a1662e..62e45373 100644 --- a/FFXIVAPP.Client/Properties/Settings.settings +++ b/FFXIVAPP.Client/Properties/Settings.settings @@ -1,5 +1,7 @@  - + + @@ -24,135 +26,141 @@ False - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>Red|Light</string> - <string>Green|Light</string> - <string>Blue|Light</string> - <string>Purple|Light</string> - <string>Orange|Light</string> - <string>Brown|Light</string> - <string>Cobalt|Light</string> - <string>Crimson|Light</string> - <string>Cyan|Light</string> - <string>Emerald|Light</string> - <string>Indigo|Light</string> - <string>Magenta|Light</string> - <string>Mauve|Light</string> - <string>Olive|Light</string> - <string>Sienna|Light</string> - <string>Steel|Light</string> - <string>Teal|Light</string> - <string>Violet|Light</string> - <string>Amber|Light</string> - <string>Yellow|Light</string> - <string>Lime|Light</string> - <string>Pink|Light</string> - <string>Red|Dark</string> - <string>Green|Dark</string> - <string>Blue|Dark</string> - <string>Purple|Dark</string> - <string>Orange|Dark</string> - <string>Brown|Dark</string> - <string>Cobalt|Dark</string> - <string>Crimson|Dark</string> - <string>Cyan|Dark</string> - <string>Emerald|Dark</string> - <string>Indigo|Dark</string> - <string>Magenta|Dark</string> - <string>Mauve|Dark</string> - <string>Olive|Dark</string> - <string>Sienna|Dark</string> - <string>Steel|Dark</string> - <string>Teal|Dark</string> - <string>Violet|Dark</string> - <string>Amber|Dark</string> - <string>Yellow|Dark</string> - <string>Lime|Dark</string> - <string>Pink|Dark</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>Red|Light</string> + <string>Green|Light</string> + <string>Blue|Light</string> + <string>Purple|Light</string> + <string>Orange|Light</string> + <string>Brown|Light</string> + <string>Cobalt|Light</string> + <string>Crimson|Light</string> + <string>Cyan|Light</string> + <string>Emerald|Light</string> + <string>Indigo|Light</string> + <string>Magenta|Light</string> + <string>Mauve|Light</string> + <string>Olive|Light</string> + <string>Sienna|Light</string> + <string>Steel|Light</string> + <string>Teal|Light</string> + <string>Violet|Light</string> + <string>Amber|Light</string> + <string>Yellow|Light</string> + <string>Lime|Light</string> + <string>Pink|Light</string> + <string>Red|Dark</string> + <string>Green|Dark</string> + <string>Blue|Dark</string> + <string>Purple|Dark</string> + <string>Orange|Dark</string> + <string>Brown|Dark</string> + <string>Cobalt|Dark</string> + <string>Crimson|Dark</string> + <string>Cyan|Dark</string> + <string>Emerald|Dark</string> + <string>Indigo|Dark</string> + <string>Magenta|Dark</string> + <string>Mauve|Dark</string> + <string>Olive|Dark</string> + <string>Sienna|Dark</string> + <string>Steel|Dark</string> + <string>Teal|Dark</string> + <string>Violet|Dark</string> + <string>Amber|Dark</string> + <string>Yellow|Dark</string> + <string>Lime|Dark</string> + <string>Pink|Dark</string> + </ArrayOfString> + Blue|Light - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>Adamantoise</string> - <string>Aegis</string> - <string>Alexander</string> - <string>Anima</string> - <string>Asura</string> - <string>Atomos</string> - <string>Bahamut</string> - <string>Balmung</string> - <string>Behemoth</string> - <string>Belias</string> - <string>Brynhildr</string> - <string>Cactuar</string> - <string>Carbuncle</string> - <string>Cerberus</string> - <string>Chocobo</string> - <string>Coeurl</string> - <string>Diabolos</string> - <string>Durandal</string> - <string>Excalibur</string> - <string>Exodus</string> - <string>Faerie</string> - <string>Famfrit</string> - <string>Fenrir</string> - <string>Garuda</string> - <string>Gilgamesh</string> - <string>Goblin</string> - <string>Gungnir</string> - <string>Hades</string> - <string>Hyperion</string> - <string>Ifrit</string> - <string>Ixion</string> - <string>Jenova</string> - <string>Kujata</string> - <string>Lamia</string> - <string>Leviathan</string> - <string>Lich</string> - <string>Malboro</string> - <string>Mandragora</string> - <string>Masamune</string> - <string>Mateus</string> - <string>Midgardsormr</string> - <string>Moogle</string> - <string>Odin</string> - <string>Pandaemonium</string> - <string>Phoenix</string> - <string>Ragnarok</string> - <string>Ramuh</string> - <string>Ridill</string> - <string>Sargatanas</string> - <string>Shinryu</string> - <string>Shiva</string> - <string>Siren</string> - <string>Tiamat</string> - <string>Titan</string> - <string>Tonberry</string> - <string>Typhon</string> - <string>Ultima</string> - <string>Ultros</string> - <string>Unicorn</string> - <string>Valefor</string> - <string>Yojimbo</string> - <string>Zalera</string> - <string>Zeromus</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>Adamantoise</string> + <string>Aegis</string> + <string>Alexander</string> + <string>Anima</string> + <string>Asura</string> + <string>Atomos</string> + <string>Bahamut</string> + <string>Balmung</string> + <string>Behemoth</string> + <string>Belias</string> + <string>Brynhildr</string> + <string>Cactuar</string> + <string>Carbuncle</string> + <string>Cerberus</string> + <string>Chocobo</string> + <string>Coeurl</string> + <string>Diabolos</string> + <string>Durandal</string> + <string>Excalibur</string> + <string>Exodus</string> + <string>Faerie</string> + <string>Famfrit</string> + <string>Fenrir</string> + <string>Garuda</string> + <string>Gilgamesh</string> + <string>Goblin</string> + <string>Gungnir</string> + <string>Hades</string> + <string>Hyperion</string> + <string>Ifrit</string> + <string>Ixion</string> + <string>Jenova</string> + <string>Kujata</string> + <string>Lamia</string> + <string>Leviathan</string> + <string>Lich</string> + <string>Malboro</string> + <string>Mandragora</string> + <string>Masamune</string> + <string>Mateus</string> + <string>Midgardsormr</string> + <string>Moogle</string> + <string>Odin</string> + <string>Pandaemonium</string> + <string>Phoenix</string> + <string>Ragnarok</string> + <string>Ramuh</string> + <string>Ridill</string> + <string>Sargatanas</string> + <string>Shinryu</string> + <string>Shiva</string> + <string>Siren</string> + <string>Tiamat</string> + <string>Titan</string> + <string>Tonberry</string> + <string>Typhon</string> + <string>Ultima</string> + <string>Ultros</string> + <string>Unicorn</string> + <string>Valefor</string> + <string>Yojimbo</string> + <string>Zalera</string> + <string>Zeromus</string> + </ArrayOfString> + - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>English</string> - <string>Japanese</string> - <string>French</string> - <string>German</string> - <string>Chinese</string> - <string>Korean</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>English</string> + <string>Japanese</string> + <string>French</string> + <string>German</string> + <string>Chinese</string> + <string>Korean</string> + </ArrayOfString> + English @@ -203,35 +211,41 @@ Parse - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>None</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>None</string> + </ArrayOfString> + 1.0 - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>0.8</string> - <string>0.9</string> - <string>1.0</string> - <string>1.1</string> - <string>1.2</string> - <string>1.3</string> - <string>1.4</string> - <string>1.5</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>0.8</string> + <string>0.9</string> + <string>1.0</string> + <string>1.1</string> + <string>1.2</string> + <string>1.3</string> + <string>1.4</string> + <string>1.5</string> + </ArrayOfString> + System Default - <?xml version="1.0" encoding="utf-16"?> -<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <string>System Default</string> -</ArrayOfString> + + <?xml version="1.0" encoding="utf-16"?> + <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <string>System Default</string> + </ArrayOfString> + 100 diff --git a/FFXIVAPP.Client/Reflection/AssemblyReflectionManager.cs b/FFXIVAPP.Client/Reflection/AssemblyReflectionManager.cs index e26896aa..8867bf60 100644 --- a/FFXIVAPP.Client/Reflection/AssemblyReflectionManager.cs +++ b/FFXIVAPP.Client/Reflection/AssemblyReflectionManager.cs @@ -1,199 +1,179 @@ -// FFXIVAPP.Client ~ AssemblyReflectionManager.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Security.Policy; -using FFXIVAPP.Common.Models; -using FFXIVAPP.Common.Utilities; -using NLog; - -namespace FFXIVAPP.Client.Reflection -{ - internal class AssemblyReflectionManager : IDisposable - { - #region Logger +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AssemblyReflectionManager.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); +namespace FFXIVAPP.Client.Reflection { + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Reflection; + using System.Security.Policy; + + using FFXIVAPP.Common.Models; + using FFXIVAPP.Common.Utilities; - #endregion + using NLog; + + internal class AssemblyReflectionManager : IDisposable { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private Dictionary _loadedAssemblies = new Dictionary(); + private Dictionary _mapDomains = new Dictionary(); + private Dictionary _proxies = new Dictionary(); - public void Dispose() - { - Dispose(true); + ~AssemblyReflectionManager() { + this.Dispose(false); + } + + public void Dispose() { + this.Dispose(true); GC.SuppressFinalize(this); } - public bool LoadAssembly(string assemblyPath, string domainName) - { + public bool LoadAssembly(string assemblyPath, string domainName) { // if the assembly file does not exist then fail - if (!File.Exists(assemblyPath)) - { + if (!File.Exists(assemblyPath)) { return false; } + // if the assembly was already loaded then fail - if (_loadedAssemblies.ContainsKey(assemblyPath)) - { + if (this._loadedAssemblies.ContainsKey(assemblyPath)) { return false; } + // check if the appdomain exists, and if not create a new one AppDomain appDomain = null; - if (_mapDomains.ContainsKey(domainName)) - { - appDomain = _mapDomains[domainName]; + if (this._mapDomains.ContainsKey(domainName)) { + appDomain = this._mapDomains[domainName]; } - else - { - appDomain = CreateChildDomain(AppDomain.CurrentDomain, domainName); - _mapDomains[domainName] = appDomain; + else { + appDomain = this.CreateChildDomain(AppDomain.CurrentDomain, domainName); + this._mapDomains[domainName] = appDomain; } + // load the assembly in the specified app domain - try - { - var proxyType = typeof(AssemblyReflectionProxy); - if (proxyType.Assembly != null) - { - var proxy = (AssemblyReflectionProxy) appDomain.CreateInstanceFrom(proxyType.Assembly.Location, proxyType.FullName) - .Unwrap(); + try { + Type proxyType = typeof(AssemblyReflectionProxy); + if (proxyType.Assembly != null) { + var proxy = (AssemblyReflectionProxy) appDomain.CreateInstanceFrom(proxyType.Assembly.Location, proxyType.FullName).Unwrap(); proxy.LoadAssembly(assemblyPath); - _loadedAssemblies[assemblyPath] = appDomain; - _proxies[assemblyPath] = proxy; + this._loadedAssemblies[assemblyPath] = appDomain; + this._proxies[assemblyPath] = proxy; return true; } } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } + return false; } - public bool UnloadAssembly(string assemblyPath) - { - if (!File.Exists(assemblyPath)) - { + public TResult Reflect(string assemblyPath, Func func) { + // check if the assembly is found in the internal dictionaries + if (this._loadedAssemblies.ContainsKey(assemblyPath) && this._proxies.ContainsKey(assemblyPath)) { + return this._proxies[assemblyPath].Reflect(func); + } + + return default(TResult); + } + + public bool UnloadAssembly(string assemblyPath) { + if (!File.Exists(assemblyPath)) { return false; } + // check if the assembly is found in the internal dictionaries - if (_loadedAssemblies.ContainsKey(assemblyPath) && _proxies.ContainsKey(assemblyPath)) - { + if (this._loadedAssemblies.ContainsKey(assemblyPath) && this._proxies.ContainsKey(assemblyPath)) { // check if there are more assemblies loaded in the same app domain; in this case fail - var appDomain = _loadedAssemblies[assemblyPath]; - var count = _loadedAssemblies.Values.Count(a => a == appDomain); - if (count != 1) - { + AppDomain appDomain = this._loadedAssemblies[assemblyPath]; + var count = this._loadedAssemblies.Values.Count(a => a == appDomain); + if (count != 1) { return false; } - try - { + + try { // remove the appdomain from the dictionary and unload it from the process - _mapDomains.Remove(appDomain.FriendlyName); + this._mapDomains.Remove(appDomain.FriendlyName); AppDomain.Unload(appDomain); + // remove the assembly from the dictionaries - _loadedAssemblies.Remove(assemblyPath); - _proxies.Remove(assemblyPath); + this._loadedAssemblies.Remove(assemblyPath); + this._proxies.Remove(assemblyPath); return true; } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } + return false; } - public bool UnloadDomain(string domainName) - { + public bool UnloadDomain(string domainName) { // check the appdomain name is valid - if (String.IsNullOrEmpty(domainName)) - { + if (string.IsNullOrEmpty(domainName)) { return false; } + // check we have an instance of the domain - if (_mapDomains.ContainsKey(domainName)) - { - try - { - var appDomain = _mapDomains[domainName]; + if (this._mapDomains.ContainsKey(domainName)) { + try { + AppDomain appDomain = this._mapDomains[domainName]; + // check the assemblies that are loaded in this app domain - var assemblies = (from kvp in _loadedAssemblies where kvp.Value == appDomain select kvp.Key).ToList(); + List assemblies = (from kvp in this._loadedAssemblies + where kvp.Value == appDomain + select kvp.Key).ToList(); + // remove these assemblies from the internal dictionaries - foreach (var assemblyName in assemblies) - { - _loadedAssemblies.Remove(assemblyName); - _proxies.Remove(assemblyName); + foreach (var assemblyName in assemblies) { + this._loadedAssemblies.Remove(assemblyName); + this._proxies.Remove(assemblyName); } + // remove the appdomain from the dictionary - _mapDomains.Remove(domainName); + this._mapDomains.Remove(domainName); + // unload the appdomain AppDomain.Unload(appDomain); return true; } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } - return false; - } - - public TResult Reflect(string assemblyPath, Func func) - { - // check if the assembly is found in the internal dictionaries - if (_loadedAssemblies.ContainsKey(assemblyPath) && _proxies.ContainsKey(assemblyPath)) - { - return _proxies[assemblyPath] - .Reflect(func); - } - return default(TResult); - } - ~AssemblyReflectionManager() - { - Dispose(false); + return false; } - protected virtual void Dispose(bool disposing) - { - if (!disposing) - { + protected virtual void Dispose(bool disposing) { + if (!disposing) { return; } - foreach (var appDomain in _mapDomains.Values) - { + + foreach (AppDomain appDomain in this._mapDomains.Values) { AppDomain.Unload(appDomain); } - _loadedAssemblies.Clear(); - _proxies.Clear(); - _mapDomains.Clear(); + + this._loadedAssemblies.Clear(); + this._proxies.Clear(); + this._mapDomains.Clear(); } - private AppDomain CreateChildDomain(AppDomain parentDomain, string domainName) - { + private AppDomain CreateChildDomain(AppDomain parentDomain, string domainName) { var evidence = new Evidence(parentDomain.Evidence); - var setup = parentDomain.SetupInformation; + AppDomainSetup setup = parentDomain.SetupInformation; return AppDomain.CreateDomain(domainName, evidence, setup); } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Reflection/AssemblyReflectionProxy.cs b/FFXIVAPP.Client/Reflection/AssemblyReflectionProxy.cs index cbea4a17..5d0f50f4 100644 --- a/FFXIVAPP.Client/Reflection/AssemblyReflectionProxy.cs +++ b/FFXIVAPP.Client/Reflection/AssemblyReflectionProxy.cs @@ -1,77 +1,63 @@ -// FFXIVAPP.Client ~ AssemblyReflectionProxy.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.IO; -using System.Linq; -using System.Reflection; - -namespace FFXIVAPP.Client.Reflection -{ - internal class AssemblyReflectionProxy : MarshalByRefObject - { +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// AssemblyReflectionProxy.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client.Reflection { + using System; + using System.IO; + using System.Linq; + using System.Reflection; + + internal class AssemblyReflectionProxy : MarshalByRefObject { private string _assemblyPath; - public void LoadAssembly(String assemblyPath) - { - try - { - _assemblyPath = assemblyPath; + public void LoadAssembly(string assemblyPath) { + try { + this._assemblyPath = assemblyPath; Assembly.ReflectionOnlyLoadFrom(assemblyPath); } - catch (FileNotFoundException) - { + catch (FileNotFoundException) { // Continue loading assemblies even if an assembly can not be loaded in the new AppDomain. } } - public TResult Reflect(Func func) - { - var directory = new FileInfo(_assemblyPath).Directory; - ResolveEventHandler resolveEventHandler = (s, e) => { return OnReflectionOnlyResolve(e, directory); }; + public TResult Reflect(Func func) { + DirectoryInfo directory = new FileInfo(this._assemblyPath).Directory; + ResolveEventHandler resolveEventHandler = (s, e) => { + return this.OnReflectionOnlyResolve(e, directory); + }; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler; - var assembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies() - .FirstOrDefault(a => a.Location.CompareTo(_assemblyPath) == 0); + Assembly assembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().FirstOrDefault(a => a.Location.CompareTo(this._assemblyPath) == 0); - var result = func(assembly); + TResult result = func(assembly); AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler; return result; } - private Assembly OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory) - { - var loadedAssembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies() - .FirstOrDefault(asm => string.Equals(asm.FullName, args.Name, Constants.InvariantComparer)); - if (loadedAssembly != null) - { + private Assembly OnReflectionOnlyResolve(ResolveEventArgs args, DirectoryInfo directory) { + Assembly loadedAssembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().FirstOrDefault(asm => string.Equals(asm.FullName, args.Name, Constants.InvariantComparer)); + if (loadedAssembly != null) { return loadedAssembly; } + var assemblyName = new AssemblyName(args.Name); var dependentAssemblyFilename = Path.Combine(directory.FullName, assemblyName.Name + ".dll"); - if (File.Exists(dependentAssemblyFilename)) - { + if (File.Exists(dependentAssemblyFilename)) { return Assembly.ReflectionOnlyLoadFrom(dependentAssemblyFilename); } + return Assembly.ReflectionOnlyLoad(args.Name); } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/Resources/ChatCodes.xml b/FFXIVAPP.Client/Resources/ChatCodes.xml index f56d69e2..4727e6f0 100644 --- a/FFXIVAPP.Client/Resources/ChatCodes.xml +++ b/FFXIVAPP.Client/Resources/ChatCodes.xml @@ -1,4 +1,5 @@  + diff --git a/FFXIVAPP.Client/SettingsProviders/Application/Settings.cs b/FFXIVAPP.Client/SettingsProviders/Application/Settings.cs index fe79ed47..22bfb160 100644 --- a/FFXIVAPP.Client/SettingsProviders/Application/Settings.cs +++ b/FFXIVAPP.Client/SettingsProviders/Application/Settings.cs @@ -1,239 +1,187 @@ -// FFXIVAPP.Client ~ Settings.cs -// -// Copyright © 2007 - 2017 Ryan Wilson - All Rights Reserved -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Configuration; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Windows.Media; -using System.Xml.Linq; -using FFXIVAPP.Client.ViewModels; -using FFXIVAPP.Common.Helpers; -using FFXIVAPP.Common.Models; -using FFXIVAPP.Common.Utilities; -using NLog; -using ColorConverter = System.Windows.Media.ColorConverter; -using FontFamily = System.Drawing.FontFamily; - -namespace FFXIVAPP.Client.SettingsProviders.Application -{ - internal class Settings : ApplicationSettingsBase, INotifyPropertyChanged - { - #region Logger - +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright(c) 2018 Ryan Wilson &lt;syndicated.life@gmail.com&gt; (http://syndicated.life/) +// Licensed under the MIT license. See LICENSE.md in the solution root for full license information. +// +// +// Settings.cs Implementation +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace FFXIVAPP.Client.SettingsProviders.Application { + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Configuration; + using System.Drawing; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Runtime.CompilerServices; + using System.Windows.Media; + using System.Xml.Linq; + + using FFXIVAPP.Client.Models; + using FFXIVAPP.Client.ViewModels; + using FFXIVAPP.Common.Helpers; + using FFXIVAPP.Common.Models; + using FFXIVAPP.Common.Utilities; + + using NLog; + + using ColorConverter = System.Windows.Media.ColorConverter; + using FontFamily = System.Drawing.FontFamily; + + internal class Settings : ApplicationSettingsBase, INotifyPropertyChanged { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - #endregion - private static Settings _default; - public static Settings Default - { - get { return _default ?? (_default = (Settings) Synchronized(new Settings())); } - } - - public override void Save() - { - DefaultSettings(); - SaveSettingsNode(); - SavePluginSourcesNode(); - Constants.XSettings.Save(Path.Combine(AppViewModel.Instance.SettingsPath, "ApplicationSettings.xml")); - } - - private void DefaultSettings() - { - Constants.Settings.Clear(); - } + public new event PropertyChangedEventHandler PropertyChanged = delegate { }; - public new void Reset() - { - DefaultSettings(); - foreach (var key in Constants.Settings) - { - var settingsProperty = Default.Properties[key]; - if (settingsProperty == null) - { - continue; - } - var value = settingsProperty.DefaultValue.ToString(); - SetValue(key, value, CultureInfo.InvariantCulture); + public static Settings Default { + get { + return _default ?? (_default = (Settings) Synchronized(new Settings())); } } - public static void SetValue(string key, string value, CultureInfo cultureInfo) - { - try - { - var type = Default[key] - .GetType() - .Name; - switch (type) - { + public static void SetValue(string key, string value, CultureInfo cultureInfo) { + try { + var type = Default[key].GetType().Name; + switch (type) { case "Boolean": - Default[key] = Boolean.Parse(value); + Default[key] = bool.Parse(value); break; case "Color": var cc = new ColorConverter(); - var color = cc.ConvertFrom(value); + object color = cc.ConvertFrom(value); Default[key] = color ?? Colors.Black; break; case "Double": - Default[key] = Double.Parse(value, cultureInfo); + Default[key] = double.Parse(value, cultureInfo); break; case "Font": var fc = new FontConverter(); - var font = fc.ConvertFromString(value); + object font = fc.ConvertFromString(value); Default[key] = font ?? new Font(new FontFamily("Microsoft Sans Serif"), 12); break; case "Int32": - Default[key] = Int32.Parse(value, cultureInfo); + Default[key] = int.Parse(value, cultureInfo); break; default: Default[key] = value; break; } } - catch (Exception ex) - { + catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } } - #region Property Bindings (Settings) - - #endregion - - #region Implementation of INotifyPropertyChanged - - public new event PropertyChangedEventHandler PropertyChanged = delegate { }; + public new void Reset() { + this.DefaultSettings(); + foreach (var key in Constants.Settings) { + SettingsProperty settingsProperty = Default.Properties[key]; + if (settingsProperty == null) { + continue; + } - private void RaisePropertyChanged([CallerMemberName] string caller = "") - { - PropertyChanged(this, new PropertyChangedEventArgs(caller)); + var value = settingsProperty.DefaultValue.ToString(); + SetValue(key, value, CultureInfo.InvariantCulture); + } } - #endregion - - #region Iterative Settings Saving - - private void SaveSettingsNode() - { - if (Constants.XSettings == null) - { - return; - } - var xElements = Constants.XSettings.Descendants() - .Elements("Setting"); - var enumerable = xElements as XElement[] ?? xElements.ToArray(); - foreach (var setting in Constants.Settings) - { - var element = enumerable.FirstOrDefault(e => e.Attribute("Key") - .Value == setting); - if (element == null) - { - var xKey = setting; - var xValue = Default[xKey] - .ToString(); - var keyPairList = new List - { - new XValuePair - { - Key = "Value", - Value = xValue - } - }; - XmlHelper.SaveXmlNode(Constants.XSettings, "Settings", "Setting", xKey, keyPairList); - } - else - { - var xElement = element.Element("Value"); - if (xElement != null) - { - xElement.Value = Default[setting] - .ToString(); - } - } - } + public override void Save() { + this.DefaultSettings(); + this.SaveSettingsNode(); + this.SavePluginSourcesNode(); + Constants.XSettings.Save(Path.Combine(AppViewModel.Instance.SettingsPath, "ApplicationSettings.xml")); } - public void SavePluginSourcesNode() - { - if (Constants.XSettings == null) - { + public void SavePluginSourcesNode() { + if (Constants.XSettings == null) { return; } - Constants.XSettings.Descendants("PluginSource") - .Where(node => UpdateViewModel.Instance.AvailableSources.All(source => source.Key.ToString() != node.Attribute("Key") - .Value)) - .Remove(); - var xElements = Constants.XSettings.Descendants() - .Elements("PluginSource"); - var enumerable = xElements as XElement[] ?? xElements.ToArray(); + + Constants.XSettings.Descendants("PluginSource").Where(node => UpdateViewModel.Instance.AvailableSources.All(source => source.Key.ToString() != node.Attribute("Key").Value)).Remove(); + IEnumerable xElements = Constants.XSettings.Descendants().Elements("PluginSource"); + XElement[] enumerable = xElements as XElement[] ?? xElements.ToArray(); + // ensure enabled plugin settings - foreach (var item in UpdateViewModel.Instance.AvailableSources) - { - var xKey = item.Key != Guid.Empty ? item.Key : Guid.NewGuid(); + foreach (PluginSourceItem item in UpdateViewModel.Instance.AvailableSources) { + Guid xKey = item.Key != Guid.Empty + ? item.Key + : Guid.NewGuid(); var xSourceURI = item.SourceURI; var xEnabled = item.Enabled; - var keyPairList = new List - { - new XValuePair - { + List keyPairList = new List { + new XValuePair { Key = "SourceURI", Value = xSourceURI }, - new XValuePair - { + new XValuePair { Key = "Enabled", Value = xEnabled.ToString() } }; - var element = enumerable.FirstOrDefault(e => e.Attribute("Key") - .Value == xKey.ToString()); - if (element == null) - { + XElement element = enumerable.FirstOrDefault(e => e.Attribute("Key").Value == xKey.ToString()); + if (element == null) { XmlHelper.SaveXmlNode(Constants.XSettings, "Settings", "PluginSource", xKey.ToString(), keyPairList); } - else - { - var xKeyElement = element.Attribute("Key"); - if (xKeyElement != null) - { + else { + XAttribute xKeyElement = element.Attribute("Key"); + if (xKeyElement != null) { xKeyElement.Value = xKey.ToString(); } - var xRegExElement = element.Element("SourceURI"); - if (xRegExElement != null) - { + + XElement xRegExElement = element.Element("SourceURI"); + if (xRegExElement != null) { xRegExElement.Value = xSourceURI; } - var xEnabledElement = element.Element("Enabled"); - if (xEnabledElement != null) - { + + XElement xEnabledElement = element.Element("Enabled"); + if (xEnabledElement != null) { xEnabledElement.Value = xEnabled.ToString(); } } } } - #endregion + private void DefaultSettings() { + Constants.Settings.Clear(); + } + + private void RaisePropertyChanged([CallerMemberName] string caller = "") { + this.PropertyChanged(this, new PropertyChangedEventArgs(caller)); + } + + private void SaveSettingsNode() { + if (Constants.XSettings == null) { + return; + } + + IEnumerable xElements = Constants.XSettings.Descendants().Elements("Setting"); + XElement[] enumerable = xElements as XElement[] ?? xElements.ToArray(); + foreach (var setting in Constants.Settings) { + XElement element = enumerable.FirstOrDefault(e => e.Attribute("Key").Value == setting); + if (element == null) { + var xKey = setting; + var xValue = Default[xKey].ToString(); + List keyPairList = new List { + new XValuePair { + Key = "Value", + Value = xValue + } + }; + XmlHelper.SaveXmlNode(Constants.XSettings, "Settings", "Setting", xKey, keyPairList); + } + else { + XElement xElement = element.Element("Value"); + if (xElement != null) { + xElement.Value = Default[setting].ToString(); + } + } + } + } } -} +} \ No newline at end of file diff --git a/FFXIVAPP.Client/ShellView.xaml b/FFXIVAPP.Client/ShellView.xaml index cc8ab6b0..b7e45344 100644 --- a/FFXIVAPP.Client/ShellView.xaml +++ b/FFXIVAPP.Client/ShellView.xaml @@ -36,10 +36,13 @@ - + - - + + @@ -79,7 +82,8 @@