Browse Source

Little edits

master
Nikita Romanenko 6 years ago
parent
commit
2ba797c4ed
  1. 4
      Pores/Controllers/ConnectedPoreReportGenerator.cs
  2. 2
      Pores/Controllers/ReportGenerator.cs
  3. 15
      Pores/Converters/CubicPowerOfInt.cs
  4. 21
      Pores/MainWindow.xaml
  5. 15
      Pores/MainWindowViewModel.cs
  6. 1
      Pores/Pores.csproj

4
Pores/Controllers/ConnectedPoreReportGenerator.cs

@ -25,7 +25,9 @@ namespace Pores.Controllers
if (!report.Any(a => a.Item1.Id == p2.Id && a.Item2.Id == p1.Id)) if (!report.Any(a => a.Item1.Id == p2.Id && a.Item2.Id == p1.Id))
if (IsTwoPoresConnecting(p1, p2)) if (IsTwoPoresConnecting(p1, p2))
report.Add(Tuple.Create(p1, p2)); report.Add(Tuple.Create(p1, p2));
ReportGenerator.Save(report, ReportGenerator.AddOther("report_connected_pores_" + index));
var s = string.Format("report_connected_pores_{0}_n{1}", index, report.Count);
ReportGenerator.Save(report, ReportGenerator.AddTime(s));
} }
public double DistanceBetweenTwoPoints(Point3D point1, Point3D point2) public double DistanceBetweenTwoPoints(Point3D point1, Point3D point2)

2
Pores/Controllers/ReportGenerator.cs

