public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    BorderTextureViewModel border = TextureBorderHelperClass.GetTextureViewModel(origVertex, angle);

                    string texture = border.Texture;

                    if ((texture == "") || (texture == "notDefined"))
                    {
                        return(null);
                    }

                    string s            = GlobalConstants.ImageDirectory + texture + ".png";
                    string fullPath     = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    string fullFileName = System.IO.Path.Combine(fullPath, s);

                    return(new BitmapImage(new Uri(fullFileName)));
                }
            }

            return(null);
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    BorderTextureViewModel border = TextureBorderHelperClass.GetTextureViewModel(origVertex, angle);
                    Vector offset = TextureBorderHelperClass.GetOffset(origVertex, currP, prevP, angle);

                    if (parameter as string == "x")
                    {
                        return(offset.X);
                    }
                    else
                    {
                        return(offset.Y);
                    }
                }
            }

            return(null);
        }
示例#3
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    double shapeAngle = 0;

                    if (origVertex.Parent is LfShapeViewModel)
                    {
                        LfShapeViewModel shape = origVertex.Parent as LfShapeViewModel;

                        shapeAngle = shape.Angle;
                    }

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    return((angle - shapeAngle) / Math.PI * 180);
                }
            }

            return(null);
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 4)
            {
                if ((values[0] is double) && (values[1] is double) &&
                    (values[2] is double) && (values[3] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[3];
                    double shapeAngle = (double)values[2];

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    return(angle + shapeAngle);
                }
            }

            return(null);
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    BorderTextureViewModel border = TextureBorderHelperClass.GetTextureViewModel(origVertex, angle);

                    Rect r = new Rect(0, 0, border.TextureWidth, border.TextureHeight);

                    return(r);
                }
            }

            return(null);
        }
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values.Count() == 3)
            {
                if ((values[0] is double) && (values[1] is double) && (values[2] is LfDragablePointViewModel))
                {
                    LfDragablePointViewModel origVertex = (LfDragablePointViewModel)values[2];

                    Point  currP = TextureBorderHelperClass.GetOriginalPoint(origVertex);
                    Point  prevP = TextureBorderHelperClass.GetPreviousPoint(origVertex);
                    double angle = TextureBorderHelperClass.GetAngle(origVertex, currP, prevP);
                    BorderTextureViewModel border = TextureBorderHelperClass.GetTextureViewModel(origVertex, angle);

                    if ((border.Texture == "") || (border.Texture == "notDefined"))
                    {
                        return(Visibility.Collapsed);
                    }

                    return(Visibility.Visible);
                }
            }

            return(null);
        }