private MatterControlApplication(double width, double height, out bool showWindow) : base(width, height) { showWindow = false; // set this at startup so that we can tell next time if it got set to true in close UserSettings.Instance.Fields.StartCount = UserSettings.Instance.Fields.StartCount + 1; this.commandLineArgs = Environment.GetCommandLineArgs(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; for (int currentCommandIndex = 0; currentCommandIndex < commandLineArgs.Length; currentCommandIndex++) { string command = commandLineArgs[currentCommandIndex]; string commandUpper = command.ToUpper(); switch (commandUpper) { case "TEST": Testing.TestingDispatch testDispatch = new Testing.TestingDispatch(); testDispatch.RunTests(); return; case "MHSERIAL_TO_ANDROID": { Dictionary <string, string> vidPid_NameDictionary = new Dictionary <string, string>(); string[] MHSerialLines = File.ReadAllLines(Path.Combine("..", "..", "StaticData", "Drivers", "MHSerial", "MHSerial.inf")); foreach (string line in MHSerialLines) { if (line.Contains("=DriverInstall,")) { string name = Regex.Match(line, "%(.*).name").Groups[1].Value; string vid = Regex.Match(line, "VID_(.*)&PID").Groups[1].Value; string pid = Regex.Match(line, "PID_([0-9a-fA-F]+)").Groups[1].Value; string vidPid = "{0},{1}".FormatWith(vid, pid); if (!vidPid_NameDictionary.ContainsKey(vidPid)) { vidPid_NameDictionary.Add(vidPid, name); } } } using (StreamWriter deviceFilter = new StreamWriter("deviceFilter.txt")) { using (StreamWriter serialPort = new StreamWriter("serialPort.txt")) { foreach (KeyValuePair <string, string> vidPid_Name in vidPid_NameDictionary) { string[] vidPid = vidPid_Name.Key.Split(','); int vid = Int32.Parse(vidPid[0], System.Globalization.NumberStyles.HexNumber); int pid = Int32.Parse(vidPid[1], System.Globalization.NumberStyles.HexNumber); serialPort.WriteLine("customTable.AddProduct(0x{0:X4}, 0x{1:X4}, cdcDriverType); // {2}".FormatWith(vid, pid, vidPid_Name.Value)); deviceFilter.WriteLine("<!-- {2} -->\n<usb-device vendor-id=\"{0}\" product-id=\"{1}\" />".FormatWith(vid, pid, vidPid_Name.Value)); } } } } return; case "CLEAR_CACHE": AboutPage.DeleteCacheData(); break; case "SHOW_MEMORY": ShowMemoryUsed = true; break; case "DO_GC_COLLECT_EVERY_DRAW": ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; case "CREATE_AND_SELECT_PRINTER": if (currentCommandIndex + 1 < commandLineArgs.Length) { currentCommandIndex++; string argument = commandLineArgs[currentCommandIndex]; string[] printerData = argument.Split(','); if (printerData.Length == 2) { Printer ActivePrinter = new Printer(); ActivePrinter.Name = "Auto: {0} {1}".FormatWith(printerData[0], printerData[1]); ActivePrinter.Make = printerData[0]; ActivePrinter.Model = printerData[1]; PrinterSetupStatus test = new PrinterSetupStatus(ActivePrinter); test.LoadDefaultSliceSettings(ActivePrinter.Make, ActivePrinter.Model); ActivePrinterProfile.Instance.ActivePrinter = ActivePrinter; } } break; } if (MeshFileIo.ValidFileExtensions().Contains(Path.GetExtension(command).ToUpper())) { // If we are the only instance running then do nothing. // Else send these to the running instance so it can load them. } } //WriteTestGCodeFile(); #if !DEBUG if (File.Exists("RunUnitTests.txt")) #endif { #if IS_WINDOWS_FORMS if (!Clipboard.IsInitialized) { Clipboard.SetSystemClipboard(new WindowsFormsClipboard()); } #endif MatterHackers.PolygonMesh.UnitTests.UnitTests.Run(); MatterHackers.RayTracer.UnitTests.Run(); MatterHackers.Agg.Tests.UnitTests.Run(); MatterHackers.VectorMath.Tests.UnitTests.Run(); MatterHackers.Agg.UI.Tests.UnitTests.Run(); MatterHackers.MatterControl.Slicing.Tests.UnitTests.Run(); // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { TextWidget.GlobalPointSizeScaleRatio = 1.3; } this.AddChild(ApplicationController.Instance.MainView); this.MinimumSize = minSize; this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); UseOpenGL = true; string version = "1.2"; Title = "MatterControl {0}".FormatWith(version); if (OemSettings.Instance.WindowTitleExtra != null && OemSettings.Instance.WindowTitleExtra.Trim().Length > 0) { Title = Title + " - {1}".FormatWith(version, OemSettings.Instance.WindowTitleExtra); } UiThread.RunOnIdle(CheckOnPrinter); string desktopPosition = ApplicationSettings.Instance.get("DesktopPosition"); if (desktopPosition != null && desktopPosition != "") { string[] sizes = desktopPosition.Split(','); //If the desktop position is less than -10,-10, override int xpos = Math.Max(int.Parse(sizes[0]), -10); int ypos = Math.Max(int.Parse(sizes[1]), -10); DesktopPosition = new Point2D(xpos, ypos); } showWindow = true; }
public MatterControlApplication(double width, double height) : base(width, height) { this.commandLineArgs = Environment.GetCommandLineArgs(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; foreach (string command in commandLineArgs) { string commandUpper = command.ToUpper(); switch (commandUpper) { case "TEST": Testing.TestingDispatch testDispatch = new Testing.TestingDispatch(); string[] testCommands = new string[commandLineArgs.Length - 2]; if (commandLineArgs.Length > 2) { commandLineArgs.CopyTo(testCommands, 2); } testDispatch.RunTests(testCommands); return; case "CLEAR_CACHE": AboutPage.DeleteCacheData(); break; case "SHOW_MEMORY": ShowMemoryUsed = true; break; case "DO_GC_COLLECT_EVERY_DRAW": ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; } } //WriteTestGCodeFile(); #if !DEBUG if (File.Exists("RunUnitTests.txt")) #endif { Clipboard.SetSystemClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); MatterHackers.PolygonMesh.UnitTests.UnitTests.Run(); MatterHackers.RayTracer.UnitTests.Run(); MatterHackers.Agg.Tests.UnitTests.Run(); MatterHackers.VectorMath.Tests.UnitTests.Run(); MatterHackers.Agg.UI.Tests.UnitTests.Run(); // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; this.AddChild(ApplicationWidget.Instance); this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); UseOpenGL = true; string version = "1.1"; Title = "MatterControl{0} {1}".FormatWith(OemSettings.Instance.WindowTitleExtra, version); ActivePrinterProfile.CheckForAndDoAutoConnect(); UiThread.RunOnIdle(CheckOnPrinter); MinimumSize = new Vector2(590, 630); string desktopPosition = ApplicationSettings.Instance.get("DesktopPosition"); if (desktopPosition != null && desktopPosition != "") { string[] sizes = desktopPosition.Split(','); //If the desktop position is less than -10,-10, override int xpos = Math.Max(int.Parse(sizes[0]), -10); int ypos = Math.Max(int.Parse(sizes[1]), -10); DesktopPosition = new Point2D(xpos, ypos); } ShowAsSystemWindow(); }
public MatterControlApplication(double width, double height) : base(width, height) { this.commandLineArgs = Environment.GetCommandLineArgs(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; if (commandLineArgs.Length > 1) { switch (commandLineArgs[1].ToUpper()) { case "TEST": Testing.TestingDispatch testDispatch = new Testing.TestingDispatch(); string[] testCommands = new string[commandLineArgs.Length - 2]; if (commandLineArgs.Length > 2) { commandLineArgs.CopyTo(testCommands, 2); } testDispatch.RunTests(testCommands); return; case "SHOW_MEMORY": ShowMemoryUsed = true; break; case "DO_GC_COLLECT_EVERY_DRAW": ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; case "SHOW_DRAW_TIMING": ShowDrawTimingWindow = true; break; } } //WriteTestGCodeFile(); if (File.Exists("RunUnitTests.txt")) { GuiHalWidget.SetClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); MatterHackers.Agg.Tests.UnitTests.Run(); MatterHackers.VectorMath.Tests.UnitTests.Run(); MatterHackers.Agg.UI.Tests.UnitTests.Run(); MatterHackers.PolygonMesh.UnitTests.UnitTests.Run(); // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom); allControls.AnchorAll(); this.AddChild(allControls); this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off //allControls.AddChild(CreateMenues()); allControls.AddChild(new ActionBarPlus()); allControls.AddChild(MainSlidePanel.Instance); #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); UseOpenGL = true; Title = "MatterControl (beta)"; ActivePrinterProfile.CheckForAndDoAutoConnect(); UiThread.RunOnIdle(CheckOnPrinter); ShowAsSystemWindow(); }
public MatterControlApplication(double width, double height) : base(width, height) { CrashTracker.Reset(); this.commandLineArgs = Environment.GetCommandLineArgs(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; foreach (string command in commandLineArgs) { string commandUpper = command.ToUpper(); switch (commandUpper) { case "TEST": Testing.TestingDispatch testDispatch = new Testing.TestingDispatch(); testDispatch.RunTests(); return; case "CLEAR_CACHE": AboutPage.DeleteCacheData(); break; case "SHOW_MEMORY": ShowMemoryUsed = true; break; case "DO_GC_COLLECT_EVERY_DRAW": ShowMemoryUsed = true; DoCGCollectEveryDraw = true; break; } if (MeshFileIo.ValidFileExtensions().Contains(Path.GetExtension(command).ToUpper())) { // If we are the only instance running then do nothing. // Else send these to the running instance so it can load them. } } //WriteTestGCodeFile(); #if !DEBUG if (File.Exists("RunUnitTests.txt")) #endif { #if IS_WINDOWS_FORMS Clipboard.SetSystemClipboardFunctions(System.Windows.Forms.Clipboard.GetText, System.Windows.Forms.Clipboard.SetText, System.Windows.Forms.Clipboard.ContainsText); #endif MatterHackers.PolygonMesh.UnitTests.UnitTests.Run(); MatterHackers.RayTracer.UnitTests.Run(); MatterHackers.Agg.Tests.UnitTests.Run(); MatterHackers.VectorMath.Tests.UnitTests.Run(); MatterHackers.Agg.UI.Tests.UnitTests.Run(); // you can turn this on to debug some bounds issues //GuiWidget.DebugBoundsUnderMouse = true; } GuiWidget.DefaultEnforceIntegerBounds = true; if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen) { TextWidget.GlobalPointSizeScaleRatio = 1.3; } this.AddChild(ApplicationController.Instance.MainView); this.MinimumSize = new Vector2(400, 400); this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off #if false // this is to test freeing gcodefile memory Button test = new Button("test"); test.Click += (sender, e) => { //MatterHackers.GCodeVisualizer.GCodeFile gcode = new GCodeVisualizer.GCodeFile(); //gcode.Load(@"C:\Users\lbrubaker\Downloads\drive assy.gcode"); SystemWindow window = new SystemWindow(100, 100); window.ShowAsSystemWindow(); }; allControls.AddChild(test); #endif this.AnchorAll(); UseOpenGL = true; string version = "1.1"; Title = "MatterControl {0}".FormatWith(version); if (OemSettings.Instance.WindowTitleExtra != null && OemSettings.Instance.WindowTitleExtra.Trim().Length > 0) { Title = Title + " - {1}".FormatWith(version, OemSettings.Instance.WindowTitleExtra); } UiThread.RunOnIdle(CheckOnPrinter); string desktopPosition = ApplicationSettings.Instance.get("DesktopPosition"); if (desktopPosition != null && desktopPosition != "") { string[] sizes = desktopPosition.Split(','); //If the desktop position is less than -10,-10, override int xpos = Math.Max(int.Parse(sizes[0]), -10); int ypos = Math.Max(int.Parse(sizes[1]), -10); DesktopPosition = new Point2D(xpos, ypos); } ShowAsSystemWindow(); }