diff --git a/UVtools.GUI/FrmMain.Designer.cs b/UVtools.GUI/FrmMain.Designer.cs index a6e77b9..152b4fe 100644 --- a/UVtools.GUI/FrmMain.Designer.cs +++ b/UVtools.GUI/FrmMain.Designer.cs @@ -77,10 +77,10 @@ this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator(); this.tsLayerImageHighlightIssues = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.tsLayerImageLayerOutline = new System.Windows.Forms.ToolStripSplitButton(); - this.tsLayerImageLayerOutlinePrintVolumeBounds = new System.Windows.Forms.ToolStripMenuItem(); this.tsLayerImageShowCrosshairs = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator25 = new System.Windows.Forms.ToolStripSeparator(); + this.tsLayerImageLayerOutline = new System.Windows.Forms.ToolStripSplitButton(); + this.tsLayerImageLayerOutlinePrintVolumeBounds = new System.Windows.Forms.ToolStripMenuItem(); this.tsLayerImageLayerOutlineLayerBounds = new System.Windows.Forms.ToolStripMenuItem(); this.tsLayerImageLayerOutlineHollowAreas = new System.Windows.Forms.ToolStripMenuItem(); this.tsLayerImageLayerOutlineEdgeDetection = new System.Windows.Forms.ToolStripMenuItem(); @@ -94,6 +94,7 @@ this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); this.tsLayerResolution = new System.Windows.Forms.ToolStripLabel(); this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); + this.tsLayerImageZoomLock = new System.Windows.Forms.ToolStripLabel(); this.tsLayerImageZoom = new System.Windows.Forms.ToolStripLabel(); this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); this.tsLayerImagePanLocation = new System.Windows.Forms.ToolStripLabel(); @@ -134,6 +135,8 @@ this.btnGCodeSave = new System.Windows.Forms.ToolStripSplitButton(); this.btnGCodeSaveFile = new System.Windows.Forms.ToolStripMenuItem(); this.btnGCodeSaveClipboard = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator(); + this.btnGCodeRebuild = new System.Windows.Forms.ToolStripButton(); this.tabPageIssues = new System.Windows.Forms.TabPage(); this.flvIssues = new BrightIdeasSoftware.FastObjectListView(); this.flvIssuesColType = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn())); @@ -247,16 +250,13 @@ this.tbLayer = new System.Windows.Forms.TrackBar(); this.lbInitialLayer = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); - this.layerZoomTimer = new System.Windows.Forms.Timer(this.components); - this.issueScrollTimer = new System.Windows.Forms.Timer(this.components); - this.tsLayerImageZoomLock = new System.Windows.Forms.ToolStripLabel(); this.btnFindLayer = new System.Windows.Forms.Button(); this.btnLastLayer = new System.Windows.Forms.Button(); this.btnFirstLayer = new System.Windows.Forms.Button(); + this.layerZoomTimer = new System.Windows.Forms.Timer(this.components); + this.issueScrollTimer = new System.Windows.Forms.Timer(this.components); this.toolTipInformation = new System.Windows.Forms.ToolTip(this.components); this.layerScrollTimer = new System.Windows.Forms.Timer(this.components); - this.btnGCodeRebuild = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator(); this.menu.SuspendLayout(); this.mainTable.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.scCenter)).BeginInit(); @@ -317,8 +317,6 @@ ((System.ComponentModel.ISupportInitialize)(this.tbLayer)).BeginInit(); this.panel2.SuspendLayout(); this.SuspendLayout(); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EventKeyDown); - this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.EventKeyUp); // // menu // @@ -689,8 +687,8 @@ this.pbLayer.Size = new System.Drawing.Size(1228, 705); this.pbLayer.TabIndex = 7; this.pbLayer.Zoomed += new System.EventHandler(this.pbLayer_Zoomed); - this.pbLayer.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.EventMouseDoubleClick); this.pbLayer.MouseClick += new System.Windows.Forms.MouseEventHandler(this.EventMouseClick); + this.pbLayer.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.EventMouseDoubleClick); this.pbLayer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pbLayer_MouseMove); this.pbLayer.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pbLayer_MouseUp); // @@ -804,22 +802,8 @@ this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25); // - // tsLayerImageLayerOutline - // - this.tsLayerImageLayerOutline.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tsLayerImageLayerOutlinePrintVolumeBounds, - this.tsLayerImageLayerOutlineLayerBounds, - this.tsLayerImageLayerOutlineHollowAreas, - this.tsLayerImageLayerOutlineEdgeDetection}); - this.tsLayerImageLayerOutline.Image = global::UVtools.GUI.Properties.Resources.Geometry_16x16; - this.tsLayerImageLayerOutline.ImageTransparentColor = System.Drawing.Color.Magenta; - this.tsLayerImageLayerOutline.Name = "tsLayerImageLayerOutline"; - this.tsLayerImageLayerOutline.Size = new System.Drawing.Size(78, 22); - this.tsLayerImageLayerOutline.Text = "&Outline"; - this.tsLayerImageLayerOutline.ButtonClick += new System.EventHandler(this.EventClick); - // // tsLayerImageShowCrosshairs - // + // this.tsLayerImageShowCrosshairs.Checked = true; this.tsLayerImageShowCrosshairs.CheckOnClick = true; this.tsLayerImageShowCrosshairs.CheckState = System.Windows.Forms.CheckState.Checked; @@ -836,6 +820,20 @@ this.toolStripSeparator25.Name = "toolStripSeparator25"; this.toolStripSeparator25.Size = new System.Drawing.Size(6, 25); // + // tsLayerImageLayerOutline + // + this.tsLayerImageLayerOutline.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsLayerImageLayerOutlinePrintVolumeBounds, + this.tsLayerImageLayerOutlineLayerBounds, + this.tsLayerImageLayerOutlineHollowAreas, + this.tsLayerImageLayerOutlineEdgeDetection}); + this.tsLayerImageLayerOutline.Image = global::UVtools.GUI.Properties.Resources.Geometry_16x16; + this.tsLayerImageLayerOutline.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tsLayerImageLayerOutline.Name = "tsLayerImageLayerOutline"; + this.tsLayerImageLayerOutline.Size = new System.Drawing.Size(78, 22); + this.tsLayerImageLayerOutline.Text = "&Outline"; + this.tsLayerImageLayerOutline.ButtonClick += new System.EventHandler(this.EventClick); + // // tsLayerImageLayerOutlinePrintVolumeBounds // this.tsLayerImageLayerOutlinePrintVolumeBounds.CheckOnClick = true; @@ -965,12 +963,23 @@ this.toolStripSeparator11.Name = "toolStripSeparator11"; this.toolStripSeparator11.Size = new System.Drawing.Size(6, 25); // + // tsLayerImageZoomLock + // + this.tsLayerImageZoomLock.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.tsLayerImageZoomLock.Image = global::UVtools.GUI.Properties.Resources.Lock_16x16; + this.tsLayerImageZoomLock.Name = "tsLayerImageZoomLock"; + this.tsLayerImageZoomLock.Size = new System.Drawing.Size(27, 22); + this.tsLayerImageZoomLock.Text = "]"; + this.tsLayerImageZoomLock.ToolTipText = "This zoom factor will be used for auto-zoom functions. Use scroll wheel to select" + + " desired auto zoom level\r\nand double-click middle mouse button to set."; + this.tsLayerImageZoomLock.Visible = false; + // // tsLayerImageZoom // this.tsLayerImageZoom.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.tsLayerImageZoom.Image = global::UVtools.GUI.Properties.Resources.search_16x16; this.tsLayerImageZoom.Name = "tsLayerImageZoom"; - this.tsLayerImageZoom.Size = new System.Drawing.Size(89, 22); + this.tsLayerImageZoom.Size = new System.Drawing.Size(81, 22); this.tsLayerImageZoom.Text = "Zoom: [1x]"; this.tsLayerImageZoom.ToolTipText = "Layer image zoom level, use mouse scroll to zoom in/out into image\r\nCtrl + 0 to s" + "cale to fit"; @@ -1366,7 +1375,7 @@ // this.btnGCodeSaveFile.Image = global::UVtools.GUI.Properties.Resources.file_image_16x16; this.btnGCodeSaveFile.Name = "btnGCodeSaveFile"; - this.btnGCodeSaveFile.Size = new System.Drawing.Size(180, 22); + this.btnGCodeSaveFile.Size = new System.Drawing.Size(141, 22); this.btnGCodeSaveFile.Text = "To &File"; this.btnGCodeSaveFile.Click += new System.EventHandler(this.EventClick); // @@ -1374,10 +1383,28 @@ // this.btnGCodeSaveClipboard.Image = global::UVtools.GUI.Properties.Resources.clipboard_16x16; this.btnGCodeSaveClipboard.Name = "btnGCodeSaveClipboard"; - this.btnGCodeSaveClipboard.Size = new System.Drawing.Size(180, 22); + this.btnGCodeSaveClipboard.Size = new System.Drawing.Size(141, 22); this.btnGCodeSaveClipboard.Text = "To &Clipboard"; this.btnGCodeSaveClipboard.Click += new System.EventHandler(this.EventClick); // + // toolStripSeparator24 + // + this.toolStripSeparator24.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.toolStripSeparator24.Name = "toolStripSeparator24"; + this.toolStripSeparator24.Size = new System.Drawing.Size(6, 25); + // + // btnGCodeRebuild + // + this.btnGCodeRebuild.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.btnGCodeRebuild.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.btnGCodeRebuild.Image = global::UVtools.GUI.Properties.Resources.refresh_16x16; + this.btnGCodeRebuild.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btnGCodeRebuild.Name = "btnGCodeRebuild"; + this.btnGCodeRebuild.Size = new System.Drawing.Size(23, 22); + this.btnGCodeRebuild.Text = "Repair"; + this.btnGCodeRebuild.ToolTipText = "Rebuild GCode with current settings"; + this.btnGCodeRebuild.Click += new System.EventHandler(this.EventClick); + // // tabPageIssues // this.tabPageIssues.Controls.Add(this.flvIssues); @@ -1970,7 +1997,7 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(3, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(272, 36); + this.label1.Size = new System.Drawing.Size(264, 36); this.label1.TabIndex = 1; this.label1.Text = "Shift+Left click to add white pixels\r\nShift+Right click to remove white pixels"; // @@ -2201,7 +2228,7 @@ this.label23.AutoSize = true; this.label23.Location = new System.Drawing.Point(3, 9); this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(299, 36); + this.label23.Size = new System.Drawing.Size(254, 36); this.label23.TabIndex = 1; this.label23.Text = "Shift+Left click to add white text\r\nShift+Right click to remove white text "; // @@ -2312,7 +2339,7 @@ this.label30.AutoSize = true; this.label30.Location = new System.Drawing.Point(3, 9); this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(321, 36); + this.label30.Size = new System.Drawing.Size(305, 36); this.label30.TabIndex = 1; this.label30.Text = "Shift click over a white pixel to remove whole \r\nlinked area (Fill with black)"; // @@ -2481,7 +2508,7 @@ this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(3, 9); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(344, 36); + this.label4.Size = new System.Drawing.Size(339, 36); this.label4.TabIndex = 1; this.label4.Text = "Shift click under a island to add a primitive support.\r\nNote: This operation can\'" + "t be previewed."; @@ -2800,6 +2827,16 @@ this.btnFirstLayer.UseVisualStyleBackColor = true; this.btnFirstLayer.Click += new System.EventHandler(this.EventClick); // + // layerZoomTimer + // + this.layerZoomTimer.Interval = 1; + this.layerZoomTimer.Tick += new System.EventHandler(this.EventTimerTick); + // + // issueScrollTimer + // + this.issueScrollTimer.Interval = 500; + this.issueScrollTimer.Tick += new System.EventHandler(this.EventTimerTick); + // // toolTipInformation // this.toolTipInformation.AutoPopDelay = 10000; @@ -2812,45 +2849,6 @@ this.layerScrollTimer.Interval = 500; this.layerScrollTimer.Tick += new System.EventHandler(this.EventTimerTick); // - // btnGCodeRebuild - // - this.btnGCodeRebuild.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.btnGCodeRebuild.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.btnGCodeRebuild.Image = global::UVtools.GUI.Properties.Resources.refresh_16x16; - this.btnGCodeRebuild.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btnGCodeRebuild.Name = "btnGCodeRebuild"; - this.btnGCodeRebuild.Size = new System.Drawing.Size(23, 22); - this.btnGCodeRebuild.Text = "Repair"; - this.btnGCodeRebuild.ToolTipText = "Rebuild GCode with current settings"; - this.btnGCodeRebuild.Click += new System.EventHandler(this.EventClick); - // - // toolStripSeparator24 - // - this.toolStripSeparator24.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.toolStripSeparator24.Name = "toolStripSeparator24"; - this.toolStripSeparator24.Size = new System.Drawing.Size(6, 25); - // - // layerZoomTimer - // - this.layerZoomTimer.Interval = 1; - this.layerZoomTimer.Tick += new System.EventHandler(this.EventTimerTick); - // - // issueScrollTimer - // - this.issueScrollTimer.Interval = 500; - this.issueScrollTimer.Tick += new System.EventHandler(this.EventTimerTick); - // - // tsLayerImageZoomLock - // - this.tsLayerImageZoomLock.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.tsLayerImageZoomLock.Image = global::UVtools.GUI.Properties.Resources.Lock_16x16; - this.tsLayerImageZoomLock.Name = "tsLayerImageZoomLock"; - this.tsLayerImageZoomLock.Size = new System.Drawing.Size(16, 22); - this.tsLayerImageZoomLock.ToolTipText = "This zoom factor will be used for auto-zoom functions. " + - "Use scroll wheel to select desired auto zoom level\r\nand double-click middle mouse button to set."; - this.tsLayerImageZoomLock.Text = "]"; - this.tsLayerImageZoomLock.Visible = false; - // // FrmMain // this.AllowDrop = true; @@ -2867,6 +2865,8 @@ this.MinimumSize = new System.Drawing.Size(1000, 600); this.Name = "FrmMain"; this.Text = "UVtools"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EventKeyDown); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.EventKeyUp); this.menu.ResumeLayout(false); this.menu.PerformLayout(); this.mainTable.ResumeLayout(false); diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index 096af50..421e129 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -168,7 +168,7 @@ namespace UVtools.GUI // Supported ZoomLevels for Layer Preview. // These settings eliminate very small zoom factors from the ImageBox default values, // while ensuring that 4K/5K build plates can still easily fit on screen. - public static int[] ZoomLevels = + public static readonly int[] ZoomLevels = { 20, 25, 30, 50, 75, 100, 150, 200, 300, 400, 500, 600, 700, 800, 1200, 1600 }; // Count of the bottom portion of the full zoom range which will be skipped for @@ -179,27 +179,21 @@ namespace UVtools.GUI /// /// Returns the zoom level at which the crosshairs will fade and no longer be displayed /// - private int CrosshairFadeLevel - { - get => ZoomLevels[Settings.Default.DefaultCrosshairFade + ZoomLevelSkipCount]; - } + public int CrosshairFadeLevel => ZoomLevels[Settings.Default.DefaultCrosshairFade + ZoomLevelSkipCount]; /// /// Returns the zoom level that will be used for autozoom actions /// - private int AutoZoomLevel - { - get => ZoomLevels[ZoomLevels.Length - AutoZoomBackIndex -1]; - } + private int AutoZoomLevel => ZoomLevels[ZoomLevels.Length - AutoZoomBackIndex -1]; public PixelHistory PixelHistory { get; } = new PixelHistory(); // Track last open tab for when PixelEditor tab is removed. - public TabPage ControlLeftLastTab { get; set; } = null; + public TabPage ControlLeftLastTab { get; set; } - public uint SavesCount { get; set; } = 0; + public uint SavesCount { get; set; } - private bool SupressLayerZoomEvent = false; + private bool SupressLayerZoomEvent { get; set; } #endregion @@ -1934,16 +1928,17 @@ namespace UVtools.GUI tsLayerImageZoom.Text = $"Zoom: [ {e.NewZoom / 100f}x ]"; tsLayerImageZoomLock.Visible = false; } - + // Refresh the layer to properly render the crosshair at various zoom transitions - if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0 - && flvIssues.SelectedObjects.Cast().Any(issue => // Find a valid candidate to update layer preview, otherwise quit - issue.LayerIndex == ActualLayer && issue.Type != LayerIssue.IssueType.EmptyLayer && issue.Type != LayerIssue.IssueType.TouchingBound) - && (e.OldZoom < 50 && e.NewZoom >= 50 // Trigger refresh as crosshair thickness increases at lower zoom levels + if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && + flvIssues.SelectedIndices.Count > 0 && + (e.OldZoom < 50 && e.NewZoom >= 50 // Trigger refresh as crosshair thickness increases at lower zoom levels || e.OldZoom > 100 && e.NewZoom <= 100 || e.OldZoom >= 50 && e.OldZoom <= 100 && (e.NewZoom < 50 || e.NewZoom > 100) || e.OldZoom <= CrosshairFadeLevel && e.NewZoom > CrosshairFadeLevel // Trigger refresh as zoom level manually crosses fade threshold - || e.OldZoom > CrosshairFadeLevel && e.NewZoom <= CrosshairFadeLevel) + || e.OldZoom > CrosshairFadeLevel && e.NewZoom <= CrosshairFadeLevel) && + flvIssues.SelectedObjects.Cast().Any(issue => // Find a valid candidate to update layer preview, otherwise quit + issue.LayerIndex == ActualLayer && issue.Type != LayerIssue.IssueType.EmptyLayer && issue.Type != LayerIssue.IssueType.TouchingBound) ) { // A timer is used here rather than invoking ShowLayer directly to eliminate sublte visual flashing @@ -2066,7 +2061,7 @@ namespace UVtools.GUI } else { - pbLayer.CenterAt(x, y); + CenterLayerAt(x, y); } // Unconditionally refresh layer preview here to ensure highlighting for pixel @@ -3296,8 +3291,8 @@ namespace UVtools.GUI { // Ignore double click if CTRL is pressed. Prevents CTRL-click // events that emulate double click from firing twice. - if ((ModifierKeys & Keys.Control) == 0) - HandleMouseDoubleClick(sender, e); + if ((ModifierKeys & Keys.Control) != 0) return; + HandleMouseDoubleClick(sender, e); } private void HandleMouseDoubleClick(object sender, MouseEventArgs e) @@ -3305,8 +3300,8 @@ namespace UVtools.GUI if (ReferenceEquals(sender, pbLayer)) { // Ignore double click events if shift is pressed. This prevents zoom - // operations from inadvertantly occuring when pixels are being edited, and - // for consistency, there is no reason not to just dissalow this any time + // operations from inadvertently occuring when pixels are being edited, and + // for consistency, there is no reason not to just disallow this any time // shift is pressed regardless of whether pixel edit mode is enabled or not. if ((ModifierKeys & Keys.Shift) != 0) return; @@ -3316,10 +3311,11 @@ namespace UVtools.GUI var location = pbLayer.PointToImage(e.Location); // Check to see if this zoom action will cross the crosshair fade threshold - if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0 - && flvIssues.SelectedObjects.Cast().Any(issue => // Find a valid candidate to update layer preview, otherwise quit - issue.LayerIndex == ActualLayer && issue.Type != LayerIssue.IssueType.EmptyLayer && issue.Type != LayerIssue.IssueType.TouchingBound) - && pbLayer.Zoom <= CrosshairFadeLevel && AutoZoomLevel > CrosshairFadeLevel) + if (tsLayerImageShowCrosshairs.Checked && + !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0 && + pbLayer.Zoom <= CrosshairFadeLevel && AutoZoomLevel > CrosshairFadeLevel && + flvIssues.SelectedObjects.Cast().Any(issue => // Find a valid candidate to update layer preview, otherwise quit + issue.LayerIndex == ActualLayer && issue.Type != LayerIssue.IssueType.EmptyLayer && issue.Type != LayerIssue.IssueType.TouchingBound)) { // Refresh the preview without the crosshairs before zooming-in. // Prevents zoomed-in crosshairs from breifly being displayed before @@ -3329,22 +3325,7 @@ namespace UVtools.GUI tsLayerImageShowCrosshairs.Checked = true; } - SupressLayerZoomEvent = true; - pbLayer.ZoomToRegion(location.X, location.Y, 5, 5); - // ZoomToRegion can result in Zoom factors much larger - // than supported levels. Zoom out and in again to - // normalize large zoom levels to the supported max zoom. - pbLayer.ZoomOut(true); - pbLayer.ZoomIn(true); - // Zoom out repeatedly to arrive at auto zoom level. - for (int i = 0; i < AutoZoomBackIndex; i++) - { - if(i == AutoZoomBackIndex-1) - SupressLayerZoomEvent = false; - pbLayer.ZoomOut(true); - } - - SupressLayerZoomEvent = false; + CenterLayerAt(location, AutoZoomLevel); return; } if ((e.Button & MouseButtons.Middle) != 0) @@ -3379,7 +3360,7 @@ namespace UVtools.GUI return; } - if ((e.Button & (MouseButtons.Right)) != 0) + if ((e.Button & MouseButtons.Right) != 0) { ZoomToFit(); return; @@ -3943,6 +3924,35 @@ namespace UVtools.GUI return issue.BoundingRectangle; } + /// + /// Centers layer view on a X,Y coordinate + /// + /// X coordinate + /// X coordinate + /// Zoom level to set, 0 to skip + public void CenterLayerAt(int x, int y, int zoomLevel = 0) + { + if (zoomLevel > 0) + pbLayer.Zoom = zoomLevel; + pbLayer.CenterAt(x, y); + } + + /// + /// Centers layer view on a middle of a given rectangle + /// + /// Rectangle holding coordinates and bounds + /// Zoom level to set, 0 to skip + public void CenterLayerAt(Rectangle rectangle, int zoomLevel = 0) => + CenterLayerAt(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2, zoomLevel); + + /// + /// Centers layer view on a + /// + /// Point holding X and Y coordinates + /// Zoom level to set, 0 to skip + public void CenterLayerAt(Point point, int zoomLevel = 0) => + CenterLayerAt(point.X, point.Y, zoomLevel); + /// /// Zoom the layer preview to the passed issue, or if appropriate for issue type, @@ -3953,8 +3963,10 @@ namespace UVtools.GUI if (issue.Type == LayerIssue.IssueType.TouchingBound || issue.Type == LayerIssue.IssueType.EmptyLayer || (issue.X == -1 && issue.Y == -1)) { ZoomToFit(); + return; } - else if (issue.X >= 0 && issue.Y >= 0) + + if (issue.X >= 0 && issue.Y >= 0) { // Check to see if this zoom action will cross the crosshair fade threshold if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0 @@ -3968,20 +3980,7 @@ namespace UVtools.GUI tsLayerImageShowCrosshairs.Checked = true; } - - SupressLayerZoomEvent = true; - pbLayer.ZoomToRegion(GetTransposedIssueBounds(issue)); - pbLayer.ZoomOut(true); - pbLayer.ZoomIn(true); - - for (int i = 0; i < AutoZoomBackIndex; i++) - { - if(i == AutoZoomBackIndex-1) - SupressLayerZoomEvent = false; - - pbLayer.ZoomOut(true); - } - SupressLayerZoomEvent = false; + CenterLayerAt(GetTransposedIssueBounds(issue), AutoZoomLevel); } } diff --git a/UVtools.GUI/FrmMain.resx b/UVtools.GUI/FrmMain.resx index 1792b12..dc9709d 100644 --- a/UVtools.GUI/FrmMain.resx +++ b/UVtools.GUI/FrmMain.resx @@ -118,41 +118,47 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 297, 17 + 421, 17 - 380, 17 + 504, 17 - 481, 17 + 605, 17 - 360, 56 + 1773, 17 + + + 297, 17 + + + 695, 17 - 831, 17 + 1040, 17 - 255, 56 + 1668, 17 - 1045, 17 + 947, 17 - 17, 56 + 1430, 17 - 174, 56 + 1587, 17 - 695, 17 + 811, 17 AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk - FAAAAk1TRnQBSQFMAgEBBgEAASABCQEgAQkBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + FAAAAk1TRnQBSQFMAgEBBgEAATABCQEwAQkBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUDMAAQEDJAE2AysBQqwAAyIBMQNWAbkDXQHi AwAB/wMAAf8BKgEtASgB/gNTAawDTQGVAwABARgAAwkBDAMzAVIDUAGdA1cB6AMAAf4DKwH8Ay8BSqQA AyEBMANZAewBKwEuASkB+gNRAfcDUgH0A1MB8QNIAfYDQQH5AwAB/wNPAZsDAAEBCAADFQEdAz8BbgNV @@ -200,7 +206,7 @@ BAADUgGpAzQBVQM0AVUgAAM0AVUDNAFVA1IBqQgAA0oBiwMAAf8DAAH/A08BnAQAA00BlQMAAf8DVAGr CAADTwGcAwAB/wMAAf8DSgGLBAADUQGgAQABzAH3Af8BAAHMAfcB/wEAAcwB9wH/AQABzAH3Af8DQwF3 CAADSgGNAgAB7AH/AgAB7AH/AgAB7wH/AgAB7AH/AgAB7AH/AgAB7QH/AVICUwGoA1IBqAMAAf8DAAH/ - AwAB/wNRAfcDKwH9A1ABnwsAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNSAagEAANSAakDNAFVAzQBVQNG + AwAB/wNRAfcDLQH9A1ABnwsAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNSAagEAANSAakDNAFVAzQBVQNG AYADUgGpA1IBqQNSAakDUgGpA1IBqQNSAakDRQF/AzQBVQM0AVUDUgGpBAADUQGiAwAB/wMAAf8DSQGJ CAADLwFKAwAB/wNUAe4MAANJAYkDAAH/AwAB/wNRAaIDAAEBAT8CQAFvAT4CXAH4AQABzQH3Af8BAAHN AfcB/wMSARgIAAMBAQIDRgF+AlIBXQHwAgAB7gH/AgAB7gH/AkABqAH9AUUCRgF+AwMBBANSAagDAAH/ @@ -242,32 +248,17 @@ AfwBPws= - - 291, 17 - - - 649, 17 - - - 1504, 17 - - - 765, 17 - - - 1155, 17 - - - 1423, 17 - 1138, 17 - - 863, 17 + + 17, 17 + + + 158, 17 - 1017, 17 + 1292, 17