296 lines
10 KiB
VB.net
296 lines
10 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class InstrumentPanelVM
|
|
Inherits ViewBase
|
|
|
|
Implements INotifyPropertyChanged
|
|
|
|
Public Event EnableCurrentPage()
|
|
|
|
Public Event SetFocusOnTextDimension()
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property GetDistToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_GRIDVIEWPANEL + 18)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PrintHardwareToolTip As String
|
|
Get
|
|
Return "Save Image"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_GetDistIsChecked As Boolean = True
|
|
Public Property GetDistIsChecked As Boolean
|
|
Get
|
|
GetDistance(m_GetDistIsChecked)
|
|
Return m_GetDistIsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_GetDistIsChecked Then
|
|
m_GetDistIsChecked = value
|
|
NotifyPropertyChanged("GetDistIsChecked")
|
|
End If
|
|
|
|
End Set
|
|
End Property
|
|
|
|
' se il bottone è selezionato (true) allora misura, altrimenti no (false)
|
|
Public Sub GetDistance(bGetDistanceIsChecked As Boolean)
|
|
If bGetDistanceIsChecked Then
|
|
Map.refSceneManagerVM.ProjectScene.SetStatusGetDistance()
|
|
Else
|
|
If m_DimensionVisibility = Visibility.Collapsed Then
|
|
Map.refSceneManagerVM.ProjectScene.SetStatusNull()
|
|
End If
|
|
Map.refSceneManagerVM.ProjectScene.ResetStatusGetDistance()
|
|
Dim rfStatusBarVM As StatusBarVM = Map.refStatusBarVM
|
|
rfStatusBarVM.StatusOutput = String.Empty
|
|
End If
|
|
End Sub
|
|
|
|
' visualizzo il bottone delle quote
|
|
Private m_DimensionVisibility As Visibility
|
|
Public Property DimensionVisibility As Visibility
|
|
Get
|
|
If Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nHardwarePage Then
|
|
m_DimensionVisibility = OptionModule.m_DimensionHardware
|
|
ElseIf Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage Then
|
|
m_DimensionVisibility = OptionModule.m_DimensionDoor
|
|
End If
|
|
If m_DimensionVisibility = Visibility.Collapsed Then
|
|
'Map.refSceneManagerVM.ProjectScene.SetStatusNull()
|
|
End If
|
|
NotifyPropertyChanged("SaveImgHardware")
|
|
Return m_DimensionVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_DimensionVisibility = value
|
|
NotifyPropertyChanged("DimensionVisibility")
|
|
End Set
|
|
End Property
|
|
|
|
' visualizzo il bottone per creare la stampa dell'immagine
|
|
Private m_SaveImgHardware As Visibility = Visibility.Collapsed
|
|
Public Property SaveImgHardware As Visibility
|
|
Get
|
|
Return m_DimensionVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_SaveImgHardware = value
|
|
NotifyPropertyChanged("SaveImgHardware")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextDimensionVisibility As Visibility = Visibility.Collapsed
|
|
Public Property TextDimensionVisibility As Visibility
|
|
Get
|
|
Return m_TextDimensionVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
Application.Current.Dispatcher.BeginInvoke(New Action(Sub()
|
|
Map.refSceneManagerVM.InstrumentPanel.TextBox1.Focus()
|
|
End Sub), System.Windows.Threading.DispatcherPriority.ContextIdle, Nothing)
|
|
m_TextDimensionVisibility = value
|
|
NotifyPropertyChanged("TextDimensionVisibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextDimension As String = "<>"
|
|
Public Property TextDimension As String
|
|
Get
|
|
Return m_TextDimension
|
|
End Get
|
|
Set(value As String)
|
|
m_TextDimension = value
|
|
NotifyPropertyChanged("TextDimension")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_EnablePage As Boolean = True
|
|
Public ReadOnly Property EnablePage As Boolean
|
|
Get
|
|
Return m_EnablePage
|
|
End Get
|
|
End Property
|
|
Public Sub SetEnablePage(bEnablePage As Boolean)
|
|
m_EnablePage = bEnablePage
|
|
NotifyPropertyChanged("EnableCmdSaveImg")
|
|
NotifyPropertyChanged("EnableCmdDimension")
|
|
NotifyPropertyChanged("EnableCmdDist")
|
|
Map.refRefreshPanelVM.NotifyPropertyChanged("EnableRefreschPanel")
|
|
Map.refDimensioningPanelVM.NotifyPropertyChanged("EnableDimensionPanel")
|
|
RaiseEvent EnableCurrentPage()
|
|
End Sub
|
|
|
|
Public ReadOnly Property EnableCmdDist As Boolean
|
|
Get
|
|
Return m_EnablePage
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EnableCmdSaveImg As Boolean
|
|
Get
|
|
Return m_EnablePage
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EnableCmdDimension As Boolean
|
|
Get
|
|
Return m_EnablePage
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
' Definizione comandi
|
|
Private m_cmdLinDim As ICommand
|
|
Private m_cmdPrintHardware As ICommand
|
|
Private m_cmdOkTextDimension As ICommand
|
|
|
|
#Region "COMMAND"
|
|
|
|
#Region "LinearDimensionCommand"
|
|
|
|
Public ReadOnly Property LinearDimensionCommand As ICommand
|
|
Get
|
|
If m_cmdLinDim Is Nothing Then
|
|
m_cmdLinDim = New Command(AddressOf LinearDimension)
|
|
End If
|
|
Return m_cmdLinDim
|
|
End Get
|
|
End Property
|
|
|
|
Private m_DimensioningLayer As Integer
|
|
Public Sub LinearDimension(ByVal param As Object)
|
|
GetDistIsChecked = False
|
|
|
|
Dim nIndFirstPart As Integer = EgtGetFirstPart()
|
|
m_DimensioningLayer = EgtGetFirstNameInGroup(nIndFirstPart, "AUX")
|
|
If Not EgtSetCurrPartLayer(nIndFirstPart, m_DimensioningLayer) Then
|
|
Map.refSceneManagerVM.GetController.ExecuteCommand(Controller.CMD.NEWPART)
|
|
Map.refSceneManagerVM.GetController.ExecuteCommand(Controller.CMD.NEWLAYER)
|
|
nIndFirstPart = EgtGetFirstPart()
|
|
m_DimensioningLayer = EgtGetCurrLayer()
|
|
EgtSetCurrPartLayer(1, m_DimensioningLayer)
|
|
'EgtSetColor(m_DimensioningLayer, "BLACK")
|
|
End If
|
|
' blocco la pagina corrente
|
|
SetEnablePage(False)
|
|
Map.refSceneManagerVM.ProjectScene.SetStatusSelPoint()
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then
|
|
Map.refSceneManagerVM.GetController.ExecuteCommand(Controller.CMD.LINEARDIMENSION)
|
|
Else
|
|
Map.refSceneManagerVM.GetController.ExecuteCommand(Controller.CMD.ALIGNEDDIMENSION)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' LinearDimensionCommand
|
|
|
|
#Region "PrintHardwareCommand"
|
|
|
|
Public ReadOnly Property PrintHardwareCommand As ICommand
|
|
Get
|
|
If m_cmdPrintHardware Is Nothing Then
|
|
m_cmdPrintHardware = New Command(AddressOf PrintHardware)
|
|
End If
|
|
Return m_cmdPrintHardware
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub PrintHardware()
|
|
If Map.refProjectManagerHardwareVM.IsModified Then
|
|
' Project must be saved before printing
|
|
MessageBox.Show(EgtMsg(50186), EgtMsg(50144), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
Return
|
|
End If
|
|
If Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nHardwarePage Then
|
|
If IsNothing(Map.refHardwarePageVM.CurrHardware) OrElse IsNothing(Map.refHardwarePageVM.CurrHardware.SelTemplate) Then Return
|
|
Dim sCurrDir As String = Path.GetDirectoryName(Map.refHardwarePageVM.CurrHardware.CurrPath())
|
|
Dim sImageFile As String = sCurrDir & "\" & Path.GetFileNameWithoutExtension(Map.refHardwarePageVM.CurrHardware.CurrPath) & ".png"
|
|
ExportPngFromNge(sImageFile, 1500, 2000)
|
|
ElseIf Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nDDFPage Then
|
|
If IsNothing(Map.refAssemblyManagerVM.CurrProject) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) OrElse IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name) Then Return
|
|
Dim sImageFile As String = IniFile.m_sTempDir & "\Image.png"
|
|
ExportPngFromNge(sImageFile, 3000, 4000)
|
|
Else
|
|
Return
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region ' PrintHardwareCommand
|
|
|
|
#Region "OkText"
|
|
|
|
Public ReadOnly Property OkTextDimension As ICommand
|
|
Get
|
|
If m_cmdOkTextDimension Is Nothing Then
|
|
m_cmdOkTextDimension = New Command(AddressOf OkText)
|
|
End If
|
|
Return m_cmdOkTextDimension
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub OkText()
|
|
TextDimensionVisibility = Visibility.Collapsed
|
|
Map.refSceneManagerVM.GetController.Done(TextDimension)
|
|
SetEnablePage(True)
|
|
End Sub
|
|
|
|
#End Region ' OkText
|
|
|
|
#End Region ' Command
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Function ExportPngFromNge(ByRef SPathImage As String, nImgW As Integer, nImgH As Integer) As Boolean
|
|
' Creo l'immagine da allegare
|
|
' Nascondo la tavola ed eseguo zoom su quello che rimane
|
|
' EgtZoom(ZM.ALL, True)
|
|
' Prendo l'immagine per la stampa
|
|
Dim colWhite As New Color3d(255, 255, 255)
|
|
' 3000x4000
|
|
' Dim nImgW As Integer = 3000
|
|
' Dim nImgH As Integer = 4000
|
|
Dim sPath As String = SPathImage
|
|
EgtSetLineAttribs(4)
|
|
If Not EgtGetImage(SM.HIDDENLINE, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
' Error in creating the print image
|
|
EgtOutLog(EgtMsg(50181))
|
|
Return False
|
|
End If
|
|
EgtSetLineAttribs(1)
|
|
SPathImage = sPath
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
Map.SetRefInstrumentPanelVM(Me)
|
|
Map.refPartPageVM.PrepareEvent()
|
|
Map.refHardwarePageVM.PrepareEvent()
|
|
IniFile.m_ProjectSceneContext = Map.refSceneManagerVM.ProjectScene.GetCtx
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class |