Ejemplo n.º 1
0
 public static void CheckForAndDoAutoConnect()
 {
     DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile();
     if (autoConnectProfile != null)
     {
         ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
         PrinterCommunication.Instance.HaltConnectionThread();
         PrinterCommunication.Instance.ConnectToActivePrinter();
     }
 }
        public static void CheckForAndDoAutoConnect()
        {
            bool    connectionAvailable;
            Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable);

            if (autoConnectProfile != null)
            {
                ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
                if (connectionAvailable)
                {
                    PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
                    PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
                }
            }
        }
 public void DoAutoConnectIfRequired()
 {
     ActivePrinterProfile.CheckForAndDoAutoConnect();
 }
        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();
        }
Ejemplo n.º 5
0
        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();
        }