コード例 #1
0
        private static void HtmlWindowTest()
        {
            try
            {
                SystemWindow htmlTestWindow = new SystemWindow(640, 480);
                string       htmlContent    = "";
                if (true)
                {
                    string releaseNotesFile = Path.Combine("C:\\Users\\lbrubaker\\Downloads", "test1.html");
                    htmlContent = File.ReadAllText(releaseNotesFile);
                }
                else
                {
                    WebClient webClient = new WebClient();
                    htmlContent = webClient.DownloadString("http://www.matterhackers.com/s/store?q=pla");
                }

                HtmlWidget content = new HtmlWidget(htmlContent, RGBA_Bytes.Black);
                content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop));
                content.VAnchor        |= VAnchor.ParentTop;
                content.BackgroundColor = RGBA_Bytes.White;
                htmlTestWindow.AddChild(content);
                htmlTestWindow.BackgroundColor = RGBA_Bytes.Cyan;
                UiThread.RunOnIdle((state) =>
                {
                    htmlTestWindow.ShowAsSystemWindow();
                }, 1);
            }
            catch
            {
                int stop = 1;
            }
        }
コード例 #2
0
        public static Task ShowWindowAndExecuteTests(SystemWindow initialSystemWindow, AutomationTest testMethod, double secondsToTestFailure = 30, string imagesDirectory = "", Action closeWindow = null)
        {
            var testRunner = new AutomationRunner(InputMethod, DrawSimulatedMouse, imagesDirectory);

            var resetEvent = new AutoResetEvent(false);

            // On load, release the reset event
            initialSystemWindow.Load += (s, e) =>
            {
                resetEvent.Set();
            };

            int testTimeout = (int)(1000 * secondsToTestFailure);
            var timer       = Stopwatch.StartNew();

            bool testTimedOut = false;

            // Start two tasks, the timeout and the test method. Block in the test method until the first draw
            Task <Task> task = Task.WhenAny(
                Task.Delay(testTimeout),
                Task.Run(() =>
            {
                // Wait until the first system window draw before running the test method, up to the timeout
                resetEvent.WaitOne(testTimeout);

                return(testMethod(testRunner));
            }));

            // Once either the timeout or the test method has completed, store if a timeout occurred and shutdown the SystemWindow
            task.ContinueWith(innerTask =>
            {
                long elapsedTime = timer.ElapsedMilliseconds;
                testTimedOut     = elapsedTime >= testTimeout;

                // Invoke the callers close implementation or fall back to CloseOnIdle
                if (closeWindow != null)
                {
                    closeWindow();
                }
                else
                {
                    initialSystemWindow.CloseOnIdle();
                }
            });

            // Main thread blocks here until released via CloseOnIdle above
            initialSystemWindow.ShowAsSystemWindow();

            // Wait for CloseOnIdle to complete
            testRunner.WaitFor(() => initialSystemWindow.HasBeenClosed);

            if (testTimedOut)
            {
                // Throw an exception for test timeouts
                throw new TimeoutException("TestMethod timed out");
            }

            // After the system window is closed return the task and any exception to the calling context
            return(task?.Result ?? Task.CompletedTask);
        }
コード例 #3
0
        public override void OnDraw(Graphics2D graphics2D)
        {
#if false
            if (firstDraw)
            {
                firstDraw = false;
                SystemWindow testAbout = new SystemWindow(600, 300);

                string     path     = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "AboutPage.html");
                string     htmlText = File.ReadAllText(path);
                HTMLCanvas canvas   = new HTMLCanvas(htmlText);
                canvas.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                canvas.AddReplacementString("textColor", RGBA_Bytes.White.GetAsHTMLString());

                canvas.AnchorAll();
                testAbout.AddChild(canvas);

                testAbout.ShowAsSystemWindow();
            }
#endif

            graphics2D.FillRectangle(new RectangleDouble(0, this.Height - 1, this.Width, this.Height), RGBA_Bytes.White);
            base.OnDraw(graphics2D);
        }
