209 lines
7.4 KiB
C#
209 lines
7.4 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
using System.Windows.Controls.Primitives;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
using System.Windows.Documents;
|
|||
|
|
using System.Windows.Input;
|
|||
|
|
using System.Windows.Media;
|
|||
|
|
using System.Windows.Media.Imaging;
|
|||
|
|
using System.Windows.Shapes;
|
|||
|
|
using BeWo.ViewModel;
|
|||
|
|
using BS.Shared;
|
|||
|
|
using BS.Shared.Core;
|
|||
|
|
using BS.Shared.DataContracts;
|
|||
|
|
using BS.Shared.Extensions;
|
|||
|
|
|
|||
|
|
namespace BeWo.View.Detail
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaktionslogik für ServiceRecordRTFWindowView.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class ServiceRecordRTFWindowView : Window
|
|||
|
|
{
|
|||
|
|
public event EventHandler<CustomRTFWindowArgs> RaiseCustomEvent;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public ServiceRecordRTFWindowView(string titel,string text, string rtfText)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
RtfWindow.Title = titel;
|
|||
|
|
|
|||
|
|
richEditControl.Text = text;
|
|||
|
|
richEditControl.RtfText = rtfText;
|
|||
|
|
|
|||
|
|
// höhe und breite vom Screen nehmen und durch 2 teilen
|
|||
|
|
Width = SystemParameters.PrimaryScreenWidth / 2;
|
|||
|
|
Height = SystemParameters.PrimaryScreenWidth / 2;
|
|||
|
|
|
|||
|
|
AddClose();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AddClose()
|
|||
|
|
{
|
|||
|
|
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => RtfRueckgabe()));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RtfRueckgabe()
|
|||
|
|
{
|
|||
|
|
RaiseCustomEvent(this, new CustomRTFWindowArgs(richEditControl.Text,richEditControl.RtfText));
|
|||
|
|
Close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//TextBausteine Bereich
|
|||
|
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
popup_textbausteine.IsOpen = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TextbausteineSearchView_OnItemSelected(object sender, EventArgs<TextbausteinDC> e)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(richEditControl.Text))
|
|||
|
|
{
|
|||
|
|
richEditControl.Text = e.Data.Text;
|
|||
|
|
richEditControl.Document.CaretPosition = richEditControl.Document.Range.End;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (richEditControl.Document.CaretPosition.ToInt() == 0)
|
|||
|
|
{
|
|||
|
|
richEditControl.Text = e.Data.Text + richEditControl.Text;
|
|||
|
|
}
|
|||
|
|
else if (richEditControl.Document.CaretPosition == richEditControl.Document.Range.End)
|
|||
|
|
{
|
|||
|
|
richEditControl.Text = richEditControl.Text + e.Data.Text;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var anzahlLeerzeichen = richEditControl.Document.CaretPosition.ToInt() - richEditControl.Text.Length;
|
|||
|
|
|
|||
|
|
var leerzeichen = String.Empty;
|
|||
|
|
for (var i = 0; i < anzahlLeerzeichen; i++)
|
|||
|
|
{
|
|||
|
|
leerzeichen += " ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var start = richEditControl.Text.Substring(0, (richEditControl.Document.CaretPosition.ToInt() - anzahlLeerzeichen));
|
|||
|
|
var ende = richEditControl.Text.Substring((richEditControl.Document.CaretPosition.ToInt() - anzahlLeerzeichen));
|
|||
|
|
|
|||
|
|
richEditControl.Text = start + leerzeichen + e.Data.Text + ende;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
richEditControl.Document.CaretPosition = richEditControl.Document.Range.End;
|
|||
|
|
|
|||
|
|
popup_textbausteine.IsOpen = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void EditTextbausteineClick(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
VMFactory.CreateTextbausteinListVMAsync(
|
|||
|
|
x => this.Dispatch(delegate
|
|||
|
|
{
|
|||
|
|
var tbv = new TextbausteinView(x) { Background = FindResource("ApplicationBackground") as LinearGradientBrush };
|
|||
|
|
|
|||
|
|
var rootGrid2 = (Grid)tbv.root.Content;
|
|||
|
|
var zielGrid = (Grid)rootGrid2.Children[0];
|
|||
|
|
var cb = new CheckBox
|
|||
|
|
{
|
|||
|
|
Content = "Nur für mich sichtbar",
|
|||
|
|
Margin = new Thickness(3),
|
|||
|
|
HorizontalAlignment = HorizontalAlignment.Left,
|
|||
|
|
VerticalAlignment = VerticalAlignment.Center
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneBearbeiten) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleBearbeiten))
|
|||
|
|
{
|
|||
|
|
cb.IsEnabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var IsOnlyForEmployeeBinding = new Binding("NewVM.IsOnlyForEmployee") { Source = tbv.ViewModel, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
|
|||
|
|
BindingOperations.SetBinding(cb, ToggleButton.IsCheckedProperty, IsOnlyForEmployeeBinding);
|
|||
|
|
|
|||
|
|
Grid.SetColumn(cb, 0);
|
|||
|
|
Grid.SetRow(cb, 2);
|
|||
|
|
Grid.SetColumnSpan(cb, 4);
|
|||
|
|
|
|||
|
|
zielGrid.Children.Add(cb);
|
|||
|
|
|
|||
|
|
var stackPanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
|
|||
|
|
|
|||
|
|
var speichernBtn = new Button
|
|||
|
|
{
|
|||
|
|
Content = "Speichern und schließen",
|
|||
|
|
HorizontalAlignment = HorizontalAlignment.Right,
|
|||
|
|
Margin = new Thickness(3),
|
|||
|
|
VerticalAlignment = VerticalAlignment.Center
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var abbrechenBtn = new Button
|
|||
|
|
{
|
|||
|
|
Content = "Abbrechen",
|
|||
|
|
HorizontalAlignment = HorizontalAlignment.Right,
|
|||
|
|
Margin = new Thickness(3),
|
|||
|
|
VerticalAlignment = VerticalAlignment.Center
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
stackPanel.Children.Add(speichernBtn);
|
|||
|
|
stackPanel.Children.Add(abbrechenBtn);
|
|||
|
|
Grid.SetRow(stackPanel, 2);
|
|||
|
|
|
|||
|
|
rootGrid2.Children.Add(stackPanel);
|
|||
|
|
tbv.root.Header = string.Empty;
|
|||
|
|
var window = new BeWoWindow(tbv) { Width = 514, Height = 400, rootGroupBox = { Header = "Textbausteine" } };
|
|||
|
|
|
|||
|
|
speichernBtn.Click += (o, args) =>
|
|||
|
|
{
|
|||
|
|
tbv.Focus();
|
|||
|
|
if (x.IsDirty || x.VMList.Any(vm => vm.IsDirty))
|
|||
|
|
tbv.Save(() => { textbausteineSearchView.ServiceCategoryOid = textbausteineSearchView.ServiceCategoryOid; });
|
|||
|
|
|
|||
|
|
window.Close();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
abbrechenBtn.Click += (o, args) =>
|
|||
|
|
{
|
|||
|
|
tbv.Focus();
|
|||
|
|
tbv.DoSaveCheck();
|
|||
|
|
|
|||
|
|
window.Close();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
window.Show();
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class CustomRTFWindowArgs : EventArgs
|
|||
|
|
{
|
|||
|
|
private string _text;
|
|||
|
|
private string _rtfText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public CustomRTFWindowArgs(string txt, string rtfTxt)
|
|||
|
|
{
|
|||
|
|
_text = txt;
|
|||
|
|
_rtfText = rtfTxt;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string Text
|
|||
|
|
{
|
|||
|
|
get { return _text; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string RtfText
|
|||
|
|
{
|
|||
|
|
get { return _rtfText;}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|