OmagCUT :

- Aggiunta funzionalità salva con nome.
- Modifica per aprire in automatico la cartella dei progetti salvati quando si vuole caricare un progetto.
This commit is contained in:
Emmanuele Sassi
2016-02-15 09:09:35 +00:00
parent 9684cb1398
commit eb427a602d
13 changed files with 249 additions and 78 deletions
+6 -3
View File
@@ -60,7 +60,8 @@
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
@@ -71,9 +72,11 @@
Style="{StaticResource OmagCut_YellowGradientYellowTextButton}"/>
<Button Name="SaveBtn" Grid.Column="2"
Style="{StaticResource OmagCut_YellowGradientYellowTextButton}"/>
<Button Name="SaveNameBtn" Grid.Column="3"
Style="{StaticResource OmagCut_YellowGradientYellowTextButton}"/>
<Button Name="SimulateBtn" Grid.Column="4" Style="{StaticResource OmagCut_GradientBlueTextButton}"/>
<Button Name="WorkBtn" Grid.Column="5" Style="{StaticResource OmagCut_GradientBlueTextButton}"/>
<Button Name="SimulateBtn" Grid.Column="5" Style="{StaticResource OmagCut_GradientBlueTextButton}"/>
<Button Name="WorkBtn" Grid.Column="6" Style="{StaticResource OmagCut_GradientBlueTextButton}"/>
</Grid>
+25 -2
View File
@@ -14,6 +14,9 @@ Public Class CadCutPageUC
Friend m_SplitPage As SplitPageUC
Friend m_MoveRawPartPage As MoveRawPartPage
' Riferimento alla finestra di salvataggio con nome
Friend m_SaveNameWD As SaveNameWD
' Variabile che indica la modalità
Friend m_MovePartPage As MovePartsPages
@@ -51,6 +54,7 @@ Public Class CadCutPageUC
NewBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 3)
LoadBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 4)
SaveBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 5)
SaveNameBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 6)
End Sub
Private Sub CadCutPage_Loaded(sender As Object, e As RoutedEventArgs)
@@ -144,6 +148,8 @@ Public Class CadCutPageUC
' Non devo fare alcunchè
End Select
End If
' Cancello progetto salvato con nome da file ini
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", m_MainWindow.GetIniFile())
m_MainWindow.m_CurrentProjectPageUC.NewProject()
EgtZoom(ZM.ALL)
End Sub
@@ -167,20 +173,37 @@ Public Class CadCutPageUC
m_MainWindow.m_ActivePage = MainWindow.Pages.Open
End Sub
Friend Sub PostLoad(ByVal sPath As String)
Friend Sub PostLoad(ByVal sCurrDir As String, sCurrFile As String)
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
If Not m_MainWindow.m_CurrentProjectPageUC.LoadProject(sPath) Then
If Not m_MainWindow.m_CurrentProjectPageUC.LoadProject(sCurrDir & "\" & sCurrFile) Then
m_MainWindow.m_CurrentProjectPageUC.NewProject()
Else
' Verifico se file salvato con nome guardando il nome della cartella in cui si trova
Dim sSaveDir As String = String.Empty
GetPrivateProfileString(S_GENERAL, K_SAVEDIR, "", sSaveDir, m_MainWindow.GetIniFile())
If Not sCurrDir = sSaveDir Then
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, sCurrFile.Substring(0, sCurrFile.Length - 4), m_MainWindow.GetIniFile())
End If
End If
EgtZoom(ZM.ALL)
End Sub
Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click
' Eseguo salvataggio
Dim sCurrNameProj As String = String.Empty
GetPrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", sCurrNameProj, m_MainWindow.GetIniFile())
If Not String.IsNullOrEmpty(sCurrNameProj) Then
m_MainWindow.m_CurrentProjectPageUC.SaveNameProject()
End If
m_MainWindow.m_CurrentProjectPageUC.SaveProject()
EgtDraw()
End Sub
Private Sub SaveNameBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveNameBtn.Click
m_SaveNameWD = New SaveNameWD(m_MainWindow)
m_SaveNameWD.ShowDialog()
End Sub
Private Sub SimulateBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulateBtn.Click
m_MainWindow.m_CurrentProjectPageUC.CurrProjGrid.Visibility = Windows.Visibility.Hidden
m_MainWindow.m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
+7 -6
View File
@@ -1,10 +1,11 @@
<Window x:Class="ChooseMachining"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Title="ChooseMachining" Height="255.9" Width="426.5">
<!--Definizione della pagina di scelta della lavorazione corrente-->
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
FontFamily="./Resources/Fonts/#Century Gothic"
ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Title="ChooseMachining" Height="255.9" Width="426.5">
<!--Definizione della pagina di scelta della lavorazione corrente-->
<Border Style="{StaticResource OmagCut_Border}">
<Grid Name="ChooseMachiningGrid">
+2
View File
@@ -41,6 +41,8 @@ Module ConstGen
Public Const CNC_DIR As String = "CNC"
' Sottodirettorio di default per il salvataggio
Public Const SAVE_DFL_DIR As String = "Data"
' Sottodirettorio di default per il salvataggio con nome
Public Const SAVE_DFL_NAMEDIR As String = "MyProjects"
' Sottodirettorio di default per le macchine
Public Const MACHINES_DFL_DIR As String = "Machines"
+2
View File
@@ -24,8 +24,10 @@ Module ConstIni
Public Const K_MMUNITS As String = "MmUnits"
Public Const K_MAXPROJ As String = "MaxProj"
Public Const K_LASTPROJ As String = "LastProj"
Public Const K_LASTNAMEPROJ As String = "LastNameProj"
Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj"
Public Const K_SAVEDIR As String = "SaveDir"
Public Const K_SAVENAMEDIR As String = "SaveNameDir"
Public Const K_IMAGEDIR As String = "ImageDir"
Public Const K_CAMERALINK As String = "CameraLink"
Public Const K_CNLINK As String = "CNLink"
+42
View File
@@ -341,6 +341,48 @@ Public Class CurrentProjectPageUC
Return bOk
End Function
Friend Function SaveNameProject() As Boolean
' Determino nome del progetto
Dim CurrProjName As String = String.Empty
If Not IsNothing(m_MainWindow.m_CadCutPageUC.m_SaveNameWD) Then
CurrProjName = m_MainWindow.m_CadCutPageUC.m_SaveNameWD.SaveNameTxBx.Text
Else
GetPrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", CurrProjName, m_MainWindow.GetIniFile())
End If
Dim sPath As String = m_MainWindow.GetSaveNameDir() & "\" & CurrProjName & ".nge"
' Aggiorno file Ini
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, CurrProjName, m_MainWindow.GetIniFile())
' Rinomino eventuale fotografia
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId <> GDB_ID.NULL Then
' Path originale
Dim sPhoto As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPhoto)
' Nuova path
Dim sNewPhoto As String = Path.ChangeExtension(sPath, Path.GetExtension(sPhoto))
' Se diverse, eseguo copia
If Not String.Equals(sPhoto, sNewPhoto, StringComparison.InvariantCultureIgnoreCase) Then
Try
File.Copy(sPhoto, sNewPhoto, True)
Catch ex As Exception
Return False
End Try
End If
' Notifico a foto il cambio di path
EgtChangePhotoPath(nPhotoId, sNewPhoto)
End If
' Se assente, inserisco contrassegno di progetto OmagCut valido
AddProjectMark()
' Eseguo
If Not SaveFile(sPath) Then
Return False
End If
' Dichiaro progetto non modificato
EgtResetModified()
Return True
End Function
Friend Function RemovePreviewFromParts() As Boolean
' Processo i sottogruppi, se di livello System li rimuovo
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT)
+10 -1
View File
@@ -42,6 +42,7 @@ Class MainWindow
Private m_sResourcesDir As String = String.Empty
Private m_sTempDir As String = String.Empty
Private m_sSaveDir As String = String.Empty
Private m_sSaveNameDir As String = String.Empty
Private m_sCncDir As String = String.Empty
Private m_sMachinesRoot As String = String.Empty
Private m_sIniFile As String = String.Empty
@@ -97,6 +98,10 @@ Class MainWindow
Return m_sSaveDir
End Function
Public Function GetSaveNameDir() As String
Return m_sSaveNameDir
End Function
Public Function GetCamAutoDir() As String
Return m_sDataRoot & "\" & CAMAUTO_DIR
End Function
@@ -135,10 +140,14 @@ Class MainWindow
m_sCncDir = m_sDataRoot & "\" & CNC_DIR
' Impostazione path Ini file
m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
' Impostazione direttorio di salvataggio
' Impostazione direttorio di salvataggio automatico
If GetPrivateProfileString(S_GENERAL, K_SAVEDIR, "", m_sSaveDir, m_sIniFile) = 0 Then
m_sSaveDir = m_sDataRoot & "\" & SAVE_DFL_DIR
End If
' Impostazione direttorio di salvataggio dei progetti con nome
If GetPrivateProfileString(S_GENERAL, K_SAVENAMEDIR, "", m_sSaveNameDir, m_sIniFile) = 0 Then
m_sSaveNameDir = m_sDataRoot & "\" & SAVE_DFL_NAMEDIR
End If
' Impostazione direttorio per le macchine
If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot, m_sIniFile) = 0 Then
m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR
+3 -3
View File
@@ -119,10 +119,10 @@
<!--LowerButtonGrid-->
<Grid Grid.Column="2" Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
</Grid.ColumnDefinitions>
+7
View File
@@ -209,6 +209,9 @@
<Compile Include="OptionsPageUC.xaml.vb">
<DependentUpon>OptionsPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="SaveNameWD.xaml.vb">
<DependentUpon>SaveNameWD.xaml</DependentUpon>
</Compile>
<Compile Include="SawTestUC.xaml.vb">
<DependentUpon>SawTestUC.xaml</DependentUpon>
</Compile>
@@ -361,6 +364,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SaveNameWD.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SawTestUC.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
+63 -61
View File
@@ -1,68 +1,70 @@
<UserControl x:Class="OpenPageUC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="853.3" d:DesignWidth="1280" Initialized="OpenPage_Initialized" Loaded="OpenPage_Loaded" Unloaded="OpenPage_Unloaded">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</UserControl.Resources>
<!-- Definizione della OpenPage -->
<Border Style="{StaticResource CustomBorder}" >
<Grid Name="OpenPageGrid" >
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="853.3" d:DesignWidth="1280" Initialized="OpenPage_Initialized" Loaded="OpenPage_Loaded" Unloaded="OpenPage_Unloaded">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</UserControl.Resources>
<!-- Definizione della OpenPage -->
<Border>
<Grid Name="OpenPageGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="12*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="8*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!-- Definizione della Grid Inferiore per i Button V e X -->
<Grid Name="UpperButtonsGrid" Grid.Column="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="12*"/>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="8*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!-- Definizione della Grid Inferiore per i Button V e X -->
<Grid Name="UpperButtonsGrid" Grid.Column="1" Grid.RowSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
</Grid>
<Label Name="FilePathTxBl" Background="White" FontSize="15"/>
<ListBox Name="FileListBox" Grid.Row="1" Grid.RowSpan="2" ItemTemplate="{DynamicResource DataTemplateItem}"
</Grid>
<Label Name="FilePathTxBl" Background="White" FontSize="15"/>
<ListBox Name="FileListBox" Grid.Row="1" Grid.RowSpan="2" ItemTemplate="{DynamicResource DataTemplateItem}"
ItemsSource="{Binding ItemList}"/>
<Border Name="MessageBrd" Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="Gray">
<TextBlock Name="MessageTxBx" FontSize="15" VerticalAlignment="Center"
TextWrapping="Wrap" HorizontalAlignment="Center" />
</Border>
<!-- Definizione della Grid Inferiore per i Button V e X -->
<Grid Name="BottomButtonsGrid" Grid.Column="1" Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Border Name="MessageBrd" Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="Gray">
<TextBlock Name="MessageTxBx" FontSize="15" VerticalAlignment="Center"
TextWrapping="Wrap" HorizontalAlignment="Center" />
</Border>
<Button Name="OkBtn" Grid.Column="2" Style="{StaticResource OmagCut_GradientBlueIconButton}">
<Image Source="Resources/V.png" Width="65" Height="65" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button>
<Button Name="ExitBtn" Grid.Column="3" Style="{StaticResource OmagCut_GradientBlueIconButton}">
<Image Source="Resources/X.png" Width="65" Height="65" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button>
<!-- Definizione della Grid Inferiore per i Button V e X -->
<Grid Name="BottomButtonsGrid" Grid.Column="1" Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Name="OkBtn" Grid.Column="2" >
<Image Source="Resources/V.png" Width="65" Height="65" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button>
<Button Name="ExitBtn" Grid.Column="3" >
<Image Source="Resources/X.png" Width="65" Height="65" HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Button>
</Grid>
</Grid>
</Border>
</Grid>
</Grid>
</Border>
</UserControl>
+2 -2
View File
@@ -81,7 +81,7 @@ Public Class OpenPageUC
' inizializzo gestore lavorazioni
EgtInitMachMgr(m_MainWindow.GetMachinesRootDir())
' leggo direttorio corrente
GetPrivateProfileString(S_GENERAL, K_SAVEDIR, "", m_sCurrDir, m_MainWindow.GetIniFile())
GetPrivateProfileString(S_GENERAL, K_SAVENAMEDIR, "", m_sCurrDir, m_MainWindow.GetIniFile())
' lo carico
LoadCurrDir()
m_bFirst = False
@@ -272,7 +272,7 @@ Public Class OpenPageUC
Private Sub ConfirmBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Lancio caricamento nuovo progetto corrente
If m_bFileOk Then
m_MainWindow.m_CadCutPageUC.PostLoad(m_sCurrDir & "\" & m_sCurrFile)
m_MainWindow.m_CadCutPageUC.PostLoad(m_sCurrDir, m_sCurrFile)
End If
' Istruzioni per chiudere OpenPageUC e aprire currentproject e cadcut page
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_OpenPage)
+54
View File
@@ -0,0 +1,54 @@
<Window x:Class="SaveNameWD"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib"
FontFamily="./Resources/Fonts/#Century Gothic"
ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
Title="SaveNameWD" Height="255.9" Width="426.5">
<!--Definizione della pagina di scelta del nome con cui salvare il progetto-->
<Border Style="{StaticResource OmagCut_Border}">
<Grid x:Name="SaveNameGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<TextBlock Name="SaveNameTxbl" Grid.Column="1" Grid.Row="0"
Style="{StaticResource OmagCut_CenteredLowerCaseCharacterTextBlock}"/>
<EgtWPFLib:EgtTextBox Name="SaveNameTxBx" Grid.Column="1" Grid.Row="1"
Style="{StaticResource OmagCut_KeyboardTextBox}"/>
<Grid Name="ButtonsGrid" Grid.Column="1" Grid.Row="3" Grid.RowSpan="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<Button Name="OkBtn" Grid.Column="1" Style="{StaticResource OmagCut_GradientBlueIconButton}"
IsCancel="True">
<Image Source="Resources/V.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
<Button Name="ExitBtn" Grid.Column="3" Style="{StaticResource OmagCut_GradientBlueIconButton}"
IsCancel="True">
<Image Source="Resources/X.png" Style="{StaticResource OmagCut_ButtonIcon}"/>
</Button>
</Grid>
</Grid>
</Border>
</Window>
+26
View File
@@ -0,0 +1,26 @@
Imports EgtUILib
Public Class SaveNameWD
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Sub New(Owner As Window)
Me.Owner = Owner
InitializeComponent()
End Sub
Private Sub SaveNameWD_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
SaveNameTxbl.Text = "Nome del progetto da salvare"
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Eseguo salvataggio
m_MainWindow.m_CurrentProjectPageUC.SaveNameProject()
m_MainWindow.m_CurrentProjectPageUC.SaveProject()
EgtDraw()
End Sub
End Class