Interpolation View for calculation result was added
This commit is contained in:
126
Windows/ViewModels/CRUDViewModelBase.cs
Normal file
126
Windows/ViewModels/CRUDViewModelBase.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public abstract class CRUDViewModelBase<TItem> : ViewModelBase, ICRUDViewModel<TItem> where TItem : class
|
||||
{
|
||||
|
||||
private RelayCommand addCommand;
|
||||
private RelayCommand deleteCommand;
|
||||
private RelayCommand copyCommand;
|
||||
private RelayCommand editCommand;
|
||||
|
||||
public List<TItem> Collection { get; set; }
|
||||
|
||||
public TItem NewItem { get; set; }
|
||||
public TItem SelectedItem { get; set; }
|
||||
|
||||
public ObservableCollection<TItem> Items { get; private set; }
|
||||
|
||||
public RelayCommand Add
|
||||
{
|
||||
get
|
||||
{
|
||||
return addCommand ??
|
||||
(
|
||||
addCommand = new RelayCommand(o =>
|
||||
{
|
||||
AddMethod(o);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
public virtual void AddMethod(object parameter)
|
||||
{
|
||||
Collection.Add(NewItem);
|
||||
Items.Add(NewItem);
|
||||
}
|
||||
public RelayCommand Delete
|
||||
{
|
||||
get
|
||||
{
|
||||
return deleteCommand ??
|
||||
(
|
||||
deleteCommand = new RelayCommand(o =>
|
||||
{
|
||||
DeleteMethod();
|
||||
}, o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
public virtual void DeleteMethod()
|
||||
{
|
||||
Collection.Remove(SelectedItem);
|
||||
Items.Remove(SelectedItem);
|
||||
}
|
||||
public RelayCommand Edit
|
||||
{
|
||||
get
|
||||
{
|
||||
return editCommand ??
|
||||
(editCommand = new RelayCommand(o=>
|
||||
{
|
||||
EditMethod(o);
|
||||
}, o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void EditMethod(object parameter)
|
||||
{
|
||||
Items.Clear();
|
||||
foreach (var item in Collection)
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}
|
||||
|
||||
public RelayCommand Copy
|
||||
{
|
||||
get
|
||||
{
|
||||
return copyCommand ??
|
||||
(copyCommand = new RelayCommand (o=>
|
||||
{
|
||||
CopyMethod();
|
||||
}, o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
public virtual void CopyMethod()
|
||||
{
|
||||
if (SelectedItem is ICloneable)
|
||||
{
|
||||
NewItem = (SelectedItem as ICloneable).Clone() as TItem;
|
||||
}
|
||||
Collection.Add(NewItem);
|
||||
Items.Add(NewItem);
|
||||
}
|
||||
public void AddItems(IEnumerable<TItem> items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
public CRUDViewModelBase()
|
||||
{
|
||||
Items = new ObservableCollection<TItem>();
|
||||
}
|
||||
|
||||
public CRUDViewModelBase(List<TItem> collection)
|
||||
{
|
||||
Collection = collection;
|
||||
Items = new ObservableCollection<TItem>(collection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,13 @@ using StructureHelper.Services.Reports;
|
||||
using StructureHelper.Services.Reports.CalculationReports;
|
||||
using StructureHelper.Services.ResultViewers;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelper.Windows.PrimitivePropertiesWindow;
|
||||
using StructureHelper.Windows.ViewModels.Forces;
|
||||
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -30,6 +35,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
private IForceCalculator forceCalculator;
|
||||
private IForcesResults forcesResults;
|
||||
private IEnumerable<INdmPrimitive> ndmPrimitives;
|
||||
private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
|
||||
private IEnumerable<INdm> ndms;
|
||||
private IReport isoFieldReport;
|
||||
|
||||
@@ -50,8 +56,15 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
return showIsoFieldCommand ??
|
||||
(showIsoFieldCommand = new RelayCommand(o =>
|
||||
{
|
||||
GetNdms();
|
||||
ShowIsoField();
|
||||
var vm = new SelectPrimitivesViewModel(ndmPrimitives);
|
||||
var wnd = new SelectPrimitivesView(vm);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
|
||||
GetNdms();
|
||||
ShowIsoField();
|
||||
}
|
||||
}, o => (SelectedResult != null) && SelectedResult.IsValid));
|
||||
}
|
||||
}
|
||||
@@ -73,7 +86,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "csv |*.csv";
|
||||
saveFileDialog.Title = "Save an Image File";
|
||||
saveFileDialog.Title = "Save an csv File";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var filename = saveFileDialog.FileName;
|
||||
@@ -119,8 +132,16 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
|
||||
private void Interpolate()
|
||||
{
|
||||
int stepCount = 100;
|
||||
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, SelectedResult.DesignForceTuple, stepCount);
|
||||
IDesignForceTuple startDesignTuple, finishDesignTuple;
|
||||
finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
|
||||
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null, 100);
|
||||
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)
|
||||
@@ -154,7 +175,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
{
|
||||
var limitState = SelectedResult.DesignForceTuple.LimitState;
|
||||
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
|
||||
ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
|
||||
ndms = NdmPrimitivesService.GetNdms(selectedNdmPrimitives, limitState, calcTerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
Windows/ViewModels/Forces/ActionsViewModel.cs
Normal file
60
Windows/ViewModels/Forces/ActionsViewModel.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ActionsViewModel : CRUDViewModelBase<IForceCombinationList>
|
||||
{
|
||||
ICrossSectionRepository repository;
|
||||
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
public override void DeleteMethod()
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
var calcRepository = repository.CalculatorsList;
|
||||
foreach (var item in calcRepository)
|
||||
{
|
||||
if (item is IForceCalculator)
|
||||
{
|
||||
var forceCalculator = item as IForceCalculator;
|
||||
var containSelected = forceCalculator.ForceCombinationLists.Contains(SelectedItem);
|
||||
if (containSelected)
|
||||
{
|
||||
var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceCombinationLists.Remove(SelectedItem); }
|
||||
else return;
|
||||
}
|
||||
}
|
||||
}
|
||||
base.DeleteMethod();
|
||||
}
|
||||
}
|
||||
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
var wnd = new ForceCombinationView(SelectedItem);
|
||||
wnd.ShowDialog();
|
||||
base.EditMethod(parameter);
|
||||
}
|
||||
|
||||
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceCombinationLists)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
IForceCombinationList combinationList;
|
||||
|
||||
public IDesignForceTuple SelectedTuple { get; set; }
|
||||
//public IDesignForceTuple SelectedTuple { get; set; }
|
||||
public ForceTuplesViewModel DesignForces { get;}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => combinationList.Name;
|
||||
@@ -55,11 +57,12 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
|
||||
//public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
|
||||
|
||||
public ForceCombinationViewModel(IForceCombinationList combinationList)
|
||||
{
|
||||
this.combinationList = combinationList;
|
||||
DesignForces = new ForceTuplesViewModel(this.combinationList.DesignForces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
Windows/ViewModels/Forces/ForceTuplesViewModel.cs
Normal file
25
Windows/ViewModels/Forces/ForceTuplesViewModel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StructureHelper.Properties;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ForceTuplesViewModel : CRUDViewModelBase<IDesignForceTuple>
|
||||
{
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new DesignForceTuple() { LimitState=LimitStates.ULS, CalcTerm=CalcTerms.ShortTerm};
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
public ForceTuplesViewModel(List<IDesignForceTuple> collection) : base(collection)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs
Normal file
40
Windows/ViewModels/Forces/InterpolateTuplesViewModel.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class InterpolateTuplesViewModel : OkCancelViewModelBase
|
||||
{
|
||||
public IDesignForceTuple StartDesignForce { get; }
|
||||
public IDesignForceTuple FinishDesignForce { get; }
|
||||
public int StepCount { get; set; }
|
||||
|
||||
public InterpolateTuplesViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce=null, int stepCount = 100)
|
||||
{
|
||||
if (startDesignForce !=null)
|
||||
{
|
||||
if (startDesignForce.LimitState != finishDesignForce.LimitState) throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
|
||||
if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm) throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
|
||||
StartDesignForce = startDesignForce;
|
||||
}
|
||||
else
|
||||
{
|
||||
StartDesignForce = new DesignForceTuple()
|
||||
{
|
||||
CalcTerm = finishDesignForce.CalcTerm,
|
||||
LimitState = finishDesignForce.LimitState,
|
||||
ForceTuple = new ForceTuple() { Mx = 0, My = 0, Nz = 0 },
|
||||
};
|
||||
}
|
||||
FinishDesignForce = finishDesignForce;
|
||||
StepCount = stepCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.Windows.AddMaterialWindow;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
@@ -56,6 +57,29 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
public ICommand DeleteMaterialCommand { get; set; }
|
||||
public ICommand EditHeadMaterial;
|
||||
|
||||
private RelayCommand showSafetyfactors;
|
||||
|
||||
public RelayCommand ShowSafetyFactors
|
||||
{
|
||||
get
|
||||
{
|
||||
return showSafetyfactors ??
|
||||
(
|
||||
showSafetyfactors = new RelayCommand(o =>
|
||||
{
|
||||
if (selectedMaterial.HelperMaterial is ILibMaterial)
|
||||
{
|
||||
var material = selectedMaterial.HelperMaterial as ILibMaterial;
|
||||
var wnd = new SafetyFactorsView(material.SafetyFactors);
|
||||
wnd.ShowDialog();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}
|
||||
}, o=> SelectedLibMaterial != null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ICommand addElasticMaterialCommand;
|
||||
|
||||
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
|
||||
@@ -74,6 +98,19 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IMaterialSafetyFactor> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
if (selectedMaterial.HelperMaterial is ILibMaterial)
|
||||
{
|
||||
var material = selectedMaterial.HelperMaterial as ILibMaterial;
|
||||
return new ObservableCollection<IMaterialSafetyFactor>(material.SafetyFactors);
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedName
|
||||
{
|
||||
get => selectedMaterial.Name;
|
||||
|
||||
15
Windows/ViewModels/Materials/ISafetyFactorViewModel.cs
Normal file
15
Windows/ViewModels/Materials/ISafetyFactorViewModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
internal interface ISafetyFactorViewModel<TItem> : ICRUDViewModel<TItem>
|
||||
{
|
||||
RelayCommand ShowPartialFactors { get; }
|
||||
}
|
||||
}
|
||||
22
Windows/ViewModels/Materials/PartialFactorsViewModel.cs
Normal file
22
Windows/ViewModels/Materials/PartialFactorsViewModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
internal class PartialFactorsViewModel : CRUDViewModelBase<IMaterialPartialFactor>
|
||||
{
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new MaterialPartialFactor();
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
public PartialFactorsViewModel(List<IMaterialPartialFactor> safetyFactors) : base(safetyFactors)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Windows/ViewModels/Materials/SafetyFactorsViewModel.cs
Normal file
41
Windows/ViewModels/Materials/SafetyFactorsViewModel.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
internal class SafetyFactorsViewModel : CRUDViewModelBase<IMaterialSafetyFactor>
|
||||
{
|
||||
private RelayCommand showPartialCommand;
|
||||
|
||||
public RelayCommand ShowPartialFactors
|
||||
{
|
||||
get
|
||||
{
|
||||
return showPartialCommand ??
|
||||
(showPartialCommand = new RelayCommand(o =>
|
||||
{
|
||||
var wnd = new PartialFactorsView(SelectedItem.PartialFactors);
|
||||
wnd.ShowDialog();
|
||||
}, o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new MaterialSafetyFactor();
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
public SafetyFactorsViewModel(List<IMaterialSafetyFactor> safetyFactors) : base(safetyFactors)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Windows/ViewModels/OkCancelViewModelBase.cs
Normal file
17
Windows/ViewModels/OkCancelViewModelBase.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public abstract class OkCancelViewModelBase : ViewModelBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
{
|
||||
public class SelectPrimitivesViewModel
|
||||
{
|
||||
public SelectItemsViewModel<PrimitiveBase> Items { get; }
|
||||
|
||||
public SelectPrimitivesViewModel(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
var primitiveViews = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(primitives);
|
||||
Items = new SelectItemsViewModel<PrimitiveBase>(primitiveViews);
|
||||
Items.ItemDataDemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Windows/ViewModels/SelectItemsViewModel.cs
Normal file
33
Windows/ViewModels/SelectItemsViewModel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public class SelectItemsViewModel<TItem>
|
||||
where TItem : class
|
||||
{
|
||||
public class CollectionItem
|
||||
{
|
||||
public bool IsSelected { get; set; }
|
||||
public TItem Item { get; set; }
|
||||
}
|
||||
|
||||
public DataTemplate ItemDataDemplate { get; set; }
|
||||
|
||||
public ObservableCollection<CollectionItem> CollectionItems { get; }
|
||||
|
||||
public SelectItemsViewModel(IEnumerable<TItem> items)
|
||||
{
|
||||
CollectionItems = new ObservableCollection<CollectionItem>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
CollectionItems.Add(new CollectionItem() { IsSelected = true, Item = item });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user