EgtCAM5 :
- Cambiati nomi classi e file.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<UserControl x:Class="MachGroupPanelV"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5">
|
||||
|
||||
<Grid IsEnabled="{Binding MachGroupPanelIsEnabled}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ListBox ItemsSource="{Binding MachGroupList}" SelectedItem="{Binding SelectedMachGroup}"
|
||||
Style="{StaticResource MachiningGroupListBox}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<ContentPresenter/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<RadioButton GroupName="MachiningGroups"
|
||||
Height="30" MaxWidth="150" Margin="0,0,2,0" Padding="5,0,5,0" ToolTip="{Binding}"
|
||||
Style="{StaticResource MachGroupButton}"
|
||||
Command="{Binding DataContext.SetCurrMachGroupCommand,
|
||||
RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type UserControl}}}"
|
||||
CommandParameter="{Binding}"
|
||||
IsChecked="{Binding Path=IsSelected, RelativeSource={
|
||||
RelativeSource AncestorType={x:Type ListBoxItem}},Mode=TwoWay}">
|
||||
<RadioButton.Content>
|
||||
<TextBlock Text="{Binding}"/>
|
||||
</RadioButton.Content>
|
||||
|
||||
</RadioButton>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<Button Content="+" Height="20" Width="20" VerticalAlignment="Center" Focusable="False"
|
||||
Margin="3,0,5,0" Command="{Binding AddMachGroupCommand}" Grid.Column="1"/>
|
||||
<Button Content="-" Height="20" Width="20" VerticalAlignment="Center" Focusable="False"
|
||||
Margin="0,0,5,0" Command="{Binding RemoveMachGroupCommand}" Grid.Column="2"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,3 @@
|
||||
Public Class MachGroupPanelV
|
||||
|
||||
End Class
|
||||
@@ -0,0 +1,279 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports System.IO
|
||||
Imports EgtUILib
|
||||
|
||||
Namespace EgtCAM5
|
||||
|
||||
Public Class MachGroupPanelVM
|
||||
Inherits ViewModelBase
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
Private m_MachGroupList As New ObservableCollection(Of String)
|
||||
Public Property MachGroupList As ObservableCollection(Of String)
|
||||
Get
|
||||
Return m_MachGroupList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of String))
|
||||
If value IsNot m_MachGroupList Then
|
||||
m_MachGroupList = value
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_SelectedMachGroup As String
|
||||
Public Property SelectedMachGroup As String
|
||||
Get
|
||||
Return m_SelectedMachGroup
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_SelectedMachGroup = value
|
||||
OnPropertyChanged("SelectedMachGroup")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_IsEnabled As Boolean = True
|
||||
Public Property MachGroupPanelIsEnabled As Boolean
|
||||
Get
|
||||
Return m_IsEnabled
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
m_IsEnabled = value
|
||||
OnPropertyChanged("MachGroupPanelIsEnabled")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdSetCurrMachGroup As ICommand
|
||||
Private m_cmdAddMachGroup As ICommand
|
||||
Private m_cmdRemoveMachGroup As ICommand
|
||||
|
||||
#End Region ' FIELDS & PROPERTIES
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
Application.Msn.Register(Application.INITIALIZEMACHGROUPS, Sub()
|
||||
InitializeMachGroups()
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.MACHGROUPSISENABLED, Sub(MgpIsEnabled As Boolean)
|
||||
Me.MachGroupPanelIsEnabled = MgpIsEnabled
|
||||
End Sub)
|
||||
End Sub
|
||||
|
||||
#End Region ' CONSTRUCTOR
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
Private Sub InitializeMachGroups()
|
||||
' calcolo bbox di tutti i pezzi disegnati
|
||||
'Dim bboxAllParts As New BBox3d
|
||||
'CalculateAllPartsBbox(bboxAllParts)
|
||||
Dim bOk As Boolean = False
|
||||
Dim nId = EgtGetLastMachGroup()
|
||||
If nId <> GDB_ID.NULL Then
|
||||
bOk = EgtSetCurrMachGroup(nId)
|
||||
Else
|
||||
bOk = AddNewMachGroup()
|
||||
End If
|
||||
If bOk Then
|
||||
'CalculatePartsTranslationVt(bboxAllParts)
|
||||
'TraslateParts()
|
||||
LoadMachGroups()
|
||||
SelectedMachGroup = MachGroupList(MachGroupList.Count() - 1)
|
||||
End If
|
||||
If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True)
|
||||
Application.Msn.NotifyColleagues(Application.MACHGROUPSRESULT, bOk)
|
||||
End Sub
|
||||
|
||||
Private Sub CalculateAllPartsBbox(ByRef bboxAllParts As BBox3d)
|
||||
Dim nPart As Integer = EgtGetFirstPart()
|
||||
While nPart <> GDB_ID.NULL
|
||||
Dim bboxPart As New BBox3d
|
||||
EgtGetBBoxGlob(nPart, GDB_BB.STANDARD, bboxPart)
|
||||
bboxAllParts.Add(bboxPart)
|
||||
nPart = EgtGetNextPart(nPart)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
Private Sub CalculatePartsTranslationVt(bboxAllParts As BBox3d)
|
||||
' recupero area della tavola
|
||||
Dim ptTableMin As Point3d
|
||||
Dim ptTableMax As Point3d
|
||||
Dim X = EgtGetTableArea(1, ptTableMin, ptTableMax)
|
||||
IniFile.m_vtMachPartsPos = (New Point3d(ptTableMin.x, ptTableMin.y - 250, ptTableMin.z) - New Point3d(bboxAllParts.Min.x, bboxAllParts.Max.y, bboxAllParts.Min.z))
|
||||
End Sub
|
||||
|
||||
Private Sub TraslateParts()
|
||||
Dim nPart As Integer = EgtGetFirstPart()
|
||||
While nPart <> GDB_ID.NULL
|
||||
EgtMove(nPart, IniFile.m_vtMachPartsPos)
|
||||
nPart = EgtGetNextPart(nPart)
|
||||
End While
|
||||
nPart = EgtGetFirstGhostPart()
|
||||
While nPart <> GDB_ID.NULL
|
||||
EgtMove(nPart, IniFile.m_vtMachPartsPos)
|
||||
nPart = EgtGetNextGhostPart(nPart)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
Private Sub LoadMachGroups()
|
||||
' Pulisco la lista
|
||||
MachGroupList.Clear()
|
||||
' Carico i gruppi di lavorazione nella lista
|
||||
Dim nId = EgtGetFirstMachGroup()
|
||||
While nId <> GDB_ID.NULL
|
||||
Dim sName As String = String.Empty
|
||||
EgtGetMachGroupName(nId, sName)
|
||||
MachGroupList.Add(sName)
|
||||
nId = EgtGetNextMachGroup(nId)
|
||||
End While
|
||||
End Sub
|
||||
|
||||
Private Function AddNewMachGroup() As Boolean
|
||||
' Creazione nuovo gruppo di lavorazione
|
||||
Dim sNewMachName As String = "Mach_1"
|
||||
EgtGetMachGroupNewName(sNewMachName)
|
||||
Dim bOk As Boolean = (EgtAddMachGroup(sNewMachName) <> GDB_ID.NULL)
|
||||
' leggo nome script di disposizione automatica
|
||||
Dim sInitScriptPath As String = String.Empty
|
||||
EgtUILib.GetPrivateProfileString(S_DISPOSITION, K_INITSCRIPT, "", sInitScriptPath, IniFile.m_sCurrMachIniFilePath)
|
||||
' se è attivo, uso lo script di disposizione
|
||||
If bOk AndAlso OptionModule.m_bUseDispositionScript And Not String.IsNullOrEmpty(sInitScriptPath) Then
|
||||
sInitScriptPath = IniFile.m_sCurrMachScriptsDirPath & "\" & sInitScriptPath
|
||||
If Not File.Exists(sInitScriptPath) OrElse Not EgtLuaExecFile(sInitScriptPath) Then
|
||||
EgtOutLog("Error executing disposition init script " & sInitScriptPath)
|
||||
MessageBox.Show(EgtMsg(MSG_DISPOSITIONERRORS + 2) & " " & sInitScriptPath, EgtMsg(MSG_DISPOSITIONERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
End If
|
||||
End If
|
||||
' leggo nome attrezzaggio di default
|
||||
Dim sDefaultSetUpName As String = String.Empty
|
||||
EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", sDefaultSetUpName, IniFile.m_sCurrMachIniFilePath)
|
||||
' se è attiva l'opzione, rendo corrente l'attrezzaggio di default
|
||||
If bOk And Not String.IsNullOrEmpty(sDefaultSetUpName) Then
|
||||
If Not EgtImportSetup(String.Empty) Then
|
||||
EgtOutLog("Error loading default setup " & sDefaultSetUpName)
|
||||
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & sDefaultSetUpName, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
End If
|
||||
End If
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "SetCurrMachGroupCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that set the selected MachGroup as the Current one.
|
||||
''' </summary>
|
||||
Public ReadOnly Property SetCurrMachGroupCommand As ICommand
|
||||
Get
|
||||
If m_cmdSetCurrMachGroup Is Nothing Then
|
||||
m_cmdSetCurrMachGroup = New RelayCommand(AddressOf SetCurrMachGroup)
|
||||
End If
|
||||
Return m_cmdSetCurrMachGroup
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub SetCurrMachGroup(ByVal param As Object)
|
||||
EgtSetCurrMachGroup(EgtGetMachGroupId(DirectCast(param, String)))
|
||||
If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True)
|
||||
EgtZoom(ZM.ALL)
|
||||
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
|
||||
Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE)
|
||||
End Sub
|
||||
|
||||
#End Region ' SetCurrMachGroupCommand
|
||||
|
||||
#Region "AddMachGroupCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that set the selected MachGroup as the Current one.
|
||||
''' </summary>
|
||||
Public ReadOnly Property AddMachGroupCommand As ICommand
|
||||
Get
|
||||
If m_cmdAddMachGroup Is Nothing Then
|
||||
m_cmdAddMachGroup = New RelayCommand(AddressOf AddMachGroup)
|
||||
End If
|
||||
Return m_cmdAddMachGroup
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub AddMachGroup()
|
||||
If AddNewMachGroup() Then
|
||||
Dim sMachName As String = String.Empty
|
||||
EgtGetMachGroupName(EgtGetCurrMachGroup(), sMachName)
|
||||
MachGroupList.Add(sMachName)
|
||||
SelectedMachGroup = sMachName
|
||||
EgtDraw()
|
||||
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
|
||||
Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region ' AddMachGroupCommand
|
||||
|
||||
#Region "RemoveMachGroupCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that set the selected MachGroup as the Current one.
|
||||
''' </summary>
|
||||
Public ReadOnly Property RemoveMachGroupCommand As ICommand
|
||||
Get
|
||||
If m_cmdRemoveMachGroup Is Nothing Then
|
||||
m_cmdRemoveMachGroup = New RelayCommand(AddressOf RemoveMachGroup)
|
||||
End If
|
||||
Return m_cmdRemoveMachGroup
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub RemoveMachGroup()
|
||||
' Calcolo indice del gruppo da cancellare
|
||||
Dim nSelectedMachGroupIndex As Integer = MachGroupList.IndexOf(SelectedMachGroup)
|
||||
If nSelectedMachGroupIndex = 0 And MachGroupList.Count = 1 Then
|
||||
' chiedo conferma prima di cancellare il gruppo di lavorazione
|
||||
Select Case MessageBox.Show(EgtMsg(MSG_MACHGROUP + 2), "", MessageBoxButton.YesNo, MessageBoxImage.Question)
|
||||
Case MessageBoxResult.Yes
|
||||
' cancello il gruppo corrente
|
||||
EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex)))
|
||||
' aggiorno la lista dei gruppi
|
||||
MachGroupList.RemoveAt(nSelectedMachGroupIndex)
|
||||
' ritorno alla modalità disegno
|
||||
Map.refTopCommandBarVM.DrawIsChecked = True
|
||||
Case MessageBoxResult.No
|
||||
Return
|
||||
End Select
|
||||
Else
|
||||
' chiedo conferma prima di cancellare il gruppo di lavorazione
|
||||
Select Case MessageBox.Show(EgtMsg(MSG_MACHGROUP + 2), "", MessageBoxButton.YesNo, MessageBoxImage.Question)
|
||||
Case MessageBoxResult.Yes
|
||||
If nSelectedMachGroupIndex = 0 And MachGroupList.Count > 1 Then
|
||||
' rendo corrente il gruppo di lavorazione successivo a quello da cancellare
|
||||
EgtSetCurrMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex + 1)))
|
||||
SelectedMachGroup = MachGroupList(nSelectedMachGroupIndex + 1)
|
||||
ElseIf nSelectedMachGroupIndex > 0 Then
|
||||
' rendo corrente il gruppo di lavorazione precedente a quello da cancellare
|
||||
EgtSetCurrMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex - 1)))
|
||||
SelectedMachGroup = MachGroupList(nSelectedMachGroupIndex - 1)
|
||||
End If
|
||||
EgtDraw()
|
||||
' cancello quello selezionato
|
||||
EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex)))
|
||||
' aggiorno la lista dei gruppi
|
||||
MachGroupList.RemoveAt(nSelectedMachGroupIndex)
|
||||
Case MessageBoxResult.No
|
||||
Return
|
||||
End Select
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region ' RemoveMachGroupCommand
|
||||
|
||||
#End Region ' COMMANDS
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user