Skip to content

Commit 3ca0abd

Browse files
JMJM
authored andcommitted
Cleaned up misc bits in the sample app.
1 parent 8cbaf9c commit 3ca0abd

2 files changed

Lines changed: 0 additions & 76 deletions

File tree

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/MainWindow.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
xmlns:sys="clr-namespace:System;assembly=mscorlib"
1313
mc:Ignorable="d"
1414
Title="MainWindow" Height="700" Width="1100">
15-
<Window.Resources>
16-
<local:ColorToBrushConverter x:Key="colorToBrushConverter"/>
17-
</Window.Resources>
18-
1915
<Grid>
2016
<Grid.ColumnDefinitions>
2117
<ColumnDefinition Width="5*"/>
@@ -108,8 +104,6 @@
108104
<local:DataSourceConfigurationInfo BaseUri="http://data.scottsdaleaz.gov/Finance/BusinessLicenses.svc" EntitySet="BusinessLicenses" Description="Scottsdale Business Licenses"/>
109105
<local:DataSourceConfigurationInfo BaseUri="http://data.scottsdaleaz.gov/Purchasing/Solicitations.svc" EntitySet="Solicitations" Description="Scottsdale Purchasing Solicitations"/>
110106
<local:DataSourceConfigurationInfo BaseUri="http://packages.nuget.org/v1/FeedService.svc" EntitySet="Packages" Description="NuGet Packages"/>
111-
<local:DataSourceConfigurationInfo BaseUri="http://odata.research.microsoft.com/odata.svc" EntitySet="Projects" Description="Microsoft Research - Projects"/>
112-
<local:DataSourceConfigurationInfo BaseUri="http://odata.research.microsoft.com/odata.svc" EntitySet="Publications" Description="Microsoft Research - Publications"/>
113107
</ComboBox>
114108
<CheckBox x:Name="chkNullOutDatasource" IsChecked="True" Style="{StaticResource CheckBoxText}">Null out datasource before setting new</CheckBox>
115109

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/MainWindow.xaml.cs

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -289,74 +289,4 @@ public class DataSourceConfigurationInfo
289289
public string[] DesiredFields { get; set; }
290290
}
291291
#endregion //DataSourceConfigurationInfo Class
292-
293-
#region ColorToBrushConverter Class
294-
public class ColorToBrushConverter : IValueConverter
295-
{
296-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
297-
{
298-
return Process(value, targetType, parameter, culture);
299-
}
300-
301-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
302-
{
303-
return Process(value, targetType, parameter, culture);
304-
}
305-
306-
private static object Process(object value, Type targetType, object parameter, CultureInfo culture)
307-
{
308-
if (value is string)
309-
{
310-
Color color = Parse((string)value);
311-
312-
if (targetType == typeof(Brush) || targetType == typeof(SolidColorBrush))
313-
return new SolidColorBrush(color);
314-
else
315-
if (targetType == typeof(Color) || targetType == typeof(Nullable<Color>))
316-
return color;
317-
}
318-
319-
if (value is SolidColorBrush)
320-
{
321-
if (targetType == typeof(Brush) || targetType == typeof(SolidColorBrush))
322-
return value;
323-
else
324-
if (targetType == typeof(Color) || targetType == typeof(Nullable<Color>))
325-
return ((SolidColorBrush)value).Color;
326-
}
327-
328-
if (value == null)
329-
{
330-
if (targetType == typeof(Brush) || targetType == typeof(SolidColorBrush))
331-
return new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
332-
else
333-
if (targetType == typeof(Color) || targetType == typeof(Nullable<Color>))
334-
return Color.FromArgb(0, 0, 0, 0);
335-
}
336-
337-
if (value is Color)
338-
{
339-
if (targetType == typeof(Brush) || targetType == typeof(SolidColorBrush))
340-
return new SolidColorBrush((Color)value);
341-
else
342-
if (targetType == typeof(Color) || targetType == typeof(Nullable<Color>))
343-
return value;
344-
}
345-
346-
throw new NotSupportedException("ColorToBrushConverter cannot convert value!");
347-
}
348-
349-
private static Color Parse(string color)
350-
{
351-
var offset = color.StartsWith("#") ? 1 : 0;
352-
353-
var a = Byte.Parse(color.Substring(0 + offset, 2), NumberStyles.HexNumber);
354-
var r = Byte.Parse(color.Substring(2 + offset, 2), NumberStyles.HexNumber);
355-
var g = Byte.Parse(color.Substring(4 + offset, 2), NumberStyles.HexNumber);
356-
var b = Byte.Parse(color.Substring(6 + offset, 2), NumberStyles.HexNumber);
357-
358-
return Color.FromArgb(a, r, g, b);
359-
}
360-
}
361-
#endregion //ColorToBrushConverter Class
362292
}

0 commit comments

Comments
 (0)