public override void OnClosed(EventArgs e)
        {
            UserSettings.Instance.Fields.StartCountDurringExit = UserSettings.Instance.Fields.StartCount;

            TerminalWindow.CloseIfOpen();
            PrinterConnectionAndCommunication.Instance.Disable();
            //Close connection to the local datastore
            Datastore.Instance.Exit();
            PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
            SlicingQueue.Instance.ShutDownSlicingThread();
            ApplicationController.Instance.OnApplicationClosed();

            if (RestartOnClose)
            {
                string appPathAndFile  = System.Reflection.Assembly.GetExecutingAssembly().Location;
                string pathToAppFolder = Path.GetDirectoryName(appPathAndFile);

                ProcessStartInfo runAppLauncherStartInfo = new ProcessStartInfo();
                runAppLauncherStartInfo.Arguments      = "\"{0}\" \"{1}\"".FormatWith(appPathAndFile, 1000);
                runAppLauncherStartInfo.FileName       = Path.Combine(pathToAppFolder, "Launcher.exe");
                runAppLauncherStartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                runAppLauncherStartInfo.CreateNoWindow = true;

                Process.Start(runAppLauncherStartInfo);
            }
            base.OnClosed(e);
        }
		public static void Show()
		{
			if (connectionWindow == null)
			{
				terminalWasOpenOnAppClose = false;
				string windowSize = UserSettings.Instance.get(TerminalWindowSizeKey);
				int width = 400;
				int height = 300;
				if (windowSize != null && windowSize != "")
				{
					string[] sizes = windowSize.Split(',');
					width = Math.Max(int.Parse(sizes[0]), (int)minSize.x);
					height = Math.Max(int.Parse(sizes[1]), (int)minSize.y);
				}

				connectionWindow = new TerminalWindow(width, height);
				connectionWindow.Closed += (parentSender, e) =>
				{
					connectionWindow = null;
				};

				// start with the assumption we are open and only change this is we see it close
				UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, true);
			}
			else
			{
				connectionWindow.BringToFront();
			}
		}
        public static void Show()
        {
            if (connectionWindow == null)
            {
                terminalWasOpenOnAppClose = false;
                string windowSize = UserSettings.Instance.get(TerminalWindowSizeKey);
                int    width      = 400;
                int    height     = 300;
                if (windowSize != null && windowSize != "")
                {
                    string[] sizes = windowSize.Split(',');
                    width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x);
                    height = Math.Max(int.Parse(sizes[1]), (int)minSize.y);
                }

                connectionWindow         = new TerminalWindow(width, height);
                connectionWindow.Closed += (parentSender, e) =>
                {
                    connectionWindow = null;
                };

                // start with the assumption we are open and only change this is we see it close
                UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, true);
            }
            else
            {
                connectionWindow.BringToFront();
            }
        }
        public override void OnLoad(EventArgs args)
        {
            foreach (string arg in commandLineArgs)
            {
                string argExtension = Path.GetExtension(arg).ToUpper();
                if (argExtension.Length > 1 &&
                    MeshFileIo.ValidFileExtensions().Contains(argExtension))
                {
                    QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                }
            }

            TerminalWindow.ShowIfLeftOpen();

            ApplicationController.Instance.OnLoadActions();

#if false
            {
                SystemWindow releaseNotes        = new SystemWindow(640, 480);
                string       releaseNotesFile    = Path.Combine("C:/Users/LarsBrubaker/Downloads", "test1.html");
                string       releaseNotesContent = StaticData.Instance.ReadAllText(releaseNotesFile);
                HtmlWidget   content             = new HtmlWidget(releaseNotesContent, RGBA_Bytes.Black);
                content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop));
                content.VAnchor        |= VAnchor.ParentTop;
                content.BackgroundColor = RGBA_Bytes.White;
                releaseNotes.AddChild(content);
                releaseNotes.BackgroundColor = RGBA_Bytes.Cyan;
                UiThread.RunOnIdle((state) =>
                {
                    releaseNotes.ShowAsSystemWindow();
                }, 1);
            }
