protected void SetUpFormsWindow(AbstractOsMappingWidget app, SystemWindow childSystemWindow) { aggAppWidget = (WidgetForWindowsFormsAbstract)app; this.AllowDrop = true; if (File.Exists("application.ico")) { try { this.Icon = new System.Drawing.Icon("application.ico"); } catch (System.ComponentModel.Win32Exception ex) { if (ex.NativeErrorCode != 0) { throw; } } } else if (File.Exists("../MonoBundle/StaticData/application.ico")) { try { this.Icon = new System.Drawing.Icon("../MonoBundle/StaticData/application.ico"); } catch (System.ComponentModel.Win32Exception ex) { if (ex.NativeErrorCode != 0) { throw; } } } }
public AbstractOsMappingWidget CreateSurface(SystemWindow childSystemWindow) { AbstractOsMappingWidget newSurface = new WidgetForWindowsFormsBitmap(childSystemWindow); ((WidgetForWindowsFormsBitmap)newSurface).Init(childSystemWindow); return newSurface; }
public override void ShowSystemWindow(SystemWindow systemWindow) { bool firstWindow = false; if (factoryToUse == null) { if (systemWindow.UseOpenGL) { factoryToUse = new WindowsFormsOpenGLFactory(); } else { factoryToUse = new WindowsFormsBitmapFactory(); } firstWindow = true; // When our top most window closes reset this so we can make a window in the future. systemWindow.Closed += (sender, e) => { factoryToUse = null; }; } AbstractOsMappingWidget osMappingWindow = factoryToUse.CreateSurface(systemWindow); osMappingWindow.Caption = systemWindow.Title; osMappingWindow.AddChild(systemWindow); osMappingWindow.MinimumSize = systemWindow.MinimumSize; systemWindow.AbstractOsMappingWidget = osMappingWindow; if (pendingSetInitialDesktopPosition) { pendingSetInitialDesktopPosition = false; systemWindow.DesktopPosition = InitialDesktopPosition; } systemWindow.AnchorAll(); systemWindow.TitleChanged += new EventHandler(TitelChangedEventHandler); // and make sure the title is correct right now TitelChangedEventHandler(systemWindow, null); if (firstWindow) { osMappingWindow.Run(); } else { if (systemWindow.IsModal) { osMappingWindow.ShowModal(); } else { osMappingWindow.Show(); osMappingWindow.BringToFront(); } } }
public override void ShowSystemWindow(SystemWindow systemWindow) { bool haveInitializedMainWindow = false; if (OsMappingWidgetFactory.PrimaryOsMappingWidget != null) { haveInitializedMainWindow = true; } if (!haveInitializedMainWindow) { if (systemWindow.UseOpenGL) { OsMappingWidgetFactory.SetFactory(new WindowsFormsOpenGLFactory()); } else { OsMappingWidgetFactory.SetFactory(new WindowsFormsBitmapFactory()); } } AbstractOsMappingWidget windowsFormsTopWindow = OsMappingWidgetFactory.CreateOsMappingWidget(systemWindow); windowsFormsTopWindow.Caption = systemWindow.Title; windowsFormsTopWindow.AddChild(systemWindow); windowsFormsTopWindow.MinimumSize = systemWindow.MinimumSize; systemWindow.AbstractOsMappingWidget = windowsFormsTopWindow; if (pendingSetInitialDesktopPosition) { pendingSetInitialDesktopPosition = false; systemWindow.DesktopPosition = InitialDesktopPosition; } systemWindow.AnchorAll(); systemWindow.TitleChanged += new EventHandler(TitelChangedEventHandler); // and make sure the title is correct right now TitelChangedEventHandler(systemWindow, null); if (haveInitializedMainWindow) { if (systemWindow.IsModal) { windowsFormsTopWindow.ShowModal(); } else { windowsFormsTopWindow.Show(); } } else { windowsFormsTopWindow.Run(); } }
internal ToolTipManager(SystemWindow owner) { this.owner = owner; owner.MouseMove += (sender, e) => { mousePosition = e.Position; timeSinceLastMouseMove.Restart(); }; // Get the an idle loop up and running UiThread.RunOnIdle(CheckIfNeedToDisplayToolTip, .02); }
public WidgetForWindowsFormsAbstract(SystemWindow childSystemWindow) : base(childSystemWindow) { // If no platform specific Clipboard implementation has been initialized, fallback to the default // WindowsForms implementation if (!Clipboard.IsInitialized) { Clipboard.SetSystemClipboard(new WindowsFormsClipboard()); } Focus(); }
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(); }
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 (ActiveTheme.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); }
public static AbstractOsMappingWidget CreateOsMappingWidget(SystemWindow childSystemWindow) { if (factoryToUse == null) { throw new NotSupportedException("You must call 'SetGuiBackend' with a GuiFactory before you can create any surfaces"); } AbstractOsMappingWidget osMappingWidget = factoryToUse.CreateSurface(childSystemWindow); if (primaryOsMappingWidget == null) { primaryOsMappingWidget = osMappingWidget; } return osMappingWidget; }
public AbstractOsMappingWidget CreateSurface(SystemWindow childSystemWindow) { AbstractOsMappingWidget newSurface; switch (childSystemWindow.BitDepth) { case 24: case 32: newSurface = new WidgetForWindowsFormsOpenGL(childSystemWindow); break; default: throw new NotImplementedException(); } return newSurface; }
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false) : base(windowController, container) { { this.editMode = editMode; textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.borderWidth = 0; editButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.hoverTextColor = RGBA_Bytes.White; editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor; editButtonFactory.pressedTextColor = RGBA_Bytes.White; editButtonFactory.borderWidth = 0; editButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio; this.AnchorAll(); this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainer.AnchorAll(); mainContainer.Padding = new BorderDouble(3, 0, 3, 5); mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight); headerRow.HAnchor = HAnchor.ParentLeftRight; headerRow.Margin = new BorderDouble(0, 3, 0, 0); headerRow.Padding = new BorderDouble(0, 3, 0, 0); { string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration"); string chooseThreeDPrinterConfigFull = string.Format("{0}:", chooseThreeDPrinterConfigLabel); TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14); elementHeader.TextColor = this.defaultTextColor; elementHeader.HAnchor = HAnchor.ParentLeftRight; elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter; headerRow.AddChild(elementHeader); } FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight); editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay; editButtonRow.HAnchor = HAnchor.ParentLeftRight; editButtonRow.Margin = new BorderDouble(0, 3, 0, 0); editButtonRow.Padding = new BorderDouble(0, 3, 0, 0); Button enterLeaveEditModeButton; if (!this.editMode) { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true); enterLeaveEditModeButton.Click += EditModeOnLink_Click; } else { enterLeaveEditModeButton = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true); enterLeaveEditModeButton.Click += EditModeOffLink_Click; } editButtonRow.AddChild(enterLeaveEditModeButton); //To do - replace with scrollable widget FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); //ListBox printerListContainer = new ListBox(); { printerListContainer.HAnchor = HAnchor.ParentLeftRight; printerListContainer.VAnchor = VAnchor.ParentBottomTop; printerListContainer.Padding = new BorderDouble(3); printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; //Get a list of printer records and add them to radio button list foreach (Printer printer in GetAllPrinters()) { PrinterListItem printerListItem; if (this.editMode) { printerListItem = new PrinterListItemEdit(printer, this.windowController); } else { printerListItem = new PrinterListItemView(printer, this.windowController); } printerListContainer.AddChild(printerListItem); } } FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight); buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight; buttonContainer.Margin = new BorderDouble(0, 3); { closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close")); Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png"); addPrinterButton.Click += new EventHandler(AddConnectionLink_Click); Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh")); refreshListButton.Click += new EventHandler(EditModeOffLink_Click); GuiWidget spacer = new GuiWidget(); spacer.HAnchor = HAnchor.ParentLeftRight; //Add buttons to ButtonContainer buttonContainer.AddChild(addPrinterButton); if (!this.editMode) { buttonContainer.AddChild(refreshListButton); } buttonContainer.AddChild(spacer); buttonContainer.AddChild(closeButton); } mainContainer.AddChild(headerRow); mainContainer.AddChild(editButtonRow); mainContainer.AddChild(printerListContainer); mainContainer.AddChild(buttonContainer); this.AddChild(mainContainer); BindCloseButtonClick(); } }
public override Point2D GetDesktopPosition(SystemWindow systemWindow) { if (systemWindow.AbstractOsMappingWidget != null) { return systemWindow.AbstractOsMappingWidget.DesktopPosition; } return new Point2D(); }
public WidgetForWindowsFormsOpenGL(SystemWindow childSystemWindow) : base(childSystemWindow) { id = count++; WindowsFormsWindow = new WindowsFormsOpenGL(this, childSystemWindow); }
public WidgetForWindowsFormsBitmap(SystemWindow childSystemWindow) : base(childSystemWindow) { WindowsFormsWindow = new WindowsFormBitmap(this, childSystemWindow); }
public abstract void SetDesktopPosition(SystemWindow systemWindow, Point2D position);
public abstract void ShowSystemWindow(SystemWindow systemWindow);
public GuiWidget GetWidgetByName(string widgetName, out SystemWindow containingWindow, double secondsToWait = 0, SearchRegion searchRegion = null) { containingWindow = null; List<GetResults> getResults = GetWidgetsByName(widgetName, secondsToWait, searchRegion); if (getResults != null && getResults.Count > 0) { containingWindow = getResults[0].containingSystemWindow; return getResults[0].widget; } return null; }
// format - see enum pix_format_e {}; // flip_y - true if you want to have the Y-axis flipped vertically. public AbstractOsMappingWidget(SystemWindow childSystemWindow) : base(childSystemWindow.Width, childSystemWindow.Height, SizeLimitsToSet.None) { this.childSystemWindow = childSystemWindow; }
private static RectangleDouble ScreenToSystemWindow(ScreenRectangle rectOnScreen, SystemWindow containingWindow) { ScreenRectangle screenPosition = new ScreenRectangle() { Left = (int)rectOnScreen.Left, Top = (int)rectOnScreen.Top, Right = (int)rectOnScreen.Right, Bottom = (int)rectOnScreen.Bottom, }; WidgetForWindowsFormsAbstract mappingWidget = containingWindow.Parent as WidgetForWindowsFormsAbstract; screenPosition.Left -= mappingWidget.WindowsFormsWindow.Location.X; screenPosition.Top -= (mappingWidget.WindowsFormsWindow.Location.Y + mappingWidget.WindowsFormsWindow.TitleBarHeight); screenPosition.Left -= mappingWidget.WindowsFormsWindow.Location.X; screenPosition.Bottom -= (mappingWidget.WindowsFormsWindow.Location.Y + mappingWidget.WindowsFormsWindow.TitleBarHeight); screenPosition.Top = (int)containingWindow.Height - screenPosition.Top; screenPosition.Bottom = (int)containingWindow.Height - screenPosition.Bottom; return new RectangleDouble() { Left = screenPosition.Left, Bottom = screenPosition.Bottom, Right = screenPosition.Right, Top = screenPosition.Top, }; }
private static Point2D ScreenToSystemWindow(Point2D pointOnScreen, SystemWindow containingWindow) { Point2D screenPosition = pointOnScreen; WidgetForWindowsFormsAbstract mappingWidget = containingWindow.Parent as WidgetForWindowsFormsAbstract; screenPosition.x -= mappingWidget.WindowsFormsWindow.Location.X; screenPosition.y -= (mappingWidget.WindowsFormsWindow.Location.Y + mappingWidget.WindowsFormsWindow.TitleBarHeight); screenPosition.y = (int)containingWindow.Height - screenPosition.y; return screenPosition; }
private static Point2D SystemWindowToScreen(Point2D pointOnWindow, SystemWindow containingWindow) { Point2D screenPosition = new Point2D(pointOnWindow.x, (int)containingWindow.Height - pointOnWindow.y); WidgetForWindowsFormsAbstract mappingWidget = containingWindow.Parent as WidgetForWindowsFormsAbstract; screenPosition.x += mappingWidget.WindowsFormsWindow.Location.X; screenPosition.y += mappingWidget.WindowsFormsWindow.Location.Y + mappingWidget.WindowsFormsWindow.TitleBarHeight; return screenPosition; }
public static void ShowPrintLevelWizard(LevelWizardBase.RuningState runningState) { if (printLevelWizardWindow == null) { printLevelWizardWindow = LevelWizardBase.CreateAndShowWizard(runningState); printLevelWizardWindow.Closed += (sender, e) => { printLevelWizardWindow = null; }; } else { printLevelWizardWindow.BringToFront(); } }
private void recalculatePosition(object sender, EventArgs e) { if (recursCount == 0 && widgetRelativeTo != null && widgetRelativeTo.Parent != null) { recursCount++; var systemWindowWidth = windowToAddTo.Width; Vector2 bottomLeftScreenSpace; // Calculate left aligned screen space position (using widgetRelativeTo.parent) Vector2 alignLeftPosition = widgetRelativeTo.Parent.TransformToScreenSpace(widgetRelativeTo.Position); // Calculate right aligned screen space position (using widgetRelativeTo.parent) var bottomLeftForAlignRight = widgetRelativeTo.Position - new Vector2(popupWidget.Width - widgetRelativeTo.LocalBounds.Width, 0); Vector2 alignRightPosition = widgetRelativeTo.Parent.TransformToScreenSpace(bottomLeftForAlignRight); // Conditionally select appropriate left/right position if (alignToRightEdge && alignRightPosition.X >= 0 || alignLeftPosition.X + popupWidget.Width > systemWindowWidth) { // Align right or align left with x > systemWindow.Width bottomLeftScreenSpace = alignRightPosition; } else { // Align left or align right with negative x bottomLeftScreenSpace = alignLeftPosition; } // we only check for the scroll bar one time (the first time we open) if (checkIfNeedScrollBar) { var minimumOpenHeight = 50; // If the bottom of the popup is below the bottom of the screen if (direction == Direction.Down) { if (bottomLeftScreenSpace.Y - popupWidget.LocalBounds.Height < 0) { if (bottomLeftScreenSpace.Y <= minimumOpenHeight) { direction = Direction.Up; } else { popupWidget.MakeMenuHaveScroll(bottomLeftScreenSpace.Y - 5); } } } else { SystemWindow windowToAddTo = widgetRelativeTo.Parents <SystemWindow>().FirstOrDefault(); if (bottomLeftScreenSpace.Y + popupWidget.LocalBounds.Height > windowToAddTo.Height) { popupWidget.MakeMenuHaveScroll(bottomLeftScreenSpace.Y - 5); } } // We only check the first time we position the popup checkIfNeedScrollBar = false; } switch (direction) { case Direction.Down: popupWidget.Position = bottomLeftScreenSpace + new Vector2(0, -popupWidget.Height); break; case Direction.Up: popupWidget.Position = bottomLeftScreenSpace + new Vector2(0, widgetRelativeTo.Height); break; default: throw new NotImplementedException(); } recursCount--; } }
private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState) { PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter); LevelWizardBase printLevelWizardWindow; switch (levelingData.levelingSystem) { case PrintLevelingData.LevelingSystem.Probe2Points: printLevelWizardWindow = new LevelWizard2Point(runningState); break; case PrintLevelingData.LevelingSystem.Probe3Points: printLevelWizardWindow = new LevelWizard3Point(runningState); break; default: throw new NotImplementedException(); } printLevelWizardWindow.ShowAsSystemWindow(); return printLevelWizardWindow; }
private void SystemWindow_Closing(object sender, WidgetClosingEnventArgs closingEvent) { if (systemWindowWithPopContent != null) { SaveSizeAndPosition(); SaveWindowShouldStartClosed(); if (systemWindowWithPopContent.Children.Count == 1) { GuiWidget child = systemWindowWithPopContent.Children[0]; systemWindowWithPopContent.RemoveChild(child); child.ClearRemovedFlag(); widgetWithPopContent.RemoveAllChildren(); widgetWithPopContent.AddChild(child); } systemWindowWithPopContent = null; } }
public abstract Point2D GetDesktopPosition(SystemWindow systemWindow);
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(); } }
private MatterControlApplication(double width, double height, out bool showWindow) : base(width, height) { Name = "MatterControl"; 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; bool forceSofwareRendering = false; for (int currentCommandIndex = 0; currentCommandIndex < commandLineArgs.Length; currentCommandIndex++) { string command = commandLineArgs[currentCommandIndex]; string commandUpper = command.ToUpper(); switch (commandUpper) { case "TEST": CheckKnownAssemblyConditionalCompSymbols(); return; case "FORCE_SOFTWARE_RENDERING": forceSofwareRendering = true; GL.ForceSoftwareRendering(); break; 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": AboutWidget.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]; if (printerData.Length == 3) { ActivePrinter.ComPort = printerData[2]; } PrinterSetupStatus test = new PrinterSetupStatus(ActivePrinter); test.LoadDefaultSliceSettings(ActivePrinter.Make, ActivePrinter.Model); ActivePrinterProfile.Instance.ActivePrinter = ActivePrinter; } } break; case "CONNECT_TO_PRINTER": if (currentCommandIndex + 1 <= commandLineArgs.Length) { PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); } break; case "START_PRINT": if (currentCommandIndex + 1 <= commandLineArgs.Length) { bool hasBeenRun = false; currentCommandIndex++; string fullPath = commandLineArgs[currentCommandIndex]; QueueData.Instance.RemoveAll(); if (!string.IsNullOrEmpty(fullPath)) { string fileName = Path.GetFileNameWithoutExtension(fullPath); QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(fileName, fullPath))); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((sender, e) => { if (!hasBeenRun && PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Connected) { hasBeenRun = true; PrinterConnectionAndCommunication.Instance.PrintActivePartIfPossible(); } }, ref unregisterEvent); } } break; case "SLICE_AND_EXPORT_GCODE": if (currentCommandIndex + 1 <= commandLineArgs.Length) { currentCommandIndex++; string fullPath = commandLineArgs[currentCommandIndex]; QueueData.Instance.RemoveAll(); if (!string.IsNullOrEmpty(fullPath)) { string fileName = Path.GetFileNameWithoutExtension(fullPath); PrintItemWrapper printItemWrapper = new PrintItemWrapper(new PrintItem(fileName, fullPath)); QueueData.Instance.AddItem(printItemWrapper); SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); ExportPrintItemWindow exportForTest = new ExportPrintItemWindow(printItemWrapper); exportForTest.ExportGcodeCommandLineUtility(fileName); } } 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 // 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; } using (new PerformanceTimer("Startup", "MainView")) { 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(); if (!forceSofwareRendering) { UseOpenGL = true; } string version = "1.4"; 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 override void SetDesktopPosition(SystemWindow systemWindow, Point2D position) { if (systemWindow.AbstractOsMappingWidget != null) { // Make sure the window is on screen (this logic should improve over time) position.x = Math.Max(0, position.x); position.y = Math.Max(0, position.y); // If it's mac make sure we are not completely under the menu bar. if (OsInformation.OperatingSystem == OSType.Mac) { position.y = Math.Max(5, position.y); } systemWindow.AbstractOsMappingWidget.DesktopPosition = position; } else { pendingSetInitialDesktopPosition = true; InitialDesktopPosition = position; } }
public void Init(SystemWindow childSystemWindow) { System.Drawing.Size clientSize = new System.Drawing.Size(); clientSize.Width = (int)childSystemWindow.Width; clientSize.Height = (int)childSystemWindow.Height; WindowsFormsWindow.ClientSize = clientSize; if (!childSystemWindow.Resizable) { WindowsFormsWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; WindowsFormsWindow.MaximizeBox = false; } clientSize.Width = (int)childSystemWindow.Width; clientSize.Height = (int)childSystemWindow.Height; WindowsFormsWindow.ClientSize = clientSize; OnInitialize(); }
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); }
/// <summary> /// Creates or connects a PlatformWindow to the given SystemWindow /// </summary> public virtual void ShowSystemWindow(SystemWindow systemWindow) { if (_openWindows.Count == 0) { this._openWindows.Add(systemWindow); } else { if (systemWindow.PlatformWindow != null) { return; } var overlayWindow = new SystemWindow(_openWindows.FirstOrDefault().Width, _openWindows.FirstOrDefault().Height) { PlatformWindow = platformWindow }; systemWindow.HAnchor = HAnchor.Stretch; systemWindow.VAnchor = VAnchor.Stretch; var theme = ApplicationController.Instance.Theme; var movable = new WindowWidget(systemWindow) { WindowBorderColor = new Color(theme.PrimaryAccentColor, 175) }; movable.Width = Math.Min(overlayWindow.Width, movable.Width); movable.Height = Math.Min(overlayWindow.Height, movable.Height); overlayWindow.AddChild(movable); var closeButton = theme.CreateSmallResetButton(); closeButton.HAnchor = HAnchor.Right; closeButton.ToolTipText = "Close".Localize(); closeButton.Click += (s, e) => { systemWindow.Close(); }; var titleBarRow = new Toolbar(theme, closeButton) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit | VAnchor.Center, }; titleBarRow.AddChild(new ImageWidget(AggContext.StaticData.LoadIcon("mh.png", 16, 16, theme.InvertIcons)) { Margin = new BorderDouble(4, 0, 6, 0), VAnchor = VAnchor.Center }); titleBarRow.ActionArea.AddChild(new TextWidget(systemWindow.Title ?? "", pointSize: theme.DefaultFontSize - 1, textColor: theme.TextColor) { VAnchor = VAnchor.Center, }); movable.TitleBar.BackgroundColor = theme.TabBarBackground; movable.TitleBar.AddChild(titleBarRow); systemWindow.Closed += (s, e) => { overlayWindow.Close(); }; movable.Width += 1; movable.Position = new VectorMath.Vector2((overlayWindow.Width - movable.Width) / 2, (overlayWindow.Height - movable.Height) / 2); this._openWindows.Add(overlayWindow); } TopWindow = _openWindows.LastOrDefault(); platformWindow.ShowSystemWindow(TopWindow); }