Esempio n. 1
0
 public ViewBox(float minx, float miny, float width, float height)
 {
     this.psr = new PreserveAspectRatio();
     this.min_x = minx;
     this.min_y = miny;
     this.width = width;
     this.height = height;
 }
Esempio n. 2
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     return(ImageData.GetHashCode() ^ (ImageWidth.GetHashCode() << 1) ^
            ((ImageHeight.GetHashCode() + 1) << 2) ^
            ((PreserveAspectRatio.GetHashCode() + 1) << 10) ^
            ((WrapMode.GetHashCode() + 1) << 20) ^
            ((ImageOffsetX.GetHashCode() + 1) << 40) ^
            ((ImageOffsetY.GetHashCode() + 1) << 60));
 }
Esempio n. 3
0
 public static ViewBox ParseViewBox(XmlElement node)
 {
     ViewBox box1 = null;
     XmlAttribute attribute1 = node.Attributes["viewBox"];
     if (attribute1 != null)
     {
         string text1 = attribute1.Value.Trim();
         char[] chArray1 = new char[2] { ',', ' ' } ;
         string[] textArray1 = text1.Trim().Split(chArray1);
         if (textArray1.Length >= 4)
         {
             NumberFormatInfo info1 = new NumberFormatInfo();
             info1.NumberDecimalSeparator = ".";
             try
             {
                 float single1 = float.Parse(textArray1[0], info1);
                 float single2 = float.Parse(textArray1[1], info1);
                 float single3 = float.Parse(textArray1[2], info1);
                 float single4 = float.Parse(textArray1[3], info1);
                 box1 = new ViewBox(single1, single2, single3, single4);
             }
             catch (Exception)
             {
             }
         }
     }
     attribute1 = node.Attributes["preserveAspectRatio"];
     if ((attribute1 != null) && (box1 != null))
     {
         string text5;
         string text2 = attribute1.Value.Trim();
         char[] chArray2 = new char[2] { ' ', ',' } ;
         string[] textArray2 = text2.Trim().Split(chArray2);
         string text3 = string.Empty;
         string text4 = string.Empty;
         PreserveAspectRatio ratio1 = null;
         parAlign align1 = parAlign.none;
         parMeetOrSlice slice1 = parMeetOrSlice.meet;
         if (textArray2.Length >= 1)
         {
             text3 = textArray2[0].Trim();
         }
         else if (textArray2.Length >= 2)
         {
             text4 = textArray2[1].Trim();
         }
         if ((text3 != string.Empty) && ((text5 = text3.Trim().ToLower()) != null))
         {
             text5 = string.IsInterned(text5);
             if (text5 != "xminymin")
             {
                 if (text5 == "xmidymin")
                 {
                     align1 = parAlign.xMidYMin;
                 }
                 else if (text5 == "xminymid")
                 {
                     align1 = parAlign.xMinYMid;
                 }
                 else if (text5 == "xmidymid")
                 {
                     align1 = parAlign.xMidYMid;
                 }
                 else if (text5 == "xmaxymid")
                 {
                     align1 = parAlign.xMaxYMid;
                 }
                 else if (text5 == "xminymax")
                 {
                     align1 = parAlign.xMinYMax;
                 }
                 else if (text5 == "xmidymax")
                 {
                     align1 = parAlign.xMidYMax;
                 }
                 else if (text5 == "xmaxymax")
                 {
                     align1 = parAlign.xMaxYMax;
                 }
             }
             else
             {
                 align1 = parAlign.xMaxYMin;
             }
         }
         if (text4 != string.Empty)
         {
             if (text4.Trim().ToLower() == "meet")
             {
                 slice1 = parMeetOrSlice.meet;
             }
             else if (text4.Trim().ToLower() == "slice")
             {
                 slice1 = parMeetOrSlice.slice;
             }
         }
         ratio1 = new PreserveAspectRatio(align1, slice1);
         box1.psr = ratio1;
     }
     return box1;
 }
