Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #42 from haevg-rz/enfore-codeing-style
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
dhcgn authored Mar 29, 2020
2 parents bdc5545 + 6d0de3c commit 96bb001
Show file tree
Hide file tree
Showing 19 changed files with 340 additions and 418 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using FluentAssertions;
using Planungsboard.Presentation.ViewModels;
using Xunit;
Expand Down Expand Up @@ -68,14 +66,14 @@ public void Convert_Multiples_Excluded(string assignedQuarterInline, string quar
{
#region Arrange

var card = new Card() { AssignedQuarter = new List<string>(assignedQuarterInline.Split(',')) };
var card = new Card() {AssignedQuarter = new List<string>(assignedQuarterInline.Split(','))};
var quarters = new List<string>(quartersInline.Split(','));

#endregion

#region Act

var actualCards = new CardsQuarterFilterForMultiples().Convert(new List<Card>() { card }, quarters);
var actualCards = new CardsQuarterFilterForMultiples().Convert(new List<Card>() {card}, quarters);

#endregion

Expand Down
13 changes: 6 additions & 7 deletions Planungsboard.Presentation.Test/MarginConverterTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using Planungsboard.Presentation.ViewModels;
Expand All @@ -18,8 +17,8 @@ public void Convert_Singles(string quarter, double left, double right)
#region Arrange

double actualWidth = 1000;
Card card = new Card() {AssignedQuarter = new List<string>() {quarter}};
List<string> quarters = new List<string>() {"1", "2", "3", "4"};
var card = new Card {AssignedQuarter = new List<string> {quarter}};
var quarters = new List<string> {"1", "2", "3", "4"};

#endregion

Expand Down Expand Up @@ -47,8 +46,8 @@ public void Convert_Multiples(string quarter, double left, double right)
#region Arrange

double actualWidth = 1000;
Card card = new Card() {AssignedQuarter = new List<string>(quarter.Split(','))};
List<string> quarters = new List<string>() {"1", "2", "3", "4"};
var card = new Card {AssignedQuarter = new List<string>(quarter.Split(','))};
var quarters = new List<string> {"1", "2", "3", "4"};

#endregion

Expand All @@ -74,8 +73,8 @@ public void Convert_MultiplesOutOfRange(string quarter, double left, double righ
#region Arrange

double actualWidth = 1000;
Card card = new Card() {AssignedQuarter = new List<string>(quarter.Split(','))};
List<string> quarters = new List<string>() {"3", "4", "5", "6"};
var card = new Card {AssignedQuarter = new List<string>(quarter.Split(','))};
var quarters = new List<string> {"3", "4", "5", "6"};

#endregion

Expand Down
11 changes: 1 addition & 10 deletions Planungsboard.Presentation/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace Planungsboard.Presentation
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
Expand Down
16 changes: 8 additions & 8 deletions Planungsboard.Presentation/Converter/CardsQuarterFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ public object[] ConvertBack(object value, Type[] targetTypes, object parameter,

public class CardsQuarterFilterForMultiples : IMultiValueConverter
{
public List<Card> Convert(IEnumerable<Card> cards, IEnumerable<string> quarters)
{
return Convert(new Object[]{ cards , quarters }, null, null, null) as List<Card>;
}

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var cards = values[0] as IEnumerable<Card>;
var quarters = values[1] as IEnumerable<string>;
var r = cards?.Where(c => c.AssignedQuarter != null

var r = cards?.Where(c => c.AssignedQuarter != null
&& c.AssignedQuarter.Count > 1
&& c.AssignedQuarter.Intersect(quarters).Any()
).ToList();
).ToList();
return r;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public List<Card> Convert(IEnumerable<Card> cards, IEnumerable<string> quarters)
{
return this.Convert(new object[] {cards, quarters}, null, null, null) as List<Card>;
}
}
}
21 changes: 10 additions & 11 deletions Planungsboard.Presentation/Converter/MarginConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,12 @@
using System.Linq;
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
using Planungsboard.Presentation.ViewModels;

namespace Planungsboard.Presentation
{
public class MarginConverter : IMultiValueConverter
{
public Thickness Convert(double actualWidth, Card card, List<string> quarters)
{
return (Thickness) Convert(new object[]
{
actualWidth,
card,
quarters
}, null, null, null);
}

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
try
Expand Down Expand Up @@ -52,5 +41,15 @@ public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
{
throw new NotImplementedException();
}

public Thickness Convert(double actualWidth, Card card, List<string> quarters)
{
return (Thickness) this.Convert(new object[]
{
actualWidth,
card,
quarters
}, null, null, null);
}
}
}
12 changes: 6 additions & 6 deletions Planungsboard.Presentation/UserControls/Card.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:Card}"
d:DesignHeight="100" d:DesignWidth="200">
<Border BorderBrush="{Binding Color}" BorderThickness="5,2,2,2" CornerRadius="2">

<Border BorderBrush="{Binding Color}" BorderThickness="5,2,2,2" CornerRadius="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand All @@ -25,12 +25,12 @@

<Rectangle Grid.Column="1" Grid.Row="0" Grid.RowSpan="3">
<Rectangle.Fill>
<VisualBrush TileMode="Tile"
Viewport="0,0,5,5" ViewportUnits="Absolute"
Viewbox="0,0,5,5" ViewboxUnits="Absolute">
<VisualBrush TileMode="Tile"
Viewport="0,0,5,5" ViewportUnits="Absolute"
Viewbox="0,0,5,5" ViewboxUnits="Absolute">
<VisualBrush.Visual>
<Grid Background="Transparent">
<Path Stroke="AliceBlue" Data="M 0 3 l 8 0" Opacity="0.5"/>
<Path Stroke="AliceBlue" Data="M 0 3 l 8 0" Opacity="0.5" />
</Grid>
</VisualBrush.Visual>
<VisualBrush.RelativeTransform>
Expand Down
26 changes: 8 additions & 18 deletions Planungsboard.Presentation/UserControls/Card.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
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 Planungsboard.Presentation.UserControls
{
/// <summary>
/// Interaktionslogik für Card.xaml
/// Interaktionslogik für Card.xaml
/// </summary>
public partial class Card : UserControl
{
public static readonly DependencyProperty ItemProperty = DependencyProperty.Register(
"Item", typeof(ViewModels.Card), typeof(Card), new PropertyMetadata(default(ViewModels.Card)));

public Card()
{
InitializeComponent();
this.InitializeComponent();
}

public static readonly DependencyProperty ItemProperty = DependencyProperty.Register(
"Item", typeof(ViewModels.Card), typeof(Card), new PropertyMetadata(default(ViewModels.Card)));

public ViewModels.Card Item
{
get { return (ViewModels.Card) GetValue(ItemProperty); }
set { SetValue(ItemProperty, value); }
get => (ViewModels.Card) this.GetValue(ItemProperty);
set => this.SetValue(ItemProperty, value);
}
}
}
3 changes: 2 additions & 1 deletion Planungsboard.Presentation/UserControls/CardsTimeLine.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<UserControl.Resources>
<local:MarginConverter x:Key="MarginConverter" />
</UserControl.Resources>
<Border Margin="2,0,0,2" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Border Margin="2,0,0,2"
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<ItemsControl ItemsSource="{Binding Cards}">
<ItemsControl.ItemTemplate>
<DataTemplate>
Expand Down
26 changes: 13 additions & 13 deletions Planungsboard.Presentation/UserControls/CardsTimeLine.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
namespace Planungsboard.Presentation.UserControls
{
/// <summary>
/// Interaktionslogik für CardsTimeLine.xaml
/// Interaktionslogik für CardsTimeLine.xaml
/// </summary>
public partial class CardsTimeLine : UserControl
{
public static readonly DependencyProperty CardsProperty = DependencyProperty.Register(
"Cards", typeof(List<ViewModels.Card>), typeof(CardsTimeLine), new PropertyMetadata(default(List<ViewModels.Card>)));

public static readonly DependencyProperty QuarterListProperty = DependencyProperty.Register(
"QuarterList", typeof(List<string>), typeof(CardsTimeLine), new PropertyMetadata(default(List<string>)));

public CardsTimeLine()
{
InitializeComponent();
this.InitializeComponent();
}

public static readonly DependencyProperty CardsProperty = DependencyProperty.Register(
"Cards", typeof(List<Planungsboard.Presentation.ViewModels.Card>), typeof(CardsTimeLine), new PropertyMetadata(default(List<Planungsboard.Presentation.ViewModels.Card>)));


public List<Planungsboard.Presentation.ViewModels.Card> Cards
public List<ViewModels.Card> Cards
{
get { return (List<Planungsboard.Presentation.ViewModels.Card>) GetValue(CardsProperty); }
set { SetValue(CardsProperty, value); }
get => (List<ViewModels.Card>) this.GetValue(CardsProperty);
set => this.SetValue(CardsProperty, value);
}

public static readonly DependencyProperty QuarterListProperty = DependencyProperty.Register(
"QuarterList", typeof(List<string>), typeof(CardsTimeLine), new PropertyMetadata(default(List<string>)));

public List<string> QuarterList
{
get { return (List<string>) GetValue(QuarterListProperty); }
set { SetValue(QuarterListProperty, value); }
get => (List<string>) this.GetValue(QuarterListProperty);
set => this.SetValue(QuarterListProperty, value);
}
}
}
63 changes: 27 additions & 36 deletions Planungsboard.Presentation/UserControls/CardsWarpPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,62 +1,53 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
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 Planungsboard.Presentation.UserControls
{
/// <summary>
/// Interaktionslogik für CardWarpPanel.xaml
/// Interaktionslogik für CardWarpPanel.xaml
/// </summary>
public partial class CardsWarpPanel : UserControl
{
public static readonly DependencyProperty Quarter1CardsProperty = DependencyProperty.Register(
"Quarter1Cards", typeof(List<ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<ViewModels.Card>)));

public static readonly DependencyProperty Quarter2CardsProperty = DependencyProperty.Register(
"Quarter2Cards", typeof(List<ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<ViewModels.Card>)));

public static readonly DependencyProperty Quarter3CardsProperty = DependencyProperty.Register(
"Quarter3Cards", typeof(List<ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<ViewModels.Card>)));

public static readonly DependencyProperty Quarter4CardsProperty = DependencyProperty.Register(
"Quarter4Cards", typeof(List<ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<ViewModels.Card>)));

public CardsWarpPanel()
{
InitializeComponent();
this.InitializeComponent();
}

public static readonly DependencyProperty Quarter1CardsProperty = DependencyProperty.Register(
"Quarter1Cards", typeof(List<Planungsboard.Presentation.ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<Planungsboard.Presentation.ViewModels.Card>)));

public List<Planungsboard.Presentation.ViewModels.Card> Quarter1Cards
public List<ViewModels.Card> Quarter1Cards
{
get { return (List<Planungsboard.Presentation.ViewModels.Card>) GetValue(Quarter1CardsProperty); }
set { SetValue(Quarter1CardsProperty, value); }
get => (List<ViewModels.Card>) this.GetValue(Quarter1CardsProperty);
set => this.SetValue(Quarter1CardsProperty, value);
}

public static readonly DependencyProperty Quarter2CardsProperty = DependencyProperty.Register(
"Quarter2Cards", typeof(List<Planungsboard.Presentation.ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<Planungsboard.Presentation.ViewModels.Card>)));

public List<Planungsboard.Presentation.ViewModels.Card> Quarter2Cards
public List<ViewModels.Card> Quarter2Cards
{
get { return (List<Planungsboard.Presentation.ViewModels.Card>) GetValue(Quarter2CardsProperty); }
set { SetValue(Quarter2CardsProperty, value); }
get => (List<ViewModels.Card>) this.GetValue(Quarter2CardsProperty);
set => this.SetValue(Quarter2CardsProperty, value);
}

