|
1 |
| -Imports System.Windows.Forms |
| 1 | +Imports System.Windows.Forms |
| 2 | +AddReference "System.Drawing.dll" |
2 | 3 | Imports System.Drawing
|
| 4 | +Imports Inventor |
| 5 | +Imports clsSharedFunctions ' Globally import so it's available to all classes |
3 | 6 | ' Title: Set All Colours
|
4 | 7 | ' Description: Change all parts to be the same colour
|
5 | 8 | ' Version: 0.2
|
@@ -44,6 +47,7 @@ Public Class RunMyForm
|
44 | 47 |
|
45 | 48 | ' Create new instance of the custom form (sends appearance list to form)
|
46 | 49 | Dim myfrm As New CustomForm(appearanceList)
|
| 50 | + ScaleForm(myfrm) |
47 | 51 |
|
48 | 52 | Dim strAppearance As String = ""
|
49 | 53 | Dim bClearOverride As Boolean = True
|
@@ -164,7 +168,7 @@ Public Class CustomForm
|
164 | 168 | '.MinimizeBox = False
|
165 | 169 | .StartPosition = FormStartPosition.CenterScreen
|
166 | 170 | .Width = 300
|
167 |
| - .Height = 175 |
| 171 | + .Height = 200 |
168 | 172 | .TopMost = True
|
169 | 173 | .Text = "Set Part Colours"
|
170 | 174 | .Name = "Set Part Colours"
|
@@ -236,6 +240,7 @@ Public Class CustomForm
|
236 | 240 | ' Set default dialog result
|
237 | 241 | Me.DialogResult = System.Windows.Forms.DialogResult.None
|
238 | 242 |
|
| 243 | + |
239 | 244 | End Sub
|
240 | 245 |
|
241 | 246 | Private Sub CustomForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
|
@@ -291,4 +296,26 @@ Public Class CustomForm
|
291 | 296 | End If
|
292 | 297 | End Sub
|
293 | 298 |
|
| 299 | + |
| 300 | + |
| 301 | +End Class |
| 302 | + |
| 303 | +Public Class clsSharedFunctions |
| 304 | + |
| 305 | + Public Shared strAppName As String = "Set All Colours" |
| 306 | + |
| 307 | + Public Shared Sub ScaleForm(WindowsForm As System.Windows.Forms.Form) |
| 308 | + Using g As System.Drawing.Graphics = WindowsForm.CreateGraphics |
| 309 | + Dim sngScaleFactor As Single = 1 |
| 310 | + Dim sngFontFactor As Single = 1 |
| 311 | + If g.DpiX > 96 Then |
| 312 | + sngScaleFactor = g.DpiX / 96 |
| 313 | + 'sngFontFactor = 96 / g.DpiY |
| 314 | + End If |
| 315 | + If WindowsForm.AutoScaleDimensions = WindowsForm.CurrentAutoScaleDimensions Then |
| 316 | + 'ucWindowsFormHost.ScaleControl(WindowsForm, sngFontFactor) |
| 317 | + WindowsForm.Scale(sngScaleFactor) |
| 318 | + End If |
| 319 | + End Using |
| 320 | + End Sub |
294 | 321 | End Class
|
0 commit comments