Esempio n. 4
0
        public static ViewBox ParseViewBox(XmlElement node)
        {
            ViewBox      box1       = null;
            XmlAttribute attribute1 = node.Attributes["viewBox"];

            if (attribute1 != null)
            {
                string text1    = attribute1.Value.Trim();
                char[] chArray1 = new char[2] {
                    ',', ' '
                };
                string[] textArray1 = text1.Trim().Split(chArray1);
                if (textArray1.Length >= 4)
                {
                    NumberFormatInfo info1 = new NumberFormatInfo();
                    info1.NumberDecimalSeparator = ".";
                    try
                    {
                        float single1 = float.Parse(textArray1[0], info1);
                        float single2 = float.Parse(textArray1[1], info1);
                        float single3 = float.Parse(textArray1[2], info1);
                        float single4 = float.Parse(textArray1[3], info1);
                        box1 = new ViewBox(single1, single2, single3, single4);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            attribute1 = node.Attributes["preserveAspectRatio"];
            if ((attribute1 != null) && (box1 != null))
            {
                string text5;
                string text2    = attribute1.Value.Trim();
                char[] chArray2 = new char[2] {
                    ' ', ','
                };
                string[]            textArray2 = text2.Trim().Split(chArray2);
                string              text3      = string.Empty;
                string              text4      = string.Empty;
                PreserveAspectRatio ratio1     = null;
                parAlign            align1     = parAlign.none;
                parMeetOrSlice      slice1     = parMeetOrSlice.meet;
                if (textArray2.Length >= 1)
                {
                    text3 = textArray2[0].Trim();
                }
                else if (textArray2.Length >= 2)
                {
                    text4 = textArray2[1].Trim();
                }
                if ((text3 != string.Empty) && ((text5 = text3.Trim().ToLower()) != null))
                {
                    text5 = string.IsInterned(text5);
                    if (text5 != "xminymin")
                    {
                        if (text5 == "xmidymin")
                        {
                            align1 = parAlign.xMidYMin;
                        }
                        else if (text5 == "xminymid")
                        {
                            align1 = parAlign.xMinYMid;
                        }
                        else if (text5 == "xmidymid")
                        {
                            align1 = parAlign.xMidYMid;
                        }
                        else if (text5 == "xmaxymid")
                        {
                            align1 = parAlign.xMaxYMid;
                        }
                        else if (text5 == "xminymax")
                        {
                            align1 = parAlign.xMinYMax;
                        }
                        else if (text5 == "xmidymax")
                        {
                            align1 = parAlign.xMidYMax;
                        }
                        else if (text5 == "xmaxymax")
                        {
                            align1 = parAlign.xMaxYMax;
                        }
                    }
                    else
                    {
                        align1 = parAlign.xMaxYMin;
                    }
                }
                if (text4 != string.Empty)
                {
                    if (text4.Trim().ToLower() == "meet")
                    {
                        slice1 = parMeetOrSlice.meet;
                    }
                    else if (text4.Trim().ToLower() == "slice")
                    {
                        slice1 = parMeetOrSlice.slice;
                    }
                }
                ratio1   = new PreserveAspectRatio(align1, slice1);
                box1.psr = ratio1;
            }
            return(box1);
        }
Esempio n. 5
0
        public override void Draw(Graphics g, int time)
        {
            float  single5;
            float  single6;
            float  single7;
            float  single8;
            float  single11;
            float  single12;
            float  single13;
            Matrix matrix1;

            ItopVector.Core.Types.ViewBox box1 = null;
            if (this.pretime != base.OwnerDocument.ControlTime)
            {
                box1         = TypeFunc.ParseViewBox(this);
                this.ViewBox = box1;
            }
            box1 = this.ViewBox;
            parAlign       align1  = parAlign.none;
            parMeetOrSlice slice1  = parMeetOrSlice.slice;
            float          single1 = this.Width;
            float          single2 = this.Height;
            float          single3 = 0f;
            float          single4 = 0f;

            if (box1 != null)
            {
                single1 = box1.width;
                single2 = box1.height;
                single3 = box1.min_x;
                single4 = box1.min_y;
                PreserveAspectRatio ratio1 = box1.psr;
                align1 = ratio1.Align;
                slice1 = ratio1.Mos;
            }
            float             single9    = this.width / single1;
            float             single10   = this.height / single2;
            GraphicsContainer container1 = g.BeginContainer();

            g.SmoothingMode = base.OwnerDocument.SmoothingMode;
            if (single9 >= single10)
            {
                single12 = single9;
                single13 = single10;
            }
            else
            {
                single12 = single10;
                single13 = single9;
            }
            if (slice1 == parMeetOrSlice.meet)
            {
                single11 = single13;
                single7  = single1 * single11;
                single8  = single2 * single11;
                switch (align1)
                {
                case parAlign.xMinYMin:
                {
                    single5 = this.X - single3;
                    single6 = this.Y - single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMin:
                {
                    single5 = ((this.Width - single7) / 2f) - single3;
                    single6 = this.Y - single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMin:
                {
                    single5 = (this.Width - single7) - single3;
                    single6 = this.Y - single4;
                    goto Label_03D1;
                }

                case parAlign.xMinYMid:
                {
                    single5 = this.X - single3;
                    single6 = ((this.Height - single8) / 2f) - single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMid:
                {
                    single5 = ((this.Width - single7) / 2f) - single3;
                    single6 = ((this.Height - single8) / 2f) - single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMid:
                {
                    single5 = (this.Width - single7) - single3;
                    single6 = ((this.Height - single8) / 2f) - single4;
                    goto Label_03D1;
                }

                case parAlign.xMinYMax:
                {
                    single5 = this.X - single3;
                    single6 = (this.Height - single8) - single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMax:
                {
                    single5 = ((this.Width - single7) / 2f) - single3;
                    single6 = (this.Height - single8) - single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMax:
                {
                    single5 = (this.Width - single7) - single3;
                    single6 = (this.Height - single8) - single4;
                    goto Label_03D1;
                }
                }
                single5 = this.X - single3;
                single6 = this.Y - single4;
                single7 = single1;
                single8 = single2;
            }
            else
            {
                single11 = single12;
                single7  = this.Width / single11;
                single8  = this.Height / single11;
                switch (align1)
                {
                case parAlign.xMinYMin:
                {
                    single5 = this.X + single3;
                    single6 = this.Y + single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMin:
                {
                    single5 = ((single1 - single7) / 2f) + single3;
                    single6 = this.Y + single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMin:
                {
                    single5 = (single1 - single7) + single3;
                    single6 = this.Y + single4;
                    goto Label_03D1;
                }

                case parAlign.xMinYMid:
                {
                    single5 = this.X + single3;
                    single6 = ((single2 - single8) / 2f) + single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMid:
                {
                    single5 = ((single1 - single7) / 2f) + single3;
                    single6 = ((single2 - single8) / 2f) + single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMid:
                {
                    single5 = (single1 - single7) + single3;
                    single6 = ((single2 - single8) / 2f) + single4;
                    goto Label_03D1;
                }

                case parAlign.xMinYMax:
                {
                    single5 = this.X + single3;
                    single6 = (single2 - single8) + single4;
                    goto Label_03D1;
                }

                case parAlign.xMidYMax:
                {
                    single5 = ((single1 - single7) / 2f) + single3;
                    single6 = (single2 - single8) + single4;
                    goto Label_03D1;
                }

                case parAlign.xMaxYMax:
                {
                    single5 = (single1 - single7) + single3;
                    single6 = (single2 - single8) + single4;
                    goto Label_03D1;
                }
                }
                single5 = this.X + single3;
                single6 = this.Y + single4;
                single7 = single1;
                single8 = single2;
            }
Label_03D1:
            matrix1 = base.GraphTransform.Matrix;
            if ((this.Width != 0f) && (this.Height != 0f))
            {
                float single14 = this.width / single7;
                float single15 = this.height / single8;
//                g.ScaleTransform(single14, single15);
                matrix1.Scale(single14, single15);
            }
            if (base.OwnerDocument.DocumentElement == this)
            {
//              g.TranslateTransform(single5, single6);
                matrix1.Translate(single5, single6);
            }
            else
            {
//                g.TranslateTransform(single5 - this.x, single6 - this.y);
                matrix1.Translate(single5 - this.x, single6 - this.y);
            }
            foreach (Layer layer in OwnerDocument.Layers)
            {
                if (!layer.Visible)
                {
                    continue;
                }

                SvgElementCollection.ISvgElementEnumerator enumerator1 = layer.GraphList.GetEnumerator();
                contectbounds = RectangleF.Empty;
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph)enumerator1.Current;
                    graph1.ShowConnectPoints = base.OwnerDocument.ShowConnectPoints;
                    try
                    {
                        //						if(graph1.LimitSize)
                        //						{
                        //							PointF [] points = {new PointF( matrix1.OffsetX,matrix1.OffsetY)};
                        //							matrix1.TransformVectors(points);
                        //							graph1.GraphTransform.Matrix = new Matrix(1,0,0,1,points[0].X,points[0].Y);
                        //						}
                        //						else
                        graph1.GraphTransform.Matrix = matrix1.Clone();
                        using (Matrix matrix2 = new Matrix())
                        {
                            if (graph1 is ConnectLine)
                            {
                                graph1.Draw(g, time); continue;
                            }
                            matrix2.Multiply(matrix1, MatrixOrder.Prepend);
                            matrix2.Multiply(graph1.Transform.Matrix, MatrixOrder.Prepend);
                            //(graph1 as ConnectLine).UpatePath(g);
                            RectangleF rtf1 = graph1.GPath.GetBounds(matrix2);
                            if (!(graph1 is Text))
                            {
                                rtf1.Width++; rtf1.Height++;
                            }
                            if (g.IsVisible(rtf1) || (rtf1 == RectangleF.Empty) || (graph1 is ConnectLine && graph1.GPath.PointCount == 0))
                            {
                                graph1.Draw(g, time);
                            }
                            else
                            {
                                graph1.GraphTransform.Matrix.Multiply(graph1.Transform.Matrix, MatrixOrder.Prepend);
#if debug
                                int i = 0;
                                i++;
#endif
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                    finally
                    {
                        graph1 = null;
                    }
                }
            }
            this.pretime = time;
            g.EndContainer(container1);
        }
Esempio n. 6
0
 // Methods
 public ViewBox()
 {
     this.psr = new PreserveAspectRatio();
 }