diff --git a/README.md b/README.md index e8593f5..5d25ebd 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Release](https://img.shields.io/github/release/Dirkster99/MLib.svg)](https://github.com/Dirkster99/MLib/releases/latest) [![NuGet](https://img.shields.io/nuget/dt/Dirkster.MLib.svg)](http://nuget.org/packages/Dirkster.MLib) +![Net4](https://badgen.net/badge/Framework/.Net 4/blue) ![NetCore3](https://badgen.net/badge/Framework/NetCore 3/blue) + # MLib MLib is a set of WPF theming libraries based on MahApps.Metro, MUI, diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..898e4f2 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,37 @@ +version: 1.3.{build} + +branches: + only: + - master + +configuration: Release + +platform: Any CPU + +image: Visual Studio 2019 Preview + +install: + - cmd: choco install dotnetcore-sdk --pre + +before_build: + - cmd: nuget restore source\MDemo.sln + +build: + parallel: true + verbosity: minimal + +artifacts: +- path: source\Components\MLib\bin\Release + name: MLib + +- path: source\Components\MWindowDialogLib\bin\Release + name: MWindowDialogLib + +- path: source\Components\MWindowLib\bin\Release + name: MWindowLib + +- path: source\MDemo\bin\Release + name: MDemo + +- path: source\PDF Binder\PDF Binder\bin\Release + name: PDF Binder diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/App.config b/source/00_DemoTemplates/Apps/ThemedDemo/App.config deleted file mode 100644 index 7cb0cd1..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml b/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml deleted file mode 100644 index a369442..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml.cs b/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml.cs deleted file mode 100644 index 360a4e5..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/App.xaml.cs +++ /dev/null @@ -1,291 +0,0 @@ -namespace ThemedDemo -{ - using log4net; - using log4net.Config; - using MLib.Interfaces; - using Models; - using MWindowInterfacesLib.Interfaces; - using Settings.Interfaces; - using Settings.UserProfile; - using System; - using System.Diagnostics; - using System.Globalization; - using System.Threading; - using System.Windows; - using ViewModels; - - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - #region fields - protected static log4net.ILog Logger; - - private ViewModels.AppViewModel _appVM = null; - private MainWindow _mainWindow = null; - #endregion fields - - #region constructors - static App() - { - XmlConfigurator.Configure(); - Logger = LogManager.GetLogger("default"); - - // Create service model to ensure available services - ServiceInjector.InjectServices(); - } - #endregion constructors - - #region methods - private void Application_Startup(object sender, StartupEventArgs e) - { - try - { - // Set shutdown mode here (and reset further below) to enable showing custom dialogs (messageboxes) - // durring start-up without shutting down application when the custom dialogs (messagebox) closes - ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; - } - catch - { - } - - var settings = GetService(); // add the default themes - var appearance = GetService(); - AppLifeCycleViewModel lifeCycle = null; - - try - { - lifeCycle = new AppLifeCycleViewModel(); - lifeCycle.LoadConfigOnAppStartup(settings, appearance); - - appearance.SetTheme(settings.Themes - , settings.Options.GetOptionValue("Appearance", "ThemeDisplayName") - , ThemeViewModel.GetCurrentAccentColor(settings)); - - // Construct Application ViewMOdel and mainWindow - _appVM = new ViewModels.AppViewModel(lifeCycle); - _appVM.SetSessionData(settings.SessionData); - - // Customize services specific items for this application - // Program message box service for Modern UI (Metro Light and Dark) - // var msgBox = GetService(); - // msgBox.Style = MsgBoxStyle.WPFThemed; - - } - catch (Exception exp) - { - Debug.WriteLine(exp.Message); - } - - try - { - var selectedLanguage = settings.Options.GetOptionValue("Options", "LanguageSelected"); - - Thread.CurrentThread.CurrentCulture = new CultureInfo(selectedLanguage); - Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); - } - catch - { - } - - // Create the optional appearance viewmodel and apply - // current settings to start-up with correct colors etc... - ////var appearSettings = new AppearanceViewModel(settings.Themes); - ////appearSettings.ApplyOptionsFromModel(settings.Options); - - // Initialize WPF theming and friends ... - _appVM.InitForMainWindow(GetService() - , settings.Options.GetOptionValue("Appearance", "ThemeDisplayName")); - - Application.Current.MainWindow = _mainWindow = new MainWindow(); - MainWindow.DataContext = _appVM; - - AppCore.CreateAppDataFolder(); - - if (MainWindow != null && _appVM != null) - { - // and show it to the user ... - MainWindow.Loaded += MainWindow_Loaded; - MainWindow.Closing += OnClosing; - - // When the ViewModel asks to be closed, close the window. - // Source: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx - MainWindow.Closed += delegate - { - // Save session data and close application - OnClosed(_appVM, _mainWindow); - - var dispose = _appVM as IDisposable; - if (dispose != null) - dispose.Dispose(); - - _mainWindow.DataContext = null; - _appVM = null; - _mainWindow = null; - }; - - ConstructMainWindowSession(_appVM, _mainWindow); - MainWindow.Show(); - } - } - - /// - /// Method is invoked when the mainwindow is loaded and visble to the user. - /// - /// - /// - private void MainWindow_Loaded(object sender, RoutedEventArgs e) - { - try - { - ShutdownMode = ShutdownMode.OnLastWindowClose; - } - catch (Exception exp) - { - Logger.Error(exp); - } - - /*** - try - { - Application.Current.MainWindow = mMainWin = new MainWindow(); - ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose; - - AppCore.CreateAppDataFolder(); - - if (mMainWin != null && app != null) - { - mMainWin.Closing += OnClosing; - - - ConstructMainWindowSession(app, mMainWin); - mMainWin.Show(); - } - } - catch (Exception exp) - { - Logger.Error(exp); - } - ***/ - } - - /// - /// COnstruct MainWindow an attach datacontext to it. - /// - /// - /// - private void ConstructMainWindowSession(AppViewModel workSpace, IViewSize win) - { - try - { - var settings = GetService(); - - // Establish command binding to accept user input via commanding framework - // workSpace.InitCommandBinding(win); - - ViewPosSizeModel viewSz; - settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName - , out viewSz); - - viewSz.SetWindowsState(win); - - string lastActiveFile = settings.SessionData.LastActiveSolution; - - MainWindow mainWin = win as MainWindow; - } - catch (Exception exp) - { - Logger.Error(exp); - } - } - - /// - /// Save session data on closing - /// - /// - /// - private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) - { - try - { - AppViewModel wsVM = base.MainWindow.DataContext as AppViewModel; - - if (wsVM != null) - { - var MainWindowCanClose = MainWindow as IMetroWindow; - - if (MainWindowCanClose != null) - { - if (MainWindowCanClose.IsContentDialogVisible == true) - { - e.Cancel = true; // Lets not close with open dialog - return; - } - } - - // Close all open files and check whether application is ready to close - if (wsVM.AppLifeCycle.Exit_CheckConditions(wsVM) == true) - { - // (other than exception and error handling) - wsVM.AppLifeCycle.OnRequestClose(true); - - e.Cancel = false; - } - else - { - wsVM.AppLifeCycle.CancelShutDown(); - e.Cancel = true; - } - } - } - catch (Exception exp) - { - Logger.Error(exp); - } - } - - /// - /// Execute closing function and persist session data to be reloaded on next restart - /// - /// - /// - private void OnClosed(AppViewModel appVM, IViewSize win) - { - try - { - var settings = GetService(); - - ViewPosSizeModel viewSz; - settings.SessionData.WindowPosSz.TryGetValue(settings.SessionData.MainWindowName - , out viewSz); - viewSz.GetWindowsState(win); - - _appVM.GetSessionData(settings.SessionData); - - // Save/initialize program options that determine global programm behaviour - appVM.AppLifeCycle.SaveConfigOnAppClosed(win); - } - catch (Exception exp) - { - Logger.Error(exp); - //// var msg = GetService(); - //// - //// msg.Show(exp.ToString(), "Unexpected Error", - //// MsgBox.MsgBoxButtons.OK, MsgBox.MsgBoxImage.Error); - } - } - - /// - /// This method gets the service locator instance - /// that is used in turn to get an application specific service instance. - /// - /// - /// - private TServiceContract GetService() where TServiceContract : class - { - return ServiceLocator.ServiceContainer.Instance.GetService(); - } - #endregion methods - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Behaviors/SelectionChangedBehavior.cs b/source/00_DemoTemplates/Apps/ThemedDemo/Behaviors/SelectionChangedBehavior.cs deleted file mode 100644 index 2c5ab3e..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Behaviors/SelectionChangedBehavior.cs +++ /dev/null @@ -1,138 +0,0 @@ -namespace ThemedDemo.Behaviors -{ - using System.Windows; - using System.Windows.Controls; - using System.Windows.Controls.Primitives; - using System.Windows.Input; - - /// - /// Attached behaviour to implement a selection changed command on a Selector (combobox). - /// The Selector (combobox) generates a SelectionChanged event which in turn generates a - /// Command (in this behavior), which in turn is, when bound, invoked on the viewmodel. - /// - public static class SelectionChangedCommand - { - // Field of attached ICommand property - private static readonly DependencyProperty ChangedCommandProperty = DependencyProperty.RegisterAttached( - "ChangedCommand", - typeof(ICommand), - typeof(SelectionChangedCommand), - new PropertyMetadata(null, OnSelectionChangedCommandChange)); - - /// - /// Setter method of the attached DropCommand property - /// - /// - /// - public static void SetChangedCommand(DependencyObject source, ICommand value) - { - source.SetValue(ChangedCommandProperty, value); - } - - /// - /// Getter method of the attached DropCommand property - /// - /// - /// - public static ICommand GetChangedCommand(DependencyObject source) - { - return (ICommand)source.GetValue(ChangedCommandProperty); - } - - /// - /// This method is hooked in the definition of the . - /// It is called whenever the attached property changes - in our case the event of binding - /// and unbinding the property to a sink is what we are looking for. - /// - /// - /// - private static void OnSelectionChangedCommandChange(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - Selector uiElement = d as Selector; // Remove the handler if it exist to avoid memory leaks - - if (uiElement != null) - { - uiElement.SelectionChanged -= Selection_Changed; - uiElement.KeyUp -= uiElement_KeyUp; - - var command = e.NewValue as ICommand; - if (command != null) - { - // the property is attached so we attach the Drop event handler - uiElement.SelectionChanged += Selection_Changed; - uiElement.KeyUp += uiElement_KeyUp; - } - } - } - - private static void uiElement_KeyUp(object sender, KeyEventArgs e) - { - if (e == null) - return; - - // Forward key event only if user has hit the return, BackSlash, or Slash key - if (e.Key != Key.Return) - return; - - ComboBox uiElement = sender as ComboBox; - - // Sanity check just in case this was somehow send by something else - if (uiElement == null) - return; - - ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); - - // There may not be a command bound to this after all - if (changedCommand == null) - return; - - // Check whether this attached behaviour is bound to a RoutedCommand - if (changedCommand is RoutedCommand) - { - // Execute the routed command - (changedCommand as RoutedCommand).Execute(uiElement.Text, uiElement); - } - else - { - // Execute the Command as bound delegate - changedCommand.Execute(uiElement.Text); - } - } - - /// - /// This method is called when the selection changed event occurs. The sender should be the control - /// on which this behaviour is attached - so we convert the sender into a - /// and receive the Command through the getter listed above. - /// - /// This implementation supports binding of delegate commands and routed commands. - /// - /// - /// - private static void Selection_Changed(object sender, System.Windows.Controls.SelectionChangedEventArgs e) - { - Selector uiElement = sender as Selector; - - // Sanity check just in case this was somehow send by something else - if (uiElement == null) - return; - - ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); - - // There may not be a command bound to this after all - if (changedCommand == null) - return; - - // Check whether this attached behaviour is bound to a RoutedCommand - if (changedCommand is RoutedCommand) - { - // Execute the routed command - (changedCommand as RoutedCommand).Execute(e.AddedItems, uiElement); - } - else - { - // Execute the Command as bound delegate - changedCommand.Execute(e.AddedItems); - } - } - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/BindToMLib/MWindowLib/DarkLightBrushs.xaml b/source/00_DemoTemplates/Apps/ThemedDemo/BindToMLib/MWindowLib/DarkLightBrushs.xaml deleted file mode 100644 index 034e55e..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/BindToMLib/MWindowLib/DarkLightBrushs.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - Blue - - - - - #FFF4F4F5 - - #FF2D2D30 - - - - - - - #FF3F3F41 - - - - \ No newline at end of file diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Behaviors/SelectionChangedBehavior.cs .cs b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Behaviors/SelectionChangedBehavior.cs .cs deleted file mode 100644 index b2db3e1..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Behaviors/SelectionChangedBehavior.cs .cs +++ /dev/null @@ -1,138 +0,0 @@ -namespace ThemedDemo.Demos.Behaviors -{ - using System.Windows; - using System.Windows.Controls; - using System.Windows.Controls.Primitives; - using System.Windows.Input; - - /// - /// Attached behaviour to implement a selection changed command on a Selector (combobox). - /// The Selector (combobox) generates a SelectionChanged event which in turn generates a - /// Command (in this behavior), which in turn is, when bound, invoked on the viewmodel. - /// - public static class SelectionChangedCommand - { - // Field of attached ICommand property - private static readonly DependencyProperty ChangedCommandProperty = DependencyProperty.RegisterAttached( - "ChangedCommand", - typeof(ICommand), - typeof(SelectionChangedCommand), - new PropertyMetadata(null, OnSelectionChangedCommandChange)); - - /// - /// Setter method of the attached DropCommand property - /// - /// - /// - public static void SetChangedCommand(DependencyObject source, ICommand value) - { - source.SetValue(ChangedCommandProperty, value); - } - - /// - /// Getter method of the attached DropCommand property - /// - /// - /// - public static ICommand GetChangedCommand(DependencyObject source) - { - return (ICommand)source.GetValue(ChangedCommandProperty); - } - - /// - /// This method is hooked in the definition of the . - /// It is called whenever the attached property changes - in our case the event of binding - /// and unbinding the property to a sink is what we are looking for. - /// - /// - /// - private static void OnSelectionChangedCommandChange(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - Selector uiElement = d as Selector; // Remove the handler if it exist to avoid memory leaks - - if (uiElement != null) - { - uiElement.SelectionChanged -= Selection_Changed; - uiElement.KeyUp -= uiElement_KeyUp; - - var command = e.NewValue as ICommand; - if (command != null) - { - // the property is attached so we attach the Drop event handler - uiElement.SelectionChanged += Selection_Changed; - uiElement.KeyUp += uiElement_KeyUp; - } - } - } - - private static void uiElement_KeyUp(object sender, KeyEventArgs e) - { - if (e == null) - return; - - // Forward key event only if user has hit the return, BackSlash, or Slash key - if (e.Key != Key.Return) - return; - - ComboBox uiElement = sender as ComboBox; - - // Sanity check just in case this was somehow send by something else - if (uiElement == null) - return; - - ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); - - // There may not be a command bound to this after all - if (changedCommand == null) - return; - - // Check whether this attached behaviour is bound to a RoutedCommand - if (changedCommand is RoutedCommand) - { - // Execute the routed command - (changedCommand as RoutedCommand).Execute(uiElement.Text, uiElement); - } - else - { - // Execute the Command as bound delegate - changedCommand.Execute(uiElement.Text); - } - } - - /// - /// This method is called when the selection changed event occurs. The sender should be the control - /// on which this behaviour is attached - so we convert the sender into a - /// and receive the Command through the getter listed above. - /// - /// This implementation supports binding of delegate commands and routed commands. - /// - /// - /// - private static void Selection_Changed(object sender, System.Windows.Controls.SelectionChangedEventArgs e) - { - Selector uiElement = sender as Selector; - - // Sanity check just in case this was somehow send by something else - if (uiElement == null) - return; - - ICommand changedCommand = SelectionChangedCommand.GetChangedCommand(uiElement); - - // There may not be a command bound to this after all - if (changedCommand == null) - return; - - // Check whether this attached behaviour is bound to a RoutedCommand - if (changedCommand is RoutedCommand) - { - // Execute the routed command - (changedCommand as RoutedCommand).Execute(e.AddedItems, uiElement); - } - else - { - // Execute the Command as bound delegate - changedCommand.Execute(e.AddedItems); - } - } - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Models/FolderBrowserResult.cs b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Models/FolderBrowserResult.cs deleted file mode 100644 index bbec5b1..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Models/FolderBrowserResult.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace ThemedDemo.Demos.Models -{ - public class FolderBrowserResult - { - #region constructors - public FolderBrowserResult() - { - this.Path = default(string); - this.Result = null; - } - #endregion constructors - - #region properties - public string Path { get; private set; } - - public bool? Result { get; private set; } - #endregion properties - - #region methods - public void SetResult(bool result) - { - this.Result = result; - } - - public void SetPath(string path) - { - if (string.IsNullOrEmpty(path) == false) - Path = path; - else - Path = default(string); - } - #endregion methods - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/ViewModels/DemoViewModel.cs b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/ViewModels/DemoViewModel.cs deleted file mode 100644 index 58efca6..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/ViewModels/DemoViewModel.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace ThemedDemo.Demos.ViewModels -{ - using System.Linq; - using System.Windows.Input; - - public class DemoViewModel : ThemedDemo.ViewModels.Base.ViewModelBase - { - #region private fields - #endregion private fields - - #region constructors - /// - /// Class constructor - /// - public DemoViewModel() - { - } - #endregion constructors - - #region properties - #endregion properties - - #region methods - #endregion methods - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml deleted file mode 100644 index 5e84496..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml.cs b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml.cs deleted file mode 100644 index 17b8832..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserContentDialogView.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace ThemedDemo.Demos.Views -{ - using System.Windows.Controls; - - /// - /// Interaction logic for FolderBrowserContentDialogView.xaml - /// - /// This type of dialog can be shown as overlay over the actual MainWindow. - /// - public partial class FolderBrowserContentDialogView : UserControl - { - public FolderBrowserContentDialogView() - { - InitializeComponent(); - } - } -} diff --git a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserDialog.xaml b/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserDialog.xaml deleted file mode 100644 index b0ddb30..0000000 --- a/source/00_DemoTemplates/Apps/ThemedDemo/Demos/Views/FolderBrowserDialog.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - -