Skip to content

Commit

Permalink
Merge pull request #44 from skowront/issue15
Browse files Browse the repository at this point in the history
Issue15
  • Loading branch information
krzysztof-lorenc authored May 19, 2020
2 parents 4371fc9 + aae414f commit 61309cd
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</DataTemplate>

<DataTemplate DataType="{x:Type connectorTreeView:ConnectorViewModel}">
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}">
<DockPanel Width="Auto" ContextMenu="{DynamicResource BuildServerProjectContextMenu}" ToolTip="Yow">
<buildServer:BuildInformationIconControl DataContext="{Binding CurrentStatus}" DockPanel.Dock="Left">
<buildServer:BuildInformationIconControl.ToolTip>
<StackPanel>
Expand Down
55 changes: 55 additions & 0 deletions src/Soloplan.WhatsON.GUI.Common/Converters/RGBAToRGBConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NullOrDefaultToVisibilityConverter.cs" company="Soloplan GmbH">
// Copyright (c) Soloplan GmbH. All rights reserved.
// Licensed under the MIT License. See License-file in the project root for license information.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Soloplan.WhatsON.GUI.Common.Converters
{
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

/// <summary>
/// Converts given value from rgba to rgb.
/// </summary>
public class RGBToRGBAConverter : IValueConverter
{
/// <summary>Converts SolidColorBrush from RGBA to RGB, if RGB given it returns RGB. F ex, when given "#FFDDFFDD" returns "#DDFFDD"</summary>
/// <param name="value">SolidColorBrush is the given brush to convert from rgba to rgb</param>
/// <param name="targetType">This parameter is not used.</param>
/// <param name="parameter">This parameter is not used.</param>
/// <param name="culture">This parameter is not used.</param>
/// <returns>
/// String with rgb />.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is SolidColorBrush)
{
string input = ((SolidColorBrush)value).ToString();
if (input.Length == 7)
{
return input;
}

string output=string.Empty;
for (int i = 0; i < input.Length; i++)
{
if (i == 1) { i = 3; }
output += input[i];
}

return output;
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</Compile>
<Compile Include="ConnectorTreeView\CustomCommand.cs" />
<Compile Include="Converters\NullableBooleanConverter.cs" />
<Compile Include="Converters\RGBAToRGBConverter.cs" />
<Compile Include="ExternalEnabledStateCommand.cs" />
<Compile Include="Converters\InvertBooleanConverter.cs" />
<Compile Include="Converters\InvertBooleanToVisibilityConverter.cs" />
Expand Down
3 changes: 2 additions & 1 deletion src/Soloplan.WhatsON.GUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<converters:InvertBooleanToVisibilityConverter x:Key="InvertBoolToVis" />
<converters:InvertBooleanConverter x:Key="InvertBoolConverter" />
</ResourceDictionary>
<converters:RGBToRGBAConverter x:Key="RGBAToRGBConverter" />
</ResourceDictionary>
</Application.Resources>
</Application>
69 changes: 40 additions & 29 deletions src/Soloplan.WhatsON.GUI/Configuration/Wizard/ProjectsTreeView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,39 @@
xmlns:local="clr-namespace:Soloplan.WhatsON.GUI.Configuration.Wizard"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpf="clr-namespace:TheArtOfDev.HtmlRenderer.WPF;assembly=HtmlRenderer.WPF"
d:DesignHeight="450"
d:DesignWidth="800"
Background="{DynamicResource MaterialDesignPaper}"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
mc:Ignorable="d">

<UserControl.Resources>
<ResourceDictionary>
<UserControl.Resources>
<ResourceDictionary>

<BooleanToVisibilityConverter x:Key="BoolToVisibility" />
<BooleanToVisibilityConverter x:Key="BoolToVisibility" />

<HierarchicalDataTemplate DataType="{x:Type local:ProjectViewModel}" ItemsSource="{Binding Path=Projects}">
<DockPanel Width="400">
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal">
<CheckBox Focusable="False"
<HierarchicalDataTemplate DataType="{x:Type local:ProjectViewModel}" ItemsSource="{Binding Path=Projects}">
<DockPanel Width="400">
<DockPanel.ToolTip>
<wpf:HtmlPanel Background="Transparent" MaxWidth="600">
<wpf:HtmlPanel.Text>
<MultiBinding StringFormat='{}&lt;font size=&quot;6&quot; face=&quot;arial&quot; color=&quot;{1}&quot;&gt; {0} &lt;/font&gt;'>
<Binding Path="Description"></Binding>
<Binding Source="{StaticResource MaterialDesignPaper}" Converter="{StaticResource RGBAToRGBConverter}"></Binding>
</MultiBinding>
</wpf:HtmlPanel.Text>
</wpf:HtmlPanel>
</DockPanel.ToolTip>
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal">
<CheckBox Focusable="False"
IsChecked="{Binding IsChecked}"
Style="{StaticResource MaterialDesignAccentCheckBox}"
Visibility="{Binding Path=IsCheckable, Converter={StaticResource BoolToVis}}" />
<TextBlock Margin="10,0,0,0"
<TextBlock Margin="10,0,0,0"
Focusable="False"
Text="{Binding Name}" />
<TextBlock Margin="5,0,0,0">
<TextBlock Margin="5,0,0,0">
<Hyperlink NavigateUri="{Binding Address}"
RequestNavigate="HyperlinkRequestNavigate"
Style="{StaticResource MaterialDesignHeadline4Hyperlink}">
Expand All @@ -35,35 +46,35 @@
</TextBlock>
</Hyperlink>
</TextBlock>
</StackPanel>
<StackPanel DockPanel.Dock="Right"
</StackPanel>
<StackPanel DockPanel.Dock="Right"
Opacity="0.5"
Orientation="Horizontal"
Visibility="{Binding AlreadyAdded, Converter={StaticResource BoolToVisibility}}">
<TextBlock Margin="10,0,0,0"
<TextBlock Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="10"
Text="Already added: " />
<TextBlock Margin="3,0,0,0"
<TextBlock Margin="3,0,0,0"
VerticalAlignment="Center"
FontSize="10"
FontWeight="Bold"
Text="{Binding AddedProject}" />
</StackPanel>
</DockPanel>
</HierarchicalDataTemplate>
</ResourceDictionary>
</UserControl.Resources>
</StackPanel>
</DockPanel>
</HierarchicalDataTemplate>
</ResourceDictionary>
</UserControl.Resources>

<TreeView Name="mainTreeView" ItemsSource="{Binding}">
<TreeView.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type TreeViewItem}}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolToVisibility}}" />
<EventSetter Event="RequestBringIntoView" Handler="NullHandler" />
<EventSetter Event="PreviewKeyUp" Handler="TreeViewItemPreviewKeyUp" />
<Setter Property="Padding" Value="0" />
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
<TreeView Name="mainTreeView" ItemsSource="{Binding}">
<TreeView.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type TreeViewItem}}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolToVisibility}}" />
<EventSetter Event="RequestBringIntoView" Handler="NullHandler" />
<EventSetter Event="PreviewKeyUp" Handler="TreeViewItemPreviewKeyUp" />
<Setter Property="Padding" Value="0" />
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</UserControl>
3 changes: 3 additions & 0 deletions src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="HtmlRenderer.WPF">
<Version>1.5.0.6</Version>
</PackageReference>
<PackageReference Include="Humanizer.Core">
<Version>2.7.9</Version>
</PackageReference>
Expand Down
2 changes: 0 additions & 2 deletions src/Soloplan.WhatsON/Composition/ConnectorTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public ConnectorTypeAttribute(string name)
{
this.Name = name;
}


public ConnectorTypeAttribute(string name, string displayName)
{
this.Name = name;
Expand Down

0 comments on commit 61309cd

Please sign in to comment.