Exemple #1
0
        //private void GroupToggleAutoSize(ViewingContext viewingContext)
        //{
        //    if (m_targetRef == null || m_targetRef.Target == null)
        //        return;

        //    var group = m_targetRef.Target.Cast<Group>();
        //    if (group.AutoSize && group.Bounds.Width == 0 && group.Bounds.Height == 0) // initialize group width & height with reasonable values
        //    {
        //        var graphAdapter = viewingContext.Control.Cast<D2dGraphAdapter<Module, Connection, ICircuitPin>>();
        //        var currentBound = graphAdapter.GetBounds(new object[] { group });
        //        group.Bounds = currentBound;
        //    }
        //    group.AutoSize = !group.AutoSize;
        //}

        private bool CanToggleShowExpandedGroupPins(object context, object target)
        {
            if (target.Is <Group>())
            {
                var viewingContext = context.Cast <CircuitEditingContext>().DomNode.Cast <ViewingContext>();
                if (viewingContext.Control != null)
                {
                    var contextMenu = viewingContext.Control.As <ContextMenuAdapter>();
                    if (CommandService.ContextMenuIsTriggering && contextMenu != null)
                    {
                        foreach (var pickingAdapter in viewingContext.Control.AsAll <IPickingAdapter2>())
                        {
                            DiagramHitRecord hitRecord = pickingAdapter.Pick(contextMenu.TriggeringLocation.GetValueOrDefault());
                            if (hitRecord.SubItem.Is <Group>())
                            {
                                m_targetRef = new WeakReference(hitRecord.SubItem); // favor inner container
                                return(true);
                            }
                        }
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #2
0
 private bool CanDoTogglePinVisibility(object context, object target)
 {
     if (target.Is <Group>())
     {
         if (CircuitUtil.IsTemplateTargetMissing(target))
         {
             return(false);
         }
         var viewingContext = context.Cast <CircuitEditingContext>().DomNode.Cast <ViewingContext>();
         if (viewingContext.Control != null)
         {
             var contextMenu = viewingContext.Control.As <ContextMenuAdapter>();
             if (CommandService.ContextMenuIsTriggering && contextMenu != null)
             {
                 foreach (var pickingAdapter in viewingContext.Control.AsAll <IPickingAdapter2>())
                 {
                     DiagramHitRecord hitRecord = pickingAdapter.Pick(contextMenu.TriggeringLocation.GetValueOrDefault());
                     if (hitRecord.Part.Is <GroupPin>())
                     {
                         return(true);
                     }
                     if (hitRecord.SubPart.Is <GroupPin>())
                     {
                         return(true);
                     }
                     if (hitRecord.SubPart.Is <ElementType.Pin>())
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
Exemple #3
0
        private void d2dControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None && AdaptedControl.Focused)
            {
                IPickingAdapter2 pickAdapter    = this as IPickingAdapter2;
                DiagramHitRecord hoverHitRecord = pickAdapter.Pick(e.Location);
                object           item           = hoverHitRecord.Item;

                bool redraw = false;
                if (m_hoverObject != item)
                {
                    m_hoverObject = item;
                    redraw        = true;
                }
                if (m_hoverSubObject != hoverHitRecord.SubItem)
                {
                    ResetCustomStyle(m_hoverSubObject);
                    m_hoverSubObject = hoverHitRecord.SubItem;
                    m_renderer.SetCustomStyle(m_hoverSubObject, DiagramDrawingStyle.DragSource);

                    redraw = true;
                }

                if (redraw)
                {
                    Invalidate();
                }
            }
        }