Imports System.Collections.ObjectModel Imports System.IO Imports EgtUILib Public Class TopCommandBarVM Inherits ViewModelBase #Region "FIELDS & PROPERTIES" Private m_ProjectMode As ProjectModeOpt Public ReadOnly Property MruFileNames As ObservableCollection(Of String) Get Return IniFile.m_MruFiles.m_FileNames End Get End Property Private m_ProjectManager_Visibility As Visibility = Visibility.Visible Public ReadOnly Property ProjectManager_Visibility As Visibility Get Return m_ProjectManager_Visibility End Get End Property Friend Sub SetProjectManagerVisibility(bValue As Boolean) m_ProjectManager_Visibility = If(bValue, Visibility.Visible, Visibility.Collapsed) OnPropertyChanged(NameOf(ProjectManager_Visibility)) End Sub ' Definizione comandi Private m_cmdNew As ICommand Private m_cmdOpen As ICommand Private Shared m_cmdOpenMruFile As ICommand Private m_cmdSave As ICommand Private m_cmdSaveAs As ICommand Private m_cmdInsert As ICommand Private m_cmdImport As ICommand Private m_cmdExport As ICommand Private m_cmdPrint As ICommand Private m_cmdOptions As ICommand Private m_cmdSendFeedback As ICommand #Region "Messages" Public ReadOnly Property DrawMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 1) End Get End Property Public ReadOnly Property MachiningMsg As String Get Return EgtMsg(MSG_MAINWINDOW + 2) End Get End Property #End Region ' Messages #Region "ToolTip" 'Proprietà ToolTip Public ReadOnly Property NewToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 1) End Get End Property Public ReadOnly Property OpenToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 2) End Get End Property Public ReadOnly Property SaveToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 3) End Get End Property Public ReadOnly Property SaveAsToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 4) End Get End Property Public ReadOnly Property InsertToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 5) End Get End Property Public ReadOnly Property ImportToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 6) End Get End Property Public ReadOnly Property ExportToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 7) End Get End Property Public ReadOnly Property PrintToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 15) End Get End Property Public ReadOnly Property OptionsToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 9) End Get End Property Public ReadOnly Property SendFeedbackToolTip As String Get Return EgtMsg(MSG_TOPCOMMANDBAR + 13) End Get End Property #End Region ' ToolTip Private m_DrawIsChecked As Boolean = False Public Property DrawIsChecked As Boolean Get Return m_DrawIsChecked End Get Set(value As Boolean) If value <> m_DrawIsChecked Then m_DrawIsChecked = value ' se non sto uscendo dalle lavorazioni ricarico l'albero delle entità geometriche SetDrawMode(value, Not m_MachiningIsChecked) OnPropertyChanged("DrawIsChecked") End If End Set End Property Private m_MachiningIsChecked As Boolean = False Public Property MachiningIsChecked As Boolean Get Return m_MachiningIsChecked End Get Set(value As Boolean) If value <> m_MachiningIsChecked Then m_MachiningIsChecked = value SetMachiningMode(value) End If End Set End Property Private m_DrawIsEnabled As Boolean = True Public Property DrawIsEnabled As Boolean Get Return m_DrawIsEnabled End Get Set(value As Boolean) m_DrawIsEnabled = value OnPropertyChanged("DrawIsEnabled") End Set End Property Private m_MachiningIsEnabled As Boolean Public Property MachiningIsEnabled As Boolean Get Return m_MachiningIsEnabled End Get Set(value As Boolean) m_MachiningIsEnabled = value OnPropertyChanged("MachiningIsEnabled") End Set End Property Private m_SaveIsEnabled As Boolean = True Public Property SaveIsEnabled As Boolean Get Return m_SaveIsEnabled End Get Set(value As Boolean) If value <> m_SaveIsEnabled Then m_SaveIsEnabled = value OnPropertyChanged("SaveIsEnabled") OnPropertyChanged("SendFeedbackIsEnabled") End If End Set End Property Public ReadOnly Property SendFeedbackIsEnabled As Boolean Get Return m_SaveIsEnabled OrElse Not EgtGetModified() End Get End Property #End Region ' Fields & Properties #Region "Get & Set" Friend Function GetProjectMode() As ProjectModeOpt Return m_ProjectMode End Function Private Sub SetDrawMode(value As Boolean, bLoadObjTree As Boolean) If value Then DrawMode_IsChecked() EgtResetCurrMachGroup() EgtResetCurrPartLayer() EgtZoom(ZM.ALL, False) If Not IsNothing(Map.refManageLayerExpanderVM) Then If bLoadObjTree Then Map.refManageLayerExpanderVM.LoadObjTree() End If IniFile.m_ProjectMode = ProjectModeOpt.DRAW ' attivo database utensili, lavorazioni e setup If Not IsNothing(Map.refMachinePanelVM) Then Map.refMachinePanelVM.ToolMachSetUpIsEnabled(value, value, value) End If ' attivo MTable If Not IsNothing(Map.refDoorPanelVM) Then Map.refDoorPanelVM.MTableIsEnabled(value) End If ' attivo SpecialPanel If Not IsNothing(Map.refSpecialPanelVM) Then Map.refSpecialPanelVM.SpecialPanelIsEnabled(value) End If End If End Sub Private Sub SetMachiningMode(value As Boolean) If value Then ' Flag creazione nuovo gruppo vuoto Dim bAllowEmpty As Boolean = (Keyboard.IsKeyDown(Key.LeftShift) OrElse Keyboard.IsKeyDown(Key.RightShift)) ' Cerco di preimpostare come corrente la macchina opportuna If Not bAllowEmpty AndAlso EgtGetSelectedObjCount() = 0 AndAlso EgtGetMachGroupCount() > 0 Then Dim nMchGrpId As Integer = EgtGetCurrMachGroup() If nMchGrpId = GDB_ID.NULL Then nMchGrpId = EgtGetFirstMachGroup() End If Dim sMachineName As String = "" If EgtGetMachGroupMachineName(nMchGrpId, sMachineName) Then Map.refMachinePanelVM.SelectedMachine = Map.refMachinePanelVM.MachinesList.FirstOrDefault(Function(x) x.Name = sMachineName) End If End If ' Eventuale esecuzione script prima di inizio Mach ExecInitMachScript() ' Inizializzazione gruppo/i di lavoro Map.refMachGroupPanelVM.InitMachGroupList(bAllowEmpty) ' Se non riuscito il passaggio al Machining, lancio lo script di uscita If EgtGetCurrMachGroup() = GDB_ID.NULL Then ExecExitMachScript() EgtDraw() ' altrimenti, aggiusto... Else ' se parametri di una lavorazione aperti, disattivo database utensili, lavorazioni e setup Dim bIsEnabled As Boolean = Not IsNothing(Map.refOperationParametersExpanderVM) AndAlso Not Map.refOperationParametersExpanderVM.ParametersIsExpanded Map.refMachinePanelVM.ToolMachSetUpIsEnabled(bIsEnabled, bIsEnabled, bIsEnabled) ' se parametri di una lavorazione aperti, disattivo MTable e SpecialPanel If Not IsNothing(Map.refDoorPanelVM) Then Map.refDoorPanelVM.MTableIsEnabled(bIsEnabled) If Not IsNothing(Map.refSpecialPanelVM) Then Map.refSpecialPanelVM.SpecialPanelIsEnabled(bIsEnabled) End If Else ' Deseleziono tutto EgtDeselectAll() ' Pulisco lista e geometria faccette di superfici di lavorazione corrente SelData.ClearIdSub() ' Eventuale esecuzione script dopo fine Mach ExecExitMachScript() ' Ricarico albero entità geometriche Map.refManageLayerExpanderVM.LoadObjTree() End If End Sub Private Function ExecInitMachScript() As Boolean ' Recupero il nome dello script e verifico esista Dim sInitMachScriptPath As String = "" If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_INITSCRIPT, "", sInitMachScriptPath, IniFile.m_sCurrMachIniFilePath) = 0 Then Return True sInitMachScriptPath = (IniFile.m_sCurrMachScriptsDirPath & "\" & sInitMachScriptPath).TrimEnd({"\"c}) If Not My.Computer.FileSystem.FileExists(sInitMachScriptPath) Then Return True ' Eseguo lo script EgtLuaCreateGlobTable("MACH") If Not EgtLuaExecFile(sInitMachScriptPath) Then EgtOutLog("Error executing Machining init script " & sInitMachScriptPath) MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 3) & " " & sInitMachScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If Dim nErr As Integer = 999 EgtLuaGetGlobIntVar("MACH.ERR", nErr) EgtLuaResetGlobVar("MACH") Return nErr = 0 End Function Private Function ExecExitMachScript() As Boolean ' Recupero il nome dello script e verifico esista Dim sExitMachScriptPath As String = "" If EgtUILib.GetPrivateProfileString(S_MACHINING, K_MACH_EXITSCRIPT, "", sExitMachScriptPath, IniFile.m_sCurrMachIniFilePath) = 0 Then Return True sExitMachScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sExitMachScriptPath If Not My.Computer.FileSystem.FileExists(sExitMachScriptPath) Then Return True ' Eseguo lo script EgtLuaCreateGlobTable("MACH") If Not EgtLuaExecFile(sExitMachScriptPath) Then EgtOutLog("Error executing Machining exit script " & sExitMachScriptPath) MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 4) & " " & sExitMachScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return False End If Dim nErr As Integer = 999 EgtLuaGetGlobIntVar("MACH.ERR", nErr) EgtLuaResetGlobVar("MACH") Return nErr = 0 End Function #End Region ' Get & Set #Region "CONSTRUCTOR" Sub New() ' Creo riferimento a questa classe in EgtCAM5Map Map.SetRefTopCommandBarVM(Me) ' Inizializzo la selezione della modilità Draw all'apertura del programma DrawIsChecked = True End Sub #End Region #Region "COMMANDS" #Region "NewCommand" ''' ''' Returns a command that do New. ''' Public ReadOnly Property NewCommand As ICommand Get If m_cmdNew Is Nothing Then m_cmdNew = New RelayCommand(AddressOf NewCmd) End If Return m_cmdNew End Get End Property ''' ''' Execute the New. This method is invoked by the NewCommand. ''' Friend Sub NewCmd() Map.refProjectVM.GetController.NewProject(True) If Not IsNothing(Map.refManageLayerExpanderVM) Then Map.refManageLayerExpanderVM.SelectIdInObjTreeNoMark(EgtGetCurrLayer()) OnPropertyChanged("MruFileNames") End Sub #End Region ' NewCommand #Region "OpenCommand" ''' ''' Returns a command that do Open. ''' Public ReadOnly Property OpenCommand As ICommand Get If m_cmdOpen Is Nothing Then m_cmdOpen = New RelayCommand(AddressOf Open) End If Return m_cmdOpen End Get End Property ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Open() OpenProject(String.Empty) End Sub Friend Sub OpenProject(sFilePath As String) If String.IsNullOrEmpty(sFilePath) Then Dim sDir As String = String.Empty GetPrivateProfileString(S_GENERAL, K_LASTNGEDIR, "", sDir) Map.refProjectVM.GetController.OpenProject(sDir) Else Map.refProjectVM.GetController.OpenProject(sFilePath, False) End If If Not IsNothing(Map.refManageLayerExpanderVM) Then Map.refManageLayerExpanderVM.SelectIdInObjTreeNoMark(EgtGetCurrLayer()) End Sub #End Region ' OpenCommand #Region "OpenMruFileCommand" ''' ''' Returns a command that do Open. ''' Public ReadOnly Property OpenMruFileCommand As ICommand Get If m_cmdOpenMruFile Is Nothing Then m_cmdOpenMruFile = New RelayCommand(AddressOf OpenMruFile) End If Return m_cmdOpenMruFile End Get End Property ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Public Sub OpenMruFile(ByVal param As Object) OpenProject(DirectCast(param, String).Replace("__", "_")) End Sub #End Region ' OpenMruFileCommand #Region "SaveCommand" ''' ''' Returns a command that do Save. ''' Public ReadOnly Property SaveCommand As ICommand Get If m_cmdSave Is Nothing Then m_cmdSave = New RelayCommand(AddressOf Save) End If Return m_cmdSave End Get End Property ''' ''' Execute the Save. This method is invoked by the SaveCommand. ''' Public Sub Save(ByVal param As Object) Map.refProjectVM.SaveProject() End Sub #End Region ' SaveCommand #Region "SaveAsCommand" ''' ''' Returns a command that do SaveAs. ''' Public ReadOnly Property SaveAsCommand As ICommand Get If m_cmdSaveAs Is Nothing Then m_cmdSaveAs = New RelayCommand(AddressOf SaveAs) End If Return m_cmdSaveAs End Get End Property ''' ''' Execute the SaveAs. This method is invoked by the SaveAsCommand. ''' Public Sub SaveAs(ByVal param As Object) Map.refProjectVM.SaveAsProject() End Sub #End Region ' SaveAsCommand #Region "InsertCommand" ''' ''' Returns a command that do Insert. ''' Public ReadOnly Property InsertCommand As ICommand Get If m_cmdInsert Is Nothing Then m_cmdInsert = New RelayCommand(AddressOf Insert) End If Return m_cmdInsert End Get End Property ''' ''' Execute the Insert. This method is invoked by the InsertCommand. ''' Public Sub Insert(ByVal param As Object) Map.refProjectVM.InsertProject() End Sub #End Region ' InsertCommand #Region "ImportCommand" ''' ''' Returns a command that do Import. ''' Public ReadOnly Property ImportCommand As ICommand Get If m_cmdImport Is Nothing Then m_cmdImport = New RelayCommand(AddressOf Import) End If Return m_cmdImport End Get End Property ''' ''' Execute the Import. This method is invoked by the ImportCommand. ''' Public Sub Import(ByVal param As Object) Map.refProjectVM.ImportProject() End Sub #End Region ' ImportCommand #Region "ExportCommand" ''' ''' Returns a command that do Export. ''' Public ReadOnly Property ExportCommand As ICommand Get If m_cmdExport Is Nothing Then m_cmdExport = New RelayCommand(AddressOf Export) End If Return m_cmdExport End Get End Property ''' ''' Execute the Export. This method is invoked by the ExportCommand. ''' Public Sub Export(ByVal param As Object) Map.refProjectVM.ExportProject() End Sub #End Region ' ExportCommand #Region "PrintCommand" ''' ''' Returns a command that do Print. ''' Public ReadOnly Property PrintCommand As ICommand Get If m_cmdPrint Is Nothing Then m_cmdPrint = New RelayCommand(AddressOf Print) End If Return m_cmdPrint End Get End Property ''' ''' Execute the Print. This method is invoked by the PrintCommand. ''' Public Sub Print(ByVal param As Object) Dim printDlg As New PrintDialog Dim sPath = IniFile.m_sTempDir & "\Image.png" If printDlg.ShowDialog() Then ' Recupero le dimensioni dell'area di stampa Dim dW As Double = printDlg.PrintableAreaWidth Dim dH As Double = printDlg.PrintableAreaHeight Try 'Prendo l'immagine per la stampa Dim colWhite As New Color3d(255, 255, 255) Dim nImgW As Integer = 3000 Dim nImgH As Integer = 2000 ' recupero lo stile di visualizzazione Dim SM_Select As SM = CType(EgtGetShowMode(), SM) If SM_Select <> SM.SHADING Then EgtSetLineAttribs(3) ' eseguo cattura immagine Dim bOk As Boolean = EgtGetImage(SM_Select, colWhite, colWhite, nImgW, nImgH, sPath) ' ripristino spessore linee Dim nLineWidth As Integer = GetPrivateProfileInt(S_SCENE, K_LINEWIDTH, 1) EgtSetLineAttribs(nLineWidth) ' in caso di errore If Not bOk Then ' Error in creating the print image EgtOutLog(EgtMsg(50181)) Return End If 'Metodo complesso di stampa che permette di rilasciare il file : ' carico la bitmap e la metto in uno stream in memoria Dim stream As System.IO.Stream = New System.IO.MemoryStream() Dim bitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(sPath) bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png) bitmap.Dispose() ' la sposto in una BitmapImage Dim bitImage As New System.Windows.Media.Imaging.BitmapImage() bitImage.BeginInit() bitImage.StreamSource = stream bitImage.EndInit() ' la sposto in un Visual Control Dim tmpImg As New Image tmpImg.BeginInit() tmpImg.Source = bitImage tmpImg.Stretch = Stretch.Uniform tmpImg.EndInit() ' eseguo la stampa printDlg.PrintVisual(tmpImg, "EgtCam5-Print") Catch ' Error in executing print EgtOutLog(EgtMsg(50182)) End Try End If End Sub #End Region ' PrintCommand #Region "OptionsCommand" ''' ''' Returns a command that display Options. ''' Public ReadOnly Property OptionsCommand As ICommand Get If m_cmdOptions Is Nothing Then m_cmdOptions = New RelayCommand(AddressOf Options) End If Return m_cmdOptions End Get End Property ''' ''' Execute the display Options. This method is invoked by the OptionsCommand. ''' Public Sub Options(ByVal param As Object) Dim OptionsWindow As New OptionWindowV OptionsWindow.DataContext = New OptionWindowVM OptionsWindow.Owner = Application.Current.MainWindow OptionsWindow.ShowDialog() End Sub #End Region ' OptionsCommand #Region "SendFeedbackCommand" ''' ''' Returns a command that do SendFeedback. ''' Public ReadOnly Property SendFeedbackCommand As ICommand Get If m_cmdSendFeedback Is Nothing Then m_cmdSendFeedback = New RelayCommand(AddressOf SendFeedback) End If Return m_cmdSendFeedback End Get End Property ''' ''' Execute the SendFeedback. This method is invoked by the SendFeedbackCommand. ''' Public Sub SendFeedback(ByVal param As Object) ' Recupero indirizzo a cui spedire la mail Dim sSupportAddress As String = String.Empty GetPrivateProfileString(S_GENERAL, K_SUPPORT, "support@egaltech.com", sSupportAddress) ' se vuoto do messaggio di errore ed esco If String.IsNullOrWhiteSpace(sSupportAddress) Then MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 10), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) Return End If ' Recupero numero chiave Dim sKey As String = String.Empty EgtGetKeyInfo(sKey) ' Recupero file del progetto corrente Dim sCurrProject As String = String.Empty EgtGetCurrFilePath(sCurrProject) ' se nome file vuoto, chiedo se si vuole salvare If String.IsNullOrWhiteSpace(sCurrProject) Then If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then Map.refProjectVM.SaveProject() End If EgtGetCurrFilePath(sCurrProject) ' se modificato, chiedo se si vuole salvare Else If EgtGetModified() Then If MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 11), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then Map.refProjectVM.SaveProject() End If End If End If ' Verifico se il progetto corrente è una porta Dim nPartId As Integer = EgtGetFirstPart() If nPartId = GDB_ID.NULL Then nPartId = EgtGetFirstPartInRawPart(EgtGetFirstRawPart()) End If Dim sPartName As String = String.Empty EgtGetName(nPartId, sPartName) Dim bPrjIsDoor As Boolean = (String.Compare(sPartName, "DOOR") = 0) ' Recupero macchine dei gruppi di lavoro del progetto Dim Machines As New List(Of String) Dim nMchGrpId As Integer = EgtGetFirstMachGroup() While nMchGrpId <> GDB_ID.NULL Dim sMachineName As String = String.Empty EgtGetMachGroupMachineName(nMchGrpId, sMachineName) If Not String.IsNullOrWhiteSpace(sMachineName) AndAlso Not Machines.Contains( sMachineName) Then Machines.Add(sMachineName) End If nMchGrpId = EgtGetNextMachGroup(nMchGrpId) End While ' Recupero altri file con lo stesso nome del progetto Dim OtherFiles As New List(Of String) If Not String.IsNullOrWhiteSpace(sCurrProject) Then Dim sCurrProjectDir As String = Path.GetDirectoryName(sCurrProject) If Not String.IsNullOrWhiteSpace(sCurrProjectDir) Then Dim sCurrProjName As String = Path.GetFileNameWithoutExtension(sCurrProject).ToUpper() Dim TempFiles() As String = Directory.GetFiles(sCurrProjectDir) For FileIndex = 0 To TempFiles.Count - 1 If TempFiles(FileIndex) = sCurrProject Then Continue For Dim sCurrFileName As String = Path.GetFileNameWithoutExtension( TempFiles(FileIndex)).ToUpper() If ( String.Compare(sCurrFileName, sCurrProjName) = 0 OrElse sCurrFileName.Contains( sCurrProjName & "_")) Then OtherFiles.Add(TempFiles(FileIndex)) End If Next End If End If ' Creo zip file da allegare Dim sZipToCreate As String = IniFile.m_sTempDir & "\Feedback.zip" If File.Exists(sZipToCreate) Then File.Delete(sZipToCreate) End If Try Using zip As New Ionic.Zip.ZipFile(sZipToCreate) zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always zip.AlternateEncoding = Text.Encoding.UTF8 ' aggiungo file macchine For Each sMachineName As String In Machines Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & sMachineName If Directory.Exists(sMachineDir) Then zip.AddSelectedFiles( "name != *\.git\*.* and name != *.git*", sMachineDir, sMachineName, True) End If Next ' aggiungo progetto corrente If File.Exists(sCurrProject) Then zip.AddItem(sCurrProject, "") End If ' aggiungo file log If File.Exists(IniFile.m_sLogFile) Then zip.AddItem(IniFile.m_sLogFile, "") End If ' aggiungo file ausiliari For Each sOther As String In OtherFiles zip.AddItem(sOther, "") Next ' se door attivo, progetto corrente è una porta e definito direttorio base di Doors If IniFile.IsActiveDoors And bPrjIsDoor And Directory.Exists(IniFile.m_sDoorsDirPath) Then ' aggiungo Doors completo zip.AddItem(IniFile.m_sDoorsDirPath, "Doors") End If ' salvo lo zip zip.Save() End Using Catch ex1 As Exception EgtOutLog("Exception in zip: " & ex1.ToString()) End Try ' preparo la mail per il supporto Dim bEx As Boolean = False Try Dim sAddressArray As String() = sSupportAddress.Split(","c) Dim SendFeedbackWindow As New EgtWPFLib5.MapiMailMessage("EgtCAM5 Feedback - " & sKey) SendFeedbackWindow.Recipients.Add(sAddressArray(0)) For index As Integer = 1 To sAddressArray.Length() - 1 SendFeedbackWindow.Recipients.Add(sAddressArray(index), EgtWPFLib5.MapiMailMessage.RecipientType.CC) Next If Not String.IsNullOrWhiteSpace(sZipToCreate) AndAlso File.Exists(sZipToCreate) Then SendFeedbackWindow.Files.Add(IniFile.m_sTempDir & "\Feedback.zip") End If SendFeedbackWindow.ShowDialog() Catch ex As Exception EgtOutLog("Feedback exception: " & ex.ToString) bEx = True End Try If bEx OrElse EgtWPFLib5.MapiMailMessage.m_ErrorCode <> 0 Then MessageBox.Show(String.Format(EgtMsg(MSG_TOPCOMMANDBAR + 12), sSupportAddress, sZipToCreate), EgtMsg(MSG_MESSAGEBOX + 3), MessageBoxButton.OK, MessageBoxImage.Information) Else Map.refStatusBarVM.NotifyStatusOutput(EgtMsg(MSG_TOPCOMMANDBAR + 14)) End If End Sub #End Region ' SendFeedbackCommand #End Region ' Commands #Region "METHODS" Friend Sub MachGroupsResult(nErr As Integer) If nErr = 0 Then Map.refMachinePanelVM.UpdateCurrentMachine() MachiningMode_IsChecked() If Not IsNothing(Map.refMachiningTreeExpanderVM) Then Map.refMachiningTreeExpanderVM.UpdateOperationMachiningList() IniFile.m_ProjectMode = ProjectModeOpt.MACHINING Else m_MachiningIsChecked = False If nErr = 1 Then ' Error loading or creating Machining Group - LAVORA MessageBox.Show(EgtMsg(10008), EgtMsg(5002), MessageBoxButton.OK, MessageBoxImage.Error) ElseIf nErr = -1 Then ' Non ci sono gruppi di lavoro - LAVORA MessageBox.Show(EgtMsg(5551), EgtMsg(5002), MessageBoxButton.OK, MessageBoxImage.Information) End If End If End Sub Friend Sub SetMachiningMode() MachiningIsChecked = True OnPropertyChanged("MachiningIsChecked") End Sub Friend Sub DrawMode_IsChecked() ' OperationsListExpanderVM If Not IsNothing(Map.refOperationsListExpanderVM) Then Map.refOperationsListExpanderVM.DrawMode_IsChecked() End If ' ProjectV If Not IsNothing(Map.refProjectV) Then If IniFile.IsActivePlugin() Then For Each Panel In Map.refProjectVM.PanelList If TypeOf Panel Is WinFormPluginControlV Then Dim WinFormPanel As WinFormPluginControlV = TryCast(Panel, WinFormPluginControlV) If Not IsNothing(WinFormPanel) Then WinFormPanel.WinFormPluginControlVM.SetPanelVisibility(ProjectModeOpt.DRAW) End If End If Next End If Map.refProjectV.DrawMode_IsChecked() Map.refMachinePanelVM.SetMachinePanelVisibility(IniFile.m_ProjectMode <> ProjectModeOpt.ONLYDRAW) Map.refExecutePanelVM.SetExecutePanelVisibility(GetPrivateProfileInt(S_GENERAL, K_EXECUTE, 0) = 1) Map.refSpecialPanelVM.SetSpecialPanelVisibility(IniFile.IsActiveSpecialPanel() And Map.refSpecialPanelVM.SetSpecialPanelButtonsVisibility(False)) Map.refBeamPanelVM.SetBeamPanelVisibility(IniFile.IsActiveBeam()) Map.refWallPanelVM.SetWallPanelVisibility(IniFile.IsActiveWall()) Map.refBeamWallPanelVM.SetBeamWallPanelVisibility(IniFile.IsActiveBeam() Or IniFile.IsActiveWall()) Map.refDoorPanelVM.SetDoorPanelVisibility(IniFile.IsActiveDoors()) Map.refGunStockPanelVM.SetGunStockPanelVisibility(IniFile.IsActiveGunStock()) If Not IsNothing(Map.refDrawPanelVM) Then Map.refDrawPanelVM.SetDrawPanelVisibility(True) Map.refMachGroupPanelVM.SetMachGroupPanelVisibility(False) If IniFile.IsActiveDoors() Then Map.refDoorPanelVM.SetDoorPanelButtonsVisibility(True) Map.refOptionPanelVM.SetPanelVisibility(ProjectModeOpt.DRAW) End If ' ProjectVM If Not IsNothing(Map.refProjectVM) Then Map.refProjectVM.DrawMode_IsChecked() End If ' OptionPanelVM If Not IsNothing(Map.refOptionPanelVM) Then Map.refOptionPanelVM.DrawMode_IsChecked() End If ' MyMachinePanelVM If Not IsNothing(Map.refMachinePanelVM) Then Map.refMachinePanelVM.MachineListIsEnabled = True End If ' InstrumentPanel If Not IsNothing(Map.refInstrumentPanelVM) Then Map.refInstrumentPanelVM.AnalyzeIsEnabled = True End If ' MyStatusBarVM If Not IsNothing(Map.refStatusBarVM) Then Map.refStatusBarVM.OutputMessage = String.Empty End If End Sub Friend Sub MachiningMode_IsChecked() ' ProjectV If IniFile.IsActivePlugin() Then For Each Panel In Map.refProjectVM.PanelList If TypeOf Panel Is WinFormPluginControlV Then Dim WinFormPanel As WinFormPluginControlV = TryCast(Panel, WinFormPluginControlV) If Not IsNothing(WinFormPanel) Then WinFormPanel.WinFormPluginControlVM.SetPanelVisibility(ProjectModeOpt.MACHINING) End If End If Next End If Map.refProjectV.MachiningMode_IsChecked() Map.refMachinePanelVM.SetMachinePanelVisibility(True) Map.refExecutePanelVM.SetExecutePanelVisibility(False) Map.refSpecialPanelVM.SetSpecialPanelVisibility(IniFile.IsActiveSpecialPanel() And Map.refSpecialPanelVM.SetSpecialPanelButtonsVisibility(True)) Map.refBeamPanelVM.SetBeamPanelVisibility(False) Map.refWallPanelVM.SetWallPanelVisibility(False) Map.refBeamWallPanelVM.SetBeamWallPanelVisibility(False) Map.refDoorPanelVM.SetDoorPanelVisibility(IniFile.IsActiveDoors()) Map.refGunStockPanelVM.SetGunStockPanelVisibility(False) If Not IsNothing(Map.refDrawPanelVM) Then Map.refDrawPanelVM.SetDrawPanelVisibility(False) Map.refMachGroupPanelVM.SetMachGroupPanelVisibility(IniFile.m_bMachiningGroup) If IniFile.IsActiveDoors() Then Map.refDoorPanelVM.SetDoorPanelButtonsVisibility(False) Map.refOptionPanelVM.SetPanelVisibility(ProjectModeOpt.MACHINING) ' ProjectVM Map.refProjectVM.MachiningMode_IsChecked() ' OptionPanelVM If Not IsNothing(Map.refOptionPanelVM) Then Map.refOptionPanelVM.MachiningMode_IsChecked() ' MyMachinePanelVM Map.refMachinePanelVM.MachineListIsEnabled = False ' InstrumentPanel Map.refInstrumentPanelVM.AnalyzeIsChecked = False Map.refInstrumentPanelVM.AnalyzeIsEnabled = False ' MyStatusBarVM Map.refStatusBarVM.OutputMessage = String.Empty End Sub #End Region End Class