第一次提交至Git
This commit is contained in:
155
UTS_Core/UTSModule/Station/DlgLoadStation.vb
Normal file
155
UTS_Core/UTSModule/Station/DlgLoadStation.vb
Normal file
@@ -0,0 +1,155 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports UTS_Core.UTSModule.Project
|
||||
|
||||
Namespace UTSModule.Station
|
||||
Public Class DlgLoadStation
|
||||
Public Property ProcessStation() As ProcessStation
|
||||
Public Property UserInfo() As Login.UserInfo
|
||||
|
||||
Public _projectInfo As ProjectInfo
|
||||
|
||||
Private _projectName As String
|
||||
|
||||
Private _stationName As String
|
||||
|
||||
Private _stationType As ProcessStation.StationTypeEnum
|
||||
|
||||
Private _snIndex As New Dictionary(Of Integer, Integer)
|
||||
|
||||
Public Function InitProjectStationWithoutShow(projectName As String, stationName As String) As Boolean
|
||||
Dim projectList As String() = ProjectInfo.LoadProjectList(ProjectInfo.InitializeModeEnum.LocalDatabaseLoad)
|
||||
If projectList.Contains(projectName) = False Then Return False
|
||||
|
||||
_projectInfo = New ProjectInfo(UserInfo.UserId, projectName, ProjectInfo.InitializeModeEnum.LocalDatabaseLoad)
|
||||
For Each projectStationInfo As ProcessStation In _projectInfo.Station
|
||||
If projectStationInfo.Name = stationName Then
|
||||
ProcessStation = projectStationInfo
|
||||
ProcessStation.UserId = UserInfo.UserId
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
Return ProcessStation IsNot Nothing
|
||||
End Function
|
||||
|
||||
Public Overloads Function ShowDialog(projectName As String, stationName As String, Optional stationType As ProcessStation.StationTypeEnum = ProcessStation.StationTypeEnum.Test) As DialogResult
|
||||
_projectName = projectName
|
||||
_stationName = stationName
|
||||
_stationType = stationType
|
||||
Return Me.ShowDialog
|
||||
End Function
|
||||
|
||||
Private Sub OK_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OK_Button.Click
|
||||
DialogResult = DialogResult.OK
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
Private Sub Cancel_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Cancel_Button.Click
|
||||
DialogResult = DialogResult.Cancel
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
Private Sub InitPreviewImage()
|
||||
PicStationPreview.SizeMode = PictureBoxSizeMode.Zoom
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeForm()
|
||||
Text = $"请选择需要加载的项目"
|
||||
End Sub
|
||||
|
||||
Private Sub DlgLoadStation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
InitializeForm()
|
||||
InitPreviewImage()
|
||||
UpdateProjectList()
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateProjectList()
|
||||
CboProject.Items.Clear()
|
||||
CboProject.Items.AddRange(ProjectInfo.LoadProjectList(ProjectInfo.InitializeModeEnum.LocalDatabaseLoad))
|
||||
|
||||
If String.IsNullOrEmpty(_projectName) = False Then
|
||||
For i As Integer = 0 To CboProject.Items.Count - 1
|
||||
If CboProject.Items(i).ToString() = _projectName Then
|
||||
CboProject.SelectedIndex = i
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
If CboProject.Items.Count > 0 Then CboProject.SelectedIndex = 0
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateProjectStation(stations As List(Of ProcessStation))
|
||||
_snIndex.Clear()
|
||||
CboStation.Items.Clear()
|
||||
|
||||
Dim index As Integer = -1
|
||||
For Each station As ProcessStation In stations
|
||||
index += 1
|
||||
|
||||
If station.StationType <> _stationType Then Continue For
|
||||
|
||||
_snIndex.Add(CboStation.Items.Count, index)
|
||||
CboStation.Items.Add(station.Name)
|
||||
Next
|
||||
|
||||
|
||||
'添加所有站位描述
|
||||
RtxStationDesc.SuspendLayout()
|
||||
RtxStationDesc.Clear()
|
||||
For Each station As ProcessStation In stations
|
||||
If station.StationType <> _stationType Then
|
||||
RtxStationDesc.SelectionColor = Color.Gray
|
||||
Else
|
||||
RtxStationDesc.SelectionColor = Color.Black
|
||||
End If
|
||||
RtxStationDesc.AppendText($"{station.Name}:{station.Description}{vbNewLine}")
|
||||
Next
|
||||
RtxStationDesc.ResumeLayout(False)
|
||||
RtxStationDesc.PerformLayout()
|
||||
|
||||
'默认选择
|
||||
If String.IsNullOrEmpty(_stationName) = False Then
|
||||
For i As Integer = 0 To CboStation.Items.Count - 1
|
||||
If CboStation.Items(i).ToString() = _stationName Then
|
||||
CboStation.SelectedIndex = i
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If CboStation.SelectedIndex = -1 AndAlso _snIndex.Count > 0 Then CboStation.SelectedIndex = _snIndex.Keys.ElementAt(0)
|
||||
End Sub
|
||||
|
||||
Private Sub CboProject_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboProject.SelectedIndexChanged
|
||||
_projectInfo = New ProjectInfo(UserInfo.UserId, CboProject.Text, ProjectInfo.InitializeModeEnum.LocalDatabaseLoad)
|
||||
|
||||
RtxProjectDesc.Text = _projectInfo.Description
|
||||
|
||||
If _projectInfo.MasterImage IsNot Nothing Then
|
||||
PicStationPreview.Image = _projectInfo.MasterImage
|
||||
End If
|
||||
|
||||
lastSelectIndex = -1
|
||||
UpdateProjectStation(_projectInfo.Station)
|
||||
End Sub
|
||||
|
||||
Private lastSelectIndex As Integer = -1
|
||||
Private Sub CboStation_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CboStation.SelectedIndexChanged
|
||||
Dim selectIndex As Integer = _snIndex(CboStation.SelectedIndex)
|
||||
ProcessStation = _projectInfo.Station.Item(selectIndex)
|
||||
ProcessStation.UserId = UserInfo.UserId
|
||||
|
||||
If lastSelectIndex <> -1 Then
|
||||
RtxStationDesc.Select(RtxStationDesc.GetFirstCharIndexFromLine(lastSelectIndex), RtxStationDesc.Lines(lastSelectIndex).Length)
|
||||
RtxStationDesc.SelectionColor = Color.Black
|
||||
End If
|
||||
lastSelectIndex = selectIndex
|
||||
|
||||
RtxStationDesc.Select(RtxStationDesc.GetFirstCharIndexFromLine(selectIndex), RtxStationDesc.Lines(selectIndex).Length)
|
||||
RtxStationDesc.SelectionColor = Color.Blue
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user