コード例 #4
0
        private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState)
        {
            PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();

            LevelWizardBase printLevelWizardWindow;

            switch (levelingData.CurrentPrinterLevelingSystem)
            {
            case PrintLevelingData.LevelingSystem.Probe2Points:
                printLevelWizardWindow = new LevelWizard2Point(runningState);
                break;

            case PrintLevelingData.LevelingSystem.Probe3Points:
                printLevelWizardWindow = new LevelWizard3Point(runningState);
                break;

            case PrintLevelingData.LevelingSystem.Probe7PointRadial:
                printLevelWizardWindow = new LevelWizard7PointRadial(runningState);
                break;

            case PrintLevelingData.LevelingSystem.Probe13PointRadial:
                printLevelWizardWindow = new LevelWizard13PointRadial(runningState);
                break;

            default:
                throw new NotImplementedException();
            }

            printLevelWizardWindow.ShowAsSystemWindow();
            return(printLevelWizardWindow);
        }
コード例 #5
0
        private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState)
        {
            // turn off print leveling
            ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(false);
            // clear any data that we are going to be acquiring (sampled positions, after z home offset)
            PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();

            levelingData.SampledPositions.Clear();
            ActiveSliceSettings.Instance.SetValue(SettingsKey.baby_step_z_offset, "0");

            ApplicationController.Instance.ReloadAdvancedControlsPanel();

            LevelWizardBase printLevelWizardWindow;

            switch (levelingData.CurrentPrinterLevelingSystem)
            {
            case PrintLevelingData.LevelingSystem.Probe3Points:
                printLevelWizardWindow = new LevelWizard3Point(runningState);
                break;

            case PrintLevelingData.LevelingSystem.Probe7PointRadial:
                printLevelWizardWindow = new LevelWizard7PointRadial(runningState);
                break;

            case PrintLevelingData.LevelingSystem.Probe13PointRadial:
                printLevelWizardWindow = new LevelWizard13PointRadial(runningState);
                break;

            default:
                throw new NotImplementedException();
            }

            printLevelWizardWindow.ShowAsSystemWindow();
            return(printLevelWizardWindow);
        }
コード例 #6
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();

#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
        }