public static readonly DependencyProperty Quarter3CardsProperty = DependencyProperty.Register(
"Quarter3Cards", typeof(List<Planungsboard.Presentation.ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<Planungsboard.Presentation.ViewModels.Card>)));

public List<Planungsboard.Presentation.ViewModels.Card> Quarter3Cards
public List<ViewModels.Card> Quarter3Cards
{
get { return (List<Planungsboard.Presentation.ViewModels.Card>) GetValue(Quarter3CardsProperty); }
set { SetValue(Quarter3CardsProperty, value); }
get => (List<ViewModels.Card>) this.GetValue(Quarter3CardsProperty);
set => this.SetValue(Quarter3CardsProperty, value);
}

public static readonly DependencyProperty Quarter4CardsProperty = DependencyProperty.Register(
"Quarter4Cards", typeof(List<Planungsboard.Presentation.ViewModels.Card>), typeof(CardsWarpPanel), new PropertyMetadata(default(List<Planungsboard.Presentation.ViewModels.Card>)));

public List<Planungsboard.Presentation.ViewModels.Card> Quarter4Cards
public List<ViewModels.Card> Quarter4Cards
{
get { return (List<Planungsboard.Presentation.ViewModels.Card>) GetValue(Quarter4CardsProperty); }
set { SetValue(Quarter4CardsProperty, value); }
get => (List<ViewModels.Card>) this.GetValue(Quarter4CardsProperty);
set => this.SetValue(Quarter4CardsProperty, value);
}
}
}
Loading

0 comments on commit 96bb001

Please sign in to comment.