Files
BeWoPlaner/BeWo/View/Detail/InformationView.xaml.cs
2021-11-09 16:48:58 +01:00

134 lines
4.3 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;
using System.Linq;
using DevExpress.Xpf.Grid;
using System.Windows.Media.Imaging;
using DevExpress.Utils;
using System.Windows.Markup;
using System.Windows.Media;
namespace BeWo.View.Detail
{
public partial class InformationView
{
public event Action ButtonCloseClicked;
public Dictionary<string, string> dict;
public string XAML { get; set; }
public InformationView()
{
InitializeComponent();
}
public void SetXaml(string xamlString)
{
try
{
if (XamlReader.Parse(xamlString) is UIElement element)
{
XAML = xamlString;
mainGrid.Children.Add(element);
}
}
catch (Exception ex)
{
//ignore
}
}
private void UseSchedulerCode(List<SupportConceptOverviewDC> analyseForScheduler)
{
button_close.Visibility = Visibility.Collapsed;
foreach (var item in analyseForScheduler)
{
mainGrid.RowDefinitions.RemoveAt(0);
mainGrid.RowDefinitions.Add(new RowDefinition() { MinHeight = 30, MaxHeight = 30 });
var label = new TextBlock()
{
Text = string.Format("{0} ({1:MM/yy} - {2:MM/yy})", item.CostBearer, item.ApprovedStartDate, item.ApprovedEndDate),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(5),
Foreground = Brushes.Black
};
var text = new TextBlock()
{
Text = string.Format("{0:0.00}% ({1:0.00} / {2:0.00})", item.FLSRecordedTillNowInPercent, item.FLSRecordedTillNow, item.FLSApprovedTillNow),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(5),
Foreground = Brushes.Black,
FontSize = 10
};
var pb = new ProgressBar()
{
Minimum = 0,
Maximum = 100,
Value = Convert.ToDouble(item.FLSRecordedTillNowInPercent),
Margin = new Thickness(5),
Width = 180,
Height = 30,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center
};
mainGrid.Children.Add(label);
mainGrid.Children.Add(pb);
mainGrid.Children.Add(text);
Grid.SetRow(label, mainGrid.RowDefinitions.Count - 1);
Grid.SetColumn(label, 0);
Grid.SetRow(pb, mainGrid.RowDefinitions.Count - 1);
Grid.SetColumn(pb, 1);
Grid.SetRow(text, mainGrid.RowDefinitions.Count - 1);
Grid.SetColumn(text, 1);
}
string ganzesGridAlsXaml = XamlWriter.Save(mainGrid);
}
/*
//public void InitView(CompactEmployeeDC employee)
//{
// dict = ServiceFacade.DoOperationsServiceSync(s => s.GetAdditionalEmployeeInformationForScheduler(employee.EmployeeOid));
// var list = dict.ToList();
// list = list.OrderBy(l => l.Key).ToList();
// datagrid_employee_infos.ItemsSource = list;
//}
*/
private void button_close_Click(object sender, RoutedEventArgs e)
{
ButtonCloseClicked?.Invoke();
}
}
}