Ejemplo n.º 1
0
        FrameworkElement getElement(SymbolTemplate type)
        {
            if (type != null)
            {
                DataTemplate     template = this.ItemTemplate;
                FrameworkElement obj      = template.LoadContent() as FrameworkElement;
#if !SILVERLIGHT
                //This code forces re-evaluation of Command in WPF
                //CanExecute is evaluated once Command is set and does not get called again once
                //CommandParameter has resolved its binding statement.
                RoutedEventHandler handler = null;
                handler = (s, a) =>
                {
                    obj.Loaded -= handler;
                    var editor = type.Editor;
                    type.Editor = null;
                    type.Editor = editor;
                };
                obj.Loaded += handler;
#endif
                obj.DataContext = type;
                return(obj);
            }
            return(null);
        }
Ejemplo n.º 2
0
    private static SymbolComparationResult CalculateValueOfSymbolsDifference(SymbolTemplate example, List <Vector3> playersShapePoints)
    {
        List <float>            distancesBetweenClosestPoints = GetDistancesBetweenClosestPointsOfLists(example.Points, playersShapePoints);
        float                   averageDistance = MathHelper.CalculateAverageValue(distancesBetweenClosestPoints);
        float                   dispertion      = MathHelper.CalculateDispertionValue(distancesBetweenClosestPoints, averageDistance);
        const int               coefficientToMakeResultReadable = 100;
        float                   comparationResultValue          = dispertion * Mathf.Pow(averageDistance, 3) * coefficientToMakeResultReadable;
        SymbolComparationResult comparationResult = new SymbolComparationResult(example.Type, comparationResultValue);

        return(comparationResult);
    }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is SymbolTemplate))
            {
                return(value);
            }

            SymbolTemplate symbolTemplate = value as SymbolTemplate;

            if (symbolTemplate.Symbol == null)
            {
                return(null);
            }
            Symbol convertedSymbol = symbolTemplate.Symbol;

            if (symbolTemplate.FeatureTemplate == null)
            {
                return(convertedSymbol);
            }

            FeatureTemplate featureTemplate = symbolTemplate.FeatureTemplate;

            if (symbolTemplate.Symbol is FSSymbols.SimpleFillSymbol ||
                symbolTemplate.Symbol is FSSymbols.PictureFillSymbol ||
                symbolTemplate.Symbol is FSSymbols.SimpleLineSymbol)
            {
                switch (featureTemplate.DrawingTool)
                {
                case FeatureEditTool.Polygon:
                    convertedSymbol = new PolygonSymbol();
                    break;

                case FeatureEditTool.AutoCompletePolygon:
                    convertedSymbol = new AutoCompletePolygonSymbol();
                    break;

                case FeatureEditTool.Circle:
                    convertedSymbol = new CircleSymbol();
                    break;

                case FeatureEditTool.Ellipse:
                    convertedSymbol = new EllipseSymbol();
                    break;

                case FeatureEditTool.Rectangle:
                    convertedSymbol = new RectangleSymbol();
                    break;

                case FeatureEditTool.Freehand:
                    if (symbolTemplate.Symbol is FSSymbols.SimpleLineSymbol)
                    {
                        convertedSymbol = new FreehandLineSymbol();
                    }
                    else
                    {
                        convertedSymbol = new FreehandPolygonSymbol();
                    }
                    break;

                case FeatureEditTool.Line:
                    convertedSymbol = new PolylineSymbol();
                    break;
                }

                if (convertedSymbol is ShapeMarkerSymbol)
                {
                    ShapeMarkerSymbol shapeMarkerSymbol = convertedSymbol as ShapeMarkerSymbol;
                    FillMarkerSymbol  fillMarkerSymbol  = convertedSymbol as FillMarkerSymbol;
                    if (symbolTemplate.Symbol is FSSymbols.SimpleFillSymbol)
                    {
                        ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleFillSymbol simpleFillSymbol =
                            symbolTemplate.Symbol as FSSymbols.SimpleFillSymbol;
                        fillMarkerSymbol.Stroke          = simpleFillSymbol.BorderBrush;
                        fillMarkerSymbol.Fill            = simpleFillSymbol.Fill;
                        fillMarkerSymbol.StrokeStyle     = simpleFillSymbol.BorderStyle;
                        fillMarkerSymbol.StrokeThickness = simpleFillSymbol.BorderThickness;
                        shapeMarkerSymbol.SelectionColor = simpleFillSymbol.SelectionColor;
                    }
                    else if (symbolTemplate.Symbol is FSSymbols.PictureFillSymbol)
                    {
                        ESRI.ArcGIS.Client.FeatureService.Symbols.PictureFillSymbol pictureFillSymbol =
                            symbolTemplate.Symbol as FSSymbols.PictureFillSymbol;
                        fillMarkerSymbol.Stroke          = pictureFillSymbol.BorderBrush;
                        fillMarkerSymbol.StrokeStyle     = pictureFillSymbol.BorderStyle;
                        fillMarkerSymbol.StrokeThickness = pictureFillSymbol.BorderThickness;
                        shapeMarkerSymbol.SelectionColor = pictureFillSymbol.SelectionColor;

                        // Create new image brush for fill in order to set stretch to Uniform
                        ImageBrush brush = new ImageBrush()
                        {
                            Stretch     = Stretch.Uniform,
                            ImageSource = pictureFillSymbol.Source
                        };
                        fillMarkerSymbol.Fill = brush;
                    }
                    else if (symbolTemplate.Symbol is FSSymbols.SimpleLineSymbol)
                    {
                        ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleLineSymbol simpleLineSymbol =
                            symbolTemplate.Symbol as FSSymbols.SimpleLineSymbol;
                        shapeMarkerSymbol.Stroke          = simpleLineSymbol.Color;
                        shapeMarkerSymbol.StrokeStyle     = simpleLineSymbol.Style;
                        shapeMarkerSymbol.StrokeThickness = simpleLineSymbol.Width;
                        shapeMarkerSymbol.SelectionColor  = simpleLineSymbol.SelectionColor;

                        if (fillMarkerSymbol != null)
                        {
                            fillMarkerSymbol.Fill = new SolidColorBrush(Colors.Transparent);
                        }
                    }
                }
            }

            return(convertedSymbol);
        }