public static MatterControlApplication CreateInstance(int overrideWidth = -1, int overrideHeight = -1)
        {
            int width  = 0;
            int height = 0;

            // check if the app has a size alread set
            string windowSize = ApplicationSettings.Instance.get(ApplicationSettingsKey.WindowSize);

            if (windowSize != null && windowSize != "")
            {
                // try and open our window matching the last size that we had for it.
                string[] sizes = windowSize.Split(',');
                width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
                height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
            }
            else             // try to set it to a big size or the min size
            {
                Point2D desktopSize = OsInformation.DesktopSize;

                if (overrideWidth != -1)
                {
                    width = overrideWidth;
                }
                else                 // try to set it to a good size
                {
                    if (width < desktopSize.x)
                    {
                        width = 1280;
                    }
                }

                if (overrideHeight != -1)
                {
                    height = overrideHeight;
                }
                else
                {
                    if (height < desktopSize.y)
                    {
                        height = 720;
                    }
                }
            }

            using (new PerformanceTimer("Startup", "Total"))
            {
                instance = new MatterControlApplication(width, height);

                if (instance.DesktopPosition == new Point2D())
                {
                    Point2D desktopSize = OsInformation.DesktopSize;

                    // Now try and center the window. If this is saved it will got overridden
                    instance.DesktopPosition = new Point2D((desktopSize.x - instance.Width) / 2, (desktopSize.y - instance.Height) / 2);
                }
            }

            return(instance);
        }
Пример #2
0
        public static MatterControlApplication CreateInstance(int overrideWidth = -1, int overrideHeight = -1)
        {
            int width  = 0;
            int height = 0;

            if (UserSettings.Instance.IsTouchScreen)
            {
                minSize = new Vector2(800, 480);
            }

            // check if the app has a size already set
            string windowSize = ApplicationSettings.Instance.get(ApplicationSettingsKey.WindowSize);

            if (windowSize != null && windowSize != "")
            {
                // try and open our window matching the last size that we had for it.
                string[] sizes = windowSize.Split(',');

                width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
                height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
            }
            else             // try to set it to a big size or the min size
            {
                Point2D desktopSize = OsInformation.DesktopSize;

                if (overrideWidth != -1)
                {
                    width = overrideWidth;
                }
                else                 // try to set it to a good size
                {
                    if (width < desktopSize.x)
                    {
                        width = 1280;
                    }
                }

                if (overrideHeight != -1)
                {
                    height = overrideHeight;
                }
                else
                {
                    if (height < desktopSize.y)
                    {
                        height = 720;
                    }
                }
            }

            using (new PerformanceTimer("Startup", "Total"))
            {
                instance = new MatterControlApplication(width, height);
            }

            return(instance);
        }
        public static void Main()
        {
            // Make sure we have the right woring directory as we assume everything relative to the executable.
            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));

            Datastore.Instance.Initialize();

            MatterControlApplication app = MatterControlApplication.Instance;
        }
Пример #4
0
        private void ConditionalyCloseNow(bool continueWithShutdown)
        {
            if (continueWithShutdown)
            {
                PrinterConnectionAndCommunication.Instance.Disable();

                MatterControlApplication app = MatterControlApplication.Instance;
                app.RestartOnClose = false;
                app.Close();
            }
        }
Пример #5
0
 public static void CheckKnownAssemblyConditionalCompSymbols()
 {
     MatterControlApplication.AssertDebugNotDefined();
     GCodeFile.AssertDebugNotDefined();
     MatterHackers.Agg.Graphics2D.AssertDebugNotDefined();
     MatterHackers.Agg.UI.SystemWindow.AssertDebugNotDefined();
     MatterHackers.Agg.ImageProcessing.InvertLightness.AssertDebugNotDefined();
     MatterHackers.Localizations.TranslationMap.AssertDebugNotDefined();
     MatterHackers.MarchingSquares.MarchingSquaresByte.AssertDebugNotDefined();
     MatterHackers.MatterControl.PluginSystem.MatterControlPlugin.AssertDebugNotDefined();
     MatterHackers.MatterSlice.MatterSlice.AssertDebugNotDefined();
     MatterHackers.RenderOpenGl.GLMeshTrianglePlugin.AssertDebugNotDefined();
 }
