diff --git a/Infrastructure/UI/Resources/ItemEditPanels.xaml b/Infrastructure/UI/Resources/ItemEditPanels.xaml
index b5745f6..4cc12ba 100644
--- a/Infrastructure/UI/Resources/ItemEditPanels.xaml
+++ b/Infrastructure/UI/Resources/ItemEditPanels.xaml
@@ -15,8 +15,8 @@
-
+
-
\ No newline at end of file
diff --git a/Libraries/LoaderCalculator.dll b/Libraries/LoaderCalculator.dll
index e96c3f0..f87555f 100644
Binary files a/Libraries/LoaderCalculator.dll and b/Libraries/LoaderCalculator.dll differ
diff --git a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs b/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
index db8746f..8fb5f97 100644
--- a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
+++ b/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
@@ -16,5 +16,7 @@ namespace StructureHelperCommon.Infrastructures.Strings
public static string LimitStatesIsNotValid => "#0005: Type of limite state is not valid";
public static string LoadTermIsNotValid => "#0006: Load term is not valid";
public static string IncorrectValue => "#0007: value is not valid";
+ public static string FileCantBeDeleted => "#0008: File can't be deleted";
+ public static string FileCantBeSaved => "#0009: File can't be saved";
}
}
diff --git a/StructureHelperCommon/Models/Forces/ForceCombinationList.cs b/StructureHelperCommon/Models/Forces/ForceCombinationList.cs
index 75c70ae..c6cd760 100644
--- a/StructureHelperCommon/Models/Forces/ForceCombinationList.cs
+++ b/StructureHelperCommon/Models/Forces/ForceCombinationList.cs
@@ -27,5 +27,21 @@ namespace StructureHelperCommon.Models.Forces
DesignForces.Add(new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm));
DesignForces.Add(new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm));
}
+
+ public object Clone()
+ {
+ var newItem = new ForceCombinationList();
+ newItem.Name = Name + " copy";
+ newItem.SetInGravityCenter = SetInGravityCenter;
+ newItem.ForcePoint.X = ForcePoint.X;
+ newItem.ForcePoint.Y = ForcePoint.Y;
+ newItem.DesignForces.Clear();
+ foreach (var item in DesignForces)
+ {
+ var newForce = item.Clone() as IDesignForceTuple;
+ newItem.DesignForces.Add(newForce);
+ }
+ return newItem;
+ }
}
}
diff --git a/StructureHelperCommon/Models/Forces/IForceCombinationList.cs b/StructureHelperCommon/Models/Forces/IForceCombinationList.cs
index fd4d056..8a89573 100644
--- a/StructureHelperCommon/Models/Forces/IForceCombinationList.cs
+++ b/StructureHelperCommon/Models/Forces/IForceCombinationList.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
- public interface IForceCombinationList
+ public interface IForceCombinationList : ICloneable
{
string Name { get; set; }
bool SetInGravityCenter { get; set; }
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
index a8aaa7f..83095e9 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs
@@ -132,6 +132,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public object Clone()
{
IForceCalculator calculator = new ForceCalculator();
+ calculator.Name = Name + " copy";
calculator.LimitStatesList.Clear();
calculator.LimitStatesList.AddRange(LimitStatesList);
calculator.CalcTermsList.Clear();
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs
index b627f0a..a7555f3 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs
@@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
- public interface IForceCalculator : INdmCalculator, IHasPrimitives, IHasForceCombinations, ICloneable
+ public interface IForceCalculator : INdmCalculator, IHasPrimitives, IHasForceCombinations
{
List CalcTermsList { get; }
double IterationAccuracy { get; set; }
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ExportToCSVLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ExportToCSVLogic.cs
new file mode 100644
index 0000000..8138b93
--- /dev/null
+++ b/StructureHelperLogics/NdmCalculations/Analyses/ExportToCSVLogic.cs
@@ -0,0 +1,75 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelperLogics.NdmCalculations.Analyses
+{
+ public class ExportToCSVLogic : IExportResultLogic
+ {
+ string filename;
+
+ public void Export(INdmResult ndmResult)
+ {
+ string separator = ";";
+ StringBuilder output = new StringBuilder();
+
+ if (ndmResult is ForcesResults)
+ {
+ var forceResults = ndmResult as ForcesResults;
+ string[] headings =
+ {
+ "Limit State",
+ "Calc duration",
+ "Mx",
+ "My",
+ "Nz",
+ "kx",
+ "ky",
+ "epsz"
+ };
+ output.AppendLine(string.Join(separator, headings));
+ foreach (var item in forceResults.ForcesResultList)
+ {
+ if (item.IsValid == true)
+ {
+ var tuple = item.DesignForceTuple.ForceTuple;
+ var strainMatrix = item.LoaderResults.StrainMatrix;
+ string[] newLine =
+ {
+ item.DesignForceTuple.LimitState.ToString(),
+ item.DesignForceTuple.CalcTerm.ToString(),
+ tuple.Mx.ToString(),
+ tuple.My.ToString(),
+ tuple.Nz.ToString(),
+ strainMatrix.Kx.ToString(),
+ strainMatrix.Ky.ToString(),
+ strainMatrix.EpsZ.ToString()
+ };
+ output.AppendLine(string.Join(separator, newLine));
+ }
+ }
+ try
+ {
+ File.AppendAllText(filename, output.ToString());
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Data could not be written to the CSV file.");
+ return;
+ }
+ }
+ else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown +": "+ nameof(ndmResult));
+ }
+
+ public ExportToCSVLogic(string filename)
+ {
+ this.filename = filename;
+ }
+ }
+}
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/IExportResultLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/IExportResultLogic.cs
index 6599e39..a3d927a 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/IExportResultLogic.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/IExportResultLogic.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
- internal interface IExportResultLogic
+ public interface IExportResultLogic
{
void Export(INdmResult ndmResult);
}
diff --git a/StructureHelperLogics/NdmCalculations/Analyses/INdmCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/INdmCalculator.cs
index 641739b..dc431ab 100644
--- a/StructureHelperLogics/NdmCalculations/Analyses/INdmCalculator.cs
+++ b/StructureHelperLogics/NdmCalculations/Analyses/INdmCalculator.cs
@@ -9,7 +9,7 @@ using TaskManager;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
- public interface INdmCalculator
+ public interface INdmCalculator : ICloneable
{
string Name { get; set; }
///
diff --git a/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml b/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml
index 9f1f3b3..b84e77d 100644
--- a/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml
+++ b/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml
@@ -55,17 +55,14 @@
-
+ ItemTemplate="{StaticResource ColoredItemTemplate}"/>
-
-
-
+
diff --git a/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml b/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
index d840d9c..546c45c 100644
--- a/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
+++ b/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsView.xaml
@@ -7,11 +7,11 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators"
d:DataContext="{d:DesignInstance vm:ForcesResultsViewModel}"
mc:Ignorable="d"
- Title="ForceResultsView" Height="350" Width="650" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
+ Title="Calculation Results" Height="350" Width="850" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
-
+
diff --git a/Windows/MainWindow/MainView.xaml b/Windows/MainWindow/MainView.xaml
index 5915f71..e382fee 100644
--- a/Windows/MainWindow/MainView.xaml
+++ b/Windows/MainWindow/MainView.xaml
@@ -72,6 +72,7 @@
+
@@ -122,6 +123,7 @@
+
diff --git a/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs b/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
index f801e82..61042cc 100644
--- a/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
+++ b/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs
@@ -7,12 +7,16 @@ using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -59,12 +63,48 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
return exportToCSVCommand ??
(exportToCSVCommand = new RelayCommand(o =>
{
-
+ ExportToCSV();
}
));
}
}
+ private void ExportToCSV()
+ {
+ SaveFileDialog saveFileDialog = new SaveFileDialog();
+ saveFileDialog.Filter = "csv |*.csv";
+ saveFileDialog.Title = "Save an Image File";
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ var filename = saveFileDialog.FileName;
+ // If the file name is not an empty string open it for saving.
+ if (filename != "")
+ {
+ if (File.Exists(filename))
+ {
+ try
+ {
+ File.Delete(filename);
+ }
+ catch (Exception ex)
+ {
+ throw new StructureHelperException(ErrorStrings.FileCantBeDeleted + ex + filename);
+ }
+ }
+
+ try
+ {
+ var logic = new ExportToCSVLogic(saveFileDialog.FileName);
+ logic.Export(forcesResults);
+ }
+ catch (Exception ex)
+ {
+ throw new StructureHelperException(ErrorStrings.FileCantBeSaved + ex + filename);
+ }
+ }
+ }
+ }
+
public RelayCommand InterpolateCommand
{
get
@@ -91,7 +131,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
- wnd.Show();
+ wnd.ShowDialog();
}
}
diff --git a/Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs b/Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs
index 645275c..c453a47 100644
--- a/Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs
+++ b/Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs
@@ -50,8 +50,12 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
(
editCalculatorCommand = new RelayCommand(o =>
{
+ var tmpSelected = SelectedItem;
EditCalculator();
+ Items.Clear();
+ AddItems(repository.CalculatorsList);
OnPropertyChanged(nameof(Items));
+ SelectedItem = tmpSelected;
}, o => SelectedItem != null));
}
}
@@ -68,6 +72,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
private RelayCommand deleteCalculatorCommand;
private RelayCommand runCommand;
+ private RelayCommand copyCalculatorCommand;
+
public RelayCommand Delete
{
get
@@ -100,13 +106,27 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
var calculator = SelectedItem as IForceCalculator;
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
- wnd.Show();
+ wnd.ShowDialog();
}
}, o => SelectedItem != null));
}
}
- public RelayCommand Copy => throw new NotImplementedException();
+ public RelayCommand Copy
+ {
+ get
+ {
+ return copyCalculatorCommand ??
+ (
+ copyCalculatorCommand = new RelayCommand(o =>
+ {
+ var item = SelectedItem.Clone() as INdmCalculator;
+ repository.CalculatorsList.Add(item);
+ Items.Add(item);
+ OnPropertyChanged(nameof(Items));
+ }, o => SelectedItem != null));
+ }
+ }
private void DeleteCalculator()
{
diff --git a/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs b/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs
index c104eb4..31af3a2 100644
--- a/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs
+++ b/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs
@@ -3,6 +3,7 @@ using StructureHelper.Windows.Forces;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.CrossSections;
+using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -65,6 +66,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
}
}
private RelayCommand editForceCombinationCommand;
+ private RelayCommand copyCommand;
+
public RelayCommand Edit
{
get
@@ -74,12 +77,28 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
editForceCombinationCommand = new RelayCommand(o =>
{
EditForceCombination();
+ Items.Clear();
+ AddItems(repository.ForceCombinationLists);
OnPropertyChanged(nameof(Items));
}, o => SelectedItem != null));
}
}
- public RelayCommand Copy => throw new NotImplementedException();
+ public RelayCommand Copy
+ {
+ get
+ {
+ return copyCommand ??
+ (
+ copyCommand = new RelayCommand(o =>
+ {
+ var item = SelectedItem.Clone() as IForceCombinationList;
+ repository.ForceCombinationLists.Add(item);
+ Items.Add(item);
+ OnPropertyChanged(nameof(Items));
+ }, o => SelectedItem != null));
+ }
+ }
private void EditForceCombination()
{