OmagCUT 1.6r8 :

- aggiunto import CSV (versione preliminare).
This commit is contained in:
Dario Sassi
2016-06-06 06:35:59 +00:00
parent 9420d825f6
commit cf650891dc
16 changed files with 1062 additions and 18 deletions
+242
View File
@@ -0,0 +1,242 @@
<UserControl x:Class="CSVPage"
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"
xmlns:self="clr-namespace:OmagCUT.TreeViewItem"
mc:Ignorable="d"
d:DesignHeight="853.3" d:DesignWidth="1280">
<!-- Chiamata al Dictionary -->
<UserControl.Resources>
<ResourceDictionary Source="OmagCUTDictionary.xaml"></ResourceDictionary>
</UserControl.Resources>
<!-- Definizione della SplitPage -->
<Grid Name="SplitPageGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="12*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="8*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!--Upper button grid-->
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<!--Griglia per oscurare i bottoni della pagina sottostante-->
<Grid Background="{StaticResource OmagCut_Gray}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
</Grid>
</Grid>
<!--Left Button Grid-->
<Grid Grid.RowSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="5.5*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Label Name="CsvPathTxBl" Grid.Row="1" Background="White" FontSize="20" VerticalAlignment="Center"/>
<TreeView Name="PartsTreeView" Grid.Row="2">
<TreeView.Resources>
<!--Modifico HierarchicalDataTemplate del CathegoryItem per poter inserire immagine e testo e per -->
<!--renderlo apribile con un solo click -->
<HierarchicalDataTemplate DataType="{x:Type self:PartCathegoryItem}" ItemsSource="{Binding Items}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Source="{Binding PictureString}" Height="32" Width="32" Margin="0,8,6,4" />
<TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="15" Margin="10" />
</Grid>
<!--Assegna ai nodi ToolItem lo Style normale dei TreeViewItem, eliminando l'ombra, data dal -->
<!-- multibinding quando sono attivi.-->
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}" >
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="0" Width="0"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ExpandCollapseToggleStyle}"/>
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="false">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" TargetName="Bd" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="BorderThickness" TargetName="Bd" Value="1"/>
<!--<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>-->
</Trigger>
<!--<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</MultiTrigger>-->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding bIsActive}" Value="False">
<Setter Property="Foreground" Value="{StaticResource OmagCut_LightGray}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
</HierarchicalDataTemplate>
<!--Modifico DataTemplate del ToolItem per poter inserire immagine e testo-->
<DataTemplate DataType="{x:Type self:PartCustomItem}">
<Grid Width="216" Margin="0,5,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Name}" Height="18" FontSize="15" />
<TextBlock Grid.Column="1" Text="{Binding sText1}" Height="18" FontSize="15" TextAlignment="Right"/>
<TextBlock Grid.Column="2" Text="{Binding sText2}" Height="18" FontSize="15" TextAlignment="Right"/>
</Grid>
</DataTemplate>
</TreeView.Resources>
<!--Style dei nodi CathegoryItem che li riquadra di azzurro quando clicckati ed elimina l'ombra grigia -->
<!--che si presenta quando la categoria rimane vuota (ombra causata dal multibinding). -->
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="19" Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border x:Name="ExpanderBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ExpandCollapseToggleStyle}"/>
</Border>
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="false">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" TargetName="Bd" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="BorderThickness" TargetName="Bd" Value="0,1,1,1"/>
<Setter Property="Background" TargetName="ExpanderBorder" Value="Transparent"/>
<Setter Property="BorderBrush" TargetName="ExpanderBorder" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="BorderThickness" TargetName="ExpanderBorder" Value="1,1,0,1"/>
<!--<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>-->
</Trigger>
<!--<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true"/>
<Condition Property="IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</MultiTrigger>-->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Name="NewBtn" Grid.Column="0" Style="{StaticResource OmagCut_YellowTextButton}" />
<Button Name="OpenBtn" Grid.Column="1" Style="{StaticResource OmagCut_YellowTextButton}" />
<Button Name="InsertBtn" Grid.Column="2" Style="{StaticResource OmagCut_YellowTextButton}" />
</Grid>
</Grid>
<!--Lower button grid, sfondo grigio per coprire i bottoni della pagina sottostante-->
<Grid Grid.Column="1" Grid.Row="2" Background="{StaticResource OmagCut_Gray}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="11*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Name="OkBtn" Grid.Column="2" Style="{StaticResource OmagCut_GradientBlueIconButton}">
<Image Source="Resources/V.png" Style="{StaticResource OmagCut_ButtonIcon}" />
</Button>
</Grid>
</Grid>
</UserControl>
+435
View File
@@ -0,0 +1,435 @@
Imports System.Collections.ObjectModel
Imports OmagCUT.TreeViewItem
Imports EgtUILib
Public Class CSVPage
' Riferimenti a pagine
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_bFirst As Boolean = True
Private m_sCsvPath As String = String.Empty
Private m_CsvPartList As New List(Of CsvPart)
Private m_ItemsList As New ObservableCollection(Of PartCathegoryItem)
Private m_sCompoDir As String = String.Empty
Private m_nRawId As Integer = GDB_ID.NULL
Private m_ptRawMin As Point3d
Private m_ptRawMax As Point3d
Private Sub CSVPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Assegno la lista dei pezzi Csv come sorgente del treeview
PartsTreeView.ItemsSource = m_ItemsList
' Messaggi
NewBtn.Content = EgtMsg(MSG_CSVPAGEUC + 3) ' Nuovo
OpenBtn.Content = EgtMsg(MSG_CSVPAGEUC + 1) ' Apri
InsertBtn.Content = EgtMsg(MSG_CSVPAGEUC + 2) ' Carica
' Leggo lista pezzi corrente
LoadCsvPartList()
End Sub
Private Sub CSVPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
If m_bFirst Then
' Leggo direttorio componenti
GetPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir, m_MainWindow.GetIniFile())
' Visualizzazione lista
ShowTreeView()
m_bFirst = False
End If
End Sub
Private Sub CSVPage_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(Me)
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_NestPage)
m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut
End Sub
Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
' Visualizzazione lista
ShowTreeView()
End Sub
'Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click
' m_CsvPartList(1 - 1).m_nToNest -= 1
' For Each Item As PartCathegoryItem In m_ItemsList
' For Each Item2 As PartCustomItem In Item.Items
' If Item2.nType = 1 Then
' Item2.sText1 = m_CsvPartList(1 - 1).m_nToNest.ToString() & "/" & m_CsvPartList(1 - 1).m_nCount.ToString()
' End If
' Next
' Next
'End Sub
Private Sub OpenBtn_Click(sender As Object, e As RoutedEventArgs) Handles OpenBtn.Click
' Leggo direttorio corrente dei file CSV
Dim sCurrDir As String = ""
GetPrivateProfileString(S_CSV, K_CSVCURRDIR, "C:\", sCurrDir, m_MainWindow.GetIniFile())
' Apro dialogo scelta file
Dim OpenFileWnd As New OpenFileWD(m_MainWindow, sCurrDir, ".CSV")
If Not OpenFileWnd.ShowDialog() Then Return
' Salvo direttorio corrente
WritePrivateProfileString(S_CSV, K_CSVCURRDIR, OpenFileWnd.GetFileDir(), m_MainWindow.GetIniFile())
' Apertura file
Dim sCsvPath = OpenFileWnd.GetFilePath()
LoadCsv(sCsvPath)
' Visualizzazione lista
ShowTreeView()
End Sub
Private Function LoadCsv(sCsvPath As String)
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
' Definizione variabili
EgtLuaCreateGlobTable("CSV")
EgtLuaSetGlobStringVar("CSV.FILE", sCsvPath)
' Esecuzione
Dim nErr As Integer = 999
If EgtLuaExecFile(m_MainWindow.GetCsvAutoDir() & "\CsvRead.lua") AndAlso
EgtLuaCallFunction("CSV.Read") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("CSV.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in CsvRead : " & nErr.ToString())
Return False
End If
' Assegno path
m_sCsvPath = sCsvPath
' Preparo lista dei pezzi
Dim nNbr As Integer = 0
EgtLuaGetGlobIntVar("CSV.NBR", nNbr)
For i As Integer = 1 To nNbr
Dim OnePart As New CsvPart
Dim sN As String = i.ToString()
EgtLuaGetGlobStringVar("CSV.NAME" & sN, OnePart.m_sName)
OnePart.m_bActive = True
EgtLuaGetGlobStringVar("CSV.MAT" & sN, OnePart.m_sMaterial)
EgtLuaGetGlobIntVar("CSV.COUNT" & sN, OnePart.m_nCount)
OnePart.m_nToNest = OnePart.m_nCount
EgtLuaGetGlobBoolVar("CSV.RECT" & sN, OnePart.m_bIsRect)
EgtLuaGetGlobNumVar("CSV.DIMX" & sN, OnePart.m_dDimX)
EgtLuaGetGlobNumVar("CSV.DIMY" & sN, OnePart.m_dDimY)
EgtLuaGetGlobNumVar("CSV.TH" & sN, OnePart.m_dTh)
OnePart.m_nOriInd = i
' inserisco in lista
m_CsvPartList.Add(OnePart)
Next
EgtLuaResetGlobVar("CSV")
' Ordinamento lista dei pezzi
m_CsvPartList.Sort(Function(x, y)
If Math.Abs(x.m_dTh - y.m_dTh) < EPS_SMALL Then
Return x.m_nOriInd < y.m_nOriInd
Else
Return x.m_dTh < y.m_dTh
End If
End Function)
Return True
End Function
Private Sub ShowTreeView()
' Path del file Csv
Dim TempPath As New Text.StringBuilder(260)
PathCompactPathEx(TempPath, m_sCsvPath, 22, 0)
CsvPathTxBl.Content = TempPath.ToString()
' Pezzi del file Csv
m_ItemsList.Clear()
Dim dCurrTh As Double = 0
Dim PartCathegory As PartCathegoryItem
For i As Integer = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
If i = 1 Or Math.Abs(dCurrTh - CurrPart.m_dTh) > 10 * EPS_SMALL Then
dCurrTh = CurrPart.m_dTh
PartCathegory = New PartCathegoryItem("Spessore " & LenToString(CurrPart.m_dTh, 2), 0)
PartCathegory.IsExpanded = True
m_ItemsList.Add(PartCathegory)
End If
Dim sCount As String = CurrPart.m_nToNest.ToString() & "/" & CurrPart.m_nCount.ToString()
Dim sDim As String = LenToString(CurrPart.m_dDimX, 1) & "x" & LenToString(CurrPart.m_dDimY, 1)
PartCathegory.Items.Add(New PartCustomItem(CurrPart.m_sName, i, sCount, sDim, CurrPart.m_bActive))
Next
End Sub
Private Sub PartsTreeView_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles PartsTreeView.PreviewMouseUp
If TypeOf PartsTreeView.SelectedItem Is PartCathegoryItem Then
Dim SelectedCathegory As PartCathegoryItem = PartsTreeView.SelectedItem
SelectedCathegory.IsExpanded = Not SelectedCathegory.IsExpanded
If SelectedCathegory.IsExpanded Then
SelectedCathegory.IsSelected = False
End If
ElseIf TypeOf PartsTreeView.SelectedItem Is PartCustomItem Then
Dim SelectedCustom As PartCustomItem = PartsTreeView.SelectedItem
SelectedCustom.bIsActive = Not SelectedCustom.bIsActive
m_CsvPartList(SelectedCustom.nType - 1).m_bActive = SelectedCustom.bIsActive
End If
End Sub
Private Sub InsertBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertBtn.Click
' Recupero lo spessore della lastra corrente
Dim dRawHeight As Double = GetRawHeight()
If dRawHeight < EPS_SMALL Then Return
' Recupero il materiale della lastra corrente
Dim sCurrMat As String = String.Empty
If Not IsNothing(m_MainWindow.m_CurrentMachine.CurrMat) Then
sCurrMat = m_MainWindow.m_CurrentMachine.CurrMat.sName
End If
' Creo la lista dei pezzi inseribili nella lastra corrente
Dim InsPartList As New List(Of CsvPart)
For i As Integer = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
If CurrPart.m_bActive And
Math.Abs(CurrPart.m_dTh - dRawHeight) < 100 * EPS_SMALL And
(String.IsNullOrWhiteSpace(CurrPart.m_sMaterial) Or
String.IsNullOrWhiteSpace(sCurrMat) Or
String.Compare(CurrPart.m_sMaterial, sCurrMat, True)) Then
InsPartList.Add(CurrPart)
End If
Next
' Lancio l'inserimento dei pezzi
ExecInsert(InsPartList)
' Aggiorno visualizzazione
EgtDraw()
' Aggiorno TreeView
ShowTreeView()
End Sub
Private Function ExecInsert(InsPartList As List(Of CsvPart))
' Ordino la lista dei pezzi secondo le Y decrescenti
InsPartList.Sort(Function(x, y)
If Math.Abs(x.m_dDimY - y.m_dDimY) < EPS_SMALL Then
Return x.m_nOriInd < y.m_nOriInd
Else
Return x.m_dDimY > y.m_dDimY
End If
End Function)
' Creo o svuoto gruppo temporaneo per i pezzi
Dim nIpGrp As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "CSV")
If nIpGrp = GDB_ID.NULL Then
nIpGrp = EgtCreateGroup(GDB_ID.ROOT)
If nIpGrp = GDB_ID.NULL Then Return False
EgtSetName(nIpGrp, "CSV")
Else
EgtEmptyGroup(nIpGrp)
End If
EgtSetLevel(nIpGrp, GDB_LV.TEMP)
EgtSetStatus(nIpGrp, GDB_ST.OFF)
' Carico lua per creare rettangoli
Dim sLuaPath = m_sCompoDir & "\Rettangolo.lua"
If Not EgtLuaExecFile(sLuaPath) Then Return False
' Inserisco nel gruppo un nuovo componente per ogni pezzo da inserire
For i As Integer = 1 To InsPartList.Count()
Dim CurrPart As CsvPart = InsPartList(i - 1)
' Definizione variabili
EgtLuaSetGlobNumVar("CMP.V1", Math.Max(CurrPart.m_dDimX, CurrPart.m_dDimY))
EgtLuaSetGlobNumVar("CMP.V2", Math.Min(CurrPart.m_dDimX, CurrPart.m_dDimY))
EgtLuaSetGlobStringVar("CMP.INFO", CurrPart.m_sName)
' Esecuzione componente
If Not EgtLuaExecLine("CMP_Draw(false)") Then Return False
' Recupero Id del nuovo componente
Dim nId As Integer = EgtGetLastPart()
If nId = GDB_ID.NULL Then Return False
CurrPart.m_nId = nId
' Muovo la regione in Z per evitare problemi in visualizzazione
Dim nRegId = EgtGetFirstNameInGroup(nId, NAME_REGION)
EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)
' Aggiusto per lavorazioni
AdjustFlatPart(nId)
' Lo sposto nel gruppo speciale
EgtRelocate(nId, nIpGrp)
Next
EgtLuaResetGlobVar("CMP")
EgtLuaResetGlobVar("CMP_Draw")
' recupero dimensioni del grezzo e kerf
m_nRawId = EgtGetFirstRawPart()
GetRawBox(m_ptRawMin, m_ptRawMax)
' Provo ad inserire i pezzi
For i As Integer = 1 To InsPartList.Count()
Dim CurrPart As CsvPart = InsPartList(i - 1)
While CurrPart.m_nToNest > 0
If PackOnePart(CurrPart.m_nId) Then
CurrPart.m_nToNest -= 1
Else
Exit While
End If
End While
Next
Return True
End Function
Private Function PackOnePart(nId As Integer)
' Dimensioni del pezzo
Dim ptPartMin, ptPartMax As Point3d
If Not EgtGetBBox(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) Then Return False
Dim dPartLen As Double = ptPartMax.x - ptPartMin.x
Dim dPartHeight As Double = ptPartMax.y - ptPartMin.y
' Centro del grezzo
Dim nRawCenId = EgtGetFirstNameInGroup(m_nRawId, "RawCenter")
Dim ptRawCenter As Point3d
EgtStartPoint(nRawCenId, GDB_ID.ROOT, ptRawCenter)
Dim dRawCenX = ptRawCenter.x - m_ptRawMin.x
Dim dRawCenY = ptRawCenter.y - m_ptRawMin.y
' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z
Dim ptP As New Point3d(dRawCenX - 0.5 * dPartLen, dRawCenY - 0.5 * dPartHeight, m_ptRawMax.z - m_ptRawMin.z)
' Ne creo una copia nella radice
Dim nId2 As Integer = EgtCopyGlob(nId, GDB_ID.ROOT)
If EgtAddPartToRawPart(nId2, ptP, m_nRawId) Then
' Aggiungo le lavorazioni standard
AddMachinings(nId2, True, False)
' Eseguo nesting
Dim bFit As Boolean = False
If m_MainWindow.m_CadCutPageUC.m_NestPage.UpdateNestRegions() Then
If Not EgtExistsInfo(m_nRawId, KEY_RAWBYPOINTS) Then
bFit = EgtPackPartInRectangle(nId2, True, True)
End If
If Not bFit Then
bFit = EgtPackPart(nId2, True, True)
End If
End If
' Gestione risultato nesting
If bFit Then
Return True
Else
EgtRemovePartFromRawPart(nId2)
EgtErase(nId2)
End If
End If
Return False
End Function
Friend Sub SaveCsvPartList()
' Path del file
Dim sFile As String = m_MainWindow.GetCsvAutoDir() & "\CsvPartList.ini"
' Gestione file
Try
' Apro file
Dim Writer As New IO.StreamWriter(sFile, False)
' Intestazione
Writer.WriteLine("[General]")
Writer.WriteLine("Path=" & m_sCsvPath)
' Ciclo sui pezzi
For i As Integer = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
Writer.WriteLine("[P" & i.ToString() & "]")
Writer.WriteLine("Nam=" & CurrPart.m_sName)
Writer.WriteLine("Mat=" & CurrPart.m_sMaterial)
Writer.WriteLine("Act=" & If(CurrPart.m_bActive, "1", "0"))
Writer.WriteLine("Cnt=" & CurrPart.m_nCount.ToString())
Writer.WriteLine("ToN=" & CurrPart.m_nToNest.ToString())
Writer.WriteLine("Rct=" & If(CurrPart.m_bIsRect, "1", "0"))
Writer.WriteLine("DX=" & DoubleToString(CurrPart.m_dDimX, 4))
Writer.WriteLine("DY=" & DoubleToString(CurrPart.m_dDimY, 4))
Writer.WriteLine("Th=" & DoubleToString(CurrPart.m_dTh, 4))
Writer.WriteLine("OIn=" & CurrPart.m_nOriInd.ToString())
Next
' Terminatore
Writer.WriteLine("[END]")
' Chiudo file
Writer.Close()
' Errore
Catch ex As Exception
EgtOutLog("Error writing " & sFile)
End Try
End Sub
Private Sub LoadCsvPartList()
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
' Path del file
Dim sFile As String = m_MainWindow.GetCsvAutoDir() & "\CsvPartList.ini"
' Gestione file
Try
' Apro file
Dim Reader As New IO.StreamReader(sFile, False)
' Lettura intestazione
Dim sLine As String = Reader.ReadLine()
While sLine <> Nothing
If sLine = "[General]" Then
' non devo fare alcunché
ElseIf sLine.Length() >= 5 AndAlso sLine.Substring(0, 5) = "Path=" Then
Dim sItems() As String = sLine.Split("=".ToCharArray)
If sItems.Count() >= 2 Then
m_sCsvPath = sItems(1)
End If
Else
Exit While
End If
sLine = Reader.ReadLine()
End While
' Ciclo di lettura dei pezzi
Dim nI As Integer = 1
Dim sPart As String = "[P" & nI.ToString() & "]"
Dim OnePart As New CsvPart
While sLine <> Nothing
' Inizio pezzo o fine del file
If sLine = sPart Or sLine = "[END]" Then
' se esiste pezzo precedente, lo salvo
If nI > 1 Then
' inserisco in lista
m_CsvPartList.Add(OnePart)
End If
' predisposizioni per prossimo pezzo
nI += 1
sPart = "[P" & nI.ToString() & "]"
OnePart = New CsvPart
' Dato
Else
Dim sItems() As String = sLine.Split("=".ToCharArray)
If sItems.Count() >= 2 Then
If sItems(0) = "Nam" Then
OnePart.m_sName = sItems(1)
ElseIf sItems(0) = "Mat" Then
OnePart.m_sMaterial = sItems(1)
ElseIf sItems(0) = "Act" Then
OnePart.m_bActive = If(sItems(1) = "0", False, True)
ElseIf sItems(0) = "Cnt" Then
OnePart.m_nCount = Int(sItems(1))
ElseIf sItems(0) = "ToN" Then
OnePart.m_nToNest = Int(sItems(1))
ElseIf sItems(0) = "Rct" Then
OnePart.m_bIsRect = If(sItems(1) = "0", False, True)
ElseIf sItems(0) = "DX" Then
StringToDouble(sItems(1), OnePart.m_dDimX)
ElseIf sItems(0) = "DY" Then
StringToDouble(sItems(1), OnePart.m_dDimY)
ElseIf sItems(0) = "Th" Then
StringToDouble(sItems(1), OnePart.m_dTh)
ElseIf sItems(0) = "OIn" Then
OnePart.m_nOriInd = Int(sItems(1))
End If
End If
End If
sLine = Reader.ReadLine()
End While
' Chiudo il file
Reader.Close()
' Errore
Catch ex As Exception
EgtOutLog("Error reading " & sFile)
End Try
End Sub
'-----------------------------------------------------------------------------------------------
Private Class CsvPart
Public m_sName As String
Public m_sMaterial As String
Public m_bActive As Boolean
Public m_nCount As Integer
Public m_nToNest As Integer
Public m_bIsRect As Boolean
Public m_dDimX As Double
Public m_dDimY As Double
Public m_dTh As Double
Public m_nOriInd As Integer
Public m_nId As Integer = GDB_ID.NULL
End Class
End Class
+6
View File
@@ -13,6 +13,7 @@ Public Class CadCutPageUC
Friend WithEvents m_NestPage As NestPageUC
Friend m_SplitPage As SplitPageUC
Friend m_MoveRawPartPage As MoveRawPartPage
Friend m_CSVPage As CSVPage
Friend m_ProjectMgr As ProjectMgrUC
'' Riferimento alla finestra di salvataggio con nome
@@ -37,6 +38,7 @@ Public Class CadCutPageUC
m_NestPage = New NestPageUC
m_SplitPage = New SplitPageUC
m_MoveRawPartPage = New MoveRawPartPage
m_CSVPage = New CSVPage
m_ProjectMgr = New ProjectMgrUC
' Posizionamento nella griglia delle Page UserControl
@@ -46,6 +48,8 @@ Public Class CadCutPageUC
m_SplitPage.SetValue(Grid.ColumnSpanProperty, 3)
m_MoveRawPartPage.SetValue(Grid.RowSpanProperty, 3)
m_MoveRawPartPage.SetValue(Grid.ColumnSpanProperty, 3)
m_CSVPage.SetValue(Grid.RowSpanProperty, 3)
m_CSVPage.SetValue(Grid.ColumnSpanProperty, 3)
m_ProjectMgr.SetValue(Grid.RowProperty, 2)
m_ProjectMgr.SetValue(Grid.ColumnProperty, 1)
@@ -55,6 +59,8 @@ Public Class CadCutPageUC
Private Sub CadCutPage_Loaded(sender As Object, e As RoutedEventArgs)
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
' Visualizzo bottone CSV
m_ProjectMgr.CSVBtn.Visibility = Windows.Visibility.Visible
' Seleziono UserControl di apertura
CadCutPageGrid.Children.Add(m_NestPage)
m_CadCutMode = CadCutModes.Nest
+2
View File
@@ -37,6 +37,8 @@ Module ConstGen
Public Const TEMP_DIR As String = "Temp"
' Sottodirettorio per Cam automatico
Public Const CAMAUTO_DIR As String = "CamAuto"
' Sottodirettorio per Csv automatico
Public Const CSVAUTO_DIR As String = "CsvAuto"
' Sottodirettorio per file Cnc
Public Const CNC_DIR As String = "CNC"
' Sottodirettorio di default per il salvataggio
+3
View File
@@ -92,6 +92,9 @@ Module ConstIni
Public Const K_RESTRADIUS As String = "RestRadius"
Public Const K_SNAPDIST As String = "SnapDist"
Public Const S_CSV As String = "Csv"
Public Const K_CSVCURRDIR As String = "CurrDir"
Public Const S_FRAME As String = "Frame"
Public Const K_OFFSZ As String = "OffsZ"
Public Const K_OFFSXY As String = "OffsXY"
+1
View File
@@ -28,5 +28,6 @@
Public Const MSG_MACHINECNPAGEUC As Integer = MSG_OMAGCUT + 930
Public Const MSG_OPTIONSPAGEUC As Integer = MSG_OMAGCUT + 950
Public Const MSG_EGTMSGBOX As Integer = MSG_OMAGCUT + 1100
Public Const MSG_CSVPAGEUC As Integer = MSG_OMAGCUT + 1200
End Module
+2
View File
@@ -72,6 +72,8 @@ Public Class FrameCutPageUC
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
m_CurrMachine = m_MainWindow.m_CurrentMachine
m_bActive = True
' Nascondo bottone CSV
m_ProjectMgr.CSVBtn.Visibility = Windows.Visibility.Hidden
' Recupero dimensioni e kerf del grezzo
m_nRawId = EgtGetFirstRawPart()
GetRawBox(m_RawBox)
+19 -15
View File
@@ -90,6 +90,7 @@ Class MainWindow
RawPart
Draw
Import
CSV
Simulation
FrameCut
Machine
@@ -121,6 +122,10 @@ Class MainWindow
Return m_sDataRoot & "\" & CAMAUTO_DIR
End Function
Public Function GetCsvAutoDir() As String
Return m_sDataRoot & "\" & CSVAUTO_DIR
End Function
Public Function GetCopyTemplateDir() As String
Return m_sCopyTemplateDir
End Function
@@ -389,7 +394,7 @@ Class MainWindow
MainWindowGrid.Children.Remove(m_CurrentProjectPageUC)
MainWindowGrid.Children.Add(m_WorkInProgressPageUC)
m_ActivePage = Pages.WorkInProgress
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.Simulation
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
WorkInProgressBtn.IsChecked = False
CadCutBtn.IsChecked = True
Case Pages.FrameCut
@@ -437,7 +442,7 @@ Class MainWindow
m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(m_CadCutPageUC)
m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_DirectCutPageUC)
m_ActivePage = Pages.DirectCut
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.Simulation
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
DirectCutBtn.IsChecked = False
CadCutBtn.IsChecked = True
Case Pages.FrameCut
@@ -486,7 +491,7 @@ Class MainWindow
m_ActivePage = Pages.CadCut
Case Pages.CadCut
CadCutBtn.IsChecked = True
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.Simulation
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
CadCutBtn.IsChecked = True
Case Pages.FrameCut
CadCutBtn.IsChecked = True
@@ -538,7 +543,7 @@ Class MainWindow
m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Remove(m_CadCutPageUC)
m_CurrentProjectPageUC.CurrentProjectPageGrid.Children.Add(m_FrameCutPageUC)
m_ActivePage = Pages.FrameCut
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.Simulation
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
CadCutBtn.IsChecked = True
FrameCutBtn.IsChecked = False
Case Pages.FrameCut
@@ -588,7 +593,7 @@ Class MainWindow
MainWindowGrid.Children.Remove(m_CurrentProjectPageUC)
MainWindowGrid.Children.Add(m_MachinePageUC)
m_ActivePage = Pages.Machine
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.Simulation
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
CadCutBtn.IsChecked = True
MachineBtn.IsChecked = False
Case Pages.FrameCut
@@ -631,16 +636,7 @@ Class MainWindow
MainWindowGrid.Children.Remove(m_CurrentProjectPageUC)
MainWindowGrid.Children.Add(m_OptionsPageUC)
m_ActivePage = Pages.Options
Case Pages.Photo, Pages.RawPart
CadCutBtn.IsChecked = True
OptionsBtn.IsChecked = False
Case Pages.Simulation
CadCutBtn.IsChecked = True
OptionsBtn.IsChecked = False
Case Pages.Draw
CadCutBtn.IsChecked = True
OptionsBtn.IsChecked = False
Case Pages.Import
Case Pages.Photo, Pages.RawPart, Pages.Draw, Pages.Import, Pages.CSV, Pages.Simulation
CadCutBtn.IsChecked = True
OptionsBtn.IsChecked = False
Case Pages.FrameCut
@@ -711,6 +707,8 @@ Class MainWindow
End If
' Uscita da pagina corrente definizione grezzo
If Not ExitFromRaw() Then Return
' Uscita da pagina corrente CSV
If Not ExitFromCsv() Then Return
' Uscita da pagina corrente di split
If Not ExitFromSplit() Then Return
' Uscita da pagina corrente di simulazione
@@ -737,6 +735,12 @@ Class MainWindow
Return m_RawPartPage.ExitRawPart(True)
End Function
Private Function ExitFromCsv() As Boolean
' Salvo lo stato attuale della lista
m_CadCutPageUC.m_CSVPage.SaveCsvPartList()
Return True
End Function
Private Function ExitFromSplit() As Boolean
' Se non sono in split tutto ok
If m_ActivePage <> Pages.CadCut Or m_CadCutPageUC.m_CadCutMode = CadCutPageUC.CadCutModes.Nest Then Return True
+2 -2
View File
@@ -60,5 +60,5 @@ Imports System.Windows
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.6.18.6")>
<Assembly: AssemblyFileVersion("1.6.18.6")>
<Assembly: AssemblyVersion("1.6.18.8")>
<Assembly: AssemblyFileVersion("1.6.18.8")>
+1 -1
View File
@@ -398,7 +398,7 @@ Public Class NestPageUC
' Eseguo nesting
Dim bFit As Boolean = False
If UpdateNestRegions() Then
If Not EgtExistsInfo(m_CurrProjPage.m_nRawId, KEY_RAWBYPOINTS) Then
If Not EgtExistsInfo(m_nRawId, KEY_RAWBYPOINTS) Then
bFit = EgtPackPartInRectangle(nId, m_bReducedCut, True)
End If
If Not bFit Then
+14
View File
@@ -147,6 +147,9 @@
<Compile Include="CopyTemplateUC.xaml.vb">
<DependentUpon>CopyTemplateUC.xaml</DependentUpon>
</Compile>
<Compile Include="CSVPage.xaml.vb">
<DependentUpon>CSVPage.xaml</DependentUpon>
</Compile>
<Compile Include="CurrentMachine.vb" />
<Compile Include="CurrentProjectPageUC.xaml.vb">
<DependentUpon>CurrentProjectPageUC.xaml</DependentUpon>
@@ -190,6 +193,9 @@
<Compile Include="NestPageUC.xaml.vb">
<DependentUpon>NestPageUC.xaml</DependentUpon>
</Compile>
<Compile Include="OpenFileWD.xaml.vb">
<DependentUpon>OpenFileWD.xaml</DependentUpon>
</Compile>
<Compile Include="OpenPageUC.xaml.vb">
<DependentUpon>OpenPageUC.xaml</DependentUpon>
</Compile>
@@ -287,6 +293,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CSVPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CurrentProjectPageUC.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -339,6 +349,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OpenFileWD.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OpenPageUC.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
+111
View File
@@ -117,6 +117,117 @@ Namespace TreeViewItem
End Class
Public Class PartCathegoryItem
Inherits TreeViewItemBase
'Private m_sTitle As String
Private m_sPictureString As String
Private m_nFType As Integer
Private m_Items As ObservableCollection(Of PartCustomItem)
'Public Property Name As String
' Get
' Return m_sTitle
' End Get
' Set(value As String)
' m_sTitle = value
' End Set
'End Property
Public ReadOnly Property PictureString As String
Get
Return "/Resources/ToolsTreeViewImages/Lama.png"
End Get
End Property
Public ReadOnly Property nFType As Integer
Get
Return m_nFType
End Get
End Property
Public Property Items As ObservableCollection(Of PartCustomItem)
Get
Return m_Items
End Get
Set(value As ObservableCollection(Of PartCustomItem))
m_Items = value
End Set
End Property
Sub New(sName As String, nType As Integer)
Name = sName
m_nFType = nType
Me.Items = New ObservableCollection(Of PartCustomItem)
End Sub
End Class
Public Class PartCustomItem
Inherits TreeViewItemBase
'Private m_sTitle As String
Private m_nType As Integer
Private m_bIsActive As Boolean
Private m_sText1 As String
Private m_sText2 As String
Public Property sText1 As String
Get
Return m_sText1
End Get
Set(value As String)
m_sText1 = value
NotifyPropertyChanged("sText1")
End Set
End Property
Public Property sText2 As String
Get
Return m_sText2
End Get
Set(value As String)
m_sText2 = value
NotifyPropertyChanged("sText2")
End Set
End Property
Public ReadOnly Property nType As Integer
Get
Return m_nType
End Get
End Property
Public Property bIsActive As Boolean
Get
Return m_bIsActive
End Get
Set(value As Boolean)
If value <> m_bIsActive Then
m_bIsActive = value
NotifyPropertyChanged("bIsActive")
End If
End Set
End Property
Sub New(Title As String, nType As Integer, sText1 As String, sText2 As String)
Me.Name = Title
m_nType = nType
m_sText1 = sText1
m_sText2 = sText2
m_bIsActive = True
End Sub
Sub New(Title As String, nType As Integer, sText1 As String, sText2 As String, bIsActive As Boolean)
Me.Name = Title
m_nType = nType
m_sText1 = sText1
m_sText2 = sText2
m_bIsActive = bIsActive
End Sub
End Class
Public Class TreeViewItemBase
Implements INotifyPropertyChanged
+55
View File
@@ -0,0 +1,55 @@
<Window x:Class="OpenFileWD"
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"
Title="OpenFile" Height="682.6" Width="426.6" WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False" AllowsTransparency="True" Background="Transparent">
<!-- Chiamata al Dictionary -->
<Window.Resources>
<ResourceDictionary Source="OmagCutDictionary.xaml"/>
</Window.Resources>
<Border Style="{StaticResource OmagCut_Border}">
<Grid>
<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="5.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Label Name="FilePathTxBl" Grid.Column="1" Grid.Row="1" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<ListBox Name="FileListBox" Grid.Column="1" Grid.Row="2" ItemTemplate="{DynamicResource DataTemplateItem}"
ItemsSource="{Binding ItemList}"/>
<Grid Grid.Column="1" Grid.Row="4">
<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}" IsDefault="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>
+159
View File
@@ -0,0 +1,159 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Public Class OpenFileWD
' Properties
Private m_sCurrDir As String = String.Empty
Private m_sCurrFile As String = String.Empty
Private m_sExt As String = String.Empty
Private m_OpenItemList As New ObservableCollection(Of IconListBoxItem)
Sub New(Owner As Window, sDir As String, sExt As String)
Me.Owner = Owner
m_sCurrDir = sDir
m_sExt = sExt
InitializeComponent()
End Sub
Private Sub OpenFile_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
' Posizione finestra
Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
' Definizione del collegamento tra ItemList e ListBox1
FileListBox.ItemsSource = m_OpenItemList
End Sub
Private Sub OpenFile_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
' carico direttorio
LoadCurrDir()
' disabilito ok
OkBtn.IsEnabled = False
End Sub
Private Function LoadCurrDir() As Boolean
' se direttorio corrente non valido, carico l'elenco dei dischi
If String.IsNullOrWhiteSpace(m_sCurrDir) OrElse Not IO.Directory.Exists(m_sCurrDir) Then
Return LoadDisks()
End If
Dim TempPath As New Text.StringBuilder(260)
PathCompactPathEx(TempPath, m_sCurrDir, 28, 0)
' lo visualizzo
FilePathTxBl.Content = TempPath.ToString
' pulisco la lista
m_OpenItemList.Clear()
' per risalire al direttorio padre
m_OpenItemList.Add(New IconListBoxItem("..", 0))
' elenco dei sottodirettori
Dim DirInfo As New DirectoryInfo(m_sCurrDir)
Dim vDirI As DirectoryInfo() = DirInfo.GetDirectories("*")
Dim DirI As DirectoryInfo
For Each DirI In vDirI
' per saltare i link, troppo complessi da gestire
If (DirI.Attributes And FileAttributes.Hidden) <> FileAttributes.Hidden Or
(DirI.Attributes And FileAttributes.System) <> FileAttributes.System Then
m_OpenItemList.Add(New IconListBoxItem(DirI.Name, 2))
End If
Next
' elenco dei file
Dim vFileI As FileInfo() = DirInfo.GetFiles()
Dim FileI As FileInfo
For Each FileI In vFileI
Dim sExt As String = Path.GetExtension(FileI.Name).ToUpper()
If sExt = m_sExt Then
m_OpenItemList.Add(New IconListBoxItem(FileI.Name, 3))
End If
Next
' riporto visualizzazione in cima alla lista (esiste sempre almeno un elemento)
FileListBox.ScrollIntoView(m_OpenItemList(0))
Return True
End Function
Private Function LoadDisks() As Boolean
' dir corrente vuoto
m_sCurrDir = ""
' lo visualizzo
FilePathTxBl.Content = m_sCurrDir
' pulisco la lista
m_OpenItemList.Clear()
' elenco dei dischi
Dim vDriI As DriveInfo() = DriveInfo.GetDrives()
Dim DriI As DriveInfo
For Each DriI In vDriI
m_OpenItemList.Add(New IconListBoxItem(DriI.Name, 1))
Next
Return True
End Function
Private Sub FileListBox_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles FileListBox.PreviewMouseUp
' Disabilito Ok
OkBtn.IsEnabled = False
' Recupero item selezionato
If FileListBox.SelectedItems.Count() = 0 Then
Return
End If
Dim vItems As IconListBoxItem = FileListBox.SelectedItems(0)
' A seconda del tipo
Select Case vItems.PictureID
Case 0 ' Vai nel direttorio padre
m_sCurrDir = IO.Path.GetDirectoryName(m_sCurrDir)
m_sCurrFile = ""
LoadCurrDir()
Case 1 ' Vai nella radice del disco
m_sCurrDir = vItems.Name
m_sCurrFile = ""
LoadCurrDir()
Case 2 ' Vai nel sottodirettorio
m_sCurrDir = IO.Path.Combine(m_sCurrDir, vItems.Name)
m_sCurrFile = ""
LoadCurrDir()
Case 3 ' File
m_sCurrFile = vItems.Name
OkBtn.IsEnabled = True
End Select
End Sub
Private Sub FileListBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles FileListBox.SelectionChanged
' Recupero item selezionato
If FileListBox.SelectedItems.Count() = 0 Then
Return
End If
Dim vItems As IconListBoxItem = FileListBox.SelectedItems(0)
' Gestisco solo aggiornamento visualizzazione file
If vItems.PictureID = 3 Then
m_sCurrFile = vItems.Name
OkBtn.IsEnabled = True
Else
m_sCurrFile = ""
OkBtn.IsEnabled = False
End If
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
DialogResult = True
End Sub
Friend Function GetFilePath() As String
If Not String.IsNullOrWhiteSpace(m_sCurrFile) Then
Return m_sCurrDir & "\" & m_sCurrFile
Else
Return ""
End If
End Function
Friend Function GetFileDir() As String
If Not String.IsNullOrWhiteSpace(m_sCurrFile) Then
Return m_sCurrDir
Else
Return ""
End If
End Function
End Class
+2
View File
@@ -29,6 +29,8 @@
<Button Name="SaveNameBtn" Grid.Column="3"
Style="{StaticResource OmagCut_YellowGradientYellowTextButton}"/>
<Button Name="CSVBtn" Grid.Column="4"
Style="{StaticResource OmagCut_YellowTextButton}"/>
<Button Name="ResetCutBtn" Grid.Column="5"
Style="{StaticResource OmagCut_YellowTextButton}"/>
+8
View File
@@ -17,6 +17,7 @@ Public Class ProjectMgrUC
LoadBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 4)
SaveBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 5)
SaveNameBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 6)
CSVBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 8)
ResetCutBtn.Content = EgtMsg(MSG_NESTPAGEUC + 6)
SimulateBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) 'Simulate - Simula
WorkBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 2) 'Work - Lavora
@@ -137,6 +138,13 @@ Public Class ProjectMgrUC
m_SaveNameWD.ShowDialog()
End Sub
Private Sub CSVBtn_Click(sender As Object, e As RoutedEventArgs) Handles CSVBtn.Click
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_NestPage)
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_CSVPage)
m_MainWindow.m_ActivePage = MainWindow.Pages.CSV
m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut
End Sub
Private Sub ResetCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCutBtn.Click
' Cancello eventuali messaggi
m_CurrProjPage.ClearMessage()