From 5602726d8de40e88f971fbcde08e95dd2603bfe1 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Wed, 19 Sep 2018 13:10:07 -0700 Subject: [PATCH] Move startup logic into program.cs in exe project --- MatterControl.cs | 17 ---- MatterControl.csproj | 15 +++- MatterControlLib/Program.cs => Program.cs | 99 +++++++++-------------- 3 files changed, 49 insertions(+), 82 deletions(-) delete mode 100644 MatterControl.cs rename MatterControlLib/Program.cs => Program.cs (55%) diff --git a/MatterControl.cs b/MatterControl.cs deleted file mode 100644 index 4bacaf9c6..000000000 --- a/MatterControl.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MatterControl -{ - class Program - { - [STAThread] - static void Main(string[] args) - { - MatterHackers.MatterControl.MatterControlLib.Main(); - } - } -} diff --git a/MatterControl.csproj b/MatterControl.csproj index 9d03c934d..b1fbfb031 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -44,7 +44,6 @@ - @@ -53,7 +52,7 @@ - + @@ -68,10 +67,22 @@ {93bebfdf-b81a-4344-ab82-0dbf58b234cd} MatterControlLib + + {865172a0-a1a9-49c2-9386-f2fdb4e141b7} + MatterControlPluginSystem + {990a9ad3-b6a4-407b-9dfc-9c722af7c9b9} InfInstaller + + {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b} + Agg + + + {74F6BB6C-9D02-4512-A59A-21940E35C532} + Gui + {b0aed568-8796-42b9-baa9-ebc796134e78} MatterSlice diff --git a/MatterControlLib/Program.cs b/Program.cs similarity index 55% rename from MatterControlLib/Program.cs rename to Program.cs index aec7c6334..8611bc74a 100644 --- a/MatterControlLib/Program.cs +++ b/Program.cs @@ -1,34 +1,47 @@ -using System; +/* +Copyright (c) 2018, Lars Brubaker, John Lewin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those +of the authors and should not be interpreted as representing official policies, +either expressed or implied, of the FreeBSD Project. +*/ + +using System; using System.Globalization; using System.IO; using System.Threading; using MatterHackers.Agg.Platform; -using MatterHackers.Agg.UI; using MatterHackers.MatterControl.DataStorage; -using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.SlicerConfiguration; using Microsoft.Extensions.Configuration; -//using Mindscape.Raygun4Net; namespace MatterHackers.MatterControl { - public static class MatterControlLib + class Program { - private const int RaygunMaxNotifications = 15; - - private static int raygunNotificationCount = 0; - - //private static RaygunClient _raygunClient; - - private class SlicerOptions - { - public bool Debug { get; set; } - } - - /// - /// The main entry point for the application. - /// - public static void Main() + [STAThread] + static void Main(string[] args) { // this sets the global culture for the app and all new threads CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; @@ -38,15 +51,6 @@ namespace MatterHackers.MatterControl Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; - //if (AggContext.OperatingSystem == OSType.Mac) - //{ - // _raygunClient = new RaygunClient("qmMBpKy3OSTJj83+tkO7BQ=="); // this is the Mac key - //} - //else - //{ - // _raygunClient = new RaygunClient("hQIlyUUZRGPyXVXbI6l1dA=="); // this is the PC key - //} - // Set default Agg providers AggContext.Config.ProviderTypes.SystemWindow = "MatterHackers.Agg.UI.OpenGLSystemWindow, agg_platform_win32"; AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.WinformsSystemWindowProvider, agg_platform_win32"; @@ -70,33 +74,11 @@ namespace MatterHackers.MatterControl Datastore.Instance.Initialize(); -//#if !DEBUG -// // Conditionally spin up error reporting if not on the Stable channel -// string channel = UserSettings.Instance.get(UserSettingsKey.UpdateFeedType); -// if (string.IsNullOrEmpty(channel) || channel != "release" || OemSettings.Instance.WindowTitleExtra == "Experimental") -//#endif -// { -// System.Windows.Forms.Application.ThreadException += (s, e) => -// { -// if(raygunNotificationCount++ < RaygunMaxNotifications) -// { -// _raygunClient.Send(e.Exception); -// } -// }; - -// AppDomain.CurrentDomain.UnhandledException += (s, e) => -// { -// if (raygunNotificationCount++ < RaygunMaxNotifications) -// { -// _raygunClient.Send(e.ExceptionObject as Exception); -// } -// }; -// } - // Init platformFeaturesProvider before ShowAsSystemWindow string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms"; - AppContext.Platform = AggContext.CreateInstanceFrom(platformFeaturesProvider); - AppContext.Platform.ProcessCommandline(); + + MatterHackers.MatterControl.AppContext.Platform = AggContext.CreateInstanceFrom(platformFeaturesProvider); + MatterHackers.MatterControl.AppContext.Platform.ProcessCommandline(); // Get startup bounds from MatterControl and construct system window //var systemWindow = new DesktopMainWindow(400, 200) @@ -105,14 +87,5 @@ namespace MatterHackers.MatterControl var systemWindow = Application.LoadRootWindow(width, height); systemWindow.ShowAsSystemWindow(); } - - // ** Standard Winforms Main ** // - //[STAThread] - //static void Main() - //{ - // Application.EnableVisualStyles(); - // Application.SetCompatibleTextRenderingDefault(false); - // Application.Run(new Form1()); - //} } }