public GoBasicNode InsertNode(PointF pt, string title, GoShape shape = null, int userFlag = 0, Object userObj = null) { if (shape == null) { shape = new GoRectangle(); } GoDocument doc = goView.Document; doc.StartTransaction(); GoBasicNode n = new GoBasicNode(); n.UserFlags = userFlag; n.UserObject = userObj; n.LabelSpot = GoObject.Middle; n.Text = title; n.Shape = shape; // specify the position and colors n.Location = pt; n.Brush = new SolidBrush(Color.White); n.Shape.PenColor = Color.Red; n.Shape.PenWidth = 2; // allow the user to edit the text in-place n.Label.Editable = true; doc.Add(n); doc.FinishTransaction("Insert node finished"); return(n); }
private Lifeline GetLifeLine(string name) { var typename = ParseType(name); if (!lifelines.ContainsKey(typename)) { var lifeline = new Lifeline(typename); doc.Add(lifeline); lifeline.Left = last == null ? 30 : last.Right + 30; last = lifeline; lifelines.Add(typename, lifeline); return(lifeline); } return(lifelines[typename]); }
private Lifeline GetLifeLine(string name) { var typename = ParseType(name); if (!_lifelines.ContainsKey(typename)) { var lifeline = new Lifeline(typename, GetColor(0), GetOppositeColor(0)); lifeline.Selectable = false; lifeline.GoToSpot = ParseFullType(name); lifeline.Clicked += lifeline_Clicked; _doc.Add(lifeline); lifeline.Left = last == null ? 30 : last.Right + 30; last = lifeline; _lifelines.Add(typename, lifeline); return(lifeline); } return(_lifelines[typename]); }
public GoNode InsertNode(PointF pt, GoNode node, int userFlag = 0, Object userObj = null) { GoDocument doc = goView.Document; doc.StartTransaction(); node.UserFlags = userFlag; node.UserObject = userObj; node.Location = pt; doc.Add(node); doc.FinishTransaction("Insert node finished"); return(node); }
Lifeline CreateOrGetLifeLine(GoDocument doc, string name) { if (!lifelines.ContainsKey(name)) { var lf = new Lifeline(name); doc.Add(lf); lifelines.Add(lf.Text, lf); return(lf); } else { return(lifelines[name]); } }
void DisplaySequence() { lifelines.Clear(); GoDocument doc = goView1.Document; doc.AllowLink = false; doc.AllowEdit = false; doc.AllowResize = false; doc.Clear(); goView1.Invoke(new Action(() => { int i = 0; foreach (var transaction in source) { var s = CreateOrGetLifeLine(doc, transaction.Source); var t = CreateOrGetLifeLine(doc, transaction.Target); var m = new Message(++i, s, t, "Buy (" + transaction.State.ToString().Remove(0, transaction.State.ToString().LastIndexOf('.') + 1) + ")", 2, transaction); m.OnMessageClicked += message => { foreach (var transactionControl in Registry.GetControls <ITransactionControl>()) { transactionControl.Changed(message); } }; doc.Add(m); } var margin = 300; foreach (var lifeline in lifelines) { lifeline.Value.Left = margin; margin *= 2; } doc.Bounds = doc.ComputeBounds(); goView1.DocPosition = doc.TopLeft; goView1.GridUnboundedSpots = GoObject.BottomLeft | GoObject.BottomRight; goView1.Grid.Top = Lifeline.LineStart; goView1.GridOriginY = Lifeline.LineStart; goView1.GridCellSizeHeight = Lifeline.MessageSpacing; // support undo/redo doc.UndoManager = new GoUndoManager(); })); }
/// <summary> /// Create a GoBasicNode with random colors and editable middle label, /// and add it to the document at the given point. /// </summary> /// <param name="pt">the location of the new node (the center of the shape)</param> /// <param name="rectangular">whether the node has a rectangle shape instead of elliptical</param> /// <returns>a GoBasicNode</returns> private GoBasicNode InsertNode(PointF pt, bool rectangular, string title) { GoDocument doc = goView1.Document; doc.StartTransaction(); GoBasicNode n = new GoBasicNode(); n.LabelSpot = GoObject.Middle; n.Text = title; //(++myNodeCounter).ToString(); //if (rectangular) //n.Shape = new GoRectangle(); ; // specify the position and colors n.Location = pt; n.Brush = new SolidBrush(GetRandomColor(100)); n.Shape.PenColor = GetRandomColor(130); n.Shape.PenWidth = 3; // allow the user to edit the text in-place //n.Label.Editable = true; doc.Add(n); doc.FinishTransaction("inserted node"); return(n); }
private void buttonX1_Click(object sender, EventArgs ea) { if (Events != null && Events.Count > 0) { if (start.Value >= end.Value) { MessageBoxEx.Show("Start event id should always be les than end event id", "Events", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lifelines.Clear(); GoDocument doc = goView1.Document; doc.AllowLink = false; doc.AllowEdit = false; doc.AllowResize = false; doc.Clear(); for (int i = start.Value; i <= end.Value; i++) { var e = Events[i]; Lifeline lf = null; Lifeline s = null, t = null; if (e.Unknow && !lifelines.ContainsKey("Unknown")) { lf = new Lifeline("Unknown"); doc.Add(lf); lifelines.Add(lf.Text, lf); } if (e.Source != null && !lifelines.ContainsKey(e.Source.Name)) { lf = new Lifeline(e.Source.Name); doc.Add(lf); lifelines.Add(lf.Text, lf); } if (e.Target != null && !lifelines.ContainsKey(e.Target.Name)) { lf = new Lifeline(e.Target.Name); doc.Add(lf); lifelines.Add(lf.Text, lf); } if (e.Unknow) { if (e.Source == null) { s = lifelines["Unknown"]; t = lifelines[e.Target.Name]; } else if (e.Target == null) { t = lifelines["Unknown"]; s = lifelines[e.Source.Name]; } else { continue; } } else { t = lifelines[e.Target.Name]; s = lifelines[e.Source.Name]; } var m = new Message(i - start.Value, s, t, e.Message.GetType().Name, 2, e.Message); m.OnMessageClicked += message => Program.MainInstance.DisplayMessageInfo(message); doc.Add(m); } int margin = integerInput1.Value; foreach (var lifeline in lifelines) { lifeline.Value.Left = margin; margin *= 2; } doc.Bounds = doc.ComputeBounds(); goView1.DocPosition = doc.TopLeft; goView1.GridUnboundedSpots = GoObject.BottomLeft | GoObject.BottomRight; goView1.Grid.Top = Lifeline.LineStart; goView1.GridOriginY = Lifeline.LineStart; goView1.GridCellSizeHeight = Lifeline.MessageSpacing; // support undo/redo doc.UndoManager = new GoUndoManager(); } }