#endif
        }
        public override void OnDraw(Graphics2D graphics2D)
        {
            totalDrawTime.Restart();
            GuiWidget.DrawCount = 0;
            using (new PerformanceTimer("Draw Timer", "MC Draw"))
            {
                base.OnDraw(graphics2D);
            }
            totalDrawTime.Stop();

            millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds);

            if (ShowMemoryUsed)
            {
                long memory = GC.GetTotalMemory(false);
                this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, widgetsDrawn = {7}".FormatWith(memory, millisecondTimer.GetAverage(), drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount);
                if (DoCGCollectEveryDraw)
                {
                    GC.Collect();
                }
            }

            if (firstDraw)
            {
                //Task.Run((Action)AutomationTest);
                UiThread.RunOnIdle(DoAutoConnectIfRequired);

                firstDraw = false;
                foreach (string arg in commandLineArgs)
                {
                    string argExtension = Path.GetExtension(arg).ToUpper();
                    if (argExtension.Length > 1 &&
                        MeshFileIo.ValidFileExtensions().Contains(argExtension))
                    {
                        QueueData.Instance.AddItem(new PrintItemWrapper(new DataStorage.PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                    }
                }

                TerminalWindow.ShowIfLeftOpen();

                if (AfterFirstDraw != null)
                {
                    AfterFirstDraw();
                }

                UiThread.RunOnIdle(() =>
                {
                    //StyledMessageBox.ShowMessageBox(null, "message that is long and wraps. message that is long and wraps. message that is long and wraps." , "caption", StyledMessageBox.MessageType.YES_NO);
                    // show a dialog to tell the user there is an update
                });
            }

            //msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
            //msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
        }
        public override void OnDraw(Graphics2D graphics2D)
        {
            totalDrawTime.Restart();
            GuiWidget.DrawCount = 0;
            base.OnDraw(graphics2D);
            totalDrawTime.Stop();

            millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds);

            if (ShowMemoryUsed)
            {
                long memory = GC.GetTotalMemory(false);
                this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, drawCount = {7}".FormatWith(memory, millisecondTimer.GetAverage(), drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount);
                if (DoCGCollectEveryDraw)
                {
                    GC.Collect();
                }
            }

            if (firstDraw)
            {
                UiThread.RunOnIdle(DoAutoConnectIfRequired);

                firstDraw = false;
                foreach (string arg in commandLineArgs)
                {
                    string argExtension = Path.GetExtension(arg).ToUpper();
                    if (argExtension.Length > 1 &&
                        MeshFileIo.ValidFileExtensions().Contains(argExtension))
                    {
                        QueueData.Instance.AddItem(new PrintItemWrapper(new DataStorage.PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                    }
                }

                TerminalWindow.ShowIfLeftOpen();

#if false
                foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
                {
                    if (creatorInfo.description.Contains("Image"))
                    {
                        creatorInfo.functionToLaunchCreator(null, null);
                    }
                }
#endif
            }

            //msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
            //msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
        }
 public static void Show()
 {
     if (connectionWindow == null)
     {
         connectionWindow         = new TerminalWindow();
         connectionWindow.Closed += (parentSender, e) =>
         {
             connectionWindow = null;
         };
     }
     else
     {
         connectionWindow.BringToFront();
     }
 }
Exemple #8
0
        public override void OnLoad(EventArgs args)
        {
            foreach (string arg in commandLineArgs)
            {
                string argExtension = Path.GetExtension(arg).ToUpper();
                if (argExtension.Length > 1 &&
                    MeshFileIo.ValidFileExtensions().Contains(argExtension))
                {
                    QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                }
            }

            TerminalWindow.ShowIfLeftOpen();

            ApplicationController.Instance.OnLoadActions();

            //HtmlWindowTest();

            IsLoading = false;
        }
        public override void OnDraw(Graphics2D graphics2D)
        {
            totalDrawTime.Restart();
            GuiWidget.DrawCount = 0;
            using (new PerformanceTimer("Draw Timer", "MC Draw"))
            {
                base.OnDraw(graphics2D);
            }
            totalDrawTime.Stop();

            millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds);

            if (ShowMemoryUsed)
            {
                long memory = GC.GetTotalMemory(false);
                this.Title = "Allocated = {0:n0} : {1:000}ms, d{2} Size = {3}x{4}, onIdle = {5:00}:{6:00}, widgetsDrawn = {7}".FormatWith(memory, millisecondTimer.GetAverage(), drawCount++, this.Width, this.Height, UiThread.CountExpired, UiThread.Count, GuiWidget.DrawCount);
                if (DoCGCollectEveryDraw)
                {
                    GC.Collect();
                }
            }

            if (firstDraw)
            {
                firstDraw = false;
                foreach (string arg in commandLineArgs)
                {
                    string argExtension = Path.GetExtension(arg).ToUpper();
                    if (argExtension.Length > 1 &&
                        MeshFileIo.ValidFileExtensions().Contains(argExtension))
                    {
                        QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg))));
                    }
                }

                TerminalWindow.ShowIfLeftOpen();

#if false
                {
                    SystemWindow releaseNotes        = new SystemWindow(640, 480);
                    string       releaseNotesFile    = Path.Combine("C:/Users/LarsBrubaker/Downloads", "test1.html");
                    string       releaseNotesContent = StaticData.Instance.ReadAllText(releaseNotesFile);
                    HtmlWidget   content             = new HtmlWidget(releaseNotesContent, RGBA_Bytes.Black);
                    content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop));
                    content.VAnchor        |= VAnchor.ParentTop;
                    content.BackgroundColor = RGBA_Bytes.White;
                    releaseNotes.AddChild(content);
                    releaseNotes.BackgroundColor = RGBA_Bytes.Cyan;
                    UiThread.RunOnIdle((state) =>
                    {
                        releaseNotes.ShowAsSystemWindow();
                    }, 1);
                }
#endif

                AfterFirstDraw?.Invoke();

                if (false && UserSettings.Instance.get("SoftwareLicenseAccepted") != "true")
                {
                    UiThread.RunOnIdle(() => WizardWindow.Show <LicenseAgreementPage>("SoftwareLicense", "Software License Agreement"));
                }

                if (!ProfileManager.Instance.ActiveProfiles.Any())
                {
                    // Start the setup wizard if no profiles exist
                    UiThread.RunOnIdle(() => WizardWindow.Show());
                }
            }

            //msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
            //msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
        }