예제 #1
0
        /// <summary>
        /// Updates the layout of the Field that the controller manages.
        /// </summary>
        protected virtual void UpdateLayout()
        {
            titleLabel.Top    = 3;
            titleLabel.Width  = this.Width - (2 * 3);
            titleLabel.Left   = 3;
            titleLabel.Height = StringMeasure.Measure(titleLabel, titleLabel.Text, titleLabel.ClientRectangle).Height;

            if (Content != null)
            {
                Content.Width = this.Width - (2 * 3);
                Content.Left  = 3;
                Content.Top   = titleLabel.Top + titleLabel.Height + 3;
            }

            errorPanel.Width  = this.Width;
            errorPanel.Height = Content != null? Content.Top + Content.Height + 3 : 0;

            if (enabled)
            {
                descriptionLabel.Width  = this.Width - (2 * 3);
                descriptionLabel.Left   = 3;
                descriptionLabel.Top    = errorPanel.Top + errorPanel.Height + 2;
                descriptionLabel.Height = StringMeasure.Measure(descriptionLabel, descriptionLabel.Text, descriptionLabel.ClientRectangle).Height;

                this.Height = descriptionLabel.Height + errorPanel.Height + 3;
                if (String.IsNullOrEmpty(descriptionLabel.Text))
                {
                    this.Height -= 3;
                }
            }
            else
            {
                this.Height = errorPanel.Height;
            }
        }
예제 #2
0
        static Graph CtreateDrawingGraph(out FastIncrementalLayoutSettings settings)
        {
            settings = new FastIncrementalLayoutSettings {
                RouteEdges = true, NodeSeparation = 30
            };
            var drawingGraph = new Graph();

            AddEdge(drawingGraph, "0", "1");
            AddEdge(drawingGraph, "0", "2");
            AddEdge(drawingGraph, "1", "3");
            AddEdge(drawingGraph, "2", "4");
            AddEdge(drawingGraph, "2", "5");
            AddEdge(drawingGraph, "2", "6");
            AddEdge(drawingGraph, "5", "7");
            AddEdge(drawingGraph, "5", "6");
            AddEdge(drawingGraph, "7", "8");
            AddEdge(drawingGraph, "8", "6");


            drawingGraph.CreateGeometryGraph();
            foreach (DrawingNode node in drawingGraph.Nodes)
            {
                double w, h;
                var    label = node.Label;
                var    font  = new Font(label.FontName, (float)label.FontSize);
                StringMeasure.MeasureWithFont(label.Text, font, out w, out h);
                node.Label.Width  = w;
                node.Label.Height = h;
                node.Attr.Shape   = Shape.DrawFromGeometry;
                node.GeometryNode.BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(1.2 * w, 1.2 * h, 3, 3, new Point());
            }

            return(drawingGraph);
        }
예제 #3
0
            void CreateNodeGeometry(DrawingNode node, Graph graph, GeometryGraph geometryGraph, GeometryPoint center, ConnectionToGraph connectionTo = ConnectionToGraph.Connected)
            {
                double width, height;

                StringMeasure.MeasureWithFont(node.Label.Text, new Font(node.Label.FontName, (float)node.Label.FontSize, (System.Drawing.FontStyle)(int) node.Label.FontStyle), out width,
                                              out height);

                node.Label.Width  = width;
                node.Label.Height = height;

                if (node.Label != null)
                {
                    width  += 2 * node.Attr.LabelMargin;
                    height += 2 * node.Attr.LabelMargin;
                }
                if (width < graph.Attr.MinNodeWidth)
                {
                    width = graph.Attr.MinNodeWidth;
                }
                if (height < graph.Attr.MinNodeHeight)
                {
                    height = graph.Attr.MinNodeHeight;
                }

                Node geomNode =
                    node.GeometryNode =
                        GeometryGraphCreator.CreateGeometryNode(graph, geometryGraph, node, connectionTo);

                geomNode.BoundaryCurve = NodeBoundaryCurves.GetNodeBoundaryCurve(node, width, height);
                geomNode.BoundaryCurve.Translate(center);
                geomNode.Center = center;
            }
예제 #4
0
        /// <summary>
        /// Show the notification on the screen
        /// </summary>
        /// <param name="info">the <see cref="FormInfo"/> object that contein information about the form</param>
        public void ShowNotification(FormRequestInfo info)
        {
            this.formInfo = info;

            name.Text        = info.CompilationRequestId.ToString();
            notified.Text    = info.Time.ToString(ResourceManager.Instance.Culture);
            from.Text        = info.From;
            fromPanel.Height = Math.Max(StringMeasure.Measure(from, info.From == null? "" : info.From, from.Bounds).Height, fromLabel.Height);

            if (info.Username == null || info.Username == "")
            {
                type.Text = "Public";
                usernamePanel.Hide();
                servicePanel.Hide();
                tokenPanel.Hide();
                contentPanel.Height = 146;
            }
            else
            {
                type.Text     = "Private";
                username.Text = info.Username;
                usernamePanel.Show();
                service.Text = info.Service;
                servicePanel.Show();
                token.Text = info.Token;
                tokenPanel.Show();
                contentPanel.Height = 212;
            }
        }
