Added ShapeToDataConverter
This commit is contained in:
Родитель
9e3f841c4d
Коммит
93d2bdca91
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
SpiroNet.Wpf
|
||||
Copyright (C) 2015 Wiesław Šoltés
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 3
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA.
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using SpiroNet;
|
||||
|
||||
namespace SpiroNet.Wpf
|
||||
{
|
||||
internal class ShapeToDataConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values == null || values.Length != 2)
|
||||
return null;
|
||||
|
||||
var shape = values[0] as PathShape;
|
||||
var dict = values[1] as IDictionary<PathShape, string>;
|
||||
if (shape == null || dict == null)
|
||||
return null;
|
||||
|
||||
string data;
|
||||
if (!dict.TryGetValue(shape, out data))
|
||||
return null;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче