Example #1
0
        /// <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);
        }
Example #2
0
        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);
        }
Example #3
0
 /// <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");
 }
Example #4
0
        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)));
        }
Example #5
0
        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();
            }));
        }
        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();
        }
        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();
        }
Example #8
0
        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();
            }
        }