-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from skowront/issue15
Issue15
- Loading branch information
Showing
7 changed files
with
102 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Soloplan.WhatsON.GUI.Common/Converters/RGBAToRGBConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters