Files
BeWoPlaner/BeWo/View/Detail/RatingEditView.xaml.cs

148 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using BeWo.Controls;
using BeWo.Core;
using BeWo.ServiceProxy;
using BeWo.Validation;
using BeWo.View.Search;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
using BeWo.Core.Service;
using BS.Shared;
using BS.Shared.Extensions;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.ClientPartials;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Services;
using BS.Shared.Translation;
using DevExpress.Xpf.RichEdit;
using SupportConceptService = BeWo.Core.Service.SupportConceptService;
namespace BeWo.View.Detail
{
public partial class RatingEditView
{
public event Action ButtonSavedClicked;
public event Action ButtonCancelClicked;
private RatingVM _RatingVM;
public RatingEditView()
{
InitializeComponent();
}
public override bool CanDelete
{
get
{
return false;
}
}
public override bool IsDirty
{
get
{
//if (ViewModel.SelectedVMForEditing != null && _SelectedEmployee != null &&
// !_SelectedEmployee.Equals(ViewModel.SelectedVMForEditing.Employee))
// return true;
return _RatingVM != null && _RatingVM.IsDirty;
}
}
public override string SaveObjectName
{
get
{
return Translator.Translate("dieser Bewertung");
}
}
public override string Title
{
get
{
return Translator.Translate("Bewertung bearbeiten");
}
}
public RatingVM ViewModel { get; set; }
public void InitView(RatingVM rating)
{
InitializeComponent();
_RatingVM = rating;
DataContext = rating;
ViewModel = rating;
ColumnRatingTypeComboBox.ItemsSource = rating.GoalRatingList.AllRatingTypes;
richEditControl1.RtfText = rating.RTFNotice;
richEditControl1.BarManager = barManager;
FontSizeComboBox.OfficeFontSizeProvider = richEditControl1;
RichEditStyleComboBox.RichEditControl = richEditControl1;
biPageLayoutSizeList.RichEditControl = richEditControl1;
biMailMergeInsertFieldPlaceholder.RichEditControl = richEditControl1;
biReviewReviewers.RichEditControl = richEditControl1;
Focus();
//ConfigureRTFDocTypes();
}
public bool IsValid()
{
bool lValid = ValidationTrigger.Validate(rootGrid);
return lValid;
}
private void RichEditControl_OnContentChanged(object sender, EventArgs e)
{
ViewModel.Notice = richEditControl1.Text;
ViewModel.RTFNotice = richEditControl1.RtfText;
}
private void BtnSave_OnClick(object sender, RoutedEventArgs e)
{
ButtonSavedClicked?.Invoke();
}
private void BtnClose_OnClick(object sender, RoutedEventArgs e)
{
bool close = true;
if (ViewModel.IsDirty)
{
if (MessageBox.Show(
Translator.Translate("Möchten Sie wirklich abbrechen und die Änderungen verwerfen?"),
"BeWoPlaner", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
{
close = false;
}
}
if (close)
{
ButtonCancelClicked?.Invoke();
}
}
}
}