Пример #6
0
 private void RestartApplication()
 {
     UiThread.RunOnIdle((state) =>
     {
         //horrible hack - to be replaced
         GuiWidget parent = this;
         while (parent as MatterControlApplication == null)
         {
             parent = parent.Parent;
         }
         MatterControlApplication app = parent as MatterControlApplication;
         app.RestartOnClose           = true;
         app.Close();
     });
 }
Пример #7
0
 bool exit_Click()
 {
     UiThread.RunOnIdle((state) =>
     {
         GuiWidget parent = this;
         while (parent as MatterControlApplication == null)
         {
             parent = parent.Parent;
         }
         MatterControlApplication app = parent as MatterControlApplication;
         app.RestartOnClose           = false;
         app.Close();
     });
     return(true);
 }
Пример #8
0
 protected override IEnumerable <MenuItemAction> GetMenuActions()
 {
     return(new List <MenuItemAction>
     {
         new MenuItemAction("Add Printer".Localize(), () => WizardWindow.Show()),
         new MenuItemAction("Add File To Queue".Localize(), importFile_Click),
         new MenuItemAction("Redeem Design Code".Localize(), () => RedeemDesignCode?.Invoke(this, null)),
         new MenuItemAction("Enter Share Code".Localize(), () => EnterShareCode?.Invoke(this, null)),
         new MenuItemAction("------------------------", null),
         new MenuItemAction("Exit".Localize(), () =>
         {
             MatterControlApplication app = this.Parents <MatterControlApplication>().FirstOrDefault();
             app.RestartOnClose = false;
             app.Close();
         })
     });
 }
        public static MatterControlApplication CreateInstance(out bool showWindow)
        {
            // try and open our window matching the last size that we had for it.
            string windowSize = ApplicationSettings.Instance.get("WindowSize");
            int    width      = 1280;
            int    height     = 720;

            if (windowSize != null && windowSize != "")
            {
                string[] sizes = windowSize.Split(',');
                width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
                height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
            }

            instance = new MatterControlApplication(width, height, out showWindow);

            return(instance);
        }
        private void ConditionalyCloseNow(bool continueWithShutdown)
        {
            // Response received, cecord that we are not waiting anymore.
            closeMessageBoxIsOpen = false;
            if (continueWithShutdown)
            {
                closeHasBeenConfirmed = true;
                bool printingFromSdCard = PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.PrintingFromSd ||
                                          (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Paused &&
                                           PrinterConnectionAndCommunication.Instance.PrePauseCommunicationState == PrinterConnectionAndCommunication.CommunicationStates.PrintingFromSd);
                if (!printingFromSdCard)
                {
                    PrinterConnectionAndCommunication.Instance.Disable();
                }

                MatterControlApplication app = MatterControlApplication.Instance;
                app.RestartOnClose = false;
                app.Close();
            }
        }