コード例 #7
0
        public void ShowContentInWindow()
        {
            if (widgetWithPopContent.HasBeenClosed)
            {
                if (systemWindowWithPopContent != null)
                {
                    systemWindowWithPopContent.Close();
                }

                return;
            }

            if (systemWindowWithPopContent == null)
            {
                // So the window is open now only change this is we close it.
                UserSettings.Instance.Fields.SetBool(WindowLeftOpenKey, true);

                string windowSize = UserSettings.Instance.get(WindowSizeKey);
                int    width      = 600;
                int    height     = 400;
                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);
                }

                systemWindowWithPopContent                   = new SystemWindow(width, height);
                systemWindowWithPopContent.Padding           = new BorderDouble(3);
                systemWindowWithPopContent.Title             = windowTitle;
                systemWindowWithPopContent.AlwaysOnTopOfMain = true;
                systemWindowWithPopContent.BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                systemWindowWithPopContent.Closing          += SystemWindow_Closing;
                if (widgetWithPopContent.Children.Count == 1)
                {
                    GuiWidget child = widgetWithPopContent.Children[0];
                    widgetWithPopContent.RemoveChild(child);
                    child.ClearRemovedFlag();
                    widgetWithPopContent.AddChild(CreateContentForEmptyControl());
                    systemWindowWithPopContent.AddChild(child);
                }
                systemWindowWithPopContent.ShowAsSystemWindow();

                systemWindowWithPopContent.MinimumSize = minSize;
                string desktopPosition = UserSettings.Instance.get(PositionKey);
                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);
                    systemWindowWithPopContent.DesktopPosition = new Point2D(xpos, ypos);
                }
            }
            else
            {
                systemWindowWithPopContent.BringToFront();
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            var demoWidget = new PolygonClippingDemo();

            var systemWindow = new SystemWindow(640, 520);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #9
0
        public static void Main(string[] args)
        {
            var demoWidget = new alpha_mask2_application();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #10
0
ファイル: gradients.cs プロジェクト: larsbrubaker/agg-sharp
        public static void Main(string[] args)
        {
            var demoWidget = new Gradients();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #11
0
        public static void Main(string[] args)
        {
            var demoWidget = new FloodFillDemo();

            var systemWindow = new SystemWindow(600, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #12
0
        public static void Main(string[] args)
        {
            var demoWidget = new line_patterns_application();

            var systemWindow = new SystemWindow(500, 450);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #13
0
        public static void Main(string[] args)
        {
            var demoWidget = new gouraud_application();

            var systemWindow = new SystemWindow(400, 300);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #14
0
        public static void Main(string[] args)
        {
            Clipboard.SetSystemClipboard(new WindowsFormsClipboard());

            var systemWindow = new SystemWindow(640, 480);

            systemWindow.Title = "Demo Runner";
            systemWindow.AddChild(new DemoRunner());
            systemWindow.ShowAsSystemWindow();
        }
コード例 #15
0
        public static void Main(string[] args)
        {
            var demoWidget = new image_filters();

            var systemWindow = new SystemWindow(305, 325);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #16
0
        public static void Main(string[] args)
        {
            var demoWidget = new MomsSolitaire();

            var systemWindow = new SystemWindow(691, 390);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #17
0
        public static void Main(string[] args)
        {
            var demoWidget = new blur();

            var systemWindow = new SystemWindow(440, 330);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #18
0
        public static void Main(string[] args)
        {
            var demoWidget = new trans_curve1_application();

            var systemWindow = new SystemWindow(600, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #19
0
        public static void Main(string[] args)
        {
            var demoWidget = new rounded_rect_application();

            var systemWindow = new SystemWindow(600, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #20
0
        public static void Main(string[] args)
        {
            var demoWidget = new image_resample();

            var systemWindow = new SystemWindow(600, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #21
0
        public override void OnLoad(EventArgs args)
        {
            if (Application.MiniTouchScreen.Enabled)
            {
                var miniTouchScreen = new SystemWindow(800, 480);

                miniTouchScreen.ShowAsSystemWindow();
            }

            base.OnLoad(args);
        }
コード例 #22
0
        public static void Main(string[] args)
        {
            var demoWidget = new FontHinter();

            var systemWindow = new SystemWindow(440, 330);

            systemWindow.PixelType = SystemWindow.PixelTypes.Depth24;
            systemWindow.Title     = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #23
0
        public MatterControlApplication(double width, double height)
            : base(width, height)
        {
            this.commandLineArgs = Environment.GetCommandLineArgs();;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            //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)";

            PrinterCommunication.Instance.Initialize();
            UiThread.RunOnIdle(CheckOnPrinter);

            ShowAsSystemWindow();
        }
コード例 #24
0
        public static void Main(string[] args)
        {
            //AggContext.Init(embeddedResourceName: "lion_outline.config.json");

            var demoWidget = new lion_outline();

            var systemWindow = new SystemWindow(512, 512);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #25
0
        public static void Main(string[] args)
        {
            Clipboard.SetSystemClipboard(new WindowsFormsClipboard());

            var demoWidget = new RenderTriangles();

            var systemWindow = new SystemWindow(800, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #26
0
        public static void Main(string[] args)
        {
            MatterHackers.Agg.Tests.AggDrawingTests.RunAllTests();

            var demoWidget = new ComponentRendering();

            var systemWindow = new SystemWindow(320, 320);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #27
0
        public static Task ShowWindowAndExecuteTests(SystemWindow initialSystemWindow, AutomationTest testMethod, double secondsToTestFailure, string imagesDirectory = "", InputType inputType = InputType.Native)
        {
            var testRunner = new AutomationRunner(imagesDirectory, inputType);

            AutoResetEvent resetEvent = new AutoResetEvent(false);

            bool firstDraw = true;

            initialSystemWindow.AfterDraw += (sender, e) =>
            {
                if (firstDraw)
                {
                    firstDraw = false;
                    resetEvent.Set();
                }
            };

            int testTimeout = (int)(1000 * secondsToTestFailure);
            var timer       = Stopwatch.StartNew();

            // Start two tasks, the timeout and the test method. Block in the test method until the first draw
            Task <Task> task = Task.WhenAny(
                Task.Delay(testTimeout),
                Task.Run(() =>
            {
                // Wait until the first system window draw before running the test method
                resetEvent.WaitOne();

                return(testMethod(testRunner));
            }));

            // Once either the timeout or the test method has completed, reassign the task/result for timeout errors and shutdown the SystemWindow
            task.ContinueWith((innerTask) =>
            {
                long elapsedTime = timer.ElapsedMilliseconds;

                // Create an exception Task for test timeouts
                if (elapsedTime >= testTimeout)
                {
                    task = new Task <Task>(() => { throw new TimeoutException("TestMethod timed out"); });
                    task.RunSynchronously();
                }

                initialSystemWindow.CloseOnIdle();
            });

            // Main thread blocks here until released via CloseOnIdle above
            initialSystemWindow.ShowAsSystemWindow();

            // After the system window is closed return the task and any exception to the calling context
            return(task?.Result ?? Task.FromResult(0));
        }
コード例 #28
0
        public static void Main(string[] args)
        {
            // Init agg with our OpenGL window definition
            //AggContext.Init(embeddedResourceName: "lion.config.json");

            var demoWidget = new Lion();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #29
0
		public void CreateWidgetAndRunInWindow(SystemWindow.PixelTypes bitDepth = SystemWindow.PixelTypes.Depth32, RenderSurface surfaceType = RenderSurface.Bitmap)
		{
			AppWidgetInfo appWidgetInfo = GetAppParameters();
			SystemWindow systemWindow = new SystemWindow(appWidgetInfo.width, appWidgetInfo.height);
			systemWindow.PixelType = bitDepth;
			systemWindow.Title = appWidgetInfo.title;
			if (surfaceType == RenderSurface.OpenGL)
			{
				systemWindow.UseOpenGL = true;
			}
			systemWindow.AddChild(NewWidget());
			systemWindow.ShowAsSystemWindow();
		}
コード例 #30
0
        public AboutWidget()
        {
            this.HAnchor = HAnchor.ParentLeftRight;
            this.VAnchor = VAnchor.ParentTop;

            this.Padding         = new BorderDouble(5);
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            FlowLayoutWidget customInfoTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            customInfoTopToBottom.Name    = "AboutPageCustomInfo";
            customInfoTopToBottom.HAnchor = HAnchor.ParentLeftRight;
            customInfoTopToBottom.VAnchor = VAnchor.Max_FitToChildren_ParentHeight;
            customInfoTopToBottom.Padding = new BorderDouble(5, 10, 5, 0);

            if (UserSettings.Instance.IsTouchScreen)
            {
                customInfoTopToBottom.AddChild(new UpdateControlView());
            }

            //AddMatterHackersInfo(customInfoTopToBottom);
            customInfoTopToBottom.AddChild(new GuiWidget(1, 10));

            string aboutHtmlFile = Path.Combine("OEMSettings", "AboutPage.html");
            string htmlContent   = StaticData.Instance.ReadAllText(aboutHtmlFile);

#if false // test
            {
                SystemWindow releaseNotes        = new SystemWindow(640, 480);
                string       releaseNotesFile    = Path.Combine("OEMSettings", "ReleaseNotes.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

            HtmlWidget htmlWidget = new HtmlWidget(htmlContent, ActiveTheme.Instance.PrimaryTextColor);

            customInfoTopToBottom.AddChild(htmlWidget);

            this.AddChild(customInfoTopToBottom);
        }
コード例 #31
0
        public static void Main(string[] args)
        {
            // Init agg with our OpenGL window definition
            //AggContext.Init(embeddedResourceName: "lion.config.json");
            AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";

            var demoWidget = new Lion();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
コード例 #32
0
		private AutomationTesterHarness(SystemWindow initialSystemWindow, Action<AutomationTesterHarness> functionContainingTests, double secondsToTestFailure)
		{
			bool firstDraw = true;
			initialSystemWindow.DrawAfter += (sender, e) =>
			{
				if (firstDraw)
				{
					Task.Run(() => CloseAfterTime(initialSystemWindow, secondsToTestFailure));

					firstDraw = false;
					Task.Run(() =>
					{
						functionContainingTests(this);

						initialSystemWindow.CloseOnIdle();
					});
				}
			};

			initialSystemWindow.ShowAsSystemWindow();
		}