예제 #5
0
        private void CreateBoundaryCurve(Microsoft.Msagl.Drawing.Node node)
        {
            double w, h;
            var    label = node.Label;
            var    font  = new Font(label.FontName, (float)label.FontSize);

            StringMeasure.MeasureWithFont(label.Text, font, out w, out h);
            node.Label.Width  = w;
            node.Label.Height = h;
            node.Attr.Shape   = Shape.DrawFromGeometry;
            node.GeometryNode.BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(1.2 * w, 1.2 * h, 3, 3, new Microsoft.Msagl.Core.Geometry.Point());
        }
예제 #6
0
        private static void SetNodeBoundary(Microsoft.Msagl.Drawing.Node drawingNode)
        {
            var font = new System.Drawing.Font(drawingNode.Label.FontName, (float)drawingNode.Label.FontSize);

            StringMeasure.MeasureWithFont(drawingNode.LabelText, font, out double width, out double height);
            drawingNode.Label.GeometryLabel        = new Microsoft.Msagl.Core.Layout.Label();
            drawingNode.Label.GeometryLabel.Width  = width;
            drawingNode.Label.GeometryLabel.Height = width;
            drawingNode.Label.Width  = width;
            drawingNode.Label.Height = height;
            int r = drawingNode.Attr.LabelMargin;

            drawingNode.GeometryNode.BoundaryCurve = CurveFactory.CreateRectangleWithRoundedCorners(width + r * 2, height + r * 2, r, r, new Point());
        }
        static ICurve CreateLabelAndBoundary(Node node)
        {
            node.Attr.Shape        = Shape.DrawFromGeometry;
            node.Attr.LabelMargin *= 2;
            double width;
            double height;

            StringMeasure.MeasureWithFont(node.Label.Text,
                                          new Font(node.Label.FontName, (float)node.Label.FontSize), out width, out height);
            node.Label.Width  = width;
            node.Label.Height = height;
            int r = node.Attr.LabelMargin;

            return(CurveFactory.CreateRectangleWithRoundedCorners(width + r * 2, height + r * 2, r, r, new Point()));
        }
예제 #8
0
        private static void InitNodeBoundary(Node node)
        {
            double width  = 0;
            double height = 0;

            if (node.Label != null)
            {
                var font = new Font(node.Label.FontName, (float)node.Label.FontSize);
                StringMeasure.MeasureWithFont(node.LabelText, font, out width, out height);
            }
            if (width <= 0)
            {
                StringMeasure.MeasureWithFont("a", new Font("New Courer", 10), out width, out height);
            }

            node.GeometryNode.BoundaryCurve = CurveFactory.CreateEllipse(width / 2, height / 2, new Point());
        }
예제 #9
0
        private void MisureString()
        {
            this.Font = new Font("Tahoma", 7F, FontStyle.Regular);
            Label test = new Label();

            test.Text = this.Text;
            test.Font = this.Font;
            float count = test.Font.Size;

            do
            {
                wstring   = StringMeasure.Measure(test, test.Text, test.ClientRectangle).Width;
                this.Font = test.Font;
                count--;
                test.Font = new Font("Tahoma", count, FontStyle.Regular);
            } while (wstring >= this.Size.Width);
            test.Dispose();
        }
예제 #10
0
        DrawingLabel CreateLabel(DrawingEdge edge, string rel)
        {
            DrawingLabel label = new DrawingLabel
            {
                Text      = rel,
                FontName  = "Times-Roman",
                FontColor = Styles.RELATION_LABEL_COLOR.ToMsAgl(),
                FontStyle = Microsoft.Msagl.Drawing.FontStyle.Regular,
                FontSize  = 4,
                Owner     = edge,
            };

            double width, height;

            StringMeasure.MeasureWithFont(rel, new Font(label.FontName, (float)label.FontSize, (System.Drawing.FontStyle)(int) label.FontStyle), out width,
                                          out height);
            label.Width  = width;
            label.Height = height;

            return(label);
        }
