Пример #1
0
        void ProcessGexf(string fileName)
        {
            int    line, column;
            string msg;
            Graph  dgraph = GexfParser.Parse(fileName, out line, out column, out msg);

            if (dgraph != null)
            {
                SetLayoutSettings(dgraph);
                var  origin      = new Microsoft.Msagl.Core.Geometry.Point(0, 0);
                bool layoutExist = dgraph.GeometryGraph != null &&
                                   dgraph.GeometryGraph.Nodes.All(n => n.BoundaryCurve != null) &&
                                   dgraph.GeometryGraph.Nodes.Any(n => n.Center != origin);
                if (layoutExist && argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption) != null)
                {
                    dgraph.Write(argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption));
                    Console.WriteLine("saved to {0}", argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption));
                    Environment.Exit(0);
                }

                graphViewer.NeedToCalculateLayout = !layoutExist;

                graphViewer.Graph = dgraph;
                graphViewer.NeedToCalculateLayout = true;
            }
            else
            {
                MessageBox.Show(msg + String.Format(" line {0} column {1}", line, column));
            }
        }
Пример #2
0
        internal static void PositionElement(FrameworkElement fe, Rectangle object_box, Rectangle bounding_box, double scale)
        {
            Microsoft.Msagl.Core.Geometry.Point origin = bounding_box.Center;
            double desiredH = object_box.Height * scale - fe.Margin.Top - fe.Margin.Bottom,
                   desiredW = object_box.Width * scale + fe.Margin.Left + fe.Margin.Right;

            if (bounding_box.Height < desiredH)
            {
                origin.Y += object_box.Center.Y * scale - fe.Margin.Top;
            }
            else
            {
                if (fe.VerticalAlignment == VerticalAlignment.Top)
                {
                    origin.Y = bounding_box.Top;
                }
                else if (fe.VerticalAlignment == VerticalAlignment.Bottom)
                {
                    origin.Y -= bounding_box.Height / 2 - object_box.Height * scale;
                }
                else
                {
                    origin.Y += object_box.Center.Y * scale;
                }
            }
            if (bounding_box.Width < desiredW)
            {
                origin.X -= object_box.Center.X * scale;
            }
            else
            {
                if (fe.HorizontalAlignment == HorizontalAlignment.Left)
                {
                    origin.X -= bounding_box.Width / 2 - fe.Margin.Left;
                }
                else if (fe.HorizontalAlignment == HorizontalAlignment.Right)
                {
                    origin.X -= bounding_box.Width / 2 - object_box.Width * scale;
                }
                else
                {
                    origin.X -= object_box.Center.X * scale;
                }
            }
            PositionElement(fe, origin, scale);
        }
Пример #3
0
 internal static System.Windows.Point WpfPoint(Microsoft.Msagl.Core.Geometry.Point p)
 {
     return(new System.Windows.Point(p.X, p.Y));
 }
Пример #4
0
        void ProcessGexf(string fileName) {
            int line, column;
            string msg;
            Graph dgraph = GexfParser.Parse(fileName, out line, out column, out msg);
            if (dgraph != null) {
                SetLayoutSettings(dgraph);
                var origin = new Microsoft.Msagl.Core.Geometry.Point(0, 0);
                bool layoutExist = dgraph.GeometryGraph != null &&
                                   dgraph.GeometryGraph.Nodes.All(n => n.BoundaryCurve != null) &&
                                   dgraph.GeometryGraph.Nodes.Any(n => n.Center != origin);
                if (layoutExist && argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption) != null) {
                    dgraph.Write(argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption));
                    Console.WriteLine("saved to {0}", argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption));
                    Environment.Exit(0);
                }

                graphViewer.NeedToCalculateLayout = !layoutExist;

                graphViewer.Graph = dgraph;
                graphViewer.NeedToCalculateLayout = true;
            }
            else
                MessageBox.Show(msg + String.Format(" line {0} column {1}", line, column));
        }