From 2aeaccf30afd4d7396b8dad23ffacab0b8bc7b21 Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Tue, 6 Sep 2016 13:50:26 +0000 Subject: [PATCH] EgtCAM5 : -Miglioramenti vari. --- AboutBoxWindow/AboutBoxView.xaml.vb | 3 +- Application.xaml.vb | 1 + .../ScrollIntoViewForListBox.vb | 42 +++++++++++++++++ EgtCAM5.vbproj | 1 + MachiningsDbWindow/MachiningTreeView.vb | 12 +++-- MainWindow/MainWindowViewModel.vb | 4 +- .../InputExpander/InputExpanderViewModel.vb | 4 +- .../ManageLayerExpanderView.xaml | 4 +- .../MachiningTreeExpanderViewModel.vb | 2 +- .../OperationExpanderView.xaml | 4 ++ .../OperationExpanderViewModel.vb | 23 +++++++++- .../OptionPanel/OptionPanelViewModel.vb | 2 +- ProjectPage/ProjectViewModel.vb | 10 ++--- ToolsDbWindow/ToolTreeView2.vb | 45 +++++++++++++++++-- ToolsDbWindow/ToolsDbViewModel.vb | 1 + 15 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 AttachedBehaviours/ScrollIntoViewForListBox.vb diff --git a/AboutBoxWindow/AboutBoxView.xaml.vb b/AboutBoxWindow/AboutBoxView.xaml.vb index 15dbd83..1cab8fb 100644 --- a/AboutBoxWindow/AboutBoxView.xaml.vb +++ b/AboutBoxWindow/AboutBoxView.xaml.vb @@ -21,11 +21,10 @@ Public Class AboutBoxView Me.Owner = Owner Me.Top = Owner.Top + (Owner.Height / 2 - Me.Height / 2) Me.Left = Owner.Left + (Owner.Width / 2 - Me.Width / 2) - End Sub Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click - Me.Visibility = Visibility.Hidden + Me.Close() End Sub Private Sub AboutBoxWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized diff --git a/Application.xaml.vb b/Application.xaml.vb index 5fd3c4b..3e30c02 100644 --- a/Application.xaml.vb +++ b/Application.xaml.vb @@ -10,6 +10,7 @@ Class Application ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose ' Creo la View principale Dim MainWndView As New MainWindow + MainWindow = MainWndView ' Creo il ViewModel principale Dim MainWndViewModel As New MainWindowViewModel ' Assegno il ViewModel alla View diff --git a/AttachedBehaviours/ScrollIntoViewForListBox.vb b/AttachedBehaviours/ScrollIntoViewForListBox.vb new file mode 100644 index 0000000..7c4f6e4 --- /dev/null +++ b/AttachedBehaviours/ScrollIntoViewForListBox.vb @@ -0,0 +1,42 @@ +Imports System.Windows.Interactivity + +Public Class ScrollIntoViewForListBox + Inherits Behavior(Of ListBox) + + ''' + ''' When Beahvior is attached + ''' + Protected Overrides Sub OnAttached() + MyBase.OnAttached() + AddHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + End Sub + + ''' + ''' On Selection Changed + ''' + ''' + ''' + Private Sub AssociatedObject_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + If TypeOf sender Is ListBox Then + Dim listBox As ListBox = TryCast(sender, ListBox) + If listBox.SelectedItem IsNot Nothing Then + listBox.Dispatcher.BeginInvoke(DirectCast(Sub() + listBox.UpdateLayout() + If listBox.SelectedItem IsNot Nothing Then + listBox.ScrollIntoView(listBox.SelectedItem) + End If + + End Sub, Action)) + End If + End If + End Sub + ''' + ''' When behavior is detached + ''' + Protected Overrides Sub OnDetaching() + MyBase.OnDetaching() + RemoveHandler Me.AssociatedObject.SelectionChanged, AddressOf AssociatedObject_SelectionChanged + + End Sub + +End Class diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index d0b840b..501985e 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -118,6 +118,7 @@ AboutBoxView.xaml + diff --git a/MachiningsDbWindow/MachiningTreeView.vb b/MachiningsDbWindow/MachiningTreeView.vb index 6381fae..b1f3772 100644 --- a/MachiningsDbWindow/MachiningTreeView.vb +++ b/MachiningsDbWindow/MachiningTreeView.vb @@ -98,6 +98,7 @@ Public Class MachiningTreeViewItem ' Variabile che indica se c'è un errore nel nome della lavorazione (ad esempio nome già utilizzato) Dim bErrorMachiningName As Boolean = False + Private m_IsModifiedName As Boolean = False ''' ''' Property that read and write to the machining's database the Name ''' @@ -116,6 +117,11 @@ Public Class MachiningTreeViewItem Else bErrorMachiningName = True End If + ' Verifico se il nome è diverso da quello nel database e imposto l'apposito flag + Dim DbName As String = String.Empty + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + EgtMdbGetCurrMachiningParam(MCH_MP.NAME, DbName) + m_IsModifiedName = If(Name <> DbName, True, False) End Set End Property @@ -197,10 +203,10 @@ Public Class MachiningTreeViewItem ' Otherwhise Tool is deselected, so it and the database will be saved to ' keep the modify effective Else - If EgtMdbIsCurrMachiningModified() And Me.IsValid Then - + If EgtMdbIsCurrMachiningModified() And Me.IsValid Or Me.NewMachining Then Select Case MsgBox(EgtMsg(MSG_MACHININGSERRORS + 30), MsgBoxStyle.YesNo, EgtMsg(MSG_MACHININGSERRORS + 31)) Case MsgBoxResult.Yes + Name = Name.Trim m_NewMachining = False EgtMdbSaveCurrMachining() EgtMdbSave() @@ -208,8 +214,6 @@ Public Class MachiningTreeViewItem If m_NewMachining Then Application.Msn.NotifyColleagues(Application.REMOVEMACHINING, Me) End If - 'EgtMdbRemoveTool(Me.Name) - 'EgtMdbSave() End Select End If End If diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index ddb1385..4cbd19a 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -46,6 +46,7 @@ Namespace EgtCAM5 End If End Set End Property + Private m_AboutBox As Window Public ReadOnly Property AboutBox As Window Get @@ -263,6 +264,7 @@ Namespace EgtCAM5 Private Sub RegisterMyMessages() Application.Msn.Register(Application.CLOSEAPPLICATIONCOMMAND, Sub() + Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION) ' Terminazione generale di EgtInterface EgtExit() ' Rilascio mutex @@ -271,7 +273,7 @@ Namespace EgtCAM5 Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) nTmp -= (1 << (m_nInstance - 1)) WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) - Application.Current.MainWindow.Close() + Application.Current.Shutdown() End Sub) Application.Msn.Register(Application.ALLOWWINDOWTOCLOSE, Sub(bBoolean As Boolean) m_allowWindowToClose = bBoolean diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/InputExpander/InputExpanderViewModel.vb b/ProjectPage/OptionPanel/DrawOptionPanel/InputExpander/InputExpanderViewModel.vb index 0cee9f8..149b75e 100644 --- a/ProjectPage/OptionPanel/DrawOptionPanel/InputExpander/InputExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/DrawOptionPanel/InputExpander/InputExpanderViewModel.vb @@ -98,7 +98,6 @@ Namespace EgtCAM5 If value <> m_IsChecked Then Application.Msn.NotifyColleagues(Application.SETLASTBOOLEAN, value) m_IsChecked = value - Application.Msn.NotifyColleagues(Application.SHOW, TextBox) OnPropertyChanged("IsChecked") End If End Set @@ -136,7 +135,6 @@ Namespace EgtCAM5 End Get Set(value As Integer) Application.Msn.NotifyColleagues(Application.SETLASTINTEGER, value) - Application.Msn.NotifyColleagues(Application.SHOW, TextBox) m_ComboSelectedIndex = value OnPropertyChanged("ComboSelectedIndex") End Set @@ -208,7 +206,7 @@ Namespace EgtCAM5 ''' Returns always true. ''' Private Function CanShow(ByVal param As Object) As Boolean - Return True + Return If(m_ShowBtnVisibility = Visibility.Visible, True, False) End Function #End Region ' ShowCommand diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml index c0bc15e..62a4bac 100644 --- a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml +++ b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml @@ -30,7 +30,7 @@ - + @@ -47,7 +47,7 @@ - + diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb index 328895f..e531268 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb @@ -93,7 +93,7 @@ Namespace EgtCAM5 EgtApplyMachining(True) EgtDraw() ' Ricarico la lista operazioni per avere quella nuova - Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST) + Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, MachiningId) ' disabilito la modalità nuova lavorazione Application.Msn.NotifyColleagues(Application.NEWMACHININGMODEISACTIVE, False) End If diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml index 7f52dc9..c78b61a 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml @@ -2,6 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:local="clr-namespace:EgtCAM5" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"> @@ -37,6 +38,9 @@ + + + diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb index c34bf01..18067fb 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb @@ -366,8 +366,9 @@ Namespace EgtCAM5 Sub New() Me.ListIsExpanded = True - Application.Msn.Register(Application.LOADOPERATIONLIST, Sub() + Application.Msn.Register(Application.LOADOPERATIONLIST, Sub(nSelectedOperation As Integer) LoadOperationList() + SelectOperation(nSelectedOperation) End Sub) Application.Msn.Register(Application.REMOVEMARKFROMLASTOPERATION, Sub() EgtResetMark(m_LastMarkedOperationId) @@ -474,7 +475,7 @@ Namespace EgtCAM5 ' Rimuovo l'operazione selezionata EgtRemoveOperation(SelectedOperation.Id) ' Ricarico la lista delle operazioni - Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST) + Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1) End If End If End Sub @@ -684,6 +685,24 @@ Namespace EgtCAM5 End While End Sub + Private Sub SelectOperation(nSelectedOperation As Integer) + If nSelectedOperation < 0 Then + SelectedOperation = OperationList(0) + Else + Dim OperationFound = False + For Each Operation In OperationList + If Operation.Id = nSelectedOperation Then + OperationFound = True + SelectedOperation = Operation + Exit For + End If + Next + If Not OperationFound Then + SelectedOperation = OperationList(0) + End If + End If + End Sub + #End Region ' Methods End Class diff --git a/ProjectPage/OptionPanel/OptionPanelViewModel.vb b/ProjectPage/OptionPanel/OptionPanelViewModel.vb index 18154b3..267db17 100644 --- a/ProjectPage/OptionPanel/OptionPanelViewModel.vb +++ b/ProjectPage/OptionPanel/OptionPanelViewModel.vb @@ -25,7 +25,7 @@ Namespace EgtCAM5 m_OperationExpander = New OperationExpanderView m_OperationExpander.DataContext = New OperationExpanderViewModel End If - Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST) + Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1) Return m_OperationExpander End If End Get diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb index 188c4c4..6885991 100644 --- a/ProjectPage/ProjectViewModel.vb +++ b/ProjectPage/ProjectViewModel.vb @@ -459,11 +459,11 @@ Namespace EgtCAM5 End If End Sub) Application.Msn.Register(Application.POLYGON, Sub() - If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then - m_Controller.ExecuteCommand(Controller.CMD.POLYGON) - Else - m_Controller.ExecuteCommand(Controller.CMD.POLYGONSIDE) - End If + 'If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then + m_Controller.ExecuteCommand(Controller.CMD.POLYGON) + 'Else + ' m_Controller.ExecuteCommand(Controller.CMD.POLYGONSIDE) + 'End If End Sub) Application.Msn.Register(Application.TEXT, Sub() If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then diff --git a/ToolsDbWindow/ToolTreeView2.vb b/ToolsDbWindow/ToolTreeView2.vb index bf39b8c..4eea397 100644 --- a/ToolsDbWindow/ToolTreeView2.vb +++ b/ToolsDbWindow/ToolTreeView2.vb @@ -100,14 +100,16 @@ Public Class ToolTreeViewItem EgtSetCurrentContext(IniFile.m_ProjectSceneContext) EgtTdbSetCurrTool(Me.Name) ReadToolParam() + IsModifiedReset() NotifyPropertyChanged("Type") Else WriteToolParam() - If EgtTdbIsCurrToolModified() Or Me.NewTool Then - + If EgtTdbIsCurrToolModified() Or m_IsModifiedName Or Me.NewTool Then Select Case MsgBox(EgtMsg(MSG_TOOLSERRORS), MsgBoxStyle.YesNo, EgtMsg(MSG_TOOLSERRORS + 1)) Case MsgBoxResult.Yes m_NewTool = False + m_Name = m_Name.Trim() + WriteToolName() If IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then SaveToolDraw() End If @@ -116,10 +118,14 @@ Public Class ToolTreeViewItem Case MsgBoxResult.No If m_NewTool Then Application.Msn.NotifyColleagues(Application.REMOVETOOL, Me) + ElseIf m_IsModifiedName Then + Dim DbName As String = String.Empty + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName) + NamePar = DbName End If End Select End If - End If NotifyPropertyChanged("IsSelected") End If @@ -893,11 +899,14 @@ Public Class ToolTreeViewItem EgtTdbSetCurrToolParam(MCH_TP.MINFEED, dValue) EgtTdbSetCurrToolParam(MCH_TP.DRAW, Draw) EgtTdbSetCurrToolParam(MCH_TP.HEAD, Head) - EgtTdbSetCurrToolParam(MCH_TP.NAME, NamePar) EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, UserNotes) EgtTdbSetCurrToolParam(MCH_TP.TCPOS, TcPos) End Sub + Private Sub WriteToolName() + EgtTdbSetCurrToolParam(MCH_TP.NAME, NamePar) + End Sub + #Region "ToolSceneUpdate" ' Enum che indica le proprietà di disegno dell'utensile @@ -1147,6 +1156,34 @@ Public Class ToolTreeViewItem End Get End Property + Private Sub IsModifiedReset() + m_IsModifiedCorr = False + m_IsModifiedExit = False + m_IsModifiedCornRad = False + m_IsModifiedDiam = False + m_IsModifiedFeed = False + m_IsModifiedEndFeed = False + m_IsModifiedStartFeed = False + m_IsModifiedTipFeed = False + m_IsModifiedLen = False + m_IsModifiedTotLen = False + m_IsModifiedMaxMat = False + m_IsModifiedLonOffset = False + m_IsModifiedRadOffset = False + m_IsModifiedSpeed = False + m_IsModifiedSideAng = False + m_IsModifiedMaxSpeed = False + m_IsModifiedThick = False + m_IsModifiedMaxAbsorption = False + m_IsModifiedMinFeed = False + m_IsModifiedDraw = False + m_IsModifiedHead = False + m_IsModifiedName = False + m_IsModifiedUserNotes = False + m_IsModifiedTcPos = False + End Sub + + Private Shared ReadOnly ValidatedProperties() As String = {"Draw", "MaxMat", "Thick", "Diam", "Len", "TotLen", "Speed", "NamePar"} Private Function GetValidationError(ByVal propertyName As String) As String diff --git a/ToolsDbWindow/ToolsDbViewModel.vb b/ToolsDbWindow/ToolsDbViewModel.vb index 75ff8c0..2488708 100644 --- a/ToolsDbWindow/ToolsDbViewModel.vb +++ b/ToolsDbWindow/ToolsDbViewModel.vb @@ -433,6 +433,7 @@ Namespace EgtCAM5 ''' Public Sub Save(ByVal param As Object) Dim CurrTool As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem) + CurrTool.m_Name = CurrTool.m_Name.Trim() CurrTool.WriteToolParam() If IsUUID(Path.GetFileNameWithoutExtension(CurrTool.m_Draw)) Then CurrTool.SaveToolDraw()