EgtWPFLib5 :

- Aggiunto MachGroupPanel per la gestione dei gruppi di lavorazione.
- Corretto errore in EgtFloatingTray che faceva sparire i panel se venivano nascosti e poi riattivati.
- Migliorie varie.
This commit is contained in:
Emmanuele Sassi
2017-04-06 11:20:35 +00:00
parent 8887f46174
commit d20d378a1c
14 changed files with 910 additions and 7 deletions
+8
View File
@@ -166,6 +166,14 @@ Public Class EgtCustomWindow
DefaultStyleKeyProperty.OverrideMetadata(GetType(EgtCustomWindow), New FrameworkPropertyMetadata(GetType(EgtCustomWindow)))
End Sub
Sub New()
End Sub
Sub New(Owner As Window)
Me.Owner = Owner
End Sub
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
m_IsResizable = IsResizable
+11 -2
View File
@@ -85,10 +85,19 @@ Namespace EgtFloating
End Sub
Private Sub Me_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
m_ParentWindow = Utility.FindAncestor(Of Window)(Me)
If TypeOf Me.Items(Me.Items.Count - 1) Is EgtFloatingTray Then
'm_ParentWindow = Utility.FindAncestor(Of Window)(Me)
m_ParentWindow = Window.GetWindow(Me)
If Me.Items.Count > 0 AndAlso TypeOf Me.Items(Me.Items.Count - 1) Is EgtFloatingTray Then
LastChildFill = False
End If
' PERMETTE DI SPOSTARE LE WINDOW TRAY NEL CASO VENGA SPOSTATA LA MAINWINDOW!!!!!!!
'For TrayIndex = 0 To Me.Items.Count - 1
' If TypeOf Me.Items(TrayIndex) Is EgtFloatingTray Then
' Dim TrayItem As EgtFloatingTray = DirectCast(Me.Items(TrayIndex), EgtFloatingTray)
' AddHandler ParentWindow.LocationChanged, AddressOf TrayItem.Me_LocationChanged
' AddHandler ParentWindow.SizeChanged, AddressOf TrayItem.Me_DimensionChanged
' End If
'Next
End Sub
Private Sub Me_Unloaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Unloaded
+2 -2
View File
@@ -89,13 +89,13 @@ Namespace EgtFloating
m_TrayWindow.Visibility = Windows.Visibility.Hidden
End Sub
Private Sub Me_LocationChanged()
Friend Sub Me_LocationChanged()
Dim pos As Point = Me.PointToScreen(New Point(0, 0))
m_TrayWindow.Top = pos.Y
m_TrayWindow.Left = pos.X
End Sub
Private Sub Me_DimensionChanged()
Friend Sub Me_DimensionChanged()
' Aggiorna le massime dimensioni del contenuto al cambiare della dimensione della Tray.
' NON TIENE CONTO DELLE TRAY CON PIU' DI UN ELEMENTO!!
For Index As Integer = 0 To Me.Items.Count - 1
+19
View File
@@ -94,6 +94,15 @@
<Compile Include="EgtFloating\EgtFloatingPanel.vb" />
<Compile Include="EgtFloating\EgtFloatingTray.vb" />
<Compile Include="EgtFloating\EgtFloatingWindow.vb" />
<Compile Include="MachGroupPanel\EgtMachGroupPanelV.xaml.vb">
<DependentUpon>EgtMachGroupPanelV.xaml</DependentUpon>
</Compile>
<Compile Include="MachGroupPanel\EgtMachGroupPanelVM.vb" />
<Compile Include="MachGroupPanel\NewMachGroupWnd\NewMachGroupWndV.xaml.vb">
<DependentUpon>NewMachGroupWndV.xaml</DependentUpon>
</Compile>
<Compile Include="MachGroupPanel\NewMachGroupWnd\NewMachGroupWndVM.vb" />
<Compile Include="Machine.vb" />
<Compile Include="Utility.vb" />
<Compile Include="EgtPanelWindow.vb" />
<Compile Include="EgtScrollViewer.vb" />
@@ -113,6 +122,8 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Utility\Command.vb" />
<Compile Include="Utility\VMBase.vb" />
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
@@ -137,6 +148,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MachGroupPanel\EgtMachGroupPanelV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MachGroupPanel\NewMachGroupWnd\NewMachGroupWndV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
+100
View File
@@ -0,0 +1,100 @@
<EgtFloating:EgtFloatingPanel x:Class="EgtMachGroupPanelV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5"
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating"
Visibility="{Binding PanelVisibility}">
<EgtFloating:EgtFloatingPanel.Resources>
<SolidColorBrush x:Key="ListBox.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Static.Border" Color="#FFABADB3"/>
<SolidColorBrush x:Key="ListBox.Disabled.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ListBox.Disabled.Border" Color="#FFD9D9D9"/>
<Style x:Key="MachiningGroupListBox" TargetType="{x:Type ListBox}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
</EgtFloating:EgtFloatingPanel.Resources>
<Grid>
<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" Padding="5,0,5,0"
ToolTip="{Binding MachGroupToolTip}"
Style="{Binding MachGroupButtonStyle,RelativeSource={RelativeSource AncestorType={x:Type EgtFloating:EgtFloatingPanel}}}"
IsChecked="{Binding Path=IsSelected,
RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}},
Mode=TwoWay}">
<RadioButton.Content>
<TextBlock Text="{Binding Name}"/>
</RadioButton.Content>
</RadioButton>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true">
<EgtWPFLib5:EgtScrollViewer IsPageSlideCommand="True" Focusable="false" Padding="{TemplateBinding Padding}" IsCustom="True" Orientation="Horizontal" RepeatButtonDimension="20"
RepeatButtonStyle="{Binding RepaetButtonStyle,RelativeSource={RelativeSource AncestorType={x:Type EgtFloating:EgtFloatingPanel}}}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</EgtWPFLib5:EgtScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<!--<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>-->
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ListBox.Template>
</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>
</EgtFloating:EgtFloatingPanel>
+25
View File
@@ -0,0 +1,25 @@
Public Class EgtMachGroupPanelV
' Proprietà che permette di impostare lo stile dei RepeatButton(bottoni per scorrere la lista)
Public Shared ReadOnly RepaetButtonStyleProperty As DependencyProperty = DependencyProperty.Register("RepaetButtonStyle", GetType(Style), GetType(EgtMachGroupPanelV), New PropertyMetadata(Nothing))
Public Property RepaetButtonStyle() As Style
Get
Return DirectCast(GetValue(RepaetButtonStyleProperty), Style)
End Get
Set(ByVal value As Style)
SetValue(RepaetButtonStyleProperty, value)
End Set
End Property
' Proprietà che permette di impostare lo stile dei RadioButton che rappresentano i gruppi
Public Shared ReadOnly MachGroupButtonStyleProperty As DependencyProperty = DependencyProperty.Register("MachGroupButtonStyle", GetType(Style), GetType(EgtMachGroupPanelV))
Public Property MachGroupButtonStyle() As Style
Get
Return DirectCast(GetValue(MachGroupButtonStyleProperty), Style)
End Get
Set(ByVal value As Style)
SetValue(MachGroupButtonStyleProperty, value)
End Set
End Property
End Class
+369
View File
@@ -0,0 +1,369 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class EgtMachGroupPanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
' Lista delle macchine disponibili
Private m_MachineList As List(Of Machine)
' Variabile che definisce se il nome è automatico
Private m_IsGroupNameAutomatic As Boolean = True
' Variabile che definisce se ci sono più gruppi di lavorazione
Private m_IsMultiMachGroup As Boolean
Private m_MachGroupList As New ObservableCollection(Of MachGroup)
Public Property MachGroupList As ObservableCollection(Of MachGroup)
Get
Return m_MachGroupList
End Get
Set(value As ObservableCollection(Of MachGroup))
If value IsNot m_MachGroupList Then
m_MachGroupList = value
End If
End Set
End Property
Private m_SelectedMachGroup As MachGroup
Public Property SelectedMachGroup As MachGroup
Get
Return m_SelectedMachGroup
End Get
Set(value As MachGroup)
m_SelectedMachGroup = value
If Not IsNothing(value) Then
EgtSetCurrMachGroup(value.Id)
EgtDraw()
End If
NotifyPropertyChanged("SelectedMachGroup")
End Set
End Property
Private m_PanelVisibility As Visibility
Public ReadOnly Property PanelVisibility As Visibility
Get
Return m_PanelVisibility
End Get
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()
' Creo riferimento a questa classe in OmagOFFICEMap
''OmagOFFICEMap.SetRefMachGroupPanelVM(Me)
''InitMachGroups(True, OmagOFFICEMap.refMachinePanelVM.MachineList.ToList())
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Function InitMachGroups(IsMultiMachGroup As Boolean, MachineList As List(Of Machine)) As Boolean
m_IsMultiMachGroup = IsMultiMachGroup
' se è a gruppo singolo, nascondo il panel
If Not m_IsMultiMachGroup Then m_PanelVisibility = Visibility.Collapsed
NotifyPropertyChanged("PanelVisibility")
' Recupero lista macchine
m_MachineList = MachineList
Return MachineList.Count > 0
End Function
Public Function LoadMachGroups() As Boolean
' Svuoto precedente lista di MachGroup
m_MachGroupList.Clear()
' verifico se esistono già gruppi di lavorazione o se devo creare il primo
Dim bOk As Boolean
Dim nId = EgtGetFirstMachGroup()
If nId <> GDB_ID.NULL Then
bOk = EgtSetCurrMachGroup(nId)
Else
bOk = AddNewMachGroup()
End If
nId = EgtGetFirstMachGroup()
If bOk Then
' Carico i gruppi di lavorazione nella lista
While nId <> GDB_ID.NULL
Dim sName As String = String.Empty
Dim sMachine As String = String.Empty
EgtGetMachGroupName(nId, sName)
EgtGetMachGroupMachineName(nId, sMachine)
MachGroupList.Add(New MachGroup(nId, sName, sMachine))
nId = EgtGetNextMachGroup(nId)
End While
SelectedMachGroup = MachGroupList(0)
End If
If bOk Then EgtZoom(ZM.ALL)
Return bOk
End Function
Private Function AddNewMachGroup() As Boolean
' se non ci sono macchine disponibili ritorno falso
If m_MachineList.Count <= 0 Then Return False
' Creo il VM per chiedere nome e macchina a seconda del caso in cui mi trovo
Dim NewMachGroupWndVM As NewMachGroupWndVM = Nothing
Dim sNewMachName As String = "MachGroup_1"
If m_IsMultiMachGroup Then
EgtGetMachGroupNewName(sNewMachName)
If m_MachineList.Count = 1 Then
If Not m_IsGroupNameAutomatic Then
NewMachGroupWndVM = New NewMachGroupWndVM(sNewMachName)
End If
Else
If m_IsGroupNameAutomatic Then
NewMachGroupWndVM = New NewMachGroupWndVM(Nothing, m_MachineList)
Else
NewMachGroupWndVM = New NewMachGroupWndVM(sNewMachName, Nothing, m_MachineList)
End If
End If
ElseIf EgtGetMachGroupCount() = 0 Then
If m_MachineList.Count > 1 Then
NewMachGroupWndVM = New NewMachGroupWndVM(Nothing, m_MachineList)
End If
End If
' lancio finestra di acquisizione dati
Dim bWindowNeeded As Boolean = False
If m_IsMultiMachGroup Then
If m_MachineList.Count = 1 Then
If Not m_IsGroupNameAutomatic Then
bWindowNeeded = True
End If
Else
If m_IsGroupNameAutomatic Then
bWindowNeeded = True
Else
bWindowNeeded = True
End If
End If
ElseIf EgtGetMachGroupCount() = 0 Then
If m_MachineList.Count > 1 Then
bWindowNeeded = True
End If
End If
If bWindowNeeded Then
Dim NewMachGroupWndV As New NewMachGroupWndV(NewMachGroupWndVM, Application.Current.MainWindow)
If NewMachGroupWndV.ShowDialog() = False Then Return False
End If
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
Dim bOk As Boolean
If m_IsMultiMachGroup Then
If m_MachineList.Count = 1 Then
If m_IsGroupNameAutomatic Then
bOk = (EgtAddMachGroup(sNewMachName, m_MachineList(0).Name) <> GDB_ID.NULL)
Else
bOk = (EgtAddMachGroup(NewMachGroupWndVM.Name, m_MachineList(0).Name) <> GDB_ID.NULL)
End If
Else
If m_IsGroupNameAutomatic Then
bOk = (EgtAddMachGroup(sNewMachName, NewMachGroupWndVM.SelectedMachine.Name) <> GDB_ID.NULL)
Else
bOk = (EgtAddMachGroup(NewMachGroupWndVM.Name, NewMachGroupWndVM.SelectedMachine.Name) <> GDB_ID.NULL)
End If
End If
ElseIf EgtGetMachGroupCount() = 0 Then
If m_MachineList.Count = 1 Then
bOk = (EgtAddMachGroup(sNewMachName, m_MachineList(0).Name) <> GDB_ID.NULL)
ElseIf m_MachineList.Count > 1 Then
bOk = (EgtAddMachGroup(sNewMachName, NewMachGroupWndVM.SelectedMachine.Name) <> GDB_ID.NULL)
Else
Return False
End If
End If
' '' 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 ' METHODS
#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 Command(AddressOf SetCurrMachGroup)
'' End If
'' Return m_cmdSetCurrMachGroup
'' End Get
'' End Property
'' Public Sub SetCurrMachGroup(ByVal param As Object)
'' Dim SelectedId As Integer = DirectCast(param, MachGroup).Id
'' EgtSetCurrMachGroup(SelectedId)
'' EgtDraw()
'' ''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 Command(AddressOf AddMachGroup)
End If
Return m_cmdAddMachGroup
End Get
End Property
Public Sub AddMachGroup()
Dim NewMachGroup As MachGroup
If AddNewMachGroup() Then
' creo oggetto gruppo creato
Dim nNewMachGroupID As Integer = EgtGetCurrMachGroup()
Dim sNewMachGroupName As String = String.Empty
Dim sNewMachGroupMachineName As String = String.Empty
EgtGetMachGroupName(EgtGetCurrMachGroup(), sNewMachGroupName)
EgtGetMachGroupMachineName(nNewMachGroupID, sNewMachGroupMachineName)
NewMachGroup = New MachGroup(EgtGetCurrMachGroup, sNewMachGroupName, sNewMachGroupMachineName)
' lo aggiungo alla lista
MachGroupList.Add(NewMachGroup)
' e lo seleziono
SelectedMachGroup = NewMachGroup
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 Command(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 MachGroupList.Count = 1 Then
'chiedo conferma prima di resettare il gruppo di lavorazione
Select Case MessageBox.Show("Eliminare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question)
Case MessageBoxResult.Yes
' cancello il gruppo corrente e ne creo uno nuovo con lo stesso nome
EgtRemoveMachGroup(MachGroupList(0).Id)
MachGroupList.Clear()
AddMachGroup()
EgtDraw()
Case MessageBoxResult.No
Return
End Select
Else
'chiedo conferma prima di cancellare il gruppo di lavorazione
Select Case MessageBox.Show("Eliminare?", "", 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(MachGroupList(nSelectedMachGroupIndex + 1).Id)
SelectedMachGroup = MachGroupList(nSelectedMachGroupIndex + 1)
ElseIf nSelectedMachGroupIndex > 0 Then
' rendo corrente il gruppo di lavorazione precedente a quello da cancellare
EgtSetCurrMachGroup(MachGroupList(nSelectedMachGroupIndex - 1).Id)
SelectedMachGroup = MachGroupList(nSelectedMachGroupIndex - 1)
End If
EgtDraw()
' cancello quello selezionato
EgtRemoveMachGroup(MachGroupList(nSelectedMachGroupIndex).Id)
' 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
Public Class MachGroup
Private m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_Id
End Get
End Property
Private m_Name As String
Public ReadOnly Property Name As String
Get
Return m_Name
End Get
End Property
Private m_Machine As String
Public ReadOnly Property Machine As String
Get
Return m_Machine
End Get
End Property
#Region "ToolTip"
Public ReadOnly Property MachGroupToolTip As String
Get
Return "Name: " & m_Name & Environment.NewLine &
"Machine: " & m_Machine
End Get
End Property
#End Region ' ToolTip
Sub New(nId As Integer, sName As String, sMachine As String)
m_Id = nId
m_Name = sName
m_Machine = sMachine
End Sub
End Class
@@ -0,0 +1,55 @@
<EgtWPFLib5:EgtCustomWindow x:Class="NewMachGroupWndV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5"
SizeToContent="WidthAndHeight"
Title="{Binding TitleMsg}"
TitleBarBrush="{StaticResource Omag_LightGray}"
BorderBrush="{StaticResource Omag_Gray}" BorderThickness="2"
WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="32"
IsResizable="False"
IsMinimizable="False" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
<StackPanel Margin="0,5,0,0">
<Grid Margin="5,0,5,5" Visibility="{Binding NameVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Width, ElementName=MachineColumn}"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding NameMsg}"/>
<TextBox Text="{Binding Name}"
Grid.Column="1"/>
</Grid>
<Grid Margin="5,0,5,5" Visibility="{Binding MachineVisibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="MachineColumn" Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding MachineMsg}"
Grid.Row="1"/>
<ComboBox Text="{Binding Machine}"
ItemsSource="{Binding MachineList}"
DisplayMemberPath="Name"
SelectedValuePath="Name"
SelectedItem="{Binding SelectedMachine}"
Grid.Row="1" Grid.Column="1"/>
</Grid>
<Grid Margin="5,0,5,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*" MinWidth="5"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button Name="OkBtn" Content="Ok" Width="60" IsDefault="True"/>
<Button Content="Annulla" Width="60" Grid.Column="2" IsCancel="True"/>
</Grid>
</StackPanel>
</EgtWPFLib5:EgtCustomWindow>
@@ -0,0 +1,25 @@
Public Class NewMachGroupWndV
Private m_NewMachGroupWndVM As NewMachGroupWndVM
#Region "CONSTRUCTOR"
Sub New(NewMachGroupWndVM As NewMachGroupWndVM, Owner As Window)
MyBase.New(Owner)
' Funzione che interpreta l'xaml
InitializeComponent()
'Me.Owner = Owner
Me.DataContext = NewMachGroupWndVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_NewMachGroupWndVM = DirectCast(Me.DataContext, NewMachGroupWndVM)
End Sub
#End Region ' CONSTRUCTOR
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
If m_NewMachGroupWndVM.IsValid Then
DialogResult = True
End If
End Sub
End Class
@@ -0,0 +1,131 @@
Imports EgtWPFLib5
Public Class NewMachGroupWndVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
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_NameVisibility As Visibility
Public Property NameVisibility As Visibility
Get
Return m_NameVisibility
End Get
Set(value As Visibility)
m_NameVisibility = value
End Set
End Property
' Lista delle macchine disponibili
Private m_MachineList As List(Of Machine)
Public Property MachineList As List(Of Machine)
Get
Return m_MachineList
End Get
Set(value As List(Of Machine))
m_MachineList = value
End Set
End Property
' Macchina correntemente selezionata e quindi attiva
Private m_SelectedMachine As Machine
Public Property SelectedMachine As Machine
Get
Return m_SelectedMachine
End Get
Set(value As Machine)
If value IsNot m_SelectedMachine Then
m_SelectedMachine = value
NotifyPropertyChanged("SelectedMachine")
End If
End Set
End Property
Private m_MachineVisibility As Visibility
Public Property MachineVisibility As Visibility
Get
Return m_MachineVisibility
End Get
Set(value As Visibility)
m_MachineVisibility = value
End Set
End Property
#Region "Messages"
Public ReadOnly Property TitleMsg As String
Get
Return "New Mach Group"
End Get
End Property
Public ReadOnly Property NameMsg As String
Get
'Return EgtMsg(MSG_MAINWINDOW + 6)
End Get
End Property
Public ReadOnly Property MachineMsg As String
Get
'Return EgtMsg(MSG_MAINWINDOW + 7)
End Get
End Property
#End Region ' Messages
' Definizione comandi
Private m_cmdOk As ICommand
Private m_cmdCancel As ICommand
#End Region 'FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New(sName As String)
NameVisibility = Visibility.Visible
MachineVisibility = Visibility.Collapsed
m_Name = sName
End Sub
Sub New(SelectedMachine As Machine, MachineList As List(Of Machine))
NameVisibility = Visibility.Collapsed
MachineVisibility = Visibility.Visible
m_MachineList = MachineList
m_SelectedMachine = SelectedMachine
End Sub
Sub New(sName As String, SelectedMachine As Machine, MachineList As List(Of Machine))
NameVisibility = Visibility.Visible
MachineVisibility = Visibility.Visible
m_Name = sName
m_MachineList = MachineList
m_SelectedMachine = SelectedMachine
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Function IsValid() As Boolean
Dim bOk As Boolean
If m_NameVisibility = Visibility.Visible Then
bOk = If(Not String.IsNullOrWhiteSpace(m_Name), True, False)
Else
bOk = True
End If
If m_MachineVisibility = Visibility.Visible Then
bOk = If(Not IsNothing(m_SelectedMachine), True, False)
Else
bOk = True
End If
Return bOk
End Function
#End Region ' METHODS
End Class
+81
View File
@@ -0,0 +1,81 @@
Imports System.IO
''' <summary>
''' Class that create the association Name/IniPath for the machine
''' </summary>
Public Class Machine
Private m_sName As String
Public ReadOnly Property Name As String
Get
Return m_sName
End Get
End Property
Private m_DirPath As String
Public ReadOnly Property DirPath As String
Get
Return m_DirPath
End Get
End Property
Private m_IniPath As String
Public ReadOnly Property IniPath As String
Get
Return m_IniPath
End Get
End Property
Sub New(sDirPath As String, sIniPath As String)
If Not String.IsNullOrWhiteSpace(sDirPath) Then
m_sName = Path.GetFileName(sDirPath)
m_DirPath = sDirPath
m_IniPath = sIniPath
Else
m_sName = String.Empty
m_DirPath = String.Empty
m_IniPath = String.Empty
End If
End Sub
Public Shared Function MachineListInit(sMachinesRootDir As String, MachineList As List(Of Machine)) As Boolean
' Se direttorio base macchine non definito o non esiste, ritorno
If String.IsNullOrWhiteSpace(sMachinesRootDir) OrElse
Not Directory.Exists(sMachinesRootDir) Then
MachineList = Nothing
Return False
End If
' Cerco le macchine
Dim Machines As String() = Directory.GetDirectories(sMachinesRootDir)
For i As Integer = 0 To Machines.Count - 1
Dim PathIni As String = Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini"
If File.Exists(PathIni) Then
MachineList.Add(New Machine(Machines(i), PathIni))
End If
Next
Return True
End Function
Public Shared Function SearchMachine(sName As String, FoundedMachine As Machine, MachineList As List(Of Machine)) As Boolean
For Each Machine In MachineList
If Machine.Name = sName Then
FoundedMachine = Machine
Return True
End If
Next
FoundedMachine = Nothing
Return False
End Function
Public Shared Function SearchMachineIni(sName As String, FoundedIni As String, MachineList As List(Of Machine)) As Boolean
For Each Machine In MachineList
If Machine.Name = sName Then
FoundedIni = Machine.IniPath
Return True
End If
Next
FoundedIni = String.Empty
Return False
End Function
End Class
+4 -3
View File
@@ -493,7 +493,8 @@
<!--Style dell'EgtFloatingPanel-->
<Style TargetType="{x:Type EgtFloating:EgtFloatingPanel}">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderBrush" Value="{StaticResource EgaltechBlue2}"/>
<Setter Property="Background" Value="{StaticResource EgaltechBlue2}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="TitleBarHeight" Value="10"/>
<Setter Property="TitleBarOrientation" Value="Horizontal"/>
@@ -508,7 +509,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type EgtFloating:EgtFloatingPanel}">
<StackPanel>
<Border Name="PanelBorder" BorderThickness="2" BorderBrush="{StaticResource EgaltechBlue2}" Background="{StaticResource EgaltechBlue2}" CornerRadius="2" Margin="0,0,0,1">
<Border Name="PanelBorder" BorderThickness="2" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="2" Margin="0,0,0,1">
<StackPanel Orientation="Vertical">
<ContentControl Name="PART_TitleBar" Height="{TemplateBinding TitleBarHeight}" Style="{StaticResource ResourceKey=VerticalTitleBarStyle}"/>
<ItemsPresenter Name="PART_PanelPresenter"/>
@@ -539,7 +540,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type EgtFloating:EgtFloatingPanel}">
<Grid>
<Border Name="PanelBorder" BorderThickness="2" BorderBrush="{StaticResource EgaltechBlue2}" Background="{StaticResource EgaltechBlue2}" CornerRadius="2" Margin="0,0,1,0">
<Border Name="PanelBorder" BorderThickness="2" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="2" Margin="0,0,1,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
+68
View File
@@ -0,0 +1,68 @@
''' <summary>
''' A command whose sole purpose is to
''' relay its functionality to other
''' objects by invoking delegates. The
''' default return value for the CanExecute
''' method is 'true'.
''' </summary>
Public Class Command
Implements ICommand
#Region "Fields"
Private ReadOnly _execute As Action(Of Object)
Private ReadOnly _canExecute As Predicate(Of Object)
#End Region ' Fields
#Region "Constructors"
''' <summary>
''' Creates a new command that can always execute.
''' </summary>
''' <param name="execute">The execution logic.</param>
Public Sub New(ByVal execute As Action(Of Object))
Me.New(execute, Nothing)
End Sub
''' <summary>
''' Creates a new command.
''' </summary>
''' <param name="execute">The execution logic.</param>
''' <param name="canExecute">The execution status logic.</param>
Public Sub New(ByVal execute As Action(Of Object), ByVal canExecute As Predicate(Of Object))
If execute Is Nothing Then
Throw New ArgumentNullException("execute")
End If
_execute = execute
_canExecute = canExecute
End Sub
#End Region ' Constructors
#Region "ICommand Members"
<DebuggerStepThrough> _
Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute
Return If(_canExecute Is Nothing, True, _canExecute(parameter))
End Function
Public Custom Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged
AddHandler(ByVal value As EventHandler)
AddHandler CommandManager.RequerySuggested, value
End AddHandler
RemoveHandler(ByVal value As EventHandler)
RemoveHandler CommandManager.RequerySuggested, value
End RemoveHandler
RaiseEvent(ByVal sender As System.Object, ByVal e As System.EventArgs)
End RaiseEvent
End Event
Public Sub Execute(ByVal parameter As Object) Implements ICommand.Execute
_execute(parameter)
End Sub
#End Region ' ICommand Members
End Class
+12
View File
@@ -0,0 +1,12 @@
Imports System.ComponentModel
Public Class VMBase
Implements INotifyPropertyChanged
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class