Progress window was edded
This commit is contained in:
@@ -6,18 +6,24 @@
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:InterpolationProgressViewModel}"
|
||||
Title="InterpolationProgressView" Height="150" Width="200" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
|
||||
<Grid>
|
||||
Title="InterpolationProgressView" Height="150" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="IterationCount"/>
|
||||
<ProgressBar Grid.Column="1" Grid.Row="0" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" Value="{Binding Value}"/>
|
||||
<TextBlock Text="Progress"/>
|
||||
<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>
|
||||
</Window>
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
||||
{
|
||||
InitializeComponent();
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
@@ -6,10 +7,36 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
||||
{
|
||||
public class InterpolationProgressViewModel
|
||||
public class InterpolationProgressViewModel : ViewModelBase
|
||||
{
|
||||
public double MinValue { get; set; }
|
||||
public double MaxValue { get; set; }
|
||||
public double Value { get; set; }
|
||||
private double progressValue;
|
||||
private double maxValue;
|
||||
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,42 +1,111 @@
|
||||
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.ViewModels.Forces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
{
|
||||
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;
|
||||
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null);
|
||||
this.forceCalculator = forceCalculator;
|
||||
var viewModel = new InterpolateTuplesViewModel(finishTuple, null);
|
||||
var wndTuples = new InterpolateTuplesView(viewModel);
|
||||
wndTuples.ShowDialog();
|
||||
if (wndTuples.DialogResult != true) return;
|
||||
|
||||
startDesignTuple = viewModel.StartDesignForce;
|
||||
finishDesignTuple = viewModel.FinishDesignForce;
|
||||
int stepCount = viewModel.StepCount;
|
||||
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
|
||||
calculator.Run();
|
||||
var result = calculator.Result;
|
||||
if (result is null || result.IsValid == false)
|
||||
stepCount = viewModel.StepCount;
|
||||
progressViewModel = new()
|
||||
{
|
||||
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
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();
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
var vm = new ForcesResultsViewModel(calculator);
|
||||
var wnd = new ForceResultsView(vm);
|
||||
wnd.ShowDialog();
|
||||
wndProgress.Close();
|
||||
|
||||
if (result is null || result.IsValid == false)
|
||||
{
|
||||
System.Windows.Forms.MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
var vm = new ForcesResultsViewModel(interpolateCalculator);
|
||||
var wnd = new ForceResultsView(vm);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public ICompressedMember CompressedMember { get; }
|
||||
public IAccuracy Accuracy { get; 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()
|
||||
{
|
||||
@@ -97,6 +97,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
result.DesignForceTuple.CalcTerm = calcTerm;
|
||||
result.DesignForceTuple.ForceTuple = newTuple;
|
||||
ndmResult.ForcesResultList.Add(result);
|
||||
ActionToOutputResults?.Invoke(ndmResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,10 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
||||
}
|
||||
return calculator;
|
||||
}
|
||||
|
||||
public static IForceCalculator InterpolateForceCalculator(IForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user