EgtCAM5 :
- Cambiati nomi classi e file.
This commit is contained in:
+74
@@ -0,0 +1,74 @@
|
||||
<UserControl x:Class="MachiningTreeExpanderView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
|
||||
xmlns:local="clr-namespace:EgtCAM5">
|
||||
|
||||
<Expander Header="{Binding MachListHdr}" IsExpanded="{Binding IsEnabled}" IsEnabled="{Binding IsEnabled}"
|
||||
Style="{StaticResource ExpanderStyle}">
|
||||
<UniformGrid MaxHeight="100">
|
||||
<TreeView Name="MachiningsTreeView" Grid.Row="1"
|
||||
ItemsSource="{Binding Path=MachiningsList}">
|
||||
<!--<interactivity:Interaction.Triggers>
|
||||
<interactivity:EventTrigger EventName="MouseDoubleClick">
|
||||
<interactivity:InvokeCommandAction Command="{Binding TreeViewDoubleClickCommand}" CommandParameter="{Binding ElementName=MachiningsTreeView,Path=SelectedItem}"/>
|
||||
</interactivity:EventTrigger>
|
||||
</interactivity:Interaction.Triggers>-->
|
||||
<TreeView.InputBindings>
|
||||
<KeyBinding Key="Escape" Command="{Binding CancelNewCommand}" CommandParameter="Escape"/>
|
||||
</TreeView.InputBindings>
|
||||
<TreeView.Resources>
|
||||
<!--Modifico HierarchicalDataTemplate del CathegoryItem per poter inserire immagine e testo e per -->
|
||||
<!--renderlo apribile con un solo click -->
|
||||
<HierarchicalDataTemplate DataType="{x:Type local:FamilyMachiningTreeViewExpanderItem}" ItemsSource="{Binding Items}">
|
||||
|
||||
<Grid >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image Grid.Column="0" Source="{Binding PictureString}" Height="15" Margin="0,0,5,0"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!--Assegna ai nodi ToolItem lo Style normale dei TreeViewItem, eliminando l'ombra, data dal
|
||||
multibinding quando sono attivi.-->
|
||||
<HierarchicalDataTemplate.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}" >
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="MachiningsTreeView_MouseDoubleClick"/>
|
||||
</Style>
|
||||
</HierarchicalDataTemplate.ItemContainerStyle>
|
||||
|
||||
</HierarchicalDataTemplate>
|
||||
<!--Modifico DataTemplate del ToolItem per poter inserire immagine e testo-->
|
||||
<DataTemplate DataType="{x:Type local:MachiningTreeViewExpanderItem}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="{Binding Name}" Margin="0,0,5,0"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Tool}"/>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
|
||||
<!--Style dei nodi CathegoryItem che li riquadra di azzurro quando clicckati ed elimina l'ombra grigia -->
|
||||
<!--che si presenta quando la categoria rimane vuota (ombra causata dal multibinding). -->
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
|
||||
</TreeView>
|
||||
</UniformGrid>
|
||||
</Expander>
|
||||
|
||||
</UserControl>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Public Class MachiningTreeExpanderView
|
||||
|
||||
' Evento necessario per impedire che venga creata la lavorazione quando si fa doppio click sulla ScrollBar
|
||||
Private Sub MachiningsTreeView_MouseDoubleClick(sender As Object, e As System.Windows.Input.MouseButtonEventArgs)
|
||||
'Dim src As DependencyObject = VisualTreeHelper.GetParent(DirectCast(e.OriginalSource, DependencyObject))
|
||||
|
||||
'' Your logic here
|
||||
'If TypeOf src Is Control AndAlso src.[GetType]() <> GetType(Grid) Then
|
||||
' e.Handled = True
|
||||
'End If
|
||||
' recupero il viewmodel associato a questa view in cui è presente la funzione che l'evento deve lanciare
|
||||
Dim MachiningTreeExpanderViewModel As EgtCAM5.MachiningTreeExpanderViewModel = DirectCast(Me.DataContext, EgtCAM5.MachiningTreeExpanderViewModel)
|
||||
' recupero il treeviewitem clickato(sorgente dell'evento)
|
||||
Dim ClickedTreeViewItem As TreeViewItem = DirectCast(sender, TreeViewItem)
|
||||
' ne recupero il VM da passare alla funzione
|
||||
Dim ClickedTreeViewItemVM As MachiningTreeViewExpanderItem = DirectCast(ClickedTreeViewItem.DataContext, MachiningTreeViewExpanderItem)
|
||||
MachiningTreeExpanderViewModel.TreeViewDoubleClick(ClickedTreeViewItemVM)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports EgtUILib
|
||||
|
||||
Namespace EgtCAM5
|
||||
|
||||
Public Class MachiningTreeExpanderViewModel
|
||||
Inherits ViewModelBase
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
Private m_CodeCommand As Boolean = False
|
||||
Private m_IsEnabled As Boolean
|
||||
Public Property IsEnabled As Boolean
|
||||
Get
|
||||
Return m_IsEnabled
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
If value <> m_IsEnabled Then
|
||||
m_IsEnabled = value
|
||||
If Not value And Not m_CodeCommand Then
|
||||
Application.Msn.NotifyColleagues(Application.CANCELOPERATIONCOMMAND)
|
||||
End If
|
||||
m_CodeCommand = False
|
||||
OnPropertyChanged("IsEnabled")
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Lista delle lavorazioni
|
||||
Private m_MachiningsList As New ObservableCollection(Of FamilyMachiningTreeViewExpanderItem)
|
||||
Public Property MachiningsList As ObservableCollection(Of FamilyMachiningTreeViewExpanderItem)
|
||||
Get
|
||||
Return m_MachiningsList
|
||||
End Get
|
||||
Set(value As ObservableCollection(Of FamilyMachiningTreeViewExpanderItem))
|
||||
m_MachiningsList = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Operazione correntemente selezionata, che permette di aggiungere al posto giusto quella nuova
|
||||
Private m_nSelectedOperationId As Integer = -1
|
||||
|
||||
Public ReadOnly Property MachListHdr As String
|
||||
Get
|
||||
Return EgtMsg(5412) ' Nuove Lavorazioni
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdTreeViewDoubleClick As ICommand
|
||||
Private m_cmdCancelNew As ICommand
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
' Per caricare l'albero la prima volta che viene aperto
|
||||
IsEnabled = False
|
||||
LoadSelectedMachineMachinings()
|
||||
Application.Msn.Register(Application.UPDATEOPERATIONMACHININGLIST, Sub()
|
||||
m_MachiningsList.Clear()
|
||||
LoadSelectedMachineMachinings()
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.MACHININGTREEVIEWEXPANDERISENABLED, Sub(bValue As Boolean)
|
||||
m_CodeCommand = True
|
||||
IsEnabled = bValue
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.SELECTEDOPERATION, Sub(SelectedOperation As OperationListBoxItem)
|
||||
m_nSelectedOperationId = SelectedOperation.Id
|
||||
End Sub)
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "TreeViewDoubleClickCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do TreeViewDoubleClick.
|
||||
''' </summary>
|
||||
Public ReadOnly Property TreeViewDoubleClickCommand As ICommand
|
||||
Get
|
||||
If m_cmdTreeViewDoubleClick Is Nothing Then
|
||||
m_cmdTreeViewDoubleClick = New RelayCommand(AddressOf TreeViewDoubleClick)
|
||||
End If
|
||||
Return m_cmdTreeViewDoubleClick
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the TreeViewDoubleClick. This method is invoked by the TreeViewDoubleClickCommand.
|
||||
''' </summary>
|
||||
Public Sub TreeViewDoubleClick(ByVal param As Object)
|
||||
If TypeOf param Is MachiningTreeViewExpanderItem Then
|
||||
Dim Machining As MachiningTreeViewExpanderItem = DirectCast(param, MachiningTreeViewExpanderItem)
|
||||
' Creo nuova lavorazione(operazione) con la lavorazione selezionata
|
||||
Dim MachiningId As Integer = EgtAddMachining(MachiningTypeToString(Machining.Type) & "_1", Machining.Name)
|
||||
' Se è abilitata l'opzione
|
||||
If Not OptionModule.m_bNewMachiningIsLastOne Then
|
||||
' Sposto la lavorazione aggiunta subito dopo quella appena selezionata
|
||||
EgtRelocate(MachiningId, m_nSelectedOperationId, GDB_POS.AFTER)
|
||||
End If
|
||||
' Recupero geometria correntemente selezionata e la metto in un vettore
|
||||
Dim SelectedEntities As New List(Of Integer)
|
||||
Dim EntityId As Integer = EgtGetFirstSelectedObj()
|
||||
While EntityId <> GDB_ID.NULL
|
||||
SelectedEntities.Add(EntityId)
|
||||
EntityId = EgtGetNextSelectedObj()
|
||||
End While
|
||||
' Imposto l'operazione appena creata come corrente
|
||||
EgtSetCurrMachining(MachiningId)
|
||||
If SelectedEntities.Count = 1 AndAlso EgtGetType(SelectedEntities(0)) = GDB_TY.SRF_MESH Then
|
||||
Dim nF As Integer = EgtSurfTmFacetFromTria(SelectedEntities(0), IniFile.m_LastSubEntityId)
|
||||
If nF < 0 Then nF = 0
|
||||
Dim SubEntityArray As Integer() = {nF}
|
||||
EgtSetMachiningGeometry(SelectedEntities.ToArray, SubEntityArray)
|
||||
Else
|
||||
' Imposto il vettore come geometria di lavorazione
|
||||
EgtSetMachiningGeometry(SelectedEntities.ToArray)
|
||||
End If
|
||||
' Calcolo la lavorazione con la nuova geometria
|
||||
EgtApplyMachining(True)
|
||||
EgtDraw()
|
||||
' Ricarico la lista operazioni per avere quella nuova
|
||||
Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1)
|
||||
' disabilito la modalità nuova lavorazione
|
||||
Application.Msn.NotifyColleagues(Application.NEWMACHININGMODEISACTIVE, New NewMachOpParam(False, MachiningId))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function MachiningTypeToString(Type As Integer) As String
|
||||
Select Case Type
|
||||
Case MCH_MY.DRILLING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 1)
|
||||
Case MCH_MY.SAWING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 2)
|
||||
Case MCH_MY.MILLING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 3)
|
||||
Case MCH_MY.POCKETING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 4)
|
||||
Case MCH_MY.MORTISING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 5)
|
||||
Case MCH_MY.SAWROUGHING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 6)
|
||||
Case MCH_MY.SAWFINISHING
|
||||
Return EgtMsg(MSG_MACHININGSDBPAGE + 7)
|
||||
Case Else
|
||||
Return "Mach"
|
||||
End Select
|
||||
End Function
|
||||
|
||||
#End Region ' TreeViewDoubleClickCommand
|
||||
|
||||
#Region "CancelNewCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that do TreeViewDoubleClick.
|
||||
''' </summary>
|
||||
Public ReadOnly Property CancelNewCommand As ICommand
|
||||
Get
|
||||
If m_cmdCancelNew Is Nothing Then
|
||||
m_cmdCancelNew = New RelayCommand(AddressOf CancelNew)
|
||||
End If
|
||||
Return m_cmdCancelNew
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Execute the TreeViewDoubleClick. This method is invoked by the TreeViewDoubleClickCommand.
|
||||
''' </summary>
|
||||
Public Sub CancelNew(ByVal param As Object)
|
||||
Application.Msn.NotifyColleagues(Application.CANCELOPERATIONCOMMAND)
|
||||
End Sub
|
||||
|
||||
#End Region ' CancelNewCommand
|
||||
|
||||
#End Region ' Commands
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
''' <summary>
|
||||
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
|
||||
''' </summary>
|
||||
Private Sub LoadSelectedMachineMachinings()
|
||||
Dim ActiveMachiningsTypes() As MachiningsType = MachineModel.ReadActiveMachiningsFamilies()
|
||||
For Each MachiningsType In ActiveMachiningsTypes
|
||||
Dim FamilyTreeView As New FamilyMachiningTreeViewExpanderItem(MachiningsType.TypeName, MachiningsType.TypeId)
|
||||
MachiningsList.Add(FamilyTreeView)
|
||||
Dim MachiningName As String = String.Empty
|
||||
Dim MachiningToolName As String = String.Empty
|
||||
EgtMdbGetFirstMachining(MachiningsType.TypeId, MachiningName)
|
||||
While Not String.IsNullOrEmpty(MachiningName)
|
||||
EgtMdbSetCurrMachining(MachiningName)
|
||||
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, MachiningToolName)
|
||||
FamilyTreeView.Items.Add(New MachiningTreeViewExpanderItem(MachiningName, MachiningsType.TypeId, MachiningToolName))
|
||||
EgtMdbGetNextMachining(MachiningsType.TypeId, MachiningName)
|
||||
End While
|
||||
Next
|
||||
' Se esiste almeno una famiglia di lavorazioni, la seleziono
|
||||
If MachiningsList.Count > 0 Then
|
||||
MachiningsList(0).IsSelected = True
|
||||
MachiningsList(0).NotifyPropertyChanged("IsSelected")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
Imports EgtUILib
|
||||
|
||||
''' <summary>
|
||||
''' Class that represent a Machining in the treeview.
|
||||
''' It's an element in the treeview that represent the child of familymachiningtreeviewitem, but also the class that read and write in the machining's database
|
||||
''' </summary>
|
||||
Public Class MachiningTreeViewExpanderItem
|
||||
Inherits ChildItem
|
||||
|
||||
#Region "Machining Property"
|
||||
|
||||
Private m_Type As MCH_MY
|
||||
Public ReadOnly Property Type As Integer
|
||||
Get
|
||||
Return m_Type
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Property that determines if the Machining is selected or not
|
||||
''' </summary>
|
||||
Public Overrides Property IsSelected As Boolean
|
||||
Get
|
||||
Return m_IsSelected
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
If (value <> m_IsSelected) Then
|
||||
m_IsSelected = value
|
||||
' If Machining is selected, set it as current and notify all machining's property
|
||||
' to refresh them values with those of the new selected machining
|
||||
If value Then
|
||||
EgtMdbSetCurrMachining(Me.Name)
|
||||
Else
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Set
|
||||
|
||||
End Property
|
||||
|
||||
Private m_Tool As String
|
||||
Public Property Tool As String
|
||||
Get
|
||||
Return m_Tool
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_Tool = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region ' Machining Property
|
||||
|
||||
#Region "Constructors"
|
||||
|
||||
Sub New(Name As String, Type As MCH_MY, Tool As String)
|
||||
MyBase.New(Name)
|
||||
Me.m_Type = Type
|
||||
Me.Tool = If(Not String.IsNullOrEmpty(Tool), "(" & Tool & ")", String.Empty)
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructors
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Class that represent a FamilyMachining in the treeview.
|
||||
''' It's an element in the treeview that represent a folder, but also a machining family
|
||||
''' </summary>
|
||||
Public Class FamilyMachiningTreeViewExpanderItem
|
||||
Inherits ParentItem
|
||||
|
||||
Private m_MachiningType As MCH_MY
|
||||
''' <summary>
|
||||
''' Property that determines the machining type of the family
|
||||
''' </summary>
|
||||
Public Property MachiningType As MCH_MY
|
||||
Get
|
||||
Return m_MachiningType
|
||||
End Get
|
||||
Set(value As MCH_MY)
|
||||
m_MachiningType = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Property that determines if the Machining is selected or not
|
||||
''' </summary>
|
||||
Public Overrides Property IsSelected As Boolean
|
||||
Get
|
||||
Return m_IsSelected
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
If (value <> m_IsSelected) Then
|
||||
m_IsSelected = value
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Constructor that receive the name of the FamilyMachiningTreeViewItem, the MachiningType, and set
|
||||
''' the picture(Folder.png)
|
||||
''' </summary>
|
||||
Sub New(Name As String, MachiningType As MCH_MY)
|
||||
MyBase.New(Name)
|
||||
Me.MachiningType = MachiningType
|
||||
Me.PictureString = "/Resources/TreeView/Folder.png"
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user