예제 #11
0
        void GViewerOnMouseMove(object sender, MouseEventArgs mouseEventArgs)
        {
            if (labelToChange == null)
            {
                return;
            }
            labelToChange.Text = MousePosition.ToString();
            if (viewerEntityCorrespondingToLabelToChange == null)
            {
                foreach (var e in gViewer.Entities)
                {
                    if (e.DrawingObject == labelToChange)
                    {
                        viewerEntityCorrespondingToLabelToChange = e;
                        break;
                    }
                }
            }
            if (viewerEntityCorrespondingToLabelToChange == null)
            {
                return;
            }
            var    rect = labelToChange.BoundingBox;
            var    font = new Font(labelToChange.FontName, (int)labelToChange.FontSize);
            double width;
            double height;

            StringMeasure.MeasureWithFont(labelToChange.Text, font, out width, out height);

            if (width <= 0)
            {
                //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " "
                StringMeasure.MeasureWithFont("a", font, out width, out height);
            }

            labelToChange.Width  = width;
            labelToChange.Height = height;
            rect.Add(labelToChange.BoundingBox);
            gViewer.Invalidate(gViewer.MapSourceRectangleToScreenRectangle(rect));
        }
예제 #12
0
        private static ICurve GetNodeBoundary(DrawingNode node)
        {
            double width;
            double height;
            var    font = new Font(node.Label.FontName, (float)node.Label.FontSize, (System.Drawing.FontStyle)(int) node.Label.FontStyle);

            StringMeasure.MeasureWithFont(node.Label.Text, font, out width, out height);
            width  += node.Attr.LabelMargin * 2;
            height += node.Attr.LabelMargin * 2;
            if (width <= 0)
            {
                // Temporary fix for Win7 where Measure fonts return negative length for the string " ".
                StringMeasure.MeasureWithFont("a", font, out width, out height);
            }

            if ((node.UserData as NodeDisplaySettings).Icon != null)
            {
                width += kIconSize;
            }

            return(NodeBoundaryCurves.GetNodeBoundaryCurve(node, width, height));
        }
예제 #13
0
        void GViewerOnMouseMove(Edge edge, string value)
        {
            if (edge.Label == null)
            {
                return;
            }
            edge.Label.Text = value;

            var rect = edge.Label.BoundingBox;
            var font = new Font(edge.Label.FontName, (int)edge.Label.FontSize);

            StringMeasure.MeasureWithFont(edge.Label.Text, font, out double width, out double height);

            if (width <= 0)
            {
                StringMeasure.MeasureWithFont("a", font, out width, out height);
            }

            edge.Label.Width  = width;
            edge.Label.Height = height;
            rect.Add(edge.Label.BoundingBox);
            gViewer.Invalidate(gViewer.MapSourceRectangleToScreenRectangle(rect));
        }
예제 #14
0
        private void SetGraph()
        {
            var graph = new Graph();

            graph.AddEdge("a", "b");
            graph.AddEdge("e", "b");
            graph.AddEdge("d", "b");
            graph.AddEdge("b", "c");

            graph.AddEdge("a22", "b22");
            graph.AddEdge("e22", "b22");
            graph.AddEdge("d22", "b22");
            graph.AddEdge("b22", "c22");

            graph.AddEdge("a0", "b0");
            graph.AddEdge("b0", "c0");

            graph.AddEdge("a33", "b33");
            graph.AddEdge("e33", "b33");
            graph.AddEdge("d33", "b33");
            graph.AddEdge("b33", "c33");

            graph.AddEdge("a11", "b11");
            graph.AddEdge("b11", "c11").LabelText = "Test labels!";

            graph.CreateGeometryGraph();
            foreach (Node node in graph.Nodes)
            {
                node.GeometryNode.BoundaryCurve = CreateLabelAndBoundary(node);
            }

            foreach (var edge in graph.Edges)
            {
                if (edge.Label != null)
                {
                    var    geomEdge = edge.GeometryEdge;
                    double width;
                    double height;
                    StringMeasure.MeasureWithFont(edge.LabelText,
                                                  new Font(edge.Label.FontName, (float)edge.Label.FontSize), out width, out height);
                    edge.Label.GeometryLabel = geomEdge.Label = new Label(width, height, geomEdge);
                }
            }

            var geomGraph = graph.GeometryGraph;

            var geomGraphComponents = GraphConnectedComponents.CreateComponents(geomGraph.Nodes, geomGraph.Edges);
            var settings            = new SugiyamaLayoutSettings();

            foreach (var subgraph in geomGraphComponents)
            {
                var layout = new LayeredLayout(subgraph, settings);
                subgraph.Margins = settings.NodeSeparation / 2;
                layout.Run();
            }

            Microsoft.Msagl.Layout.MDS.MdsGraphLayout.PackGraphs(geomGraphComponents, settings);

            geomGraph.UpdateBoundingBox();


            gViewer1.NeedToCalculateLayout = false;
            gViewer1.Graph = graph;
        }