Gui neu angelegt
This commit is contained in:
209
StammGenerator/ViewModel/Haltung/HaltungEditViewModel.cs
Normal file
209
StammGenerator/ViewModel/Haltung/HaltungEditViewModel.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using StammGenerator.Commands;
|
||||
using StammGenerator.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StammGenerator.ViewModel
|
||||
{
|
||||
internal class HaltungEditViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IHaltungDataService _haltungDataService;
|
||||
private readonly ISchachtDataService _schachtDataService;
|
||||
private List<Schacht> avaibleSchaechte;
|
||||
private int _selectedObenIndex;
|
||||
private int _selectedUntenIndex;
|
||||
private Kanal _model;
|
||||
|
||||
public List<Schacht> AvSchaechte
|
||||
{
|
||||
get
|
||||
{
|
||||
return avaibleSchaechte;
|
||||
}
|
||||
}
|
||||
|
||||
public EEntwaeserung Entwaeserung
|
||||
{
|
||||
get => _model.Entwaesserung;
|
||||
set
|
||||
{
|
||||
if(_model.Entwaesserung != value)
|
||||
{
|
||||
_model.Entwaesserung = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int SelectedObenIndex
|
||||
{
|
||||
get => _selectedObenIndex;
|
||||
set
|
||||
{
|
||||
if (_selectedObenIndex != value)
|
||||
{
|
||||
_selectedObenIndex = value;
|
||||
_model.StartSchacht = avaibleSchaechte[value];
|
||||
RecalculateLength();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public int SelectedUntenIndex
|
||||
{
|
||||
get => _selectedUntenIndex;
|
||||
set
|
||||
{
|
||||
if (_selectedUntenIndex != value)
|
||||
{
|
||||
_selectedUntenIndex = value;
|
||||
_model.EndSchacht = avaibleSchaechte[value];
|
||||
RecalculateLength();
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Kanal Model
|
||||
{
|
||||
get => _model;
|
||||
set
|
||||
{
|
||||
_model = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string Haltungsbezeichnung
|
||||
{
|
||||
get => _model.Objektbezeichnung;
|
||||
set
|
||||
{
|
||||
if (_model.Objektbezeichnung != value)
|
||||
{
|
||||
_model.Objektbezeichnung = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Material
|
||||
{
|
||||
get => _model.Material;
|
||||
set
|
||||
{
|
||||
if (_model.Material != value)
|
||||
{
|
||||
_model.Material = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Durchmesser
|
||||
{
|
||||
get => _model.DN.ToString();
|
||||
set
|
||||
{
|
||||
if (_model.DN.ToString() != value)
|
||||
{
|
||||
_model.DN = int.Parse(value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Haltungslaenge
|
||||
{
|
||||
get => _model.Haltungslaenge.ToString();
|
||||
set
|
||||
{
|
||||
if (_model.Haltungslaenge.ToString() != value)
|
||||
{
|
||||
_model.Haltungslaenge = decimal.Parse(value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand Speichern { get; set; }
|
||||
public ICommand Abbrechen { get; set; }
|
||||
|
||||
public HaltungEditViewModel(
|
||||
IHaltungDataService haltungDataService,
|
||||
IActualState actualState,
|
||||
IRenavigator renavigator,
|
||||
ISchachtDataService schachtDataService)
|
||||
{
|
||||
_actualState = actualState;
|
||||
_haltungDataService = haltungDataService;
|
||||
_schachtDataService = schachtDataService;
|
||||
|
||||
|
||||
|
||||
_model = _actualState.SelectedHaltung;
|
||||
|
||||
Speichern = new HaltungEditSaveCommand(_haltungDataService, renavigator, this);
|
||||
Abbrechen = new RelayCommand((x) => Abbruch(renavigator));
|
||||
|
||||
ladeVerfuegbareSchaechte();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void RecalculateLength()
|
||||
{
|
||||
|
||||
double x1 = (double)Model.StartSchacht.DeckelRechtsWert;
|
||||
double x2 = (double)Model.EndSchacht.DeckelRechtsWert;
|
||||
double y1 = (double)Model.StartSchacht.DeckelHochWert;
|
||||
double y2 = (double)Model.EndSchacht.DeckelHochWert;
|
||||
|
||||
|
||||
double length = Math.Sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
|
||||
Haltungslaenge = length.ToString();
|
||||
OnPropertyChanged(nameof(Haltungslaenge));
|
||||
}
|
||||
|
||||
private void Abbruch(IRenavigator renavigator)
|
||||
{
|
||||
renavigator.Renavigate();
|
||||
}
|
||||
|
||||
private async void ladeVerfuegbareSchaechte()
|
||||
{
|
||||
var s = await _schachtDataService.GetAllByProjekt(_actualState.ProjektID);
|
||||
avaibleSchaechte = s.ToList();
|
||||
int counter = 0;
|
||||
foreach (var d in avaibleSchaechte)
|
||||
{
|
||||
if (d.Id == Model.StartSchacht.Id)
|
||||
{
|
||||
SelectedObenIndex = counter;
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
counter = 0;
|
||||
foreach (var d in avaibleSchaechte)
|
||||
{
|
||||
if (d.Id == Model.EndSchacht.Id)
|
||||
{
|
||||
SelectedUntenIndex = counter;
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
OnPropertyChanged(nameof(AvSchaechte));
|
||||
OnPropertyChanged(nameof(SelectedObenIndex));
|
||||
OnPropertyChanged(nameof(SelectedUntenIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
55
StammGenerator/ViewModel/Haltung/HaltungListViewModel.cs
Normal file
55
StammGenerator/ViewModel/Haltung/HaltungListViewModel.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using StammGenerator.Commands;
|
||||
using StammGenerator.Interface;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StammGenerator.ViewModel
|
||||
{
|
||||
public class HaltungListViewModel : BaseViewModel
|
||||
{
|
||||
private readonly ObservableCollection<Kanal> _haltungen;
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IHaltungDataService _haltungDataService;
|
||||
|
||||
public Kanal? SelectedHaltung { get; set; }
|
||||
public ObservableCollection<Kanal> Haltungen { get => _haltungen; }
|
||||
|
||||
public ICommand EditCommand { get; set; }
|
||||
public ICommand AddCommand { get; set; }
|
||||
public ICommand ExportCommand { get; set; }
|
||||
|
||||
public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
|
||||
{
|
||||
_haltungen = new ObservableCollection<Kanal>();
|
||||
_haltungDataService = haltungDataService;
|
||||
|
||||
_actualState = actualState;
|
||||
|
||||
|
||||
EditCommand = new HaltungEditCommand(actualState, renavigator, this);
|
||||
AddCommand = new HaltungAddCommand(actualState, renavigator);
|
||||
ExportCommand = new ProjectExportCommand(actualState);
|
||||
|
||||
LoadHaltungen();
|
||||
}
|
||||
|
||||
private async void LoadHaltungen()
|
||||
{
|
||||
var haltungen = await _haltungDataService.GetAllByProjekt(_actualState.ProjektID);
|
||||
InitCollection(_haltungen, haltungen);
|
||||
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Kanal> dest, IEnumerable<Kanal> source)
|
||||
{
|
||||
dest.Clear();
|
||||
foreach (var sourceItem in source)
|
||||
{
|
||||
dest.Add(sourceItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
StammGenerator/ViewModel/Haltung/TextBoxFilterAction.cs
Normal file
20
StammGenerator/ViewModel/Haltung/TextBoxFilterAction.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
//using Microsoft.Xaml.Behaviors;
|
||||
//using Syncfusion.UI.Xaml.Grid;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StammGenerator.Views
|
||||
{
|
||||
/*
|
||||
public class TextBoxFilterAction : TargetedTriggerAction<SfMultiColumnDropDownControl>
|
||||
{
|
||||
protected override void Invoke(object parameter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user