@ -12,7 +12,7 @@ namespace Pores.Controllers
{ {
public class ReportGenerator : BaseSaveLoadController public class ReportGenerator : BaseSaveLoadController
{ {
public string AddOther(string fileName) public string AddTime(string fileName)
{ {
return return
".\\results\\" ".\\results\\"

15
Pores/Converters/CubicPowerOfInt.cs

@ -0,0 +1,15 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace Pores.Converters
{
public class CubicPowerOfInt : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> Math.Pow((int)value, 3).ToString();
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
}

21
Pores/MainWindow.xaml

@ -4,11 +4,15 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:spreads="clr-namespace:Pores.Models.Spreads" xmlns:spreads="clr-namespace:Pores.Models.Spreads"
xmlns:converters="clr-namespace:Pores.Converters"
mc:Ignorable="d" mc:Ignorable="d"
Title="Pores" Height="600" Width="1000"> Title="Pores" Height="600" Width="1000">
<Window.Resources>
<converters:CubicPowerOfInt x:Key="CubicPowerOfInt"/>
</Window.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/> <ColumnDefinition Width="0"/>
<ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/> <ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -34,8 +38,15 @@
<TextBox Text="{Binding CurrentMaterial.Depth}"/> <TextBox Text="{Binding CurrentMaterial.Depth}"/>
<TextBlock Text="Высота: "/> <TextBlock Text="Высота: "/>
<TextBox Text="{Binding CurrentMaterial.Height}"/> <TextBox Text="{Binding CurrentMaterial.Height}"/>
<TextBlock Text="Разрешение модели (n^3): " TextWrapping="Wrap"/> <ContentControl>
<TextBox Text="{Binding CurrentMaterial.NumberOfPores}"/> <StackPanel Orientation="Horizontal">
<TextBlock Text="Разрешение модели (n="/>
<TextBlock Text="{Binding CurrentMaterial.NumberOfPores,
Converter={StaticResource CubicPowerOfInt}, Mode=OneWay}"/>
<TextBlock Text="):"/>
</StackPanel>
</ContentControl>
<TextBox Text="{Binding CurrentMaterial.NumberOfPores, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="Параметры модели распределения:"/> <TextBlock Text="Параметры модели распределения:"/>
<ComboBox ItemsSource="{Binding Spreads}" SelectedItem="{Binding SelectedSpread}" HorizontalAlignment="Left" Width="198"></ComboBox> <ComboBox ItemsSource="{Binding Spreads}" SelectedItem="{Binding SelectedSpread}" HorizontalAlignment="Left" Width="198"></ComboBox>
<ContentControl Content="{Binding SelectedSpread}"> <ContentControl Content="{Binding SelectedSpread}">
@ -89,9 +100,9 @@
<TextBox Text="{Binding BatchPoint.Center.X}"/> <TextBox Text="{Binding BatchPoint.Center.X}"/>
<TextBlock Text="Координаты центра (Y): "/> <TextBlock Text="Координаты центра (Y): "/>
<TextBox Text="{Binding BatchPoint.Center.Y}"/> <TextBox Text="{Binding BatchPoint.Center.Y}"/>
<TextBlock Text="Координаты центра (Z): "/> <TextBlock Text="Координаты центра (Z-высота): "/>
<TextBox Text="{Binding BatchPoint.Center.Z}"/> <TextBox Text="{Binding BatchPoint.Center.Z}"/>
<TextBlock Text="Ширина: "/> <TextBlock Text="Длина и ширина основания: "/>
<TextBox Text="{Binding BatchPoint.Width}"/> <TextBox Text="{Binding BatchPoint.Width}"/>
<TextBlock Text="Глубина:"/> <TextBlock Text="Глубина:"/>
<TextBox Text="{Binding BatchPoint.Depth}"/> <TextBox Text="{Binding BatchPoint.Depth}"/>

15
Pores/MainWindowViewModel.cs

@ -8,6 +8,8 @@ using System.Threading;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows;
using System.Linq;
namespace Pores namespace Pores
{ {
@ -83,7 +85,7 @@ namespace Pores
public void Save() public void Save()
=> Save(Pores); => Save(Pores);
public void Save(IList<Pore> pores, int i = 0) public void Save(IList<Pore> pores, int i = -1)
{ {
var n = string.Format( var n = string.Format(
"model_{0}_w{1}_d{2}_h{3}_n{4}", "model_{0}_w{1}_d{2}_h{3}_n{4}",
@ -93,7 +95,8 @@ namespace Pores
CurrentMaterial.Height, CurrentMaterial.Height,
pores.Count); pores.Count);
ReportSaver.Save(pores, ReportSaver.AddOther(n)); ReportSaver.Save(pores, ReportSaver.AddTime(n));
if (i == -1) OperationCompletedMessage();
} }
public void SaveBatch() public void SaveBatch()
@ -102,8 +105,8 @@ namespace Pores
public IEnumerable<Pore> SaveBatch(IEnumerable<Pore> pores, int i = -1) public IEnumerable<Pore> SaveBatch(IEnumerable<Pore> pores, int i = -1)
{ {
var batch = BatchGenerator.GenerateBatch(BatchPoint, pores); var batch = BatchGenerator.GenerateBatch(BatchPoint, pores);
if (i != -1) var s = string.Format("batch_{0}_n{1}", i, batch.ToList().Count);
ReportSaver.Save(batch, ReportSaver.AddOther(string.Format("batch_{0}", i))); ReportSaver.Save(batch, ReportSaver.AddTime(s));
return batch; return batch;
} }
@ -121,8 +124,12 @@ namespace Pores
ConnectedPoreReportGenerator.CreateReport(list2, i); ConnectedPoreReportGenerator.CreateReport(list2, i);
} }
DisableGenerateAllFlag = false; DisableGenerateAllFlag = false;
OperationCompletedMessage();
}); });
AllSavingThread.Start(); AllSavingThread.Start();
} }
private void OperationCompletedMessage()
=> MessageBox.Show("Операция завершена!", "Сообщение");
} }
} }

1
Pores/Pores.csproj

@ -85,6 +85,7 @@
<Compile Include="Controllers\ConnectedPoreReportGenerator.cs" /> <Compile Include="Controllers\ConnectedPoreReportGenerator.cs" />
<Compile Include="Controllers\ReportGenerator.cs" /> <Compile Include="Controllers\ReportGenerator.cs" />
<Compile Include="Controllers\PoreGenerator.cs" /> <Compile Include="Controllers\PoreGenerator.cs" />
<Compile Include="Converters\CubicPowerOfInt.cs" />
<Compile Include="Helpers\PropertyChanged.cs" /> <Compile Include="Helpers\PropertyChanged.cs" />
<Compile Include="Helpers\RelayCommand.cs" /> <Compile Include="Helpers\RelayCommand.cs" />
<Compile Include="Interfaces\IPoreGenerator.cs" /> <Compile Include="Interfaces\IPoreGenerator.cs" />

Loading…
Cancel
Save