Пример #11
0
        public static MatterControlApplication CreateInstance()
        {
            // try and open our window matching the last size that we had for it.
            string windowSize = ApplicationSettings.Instance.get("WindowSize");
            int    width      = 1280;
            int    height     = 720;

            if (windowSize != null && windowSize != "")
            {
                string[] sizes = windowSize.Split(',');
                width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
                height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
            }

            using (new PerformanceTimer("Startup", "Total"))
            {
                instance = new MatterControlApplication(width, height);
            }

            return(instance);
        }
 protected override IEnumerable <MenuItemAction> GetMenuActions()
 {
     return(new List <MenuItemAction>
     {
         // TODO: Helper while building printing window prototype... remove once finalized
         new MenuItemAction("Printing Window...".Localize(), () => PrintingWindow.Show()),
         new MenuItemAction("------------------------", null),
         new MenuItemAction("Add Printer".Localize(), AddPrinter_Click),
         new MenuItemAction("Import Printer".Localize(), ImportPrinter),
         new MenuItemAction("Add File To Queue".Localize(), importFile_Click),
         new MenuItemAction("Redeem Design Code".Localize(), () => ApplicationController.Instance.RedeemDesignCode?.Invoke()),
         new MenuItemAction("Enter Share Code".Localize(), () => ApplicationController.Instance.EnterShareCode?.Invoke()),
         new MenuItemAction("------------------------", null),
         new MenuItemAction("Exit".Localize(), () =>
         {
             MatterControlApplication app = this.Parents <MatterControlApplication>().FirstOrDefault();
             app.RestartOnClose = false;
             app.Close();
         })
     });
 }
        public static void Main()
        {
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentCulture     = CultureInfo.InvariantCulture;

            // Make sure we have the right working directory as we assume everything relative to the executable.
            Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));

            Datastore.Instance.Initialize();

#if !DEBUG
            // Conditionally spin up error reporting if not on the Stable channel
            string channel = UserSettings.Instance.get("UpdateFeedType");
            if (string.IsNullOrEmpty(channel) || channel != "release" || OemSettings.Instance.WindowTitleExtra == "Experimental")
#endif
            {
                System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException       += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            }

            MatterControlApplication app = MatterControlApplication.Instance;
        }
Пример #14
0
        private bool exit_Click()
        {
            UiThread.RunOnIdle(() =>
            {
                GuiWidget parent = this;
                while (parent as MatterControlApplication == null)
                {
                    parent = parent.Parent;
                }

                if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
                {
                    StyledMessageBox.ShowMessageBox(null, cannotExitWhileActiveMessage, cannotExitWhileActiveTitle);
                }
                else
                {
                    MatterControlApplication app = parent as MatterControlApplication;
                    app.RestartOnClose           = false;
                    app.Close();
                }
            });
            return(true);
        }
		public static MatterControlApplication CreateInstance(out bool showWindow)
		{
			// try and open our window matching the last size that we had for it.
			string windowSize = ApplicationSettings.Instance.get("WindowSize");
			int width = 1280;
			int height = 720;
			if (windowSize != null && windowSize != "")
			{
				string[] sizes = windowSize.Split(',');
				width = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
				height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
			}

            using (new PerformanceTimer("Startup", "Total"))
            {
                instance = new MatterControlApplication(width, height, out showWindow);
            }

			return instance;
		}
		public static MatterControlApplication CreateInstance(int overrideWidth = -1, int overrideHeight = -1)
		{
			int width = 0;
			int height = 0;

			// check if the app has a size alread set
			string windowSize = ApplicationSettings.Instance.get(ApplicationSettingsKey.WindowSize);
			if (windowSize != null && windowSize != "")
			{
				// try and open our window matching the last size that we had for it.
				string[] sizes = windowSize.Split(',');
				width = Math.Max(int.Parse(sizes[0]), (int)minSize.x + 1);
				height = Math.Max(int.Parse(sizes[1]), (int)minSize.y + 1);
			}
			else // try to set it to a big size or the min size
			{
				Point2D desktopSize = OsInformation.DesktopSize;

				if (overrideWidth != -1)
				{
					width = overrideWidth;
				}
				else // try to set it to a good size
				{
					if (width < desktopSize.x)
					{
						width = 1280;
					}
				}

				if (overrideHeight != -1)
				{
					height = overrideHeight;
				}
				else
				{
					if (height < desktopSize.y)
					{
						height = 720;
					}
				}
			}

			using (new PerformanceTimer("Startup", "Total"))
			{
				instance = new MatterControlApplication(width, height);

				if (instance.DesktopPosition == new Point2D())
				{
					Point2D desktopSize = OsInformation.DesktopSize;

					// Now try and center the window. If this is saved it will got overridden
					instance.DesktopPosition = new Point2D((desktopSize.x - instance.Width) / 2, (desktopSize.y - instance.Height) / 2);
				}
			}

			return instance;
		}