Пример #1
0
        private DiagramHitRecord Pick(Point p)
        {
            DiagramHitRecord hitRecord = null;

            foreach (IPickingAdapter pickingAdapter in m_pickingAdapters)
            {
                hitRecord = pickingAdapter.Pick(p);
                if (hitRecord.Item != null)
                {
                    break;
                }
            }
            if (hitRecord == null || hitRecord.Item == null)
            {
                foreach (IPickingAdapter2 pickingAdapter in m_pickingAdapters2)
                {
                    hitRecord = pickingAdapter.Pick(p);
                    if (hitRecord.Item != null)
                    {
                        break;
                    }
                }
            }
            return(hitRecord);
        }
Пример #2
0
 private void StartHover(DiagramHitRecord hitRecord)
 {
     m_hoverItem    = hitRecord.Item;
     m_hoverPart    = hitRecord.Part;
     m_hoverSubItem = hitRecord.SubItem;
     m_hoverSubPart = hitRecord.SubPart;
     StopHover();
     m_hoverTimer.Start();
 }
Пример #3
0
        private void control_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right && ((Control.ModifierKeys & Keys.Alt) == 0))
            {
                Point  p      = new Point(e.X, e.Y);
                object target = null;

                foreach (IPickingAdapter pickingAdapter in AdaptedControl.AsAll <IPickingAdapter>())
                {
                    DiagramHitRecord hitRecord = pickingAdapter.Pick(p);
                    if (hitRecord.Item != null)
                    {
                        target = hitRecord.Item;
                        break;
                    }
                }

                // iter over IPickingAdapter
                if (target == null)
                {
                    foreach (IPickingAdapter2 pickingAdapter in AdaptedControl.AsAll <IPickingAdapter2>())
                    {
                        DiagramHitRecord hitRecord = pickingAdapter.Pick(p);
                        if (hitRecord.Item != null)
                        {
                            target = hitRecord.Item;
                            break;
                        }
                    }
                }

                object context = AdaptedControl.Context;
                TriggeringLocation = p;
                var commands = new List <object>(m_providers.GetCommands(context, target));

                OnContextMenuOpening(commands);


                Point screenP = AdaptedControl.PointToScreen(p);
                m_commandService.RunContextMenu(commands, screenP);
            }
        }
Пример #4
0
        private void control_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None &&
                AdaptedControl.Focused)
            {
                object           pickedItem = null;
                object           pickedPart = null;
                DiagramHitRecord hitRecord  = null;
                foreach (IPickingAdapter pickingAdapter in AdaptedControl.AsAll <IPickingAdapter>())
                {
                    hitRecord = pickingAdapter.Pick(new Point(e.X, e.Y));
                    if (hitRecord.Item != null)
                    {
                        pickedItem = hitRecord.Item;
                        pickedPart = hitRecord.Part;
                        break;
                    }
                }

                if (pickedItem == null)
                {
                    foreach (IPickingAdapter2 pickingAdapter in AdaptedControl.AsAll <IPickingAdapter2>())
                    {
                        hitRecord = pickingAdapter.Pick(new Point(e.X, e.Y));
                        if (hitRecord.Item != null)
                        {
                            pickedItem = hitRecord.Item;
                            pickedPart = hitRecord.Part;
                            break;
                        }
                    }
                }

                if (hitRecord.Item != m_hoverItem || hitRecord.Part != m_hoverPart ||
                    hitRecord.SubItem != m_hoverSubItem || hitRecord.SubPart != m_hoverSubPart)
                {
                    StartHover(hitRecord);
                }
            }
        }
Пример #5
0
        private void control_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None && AdaptedControl.Focused)
            {
                DiagramHitRecord hitRecord = null;
                foreach (var pickingAdapter in m_pickingAdapters)
                {
                    hitRecord = pickingAdapter.Pick(e.Location);
                    if (hitRecord.Item != null)
                    {
                        break;
                    }
                }

                if (hitRecord != null &&
                    (hitRecord.Item != m_hoverItem || hitRecord.Part != m_hoverPart ||
                     hitRecord.SubItem != m_hoverSubItem || hitRecord.SubPart != m_hoverSubPart))
                {
                    StartHover(hitRecord);
                }
            }
        }
Пример #6
0
 private void StartHover(DiagramHitRecord hitRecord)
 {
     m_hoverItem = hitRecord.Item;
     m_hoverPart = hitRecord.Part;
     m_hoverSubItem = hitRecord.SubItem;
     m_hoverSubPart = hitRecord.SubPart;
     StopHover();
     m_hoverTimer.Start();
 }
Пример #7
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="hitRecord">Hit record from picking operation</param>
 public DiagramHitEventArgs(DiagramHitRecord hitRecord)
 {
     HitRecord = hitRecord;
 }
Пример #8
0
 /// <summary>
 /// Constructor</summary>
 /// <param name="hitRecord">Hit record from picking operation</param>
 public DiagramHitEventArgs(DiagramHitRecord hitRecord)
 {
     HitRecord = hitRecord;
 }