EgtCAM5 :

- Migliorie varie.
This commit is contained in:
Emmanuele Sassi
2016-07-09 19:17:02 +00:00
parent a10b8d2ec6
commit 4db56e7e09
25 changed files with 510 additions and 44 deletions
@@ -0,0 +1,33 @@
<UserControl x:Class="OperationExpanderView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Expander Header="Operations List" IsExpanded="{Binding IsExpanded}">
<StackPanel>
<UniformGrid Rows="1">
<Button Content="New Machining" Command="{Binding NewMachiningCommand}" Height="40"/>
<Button Content="New Positioning" Command="{Binding NewPositioningCommand}" Height="40"/>
<Button Content="Cancel Operation" Command="{Binding CancelOperationCommand}" Height="40"/>
</UniformGrid>
<ListBox ItemsSource="{Binding OperationList}" SelectedItem="{Binding SelectedOperation}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Image Source="{Binding Image}" Height="15" Margin="0,0,5,0"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="0,0,5,0"/>
<TextBlock Grid.Column="2" Text="{Binding Tool}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Expander>
</UserControl>
@@ -0,0 +1,3 @@
Public Class OperationExpanderView
End Class
@@ -0,0 +1,167 @@
Imports System.Collections.ObjectModel
Imports EgtUILib
Namespace EgtCAM5
Public Class OperationExpanderViewModel
Inherits ViewModelBase
Private m_IsExpanded As Boolean
Public Property IsExpanded As Boolean
Get
Return m_IsExpanded
End Get
Set(value As Boolean)
If value <> m_IsExpanded Then
m_IsExpanded = value
OnPropertyChanged("IsExpanded")
End If
End Set
End Property
Private m_OperationList As New ObservableCollection(Of OperationListBoxItem)
Public Property OperationList As ObservableCollection(Of OperationListBoxItem)
Get
Return m_OperationList
End Get
Set(value As ObservableCollection(Of OperationListBoxItem))
m_OperationList = value
End Set
End Property
Private m_SelectedOperation As OperationListBoxItem
Public Property SelectedOperation As OperationListBoxItem
Get
Return m_SelectedOperation
End Get
Set(value As OperationListBoxItem)
m_SelectedOperation = value
End Set
End Property
' Definizione comandi
Private m_cmdNewMachining As ICommand
Private m_cmdNewPositioning As ICommand
Private m_cmdCancelOperation As ICommand
Sub New()
Application.Msn.Register(Application.LOADOPERATIONLIST, Sub()
LoadOperationList()
End Sub)
End Sub
#Region "COMMANDS"
#Region "NewMachiningCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewMachiningCommand As ICommand
Get
If m_cmdNewMachining Is Nothing Then
m_cmdNewMachining = New RelayCommand(AddressOf NewMachining, AddressOf CanNewMachining)
End If
Return m_cmdNewMachining
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewMachining(ByVal param As Object)
End Sub
''' <summary>
''' Returns always true.
''' </summary>
Private Function CanNewMachining(ByVal param As Object) As Boolean
Return True
End Function
#End Region ' NewMachiningCommand
#Region "NewPositioningCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewPositioningCommand As ICommand
Get
If m_cmdNewPositioning Is Nothing Then
m_cmdNewPositioning = New RelayCommand(AddressOf NewPositioning, AddressOf CanNewPositioning)
End If
Return m_cmdNewPositioning
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewPositioning(ByVal param As Object)
End Sub
''' <summary>
''' Returns always true.
''' </summary>
Private Function CanNewPositioning(ByVal param As Object) As Boolean
Return True
End Function
#End Region ' NewPositioningCommand
#Region "CancelOperationCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property CancelOperationCommand As ICommand
Get
If m_cmdCancelOperation Is Nothing Then
m_cmdCancelOperation = New RelayCommand(AddressOf CancelOperation, AddressOf CanCancelOperation)
End If
Return m_cmdCancelOperation
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub CancelOperation(ByVal param As Object)
End Sub
''' <summary>
''' Returns always true.
''' </summary>
Private Function CanCancelOperation(ByVal param As Object) As Boolean
Return True
End Function
#End Region ' CancelOperationCommand
#End Region ' Commands
Private Sub LoadOperationList()
Dim Id As Integer
Dim OpName As String = String.Empty
Dim OpType As Integer = 0
Dim OpTool As String = String.Empty
Id = EgtGetFirstOperation()
While Id <> GDB_ID.NULL
EgtGetOperationName(Id, OpName)
OpType = EgtGetOperationType(Id)
Select Case OpType
Case MCH_OY.DRILLING, MCH_OY.SAWING, MCH_OY.MILLING, MCH_OY.POCKETING, MCH_OY.MORTISING, MCH_OY.SAWROUGHING, MCH_OY.SAWFINISHING
EgtSetCurrMachining(Id)
EgtGetMachiningParam(MCH_MP.TOOL, OpTool)
Case MCH_OY.DISP
OpTool = String.Empty
End Select
OperationList.Add(New OperationListBoxItem(Id, OpName, OpType, OpTool))
Id = EgtGetNextOperation(Id)
End While
End Sub
End Class
End Namespace
@@ -0,0 +1,75 @@
Imports EgtUILib
Public Class OperationListBoxItem
Private m_Id As Integer
Public Property Id As Integer
Get
Return m_Id
End Get
Set(value As Integer)
m_Id = value
End Set
End Property
Private m_Name As String
Public Property Name As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Private m_Image As String
Public Property Image As String
Get
Return m_Image
End Get
Set(value As String)
m_Image = value
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
Sub New(Id As Integer, Name As String, Type As Integer, Tool As String)
Me.Id = Id
Me.Name = Name
Me.Image = ConvertTypeToImage(Type)
Me.Tool = Tool
End Sub
Private Function ConvertTypeToImage(Type As Integer) As String
Select Type
Case MCH_OY.DISP
Return ""
Case MCH_OY.DRILLING
Return ""
Case MCH_OY.SAWING
Return ""
Case MCH_OY.MILLING
Return ""
Case MCH_OY.POCKETING
Return ""
Case MCH_OY.MORTISING
Return ""
Case MCH_OY.SAWROUGHING
Return ""
Case MCH_OY.SAWFINISHING
Return ""
Case Else
Return String.Empty
End Select
End Function
End Class