Ejemplo n.º 1
0
        private void DrawBond(Bond bond, PointF pt, int handleIndex)
        {
            BondAttachment ba         = BondAttachmentExtensions.GetTargetFromHandleIndex(handleIndex);
            HandleIcon     handleIcon = GetHandleIcon(bond.BondType, TransformKind.Scale);

            if (handleIcon != HandleIcon.Anchor && handleIcon != HandleIcon.Spring)
            {
                float hr             = handleSize / 2f;
                int   variationIndex = handleIndex % icons[(int)handleIcon].Length;
                Point p = new Point((int)(pt.X - hr), (int)(pt.Y - hr));
                graphicHolder.DrawImage(icons[(int)handleIcon][variationIndex], p);
            }

            long handleHash = bond.GetHandleHash(ba);

            if (bondPoints.ContainsKey(handleHash))
            {
                // todo: need to allow vertical align inside horz dist chain (which will conflict on a handle).
                Console.WriteLine("conflict handle: " + handleHash);
            }
            else
            {
                bondPoints.Add(handleHash, pt);
            }
        }
Ejemplo n.º 2
0
        private void DrawSelectionHandles(Graphics g, PointF[] pts)
        {
            BondType[] bondTypes = (stage.Selection.Count == 1) ?
                                   stage.CurrentEditItem.BondStore.GetHandlesForInstance(stage.Selection[0]) :
                                   BondStore.emptyHandles;

            float hr = handleSize / 2f;

            for (int i = 0; i < pts.Length - 1; i++)
            {
                HandleIcon handleIcon = GetHandleIcon(bondTypes[i], transformKind);
                // draw bond icons on separate pass
                if (handleIcon == HandleIcon.Handle || handleIcon == HandleIcon.Rotate)
                {
                    int   variationIndex = i % icons[(int)handleIcon].Length;
                    Point loc            = new Point((int)(pts[i].X - hr), (int)(pts[i].Y - hr));
                    g.DrawImage(icons[(int)handleIcon][variationIndex], loc);
                    if (AspectConstrainTarget != BondAttachment.None && AspectConstrainTarget.GetHandleIndex() == i)
                    {
                        g.DrawRectangle(selfConstraintTargetPen, new Rectangle(loc.X, loc.Y, handleSquare.Width, handleSquare.Height));
                    }
                }
            }

            if (transformKind == Enums.TransformKind.Rotate)
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode   = PixelOffsetMode.Default;

                // center dot
                if (transformKind == TransformKind.Rotate)
                {
                    PointF    center     = stage.RotationCenterToCamera;
                    Rectangle centerRect = new Rectangle(
                        (int)(center.X - hr),
                        (int)(center.Y - hr),
                        (int)(hr * 2),
                        (int)(hr * 2));

                    g.FillEllipse(Brushes.White, centerRect);
                    g.DrawEllipse(Pens.Black, centerRect);
                }
            }
        }