Progress window was edded
This commit is contained in:
@@ -6,18 +6,24 @@
|
|||||||
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
|
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance local:InterpolationProgressViewModel}"
|
d:DataContext="{d:DesignInstance local:InterpolationProgressViewModel}"
|
||||||
Title="InterpolationProgressView" Height="150" Width="200" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
|
Title="InterpolationProgressView" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None">
|
||||||
<Grid>
|
<Grid Margin="10">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
<RowDefinition Height="25"/>
|
<RowDefinition Height="25"/>
|
||||||
<RowDefinition Height="25"/>
|
<RowDefinition Height="25"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Text="IterationCount"/>
|
<TextBlock Text="Progress"/>
|
||||||
<ProgressBar Grid.Column="1" Grid.Row="0" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding Value}"/>
|
<ProgressBar Grid.Column="1" Grid.Row="0" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding ProgressValue}"/>
|
||||||
|
<TextBlock Grid.Row="1" Text="Total step"/>
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding MaxValue}" IsEnabled="False"/>
|
||||||
|
<TextBlock Grid.Row="2" Text="Current step"/>
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ProgressValue}" IsEnabled="False"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.viewModel = viewModel;
|
this.viewModel = viewModel;
|
||||||
this.DataContext = this.viewModel;
|
DataContext = this.viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using StructureHelper.Infrastructure;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -6,10 +7,36 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
||||||
{
|
{
|
||||||
public class InterpolationProgressViewModel
|
public class InterpolationProgressViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public double MinValue { get; set; }
|
private double progressValue;
|
||||||
public double MaxValue { get; set; }
|
private double maxValue;
|
||||||
public double Value { get; set; }
|
private double minValue;
|
||||||
|
|
||||||
|
public double MinValue
|
||||||
|
{
|
||||||
|
get => minValue; set
|
||||||
|
{
|
||||||
|
minValue = value;
|
||||||
|
OnPropertyChanged(nameof(MinValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double MaxValue
|
||||||
|
{
|
||||||
|
get => maxValue; set
|
||||||
|
{
|
||||||
|
maxValue = value;
|
||||||
|
OnPropertyChanged(nameof(MaxValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public double ProgressValue
|
||||||
|
{
|
||||||
|
get => progressValue;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
progressValue = value;
|
||||||
|
OnPropertyChanged(nameof(ProgressValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,112 @@
|
|||||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
using LoaderCalculator;
|
||||||
|
using LoaderCalculator.Data.ResultData;
|
||||||
|
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||||
|
using StructureHelper.Windows.CalculationWindows.ProgressViews;
|
||||||
using StructureHelper.Windows.Forces;
|
using StructureHelper.Windows.Forces;
|
||||||
using StructureHelper.Windows.ViewModels.Forces;
|
using StructureHelper.Windows.ViewModels.Forces;
|
||||||
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||||
using StructureHelperLogics.Services.NdmCalculations;
|
using StructureHelperLogics.Services.NdmCalculations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||||
{
|
{
|
||||||
internal class InterpolateLogic
|
internal class InterpolateLogic
|
||||||
{
|
{
|
||||||
public void Show(IDesignForceTuple finishDesignTuple, IForceCalculator forceCalculator)
|
private InterpolationProgressViewModel progressViewModel;
|
||||||
|
private InterpolationProgressView wndProgress;
|
||||||
|
private IForceCalculator forceCalculator;
|
||||||
|
private IDesignForceTuple finishDesignTuple;
|
||||||
|
private IDesignForceTuple startDesignTuple;
|
||||||
|
private int stepCount;
|
||||||
|
private IResult result;
|
||||||
|
private IForceCalculator interpolateCalculator;
|
||||||
|
|
||||||
|
public void Show(IDesignForceTuple finishTuple, IForceCalculator forceCalculator)
|
||||||
{
|
{
|
||||||
IDesignForceTuple startDesignTuple;
|
this.forceCalculator = forceCalculator;
|
||||||
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null);
|
var viewModel = new InterpolateTuplesViewModel(finishTuple, null);
|
||||||
var wndTuples = new InterpolateTuplesView(viewModel);
|
var wndTuples = new InterpolateTuplesView(viewModel);
|
||||||
wndTuples.ShowDialog();
|
wndTuples.ShowDialog();
|
||||||
if (wndTuples.DialogResult != true) return;
|
if (wndTuples.DialogResult != true) return;
|
||||||
|
|
||||||
startDesignTuple = viewModel.StartDesignForce;
|
startDesignTuple = viewModel.StartDesignForce;
|
||||||
finishDesignTuple = viewModel.FinishDesignForce;
|
finishDesignTuple = viewModel.FinishDesignForce;
|
||||||
int stepCount = viewModel.StepCount;
|
stepCount = viewModel.StepCount;
|
||||||
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
|
progressViewModel = new()
|
||||||
calculator.Run();
|
{
|
||||||
var result = calculator.Result;
|
MinValue = 0,
|
||||||
|
MaxValue = stepCount,
|
||||||
|
ProgressValue = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
wndProgress =new InterpolationProgressView(progressViewModel);
|
||||||
|
wndProgress.Loaded += RunCalc;
|
||||||
|
wndProgress.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunCalc(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
BackgroundWorker worker = new();
|
||||||
|
worker.DoWork += WorkerDoWork;
|
||||||
|
worker.ProgressChanged += WorkerProgressChanged;
|
||||||
|
worker.RunWorkerCompleted += WorkerRunWorkCompleted;
|
||||||
|
worker.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowProgressResult(IResult result)
|
||||||
|
{
|
||||||
|
if (result is ForcesResults)
|
||||||
|
{
|
||||||
|
var forceResult = result as ForcesResults;
|
||||||
|
progressViewModel.ProgressValue = forceResult.ForcesResultList.Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WorkerDoWork(object sender, DoWorkEventArgs e)
|
||||||
|
{
|
||||||
|
interpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
|
||||||
|
interpolateCalculator.ActionToOutputResults = ShowProgressResult;
|
||||||
|
interpolateCalculator.Run();
|
||||||
|
result = interpolateCalculator.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WorkerRunWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wndProgress.Close();
|
||||||
|
|
||||||
if (result is null || result.IsValid == false)
|
if (result is null || result.IsValid == false)
|
||||||
{
|
{
|
||||||
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
System.Windows.Forms.MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var vm = new ForcesResultsViewModel(calculator);
|
var vm = new ForcesResultsViewModel(interpolateCalculator);
|
||||||
var wnd = new ForceResultsView(vm);
|
var wnd = new ForceResultsView(vm);
|
||||||
wnd.ShowDialog();
|
wnd.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
public ICompressedMember CompressedMember { get; }
|
public ICompressedMember CompressedMember { get; }
|
||||||
public IAccuracy Accuracy { get; set; }
|
public IAccuracy Accuracy { get; set; }
|
||||||
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
||||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
public Action<IResult> ActionToOutputResults { get; set; }
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
@@ -97,6 +97,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
|||||||
result.DesignForceTuple.CalcTerm = calcTerm;
|
result.DesignForceTuple.CalcTerm = calcTerm;
|
||||||
result.DesignForceTuple.ForceTuple = newTuple;
|
result.DesignForceTuple.ForceTuple = newTuple;
|
||||||
ndmResult.ForcesResultList.Add(result);
|
ndmResult.ForcesResultList.Add(result);
|
||||||
|
ActionToOutputResults?.Invoke(ndmResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,10 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
|||||||
}
|
}
|
||||||
return calculator;
|
return calculator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IForceCalculator InterpolateForceCalculator(IForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user