Пример #1
0
 static Tuple<string, VoidDelegate> ColorChangeMenuTuple(AttributeBase attr) {
     return new Tuple<string, VoidDelegate>("set color", () => {
         var dialog = new ColorDialog();
         if (dialog.ShowDialog() == DialogResult.OK) {
             var color = dialog.Color;
             attr.Color = new Color(color.A, color.R, color.G, color.B);
         }
     });
 }
 void WriteStroke(AttributeBase attr)
 {
     WriteAttribute("stroke", MsaglColorToSvgColor(attr.Color));
     WriteAttribute("stroke-opacity", MsaglColorToSvgOpacity(attr.Color));
     WriteAttribute("stroke-width", attr.LineWidth);
 }
Пример #3
0
 Tuple<string, VoidDelegate>[] ChangeColorDialog(AttributeBase attr) {
     return new[] {ColorChangeMenuTuple(attr)};
 }
Пример #4
0
 static Tuple<string, VoidDelegate> ColorChangeMenuTuple(AttributeBase attr) {
     return new Tuple<string, VoidDelegate>("set color", () => {
         var dialog = new System.Windows.Forms.ColorDialog();
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
             var color = dialog.Color;
             attr.Color = new Microsoft.Msagl.Drawing.Color(color.A, color.R, color.G, color.B);
         }
     });
 }
 void DrawArrowPolygon(AttributeBase attr, Point[] points)
 {
     WriteStartElement("polygon");
     WriteStroke(attr);
     var edgeAttr = attr as EdgeAttr;
     if (edgeAttr != null)
     {
         WriteAttribute("fill", "#000000");
     }
     else
     {
         var nodeAttr = attr as NodeAttr;
         if (nodeAttr != null)
             WriteFill(nodeAttr);
     }
     WriteAttribute("points", PointsToString(points));
     WriteEndElement();
 }
 private void WriteBaseAttr(AttributeBase baseAttr) {
     WriteStartElement(Tokens.BaseAttr);
     WriteStyles(baseAttr.Styles);
     WriteColorElement(Tokens.Color, baseAttr.Color);
     WriteStringElement(Tokens.LineWidth, baseAttr.LineWidth);
     WriteStringElement(Tokens.ID, baseAttr.Id == null ? "" : baseAttr.Id);
     WriteEndElement();
 }
 static void AddStyles(AttributeBase a, object o)
 {
     if (o is Styles)
     {
         Styles styles = o as Styles;
         foreach (var s in styles.styles)
         {
             a.AddStyle(s);
         }
         if (styles.lineWidth != 0) 
         {
             a.LineWidth = styles.lineWidth;
         }
     }
 }
 private void ReadStyles(AttributeBase baseAttr) {
     CheckToken(Tokens.Styles);
     XmlRead();
     bool haveStyles = false;
     while (TokenIs(Tokens.Style)) {
         baseAttr.AddStyle((Style)Enum.Parse(typeof(Style), ReadStringElement(Tokens.Style), false));
         haveStyles = true;
     }
     if (haveStyles)
         ReadEndElement();
 }
 private void ReadBaseAttr(AttributeBase baseAttr) {
     CheckToken(Tokens.BaseAttr);
     XmlRead();
     ReadStyles(baseAttr);
     baseAttr.Color = ReadColorElement(Tokens.Color);
     baseAttr.LineWidth = ReadDoubleElement(Tokens.LineWidth);
     baseAttr.Id = ReadStringElement(Tokens.ID);
     ReadEndElement();
 }
Пример #10
0
        void GViewerObjectUnderMouseCursorChanged(object sender, ObjectUnderMouseCursorChangedEventArgs e)
        {
            selectedObject = e.OldObject != null ? e.OldObject.DrawingObject : null;

            if (selectedObject != null) {
                RestoreSelectedObjAttr();
                gViewer.Invalidate(e.OldObject);
                selectedObject = null;
            }

            if (gViewer.SelectedObject == null) {
                label1.Text = "No object under the mouse";
                gViewer.SetToolTip(toolTip1, "");
            } else {
                selectedObject = gViewer.SelectedObject;
                var edge = selectedObject as Edge;
                if (edge != null) {
                    selectedObjectAttr = edge.Attr.Clone();
                   edge.Attr.Color = Color.Blue;
                    gViewer.Invalidate(e.NewObject);

               //         here we can use e.Attr.Id or e.UserData to get back to the user data
                    gViewer.SetToolTip(toolTip1, String.Format("edge from {0} to {1}", edge.Source, edge.Target));
                } else if (selectedObject is Microsoft.Msagl.Drawing.Node) {
                    selectedObjectAttr = (gViewer.SelectedObject as Microsoft.Msagl.Drawing.Node).Attr.Clone();
                    (selectedObject as Microsoft.Msagl.Drawing.Node).Attr.Color = Color.Green;
                 // //   here you can use e.Attr.Id to get back to your data
                    gViewer.SetToolTip(toolTip1,
                                       String.Format("node {0}",
                                                     (selectedObject as Microsoft.Msagl.Drawing.Node).Attr.Id));
                    gViewer.Invalidate(e.NewObject);
                }
                label1.Text = selectedObject.ToString();
            }
        }