- gestiti eventi del plugin

- gestita visibility del right panel tra draw e machining
- gestita assenza cartella plugin o nomi sbagliati
- gestita visibility dei comandi principali della TopCommandBar
This commit is contained in:
Emmanuele Sassi
2023-11-21 12:56:33 +01:00
parent 75d05a8b31
commit 78a9b32973
13 changed files with 186 additions and 84 deletions
+1
View File
@@ -292,6 +292,7 @@
<DependentUpon>TopTrayV.xaml</DependentUpon>
</Compile>
<Compile Include="Utility\Analyze.vb" />
<Compile Include="Utility\BasePanelVM.vb" />
<Compile Include="Utility\BindingProxy.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="Internals\MruList.vb" />
-1
View File
@@ -2,7 +2,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EgtCAM5"
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5"
DockPanel.Dock="Left">
<local:DrawPanelV DataContext="{StaticResource DrawPanelViewModel}"/>
+16 -3
View File
@@ -603,15 +603,20 @@ Public Class MainWindowVM
Return res
End Function
Friend Function GetControlByName(Of T)(ByVal name As String) As Panel
Dim PlugInControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(name), name).FirstOrDefault()
Friend Function GetControlByName(Of T)(Element As PluginControl) As Panel
Dim PlugInControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(Element.Name), Element.Name).FirstOrDefault()
Dim PluginPanel As Panel = Nothing
Select Case PlugInControl.GetType().BaseType.FullName
Case GetType(Panel).FullName, GetType(Grid).FullName
PluginPanel = TryCast(PlugInControl, Panel)
Case GetType(Forms.UserControl).FullName
Dim PluginUserControl As Forms.UserControl = TryCast(PlugInControl, Forms.UserControl)
PluginPanel = New WinFormPluginControlV(New WinFormPluginControlVM(PluginUserControl))
Dim PluginControlInterface As IPluginControl = TryCast(PlugInControl, IPluginControl)
If Not IsNothing(PluginControlInterface) Then
AddHandler PluginControlInterface.UpdateProjectName, AddressOf UpdateProjectName
AddHandler PluginControlInterface.UpdateUI, AddressOf UpdateUI
End If
PluginPanel = New WinFormPluginControlV(New WinFormPluginControlVM(PluginUserControl, Element.ViewPanelState))
End Select
Return PluginPanel
End Function
@@ -627,6 +632,14 @@ Public Class MainWindowVM
End If
End Function
Private Sub UpdateProjectName(ProjectName As String)
Map.refMainWindowVM.Title = ProjectName & " - EgtCAM5"
End Sub
Private Sub UpdateUI()
Map.refProjectVM.UpdateProjectUI(True)
End Sub
#End Region ' MEF Plugin
End Class
+8 -7
View File
@@ -1,13 +1,14 @@
<UserControl x:Class="OptionPanelV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="250"
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
<EgtFloating:EgtFloatingPanel x:Class="OptionPanelV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="250"
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5"
TitleBarOrientation="Vertical"
Visibility="{Binding Panel_Visibility}">
<StackPanel Name="ciao" Background="Transparent" MaxHeight="{Binding MaxHeight,RelativeSource={RelativeSource AncestorType={x:Type EgtFloating:EgtFloatingPanel}}}">
<StackPanel Background="Transparent" MaxHeight="{Binding MaxHeight,RelativeSource={RelativeSource AncestorType={x:Type EgtFloating:EgtFloatingPanel}}}">
<!--ContentPresenter that contains the ModePanel-->
<ContentPresenter Content="{Binding ModePanel}"/>
</StackPanel>
</UserControl>
</EgtFloating:EgtFloatingPanel>
-4
View File
@@ -1,7 +1,3 @@
Public Class OptionPanelV
Private Sub Me_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim x = ciao.MaxHeight
End Sub
End Class
+13 -11
View File
@@ -1,20 +1,12 @@
Imports EgtUILib
Public Class OptionPanelVM
Inherits ViewModelBase
Inherits BasePanelVM
Private m_DrawIsChecked As Boolean = True
Private m_MachiningIsChecked As Boolean = False
Sub New()
Map.SetRefOptionPanelVM(Me)
DrawOptPanelV = New DrawOptionPanelV
MachOptPanelV = New MachiningOptionPanelV
End Sub
Dim DrawOptPanelV As DrawOptionPanelV
Dim MachOptPanelV As MachiningOptionPanelV
@@ -50,6 +42,16 @@ Public Class OptionPanelVM
End Get
End Property
Sub New()
Map.SetRefOptionPanelVM(Me)
SetPanelViewState(ViewPanelStates.ALWAYS)
DrawOptPanelV = New DrawOptionPanelV
MachOptPanelV = New MachiningOptionPanelV
End Sub
Friend Sub DrawMode_IsChecked()
m_DrawIsChecked = True
m_MachiningIsChecked = False
@@ -58,14 +60,14 @@ Public Class OptionPanelVM
Map.refSimulationExpanderVM.Simulation_IsExpanded = False
Map.refEstimationsExpanderVM.Estimation_IsExpanded = False
End If
OnPropertyChanged("ModePanel")
NotifyPropertyChanged("ModePanel")
End Sub
Friend Sub MachiningMode_IsChecked()
m_DrawIsChecked = False
m_MachiningIsChecked = True
EgtZoom(ZM.ALL, False)
OnPropertyChanged("ModePanel")
NotifyPropertyChanged("ModePanel")
End Sub
End Class
+36 -18
View File
@@ -82,30 +82,48 @@ Public Class ProjectVM
' Inizializza i parametri della scena
'InitializeEgtProject()
' aggiungo componenti interfaccia
Dim bPlugin As Boolean = True
Dim bPlugin As Boolean = False
Dim PluginDirNameList() As String = {}
If IsActivePlugin() Then
' recupero nome del plugin
Dim PluginDirNameList() As String = Directory.GetDirectories(IniFile.m_sDataRoot & "\Plugin")
Dim sPluginDirPath As String = IniFile.m_sDataRoot & "\Plugin"
If Directory.Exists(sPluginDirPath) Then
' recupero nome del plugin
PluginDirNameList = Directory.GetDirectories(IniFile.m_sDataRoot & "\Plugin")
' verifico che il nome delle cartelle corrisponda al nome delle dll
For PluginDirIndex As Integer = 0 To PluginDirNameList.Count - 1
Dim sPluginDirName As String = Path.GetFileName(PluginDirNameList(PluginDirIndex))
Dim sPluginFileNameList() As String = Directory.GetFiles(PluginDirNameList(PluginDirIndex))
If sPluginFileNameList.Count = 0 OrElse Not sPluginFileNameList.Any(Function(x) Path.GetFileNameWithoutExtension(x) = sPluginDirName) Then
PluginDirNameList(PluginDirIndex) = ""
End If
Next
bPlugin = PluginDirNameList.Count(Function(x) Not String.IsNullOrWhiteSpace(x)) > 0
End If
End If
If bPlugin Then
For Each PluginDirName In PluginDirNameList
Dim PluginName As String = Path.GetFileNameWithoutExtension(PluginDirName)
Dim ConfigurationData As IPluginConfigData = Map.refMainWindowVM.GetConfigData(Of IPluginConfigData)(PluginName & ".ConfigurationData")
If Not IsNothing(ConfigurationData) And ConfigurationData.ControlList.Count > 0 Then
For Each Element In ConfigurationData.ControlList
Select Case Element
Case PLUGIN_RIGHT_TRAY
m_PanelList.Add(New RightTrayV)
Case PLUGIN_LEFT_TRAY
m_PanelList.Add(New LeftTrayV)
Case Else
m_PanelList.Add(Map.refMainWindowVM.GetControlByName(Of IPluginControl)(Element))
End Select
Next
If Not String.IsNullOrWhiteSpace(PluginDirName) Then
Dim PluginName As String = Path.GetFileName(PluginDirName)
Dim ConfigurationData As IPluginConfigData = Map.refMainWindowVM.GetConfigData(Of IPluginConfigData)(PluginName & ".ConfigurationData")
If Not IsNothing(ConfigurationData) And ConfigurationData.ControlList.Count > 0 Then
For Each Element In ConfigurationData.ControlList
Select Case Element.Name
Case PLUGIN_RIGHT_TRAY
m_PanelList.Add(New RightTrayV)
Map.refOptionPanelVM.SetPanelViewState(Element.ViewPanelState)
Case PLUGIN_LEFT_TRAY
m_PanelList.Add(New LeftTrayV)
Case Else
m_PanelList.Add(Map.refMainWindowVM.GetControlByName(Of IPluginControl)(Element))
End Select
Next
End If
End If
Next
m_PanelList.Add(New BottomTrayV)
m_PanelList.Add(New TopTrayV)
' nascondo tasti gestione progetto se attivo plugin
Map.refTopCommandBarVM.SetProjectManagerVisibility(False)
Else
m_PanelList.Add(New TopTrayV)
m_PanelList.Add(New LeftTrayV)
+1 -9
View File
@@ -2,14 +2,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EgtCAM5"
xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5"
DockPanel.Dock="Right">
<EgtFloating:EgtFloatingPanel Name="OptionPanel"
TitleBarOrientation="Vertical"
IsTopDockable="False"
IsBottomDockable="False"
IsLeftDockable="True"
IsRightDockable="True">
<local:OptionPanelV DataContext="{StaticResource OptionPanelViewModel}"/>
</EgtFloating:EgtFloatingPanel>
<local:OptionPanelV DataContext="{StaticResource OptionPanelViewModel}"/>
</Grid>
+28 -25
View File
@@ -2,15 +2,17 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Orientation="Horizontal">
<!--Barra superiore dei comandi-->
<UniformGrid Rows="1"
Visibility="{Binding ProjectManager_Visibility}">
<Button Command="{Binding NewCommand}" ToolTip="{Binding NewToolTip}"
IsEnabled="{Binding DrawIsChecked}">
<Image Source="/Resources/TopCommandBar/New.png" Stretch="Uniform"/>
IsEnabled="{Binding DrawIsChecked}">
<Image Source="/Resources/TopCommandBar/New.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding OpenCommand}" ToolTip="{Binding OpenToolTip}"
ContextMenuService.Placement="Bottom" IsEnabled="{Binding DrawIsChecked}"
Tag="{Binding}">
ContextMenuService.Placement="Bottom" IsEnabled="{Binding DrawIsChecked}"
Tag="{Binding}">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding MruFileNames}">
<ContextMenu.Resources>
@@ -33,35 +35,36 @@
<Image Source="/Resources/TopCommandBar/SaveAs.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding InsertCommand}" ToolTip="{Binding InsertToolTip}"
IsEnabled="{Binding DrawIsChecked}">
IsEnabled="{Binding DrawIsChecked}">
<Image Source="/Resources/TopCommandBar/Insert.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding ImportCommand}" ToolTip="{Binding ImportToolTip}"
IsEnabled="{Binding DrawIsChecked}">
IsEnabled="{Binding DrawIsChecked}">
<Image Source="/Resources/TopCommandBar/Import.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding ExportCommand}" ToolTip="{Binding ExportToolTip}"
IsEnabled="{Binding DrawIsChecked}">
IsEnabled="{Binding DrawIsChecked}">
<Image Source="/Resources/TopCommandBar/Export.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding PrintCommand}" ToolTip="{Binding PrintToolTip}"
<Button Command="{Binding PrintCommand}" ToolTip="{Binding PrintToolTip}"
IsEnabled="True">
<Image Source="/Resources/TopCommandBar/Print.png" Height="22" />
</Button>
<Button Command="{Binding OptionsCommand}" ToolTip="{Binding OptionsToolTip}"
IsEnabled="{Binding SaveIsEnabled}">
<Image Source="/Resources/TopCommandBar/Options.png" Height="22" />
</Button>
<Button Command="{Binding SendFeedbackCommand}" ToolTip="{Binding SendFeedbackToolTip}"
IsEnabled="{Binding SaveIsEnabled}">
<Image Source="/Resources/TopCommandBar/Send.png" Height="22" Margin="3,0,3,0" />
<Image Source="/Resources/TopCommandBar/Print.png" Height="22" />
</Button>
<UniformGrid Rows="1">
<RadioButton Style="{StaticResource ModeButton}" Content="{Binding DrawMsg}"
IsChecked="{Binding DrawIsChecked}" IsEnabled="{Binding DrawIsEnabled}"/>
<RadioButton Style="{StaticResource ModeButton}" Content="{Binding MachiningMsg}"
IsChecked="{Binding MachiningIsChecked}" IsEnabled="{Binding MachiningIsEnabled}"/>
</UniformGrid>
</UniformGrid>
<Button Command="{Binding OptionsCommand}" ToolTip="{Binding OptionsToolTip}"
IsEnabled="{Binding SaveIsEnabled}">
<Image Source="/Resources/TopCommandBar/Options.png" Height="22" />
</Button>
<Button Command="{Binding SendFeedbackCommand}" ToolTip="{Binding SendFeedbackToolTip}"
IsEnabled="{Binding SaveIsEnabled}">
<Image Source="/Resources/TopCommandBar/Send.png" Height="22" Margin="3,0,3,0" />
</Button>
<UniformGrid Rows="1">
<RadioButton Style="{StaticResource ModeButton}" Content="{Binding DrawMsg}"
IsChecked="{Binding DrawIsChecked}" IsEnabled="{Binding DrawIsEnabled}"/>
<RadioButton Style="{StaticResource ModeButton}" Content="{Binding MachiningMsg}"
IsChecked="{Binding MachiningIsChecked}" IsEnabled="{Binding MachiningIsEnabled}"/>
</UniformGrid>
</StackPanel>
</StackPanel>
+33 -2
View File
@@ -15,6 +15,17 @@ Public Class TopCommandBarVM
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
@@ -759,6 +770,16 @@ Public Class TopCommandBarVM
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(True)
@@ -771,7 +792,7 @@ Public Class TopCommandBarVM
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
@@ -797,6 +818,16 @@ Public Class TopCommandBarVM
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)
@@ -806,10 +837,10 @@ Public Class TopCommandBarVM
Map.refBeamWallPanelVM.SetBeamWallPanelVisibility(False)
Map.refDoorPanelVM.SetDoorPanelVisibility(False)
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
+28
View File
@@ -0,0 +1,28 @@
Imports EgtUILib
Public Class BasePanelVM
Inherits VMBase
Private m_PanelViewState As ViewPanelStates = ViewPanelStates.NEVER
Friend Sub SetPanelViewState(value As ViewPanelStates)
m_PanelViewState = value
End Sub
Private m_Panel_Visibility As Visibility
Public ReadOnly Property Panel_Visibility As Visibility
Get
Return m_Panel_Visibility
End Get
End Property
Friend Sub SetPanelVisibility(ProjectMode As ProjectModeOpt)
Dim bValue As Boolean = True
Select Case ProjectMode
Case ProjectModeOpt.DRAW, ProjectModeOpt.ONLYDRAW
m_Panel_Visibility = If(m_PanelViewState = ViewPanelStates.ONLYDRAW Or m_PanelViewState = ViewPanelStates.ALWAYS, Visibility.Visible, Visibility.Collapsed)
Case ProjectModeOpt.MACHINING
m_Panel_Visibility = If(m_PanelViewState = ViewPanelStates.ONLYMACHINING Or m_PanelViewState = ViewPanelStates.ALWAYS, Visibility.Visible, Visibility.Collapsed)
End Select
NotifyPropertyChanged(NameOf(Panel_Visibility))
End Sub
End Class
@@ -1,7 +1,10 @@
<Grid x:Class="WinFormPluginControlV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DockPanel.Dock="{Binding DockSide}">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DockPanel.Dock="{Binding DockSide}"
Height="{Binding Height}"
Width="{Binding Width}"
Visibility="{Binding Panel_Visibility}">
<!--ContentControl che ospita la scena restituita sotto forma di WindowsFormsHost-->
<!--<ContentControl Content="{Binding WinFormUserControlHost}"/>-->
+16 -1
View File
@@ -2,6 +2,7 @@
Imports EgtUILib
Public Class WinFormPluginControlVM
Inherits BasePanelVM
Private m_WinFormUserControl As Forms.Control
Public ReadOnly Property WinFormUserControl As Forms.Control
@@ -28,8 +29,22 @@ Public Class WinFormPluginControlVM
End Get
End Property
Sub New(WinFormControl As Forms.Control)
Public ReadOnly Property Height As Double
Get
Return If(TryCast(m_WinFormUserControl, IPluginControl).DockSide = Forms.DockStyle.Left Or TryCast(m_WinFormUserControl, IPluginControl).DockSide = Forms.DockStyle.Right, Double.NaN, m_WinFormUserControl.Height)
End Get
End Property
Public ReadOnly Property Width As Double
Get
Return If(TryCast(m_WinFormUserControl, IPluginControl).DockSide = Forms.DockStyle.Top Or TryCast(m_WinFormUserControl, IPluginControl).DockSide = Forms.DockStyle.Bottom, Double.NaN, m_WinFormUserControl.Width)
End Get
End Property
Sub New(WinFormControl As Forms.Control, ViewPanelState As ViewPanelStates)
m_WinFormUserControl = WinFormControl
' imposto visibilita' standard
SetPanelViewState(ViewPanelState)
End Sub
End Class