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);
        }
        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);
        }
Exemplo n.º 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 static Vector GetOffset(LfDragablePointViewModel myPoint, Point origP, Point prevP, double angle)
        {
            Vector diffV                  = origP - prevP;
            double distance               = diffV.Length;
            Vector rotatedNormal          = new Vector(-Math.Sin(angle * Math.PI / 180), Math.Cos(angle * Math.PI / 180));
            BorderTextureViewModel border = TextureBorderHelperClass.GetTextureViewModel(myPoint, angle);
            Vector offset                 = -rotatedNormal * border.HorisontalOffset;

            return(offset);
        }
        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);
                    Vector v     = (currP - prevP);
                    return(v.Length);
                }
            }

            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);
        }