/// <summary> /// Forget any references that this object may have. /// </summary> public void Clear() { myDocument = null; myObject = null; myOldValue = null; myNewValue = null; }
private bool UpdateFlowInfo() { try { var subViews = mdockPanel.Contents.Where(item => item.GetType() == typeof(GraphViewWindow)).Select(item => item as GraphViewWindow); Flow.Instance.SubFlows.Clear(); Flow.Instance.MainFlows.Clear(); foreach (var canvas in subViews) { GoDocument doc = canvas.Doc; foreach (var item in canvas.Doc) { if (item is GraphNode) { GraphNode nodeItem = (GraphNode)item; if (nodeItem.Kind == "SubStart") { Flow.Instance.SubFlows.Add(nodeItem.Text, nodeItem); } if (nodeItem.Kind == "Start") { Flow.Instance.MainFlows.Add(nodeItem); } } } } return(true); } catch (Exception e) { UiHelper.ShowError(e.Message); return(false); } }
/// <summary> /// Make sure this undo manager knows about a <see cref="T:Northwoods.Go.GoDocument" /> for which /// it is receiving document Changed event notifications. /// </summary> /// <param name="doc"></param> /// <remarks> /// This just adds <paramref name="doc" /> to the list of <see cref="P:Northwoods.Go.GoUndoManager.Documents" />. /// </remarks> /// <seealso cref="M:Northwoods.Go.GoUndoManager.RemoveDocument(Northwoods.Go.GoDocument)" /> public virtual void AddDocument(GoDocument doc) { if (!myDocuments.Contains(doc)) { myDocuments.Add(doc); } }
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); }
/// <summary> /// Create a new selection object containing an image of all of the real selected objects. /// </summary> /// <returns>a new <see cref="T:Northwoods.Go.GoSelection" /> holding view objects that represent the /// objects in the <see cref="P:Northwoods.Go.GoView.Selection" /></returns> /// <remarks> /// This creates a new <see cref="T:Northwoods.Go.GoSelection" /> for this view. /// The objects that are in this selection have been added to the default /// layer of the view. /// </remarks> public virtual GoSelection CreateDragSelection() { GoSelection goSelection = new GoSelection(null); PointF position = base.CurrentObject.Position; SizeF offset = GoTool.SubtractPoints(base.CurrentObject.Location, position); GoDragRectangle goDragRectangle = new GoDragRectangle(); goDragRectangle.Bounds = base.CurrentObject.Bounds; goDragRectangle.Offset = offset; goDragRectangle.Visible = false; base.View.Layers.Default.Add(goDragRectangle); goSelection.Add(goDragRectangle); GoCollection goCollection = new GoCollection(); goCollection.InternalChecksForDuplicates = false; foreach (GoObject item in (EffectiveSelection != null) ? EffectiveSelection : base.Selection) { goCollection.Add(item.DraggingObject); } base.View.Document.Layers.SortByZOrder(goCollection); RectangleF bounds = GoDocument.ComputeBounds(goCollection, base.View); float num = 1E+21f; float num2 = 1E+21f; foreach (GoObject item2 in goCollection) { if (item2.Top < num) { num = item2.Top; } if (item2.Left < num2) { num2 = item2.Left; } } float num3 = base.View.WorldScale.Width; if (bounds.Width * num3 > 2000f || bounds.Height * num3 > 2000f) { num3 *= Math.Min(2000f / (bounds.Width * num3), 2000f / (bounds.Height * num3)); } Bitmap bitmapFromCollection = base.View.GetBitmapFromCollection(goCollection, bounds, num3, paper: false); GoDragImage goDragImage = new GoDragImage(); goDragImage.Image = bitmapFromCollection; goDragImage.Bounds = new RectangleF(bounds.X, bounds.Y, (float)bitmapFromCollection.Width / num3, (float)bitmapFromCollection.Height / num3); if (num < 1E+21f && num2 < 1E+21f) { goDragImage.Offset = new SizeF(num2 - bounds.X + offset.Width, num - bounds.Y + offset.Height); } else { goDragImage.Offset = offset; } base.View.Layers.Default.Add(goDragImage); goSelection.Add(goDragImage); return(goSelection); }
public override void CopyToClipboard(IGoCollection coll) { base.CopyToClipboard(coll); RectangleF bounds = GoDocument.ComputeBounds(coll, this); Metafile mf = GetMetafileFromCollection(coll, bounds, this.DocScale, false); PutEnhMetafileOnClipboard(this.Handle, mf); }
public override void OnLogout() { lifelines.Clear(); GoDocument doc = goView1.Document; doc.AllowLink = false; doc.AllowEdit = false; doc.AllowResize = false; doc.Clear(); }
/// <summary> /// Re-perform the document change after an <see cref="M:Northwoods.Go.GoChangedEventArgs.Undo" /> /// by calling <see cref="M:Northwoods.Go.GoDocument.ChangeValue(Northwoods.Go.GoChangedEventArgs,System.Boolean)" />. /// </summary> /// <remarks> /// <see cref="M:Northwoods.Go.GoChangedEventArgs.CanRedo" /> must be true for this method to call <see cref="M:Northwoods.Go.GoDocument.ChangeValue(Northwoods.Go.GoChangedEventArgs,System.Boolean)" />. /// </remarks> public void Redo() { if (CanRedo()) { GoDocument document = Document; document.Initializing = true; document.ChangeValue(this, undo: false); document.Initializing = false; } }
/// <summary> /// Called when the user clicks on the background context menu Paste menu item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// This calls <see cref="GoView.EditPaste"/> and selects all of the newly pasted objects. /// </remarks> public void Paste_Command(Object sender, EventArgs e) { PointF docpt = this.LastInput.DocPoint; StartTransaction(); this.Selection.Clear(); EditPaste(); // selects all newly pasted objects RectangleF copybounds = GoDocument.ComputeBounds(this.Selection, this); SizeF offset = new SizeF(docpt.X - copybounds.X, docpt.Y - copybounds.Y); MoveSelection(this.Selection, offset, true); FinishTransaction("Just Paste"); }
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); }
public GraphViewer() { InitializeComponent(); myView.KeyDown += MyView_KeyDown; GoDocument doc = myView.Document; // create a layer in back to hold all the links doc.LinksLayer = doc.Layers.CreateNewLayerBefore(doc.Layers.Default); doc.LinksLayer.Identifier = "links"; // create a layer in front to hold selected nodes doc.Layers.CreateNewLayerAfter(doc.Layers.Default).Identifier = "selected"; }
public void PerformLayout(IContainerBase containerBase, IList <IHasLayoutInfo> freeNodes) { GoDocument doc = containerBase as GoDocument; if (doc == null && containerBase as GoObject == null) { _dialogCreator.MessageBoxInfo("Bad ContainerBase Type = " + containerBase.GetType().Name); return; } if (doc == null) { doc = ((GoObject)containerBase).Document; } Document = doc; doc.StartTransaction(); string text = "DiagramModel"; var containerBaseNode = containerBase as IContainerNode; if (containerBaseNode != null) { text = containerBaseNode.GetLongName(); } LayerSpacing = 0F; ColumnSpacing = 0F; DirectionOption = GoLayoutDirection.Right; CycleRemoveOption = GoLayoutLayeredDigraphCycleRemove.DepthFirst; LayeringOption = GoLayoutLayeredDigraphLayering.OptimalLinkLength; InitializeOption = GoLayoutLayeredDigraphInitIndices.DepthFirstOut; Iterations = 4; AggressiveOption = GoLayoutLayeredDigraphAggressive.Less; PackOption = GoLayoutLayeredDigraphPack.Straighten; SetsPortSpots = false; var net = CreateNetwork(); net.AddNodesAndLinksFromCollection(containerBase as IGoCollection, true); setNodeType(net, freeNodes); Network = net; if (net.NodeCount > 0) { base.PerformLayout(); } doc.FinishTransaction("DoLayerLayout"); }
/// <summary> /// Request the reshaping of the balloon's polygon background. /// </summary> /// <remarks> /// If this is part of a <see cref="T:Northwoods.Go.GoDocument" />, /// this calls <see cref="T:Northwoods.Go.GoDocument" />.<see cref="M:Northwoods.Go.GoDocument.UpdateRoute(Northwoods.Go.IGoRoutable)" /> in order to maybe delay /// the call to <see cref="M:Northwoods.Go.GoBalloon.CalculateRoute" /> (depending on the value of <see cref="P:Northwoods.Go.GoDocument.RoutingTime" />). /// If there is no <see cref="T:Northwoods.Go.GoDocument" />, this just calls <see cref="M:Northwoods.Go.GoBalloon.CalculateRoute" /> immediately. /// </remarks> public virtual void UpdateRoute() { GoDocument document = base.Document; if (document != null) { document.UpdateRoute(this); } else { CalculateRoute(); } }
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]); } }
public Metafile ToMetafile() { var selection = Selection; SelectAll(); RectangleF bounds = GoDocument.ComputeBounds(Selection, this); Graphics gbm = CreateGraphics(); IntPtr bufdc = gbm.GetHdc(); MemoryStream str = new MemoryStream(); Metafile mf = new Metafile(str, bufdc, bounds, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual); Graphics gmf = Graphics.FromImage(mf); gmf.PageUnit = GraphicsUnit.Pixel; gmf.SmoothingMode = this.SmoothingMode; gmf.TextRenderingHint = this.TextRenderingHint; gmf.InterpolationMode = this.InterpolationMode; gmf.CompositingQuality = this.CompositingQuality; gmf.PixelOffsetMode = this.PixelOffsetMode; RectangleF b = bounds; b.Inflate(1, 1); PaintPaperColor(gmf, b); foreach (GoObject obj in Selection) { if (!obj.CanView()) { continue; } obj.Paint(gmf, this); } gmf.Dispose(); gbm.ReleaseHdc(bufdc); gbm.Dispose(); mf.Dispose(); byte[] data = str.GetBuffer(); Selection.Clear(); Selection.AddRange(selection); return(new Metafile(new MemoryStream(data, false))); }
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> /// This copy constructor makes a copy of the argument object. /// </summary> /// <param name="e"></param> public GoChangedEventArgs(GoChangedEventArgs e) { myIsBeforeChanging = e.IsBeforeChanging; myDocument = e.Document; myHint = e.Hint; mySubHint = e.SubHint; myObject = e.Object; myOldInt = e.OldInt; myOldValue = e.OldValue; myOldRect = e.OldRect; myNewInt = e.NewInt; myNewValue = e.NewValue; myNewRect = e.NewRect; if (myDocument != null) { myDocument.CopyOldValueForUndo(this); myDocument.CopyNewValueForRedo(this); } }
/// <summary> /// Handle basic changes to the observed view's DocPosition or DocScale, /// or when the observed view's Document got swapped for a different document. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void ViewChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "DocPosition" || e.PropertyName == "DocScale") { UpdateOverviewRect(); } else if (e.PropertyName == "Document" && sender is GoView) { if (myObservedDocument != null) { myObservedDocument.Changed -= myDocChangedEventHandler; } myObservedDocument = ((GoView)sender).Document; if (myObservedDocument != null) { myObservedDocument.Changed += myDocChangedEventHandler; } InitializeLayersFromDocument(); UpdateOverviewRect(); } }
public void CreateDiagramFor(TestInformationGeneratedMessage message) { doc = goView1.Document; doc.AllowLink = false; doc.AllowEdit = false; doc.AllowResize = false; RecurseElements(message.Test, null, false, false, false); label1.Text = "Sequence diagram for " + message.Item; 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); }
/// <summary> /// Search for a <see cref="T:Northwoods.Go.GoChangedEventArgs" /> that matches this /// one's <see cref="P:Northwoods.Go.GoChangedEventArgs.Document" />, <see cref="P:Northwoods.Go.GoChangedEventArgs.Hint" />, <see cref="P:Northwoods.Go.GoChangedEventArgs.SubHint" />, /// and <see cref="P:Northwoods.Go.GoChangedEventArgs.Object" />, and whose <see cref="P:Northwoods.Go.GoChangedEventArgs.IsBeforeChanging" /> /// property is true. /// </summary> /// <returns></returns> /// <remarks> /// The assumption is that there are always pairs of calls to /// <see cref="M:Northwoods.Go.GoDocument.RaiseChanging(System.Int32,System.Int32,System.Object)" /> and <see cref="M:Northwoods.Go.GoDocument.RaiseChanged(System.Int32,System.Int32,System.Object,System.Int32,System.Object,System.Drawing.RectangleF,System.Int32,System.Object,System.Drawing.RectangleF)" />, /// resulting in pairs of <see cref="T:Northwoods.Go.GoChangedEventArgs" />. /// This method is not called except when <see cref="M:Northwoods.Go.GoDocument.RaiseChanging(System.Int32,System.Int32,System.Object)" /> /// should have produced recently a <see cref="P:Northwoods.Go.GoChangedEventArgs.IsBeforeChanging" /> event args. /// This searches <see cref="P:Northwoods.Go.GoUndoManager.CurrentEdit" /> backwards. /// </remarks> public GoChangedEventArgs FindBeforeChangingEdit() { if (IsBeforeChanging) { return(null); } GoDocument document = Document; if (document == null) { return(null); } GoUndoManager undoManager = document.UndoManager; if (undoManager == null) { return(null); } GoUndoManagerCompoundEdit currentEdit = undoManager.CurrentEdit; if (currentEdit == null) { return(null); } IList <IGoUndoableEdit> allEdits = currentEdit.AllEdits; checked { for (int num = allEdits.Count - 1; num >= 0; num--) { GoChangedEventArgs goChangedEventArgs = allEdits[num] as GoChangedEventArgs; if (goChangedEventArgs != null && goChangedEventArgs.IsBeforeChanging && goChangedEventArgs.Document == Document && goChangedEventArgs.Hint == Hint && goChangedEventArgs.SubHint == SubHint && goChangedEventArgs.Object == Object) { return(goChangedEventArgs); } } return(null); } }
/// <summary> /// Call this method to inform this undo manager that it no longer will be /// notified of document Changed events. /// </summary> /// <param name="doc"></param> /// <remarks> /// This just removes <paramref name="doc" /> from the list of <see cref="P:Northwoods.Go.GoUndoManager.Documents" />. /// </remarks> /// <seealso cref="M:Northwoods.Go.GoUndoManager.AddDocument(Northwoods.Go.GoDocument)" /> public virtual void RemoveDocument(GoDocument doc) { myDocuments.Remove(doc); }
//SoundPlayer warnSoundPlayer = new SoundPlayer(); public SRControl() { InitializeComponent(); ToolStripMenuItem btnSave = new ToolStripMenuItem(); btnSave.Text = "保存布局"; btnSave.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; btnSave.Click += new EventHandler(btnSave_Click); ToolStripMenuItem btnDelete = new ToolStripMenuItem(); btnDelete.Text = "删除布局"; btnDelete.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; btnDelete.Click += new EventHandler(btnDelete_Click); ToolStripMenuItem btnClear = new ToolStripMenuItem(); btnClear.Text = "清除警告信息"; btnClear.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; btnClear.Click += new EventHandler(btnClear_Click); contextMenuStrip.Items.Add(btnSave); contextMenuStrip.Items.Add(btnDelete); contextMenuStrip.Items.Add(new ToolStripSeparator()); contextMenuStrip.Items.Add(btnClear); this.Disposed += new EventHandler(SRControl_Disposed); goView1.NewLinkPrototype = new AnimatedLink(); this.goView1.NewLinkClass = typeof(AnimatedLink); StateChartDocument filedoc = StateChartDocument.LoadXml(loc); if (filedoc == null) { filedoc = new StateChartDocument(); GoComment com = StateChartDocument.NewComment(); com.Width = this.Width; com.Visible = false; filedoc.Add(com); } else { isLoad = true; } GoDocument doc = filedoc; this.goView1.Document = doc; goView1.ObjectDoubleClicked += new GoObjectEventHandler(goView1_ObjectDoubleClicked); goView1.Document.UndoManager = new GoUndoManager(); logHelper = new TextLogHelper(label1, this, ip, port); logHelper.SRControl = this; _cedaSubscribe = new CedaManager(logHelper); timer1 = new Timer(); this.timer1.Interval = 50; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); //setTimeEnable(true); //_cedaSubscribe.SRControl = this; //warnSoundPlayer.SoundLocation = Consts.SoundLocation; device = new DeviceImpl(); device.init(this, Microsoft.DirectX.DirectSound.CooperativeLevel.Priority); }
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(); } }