aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2021-11-18 11:27:19 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2021-11-18 11:27:19 +0200
commitb88f12398df6b1d3126369a4016eceecdfa4dbc8 (patch)
tree1b6ef829d9891c6083be02bf6de5ac8980e4c9c5 /Software/Visual_Studio/MachineStudio
parent854f883509443230cc0360ea45c7d8085dd52882 (diff)
downloadTango-b88f12398df6b1d3126369a4016eceecdfa4dbc8.tar.gz
Tango-b88f12398df6b1d3126369a4016eceecdfa4dbc8.zip
5818 RML EXTANSION- EXPORT EXCEL FILE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ThreadCharacteristicsExelModel.cs46
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Templates/ExportRMLTemplate.xlsxbin0 -> 21466 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs120
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml18
5 files changed, 180 insertions, 6 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ThreadCharacteristicsExelModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ThreadCharacteristicsExelModel.cs
new file mode 100644
index 000000000..dc205b7f5
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ThreadCharacteristicsExelModel.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.ThreadExtensions.Models
+{
+ public class ThreadCharacteristicsExelModel
+ {
+ public String ThreadName { get; set; }
+ public String Manufacturer { get; set; }
+ public String Brand { get; set; }
+ public String Country { get; set; }
+ public String EndUse { get; set; }
+ public String Applications { get; set; }
+ public String IndustrySector { get; set; }
+ public String Material { get; set; }
+ public String Type { get; set; }
+ public String SubFamily { get; set; }
+ public String Family { get; set; }
+ public String Group { get; set; }
+ public String Texturing { get; set; }
+ public String Geometry { get; set; }
+ public String Color { get; set; }
+ public String GlossLevel { get; set; }
+ public double LinearDensity { get; set; }
+ public String Unit { get; set; }
+ public int Plies { get; set; }
+ public int FilamentCountPerPlie { get; set; }
+ public int LinearDensityCount { get; set; }
+ public int CountDen { get; set; }
+ public String FiberCount  { get; set; }
+ public int Twist { get; set; }
+ public String TwistDirection { get; set; }
+
+ //public Color R_Color { get; set; }
+ //public String R_Name { get; set; }
+ //public String R_Media { get; set; }
+ //public double R_Cyan { get; set; }
+ //public double R_Magenta { get; set; }
+ //public double R_Yellow { get; set; }
+ //public double R_Black { get; set; }
+ //public int R_Region { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj
index fdcef6361..dde2df976 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj
@@ -100,6 +100,7 @@
<Compile Include="Models\MachineModel.cs" />
<Compile Include="Models\PlotProperties.cs" />
<Compile Include="Models\RmlExtensionModel.cs" />
+ <Compile Include="Models\ThreadCharacteristicsExelModel.cs" />
<Compile Include="ViewModelLocator.cs" />
<Compile Include="ViewModels\AddItemDialogVM.cs" />
<Compile Include="ViewModels\ColorParametersVewVM.cs" />
@@ -199,6 +200,7 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
+ <EmbeddedResource Include="Templates\ExportRMLTemplate.xlsx" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\threads.png" />
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Templates/ExportRMLTemplate.xlsx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Templates/ExportRMLTemplate.xlsx
new file mode 100644
index 000000000..7cd21386f
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Templates/ExportRMLTemplate.xlsx
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs
index 12ae1aa89..954500b60 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs
@@ -28,6 +28,8 @@ using Tango.MachineStudio.ThreadExtensions.Views;
using Tango.MachineStudio.ThreadExtensions.Models;
using Tango.Settings;
using System.Reflection;
+using Tango.Core.Helpers;
+using Tango.Documents;
namespace Tango.MachineStudio.ThreadExtensions.ViewModels
{
@@ -312,6 +314,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels
#region commands
public RelayCommand SaveCommand { get; set; }
+ public RelayCommand ExportToFileCommand { get; set; }
public RelayCommand ManageRmlExtensionCommand { get; set; }
@@ -790,6 +793,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels
BackToThreadExtensionViewsCommand = new RelayCommand(BackToThreadExtensionViews, () => IsFree);
SaveCommand = new RelayCommand(Save, () => IsFree);
+ ExportToFileCommand = new RelayCommand(ExportRMLToExcel, () => IsFree);
ManageRmlExtensionCommand = new RelayCommand(() => LoadActiveRMLExtension(SelectedRMLExtension.Guid), () => SelectedRMLExtension != null);
@@ -1201,5 +1205,121 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels
}
#endregion
+
+ #region Export / Import Excel
+
+ public void ExportRMLToExcel()
+ {
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Filter = "Excel Documents|*.xlsx";
+ if (dlg.ShowDialog().Value)
+ {
+ using (_notification.PushTaskItem("Exporting RML to file..."))
+ {
+ Task.Factory.StartNew(() =>
+ {
+ try
+ {
+ IsFree = false;
+
+ Stream stream = null;
+ bool dispose = false;
+ String file = AssemblyHelper.GetCurrentAssemblyFolder() + "\\Templates\\ExportRMLTemplate.xlsx";
+
+ if (File.Exists(file))
+ {
+ stream = File.OpenRead(file);
+ dispose = true;
+ }
+ else
+ {
+ stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.ThreadExtensions.Templates.ExportRMLTemplate.xlsx");
+ }
+
+ byte[] data = new byte[stream.Length];
+ stream.Read(data, 0, data.Length);
+ File.WriteAllBytes(dlg.FileName, data);
+
+ if (dispose)
+ {
+ stream.Dispose();
+ }
+
+ ExcelWriter writer = new ExcelWriter(dlg.FileName);
+ //ActiveRMLExtension = await new RmlExtensionsBuilder(_active_context)
+ // .Set(guid)
+ // .WithUser()
+ // .BuildAsync();
+
+ //ActiveRML = new RmlBuilder(_active_context)
+ // .Set(SelectedRMLExtension.RMLGuid)
+ // .Build();
+
+ List<ThreadCharacteristicsExelModel> threadCharacteristicsExelModels = new List<ThreadCharacteristicsExelModel>();
+ ThreadCharacteristicsExelModel model = new ThreadCharacteristicsExelModel();
+ model.ThreadName = ActiveRML.Name;
+ model.Manufacturer = ActiveRML.Manufacturer == null? "": ActiveRML.Manufacturer;
+ model.Brand = ActiveRMLExtension.YarnBrand == null ? "": ActiveRMLExtension.YarnBrand.Name;
+ model.Country = ActiveRMLExtension.Country == null? "" : ActiveRMLExtension.Country;
+ model.EndUse = ActiveRML.MediaPurpose == null ? "" : ActiveRML.MediaPurpose.Name;
+ model.Applications = ActiveRMLExtension.YarnApplication == null ? "" : ActiveRMLExtension.YarnApplication.Name;
+ model.IndustrySector = ActiveRMLExtension.YarnIndustrysector == null ? "" : ActiveRMLExtension.YarnIndustrysector.Name;
+ model.Material = ActiveRML.MediaMaterial == null ? "" : ActiveRML.MediaMaterial.Name;
+ model.Type = ActiveRMLExtension.YarnType == null ? "" : ActiveRMLExtension.YarnType.Name;
+ model.SubFamily = ActiveRMLExtension.YarnSubFamily == null ? "" : ActiveRMLExtension.YarnSubFamily.Name;
+ model.Family = ActiveRMLExtension.YarnFamily == null ? "" : ActiveRMLExtension.YarnFamily.Name;
+ model.Group = ActiveRMLExtension.YarnGroup == null ? "" : ActiveRMLExtension.YarnGroup.Name;
+ model.Texturing = ActiveRMLExtension.YarnTexturing == null ? "" : ActiveRMLExtension.YarnTexturing.Name;
+ model.Geometry = ActiveRML.FiberShape == null ? "" : ActiveRML.FiberShape.Name;
+ model.Color = ActiveRMLExtension.YarnWhiteShade == null ? "" : ActiveRMLExtension.YarnWhiteShade.Name;
+ model.GlossLevel = ActiveRMLExtension.YarnGlossLevel == null ? "" : ActiveRMLExtension.YarnGlossLevel.Name;
+ model.LinearDensity = ActiveRML.FiberSize;
+ model.Unit = ActiveRML.LinearMassDensityUnit == null ? "" : ActiveRML.LinearMassDensityUnit.Name;
+ model.Plies = (int) ActiveRML.RMLPlies;
+ model.FilamentCountPerPlie = ActiveRML.PliesPerFiber;
+ model.LinearDensityCount = ActiveRML.DencityCount;
+ model.CountDen = ActiveRML.DencityCount;
+ model.FiberCount = ActiveRML.FiberCount;
+ model.Twist = ActiveRMLExtension.TwistTpm;
+ model.TwistDirection = ActiveRMLExtension.YarnTwistDirections.ToDescription();
+ threadCharacteristicsExelModels.Add(model);
+ writer.WriteData(threadCharacteristicsExelModels, "Thread characteristics");
+ //List<ColorGroup> groups = ActiveCatalog.ColorCatalogsGroups.Select(x => new ColorGroup()
+ //{
+ // GroupColor = x.Color,
+ // GroupName = x.Name,
+ // GroupIndex = x.GroupIndex,
+ //}).ToList();
+
+ //writer.WriteData(groups, "Groups");
+
+ //ActiveRMLExtension.
+
+ writer.Dispose();
+
+ InvokeUI(() =>
+ {
+ _notification.ShowInfo("RML extensions exported successfully.");
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, $"Error exporting RML extensions to {dlg.FileName}");
+
+ InvokeUI(() =>
+ {
+ _notification.ShowError($"An error occurred while trying to export the RML extensions. Make sure the selected excel file is closed and data is valid.\n{ex.FlattenMessage()}");
+ });
+ }
+ finally
+ {
+ IsFree = true;
+ }
+ });
+ }
+ }
+ }
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml
index aeedcb6df..05ad00b72 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml
@@ -225,12 +225,18 @@
</Grid>
</UniformGrid>
- <Button Grid.Row="1" HorizontalAlignment="Right" Width="170" Height="45" Margin="0 0 20 0" VerticalAlignment="Center" Command="{Binding SaveCommand}">
- <StackPanel Orientation="Horizontal">
- <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" />
- <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock>
- </StackPanel>
- </Button>
+ <DockPanel Grid.Row="1">
+
+
+ <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Width="170" Height="45" Margin="0 0 20 0" VerticalAlignment="Center" Command="{Binding SaveCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" />
+ <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock>
+ </StackPanel>
+ </Button>
+ <Button DockPanel.Dock="Left" Width="170" Height="45" HorizontalAlignment="Left" Margin="20" Command="{Binding ExportToFileCommand}" >Export to File</Button>
+
+ </DockPanel>
</Grid>
</materialDesign:Card>
</Grid>