|
Imports System.IO
Imports System.Drawing.Printing
Public Class Form1
Sub getFiles()
strTmp = "$"
If File.Exists(workDir) Then
If workDir.EndsWith(".slddrw", True, Nothing) And InStr(workDir, strTmp) = 0 Then
ListBox1.Items.Add(workDir)
End If
Else
Dim i As Integer = 0
'临时文件包含此字符,如果文件名包括此字符,应该排除此项
SwFiles = Directory.GetFiles(workDir, "*.slddrw", SearchOption.AllDirectories)
For Each myfile As String In SwFiles
If InStr(myfile, strTmp) = 0 Then
ListBox1.Items.Add(myfile)
End If
Next
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FBD1.ShowDialog()
workDir = FBD1.SelectedPath
If workDir <> "" Then
getFiles()
End If
End Sub
Private Sub Form1_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop
Dim myfiles() As String
myfiles = e.Data.GetData(DataFormats.FileDrop)
For i = 0 To myfiles.GetUpperBound(0)
workDir = myfiles(i) '检入文件夹
getFiles()
Next
End Sub
Private Sub Form1_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.All
End If
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If Not swApp Is Nothing Then
If MsgBox("在退出时是否关闭solidworks程序?", MsgBoxStyle.YesNo) = MsgBoxResult.Ok Then
swApp.ExitApp()
swApp = Nothing
End If
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CboxShowSW.Checked = True
For Each ptName As String In PrinterSettings.InstalledPrinters
cbxPtA4.Items.Add(ptName)
cbxPtOut.Items.Add(ptName)
Next
cbxPtA4.SelectedIndex = 0
cbxPtOut.SelectedIndex = 0
For i As Integer = 0 To userDPI.GetUpperBound(0)
cbxDpi.Items.Add(userDPI(i))
Next
cbxDpi.SelectedIndex = 6
intDPI = cbxDpi.Items(cbxDpi.SelectedIndex)
For i = 0 To PrintSize.GetUpperBound(0)
CBoxPaperSize.Items.Add(PrintSize(i))
Next
CBoxPaperSize.SelectedIndex = 0
RadioButtonHigh.Checked = True
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
loadsw()
End Sub
Private Sub cbxDpi_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxDpi.SelectedIndexChanged
intDPI = cbxDpi.Items(cbxDpi.SelectedIndex)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ListBox1.Items.Clear()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
For i = 0 To ListBox1.SelectedItems.Count - 1
ListBox1.Items.Remove(ListBox1.SelectedItems(0))
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs)
End Sub
Private Sub cbxPtTiff_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxPtOut.SelectedIndexChanged
PT1.PrinterSettings.PrinterName = cbxPtOut.SelectedItem
End Sub
Private Sub ListLargePapers_DoubleClick(sender As Object, e As EventArgs) Handles ListLargePapers.DoubleClick
If ListLargePapers.SelectedIndex <> -1 Then
swApp.OpenDoc(ListLargePapers.SelectedItem, 3)
End If
End Sub
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
MsgBox("本程序完全免费!!" & vbCrLf & "编写此程序一是为了为大家提供便利,二是为了展示我们作为专利代理人,在机械设计方面的实力" & vbCrLf & "如果您想要申请专利,欢迎联系我。 郜文刚,QQ:258453495")
End Sub
End Class
复制代码 |
|