123 lines
3.7 KiB
C#
123 lines
3.7 KiB
C#
using BeWo.ViewModel;
|
|
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.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace BeWo.View.Controls.Wohnhilfe
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für CustomerWohnhilfeControl.xaml
|
|
/// </summary>
|
|
public partial class CustomerWohnhilfeControl : UserControl
|
|
{
|
|
public bool PermissionCustomerWohnhilfeManage { get; } = BeWoApp.HasLoggedOnUserRight(BS.Shared.UserRightType.Customer_Wohnhilfe_Manage);
|
|
|
|
public bool IsLarge
|
|
{
|
|
get { return (bool)GetValue(IsLargeProperty); }
|
|
set
|
|
{
|
|
SetValue(IsLargeProperty, value);
|
|
}
|
|
}
|
|
|
|
// Using a DependencyProperty as the backing store for IsLarge. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty IsLargeProperty =
|
|
DependencyProperty.Register("IsLarge", typeof(bool), typeof(CustomerWohnhilfeControl),
|
|
new PropertyMetadata(false, OnIsLargeChanged));
|
|
|
|
public double MinWidthGrid { get; set; }
|
|
|
|
public double ParentWidth
|
|
{
|
|
get { return (double)GetValue(ParentWidthProperty); }
|
|
set { SetValue(ParentWidthProperty, value); }
|
|
}
|
|
|
|
// Using a DependencyProperty as the backing store for ParentWidth. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty ParentWidthProperty =
|
|
DependencyProperty.Register("ParentWidth", typeof(double), typeof(CustomerWohnhilfeControl), new PropertyMetadata(0.0d));
|
|
|
|
public CustomerWohnhilfeControl()
|
|
{
|
|
InitializeComponent();
|
|
|
|
root.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
|
|
|
var size = root.DesiredSize;
|
|
|
|
MinWidthGrid = size.Width;
|
|
}
|
|
|
|
private static void OnIsLargeChanged(DependencyObject defectImageControl, DependencyPropertyChangedEventArgs eventArgs)
|
|
{
|
|
var control = defectImageControl as CustomerWohnhilfeControl;
|
|
|
|
if(control is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (control.IsLarge)
|
|
{
|
|
control.SetLarge();
|
|
}
|
|
else
|
|
{
|
|
control.SetSmall();
|
|
}
|
|
}
|
|
|
|
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
{
|
|
if (e.WidthChanged)
|
|
{
|
|
var parent_width = ParentWidth;
|
|
if (parent_width > MinWidthGrid + 50)
|
|
{
|
|
IsLarge = true;
|
|
}
|
|
else
|
|
{
|
|
//IsLarge = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetLarge()
|
|
{
|
|
grid_secondcolumn.Width = new GridLength(7, GridUnitType.Star);
|
|
|
|
Grid.SetColumn(groupbox_2, 1);
|
|
Grid.SetRow(groupbox_2, 0);
|
|
Grid.SetColumn(groupbox_3, 0);
|
|
Grid.SetRow(groupbox_3, 1);
|
|
Grid.SetColumn(groupbox_4, 1);
|
|
Grid.SetRow(groupbox_4, 1);
|
|
}
|
|
|
|
private void SetSmall()
|
|
{
|
|
grid_secondcolumn.Width = new GridLength(0);
|
|
|
|
Grid.SetColumn(groupbox_2, 0);
|
|
Grid.SetRow(groupbox_2, 1);
|
|
Grid.SetColumn(groupbox_3, 0);
|
|
Grid.SetRow(groupbox_3, 2);
|
|
Grid.SetColumn(groupbox_4, 0);
|
|
Grid.SetRow(groupbox_4, 3);
|
|
}
|
|
}
|
|
}
|