private void HoverTimerTick(object sender, EventArgs e)
        {
            EndHover();

            if (m_hoverLabel == null && m_hoverThumbnail != null)
            {
                m_hoverLabel =
                    new HoverLabel(m_hoverThumbnail.Description)
                {
                    Location = new Point(MousePosition.X - 8, MousePosition.Y + 8)
                };
                m_hoverLabel.ShowWithoutFocus();
            }
        }
Beispiel #2
0
        // create hover form for module or connection
        private HoverBase CreateHoverForm(HoverEventArgs<object, object> e)
        {
            StringBuilder sb = new StringBuilder();

            var hoverItem = e.Object;
            var hoverPart = e.Part;

            if (e.SubPart.Is<GroupPin>())
            {
                sb.Append(e.SubPart.Cast<GroupPin>().Name);
                CircuitUtil.GetDomNodeName(e.SubPart.Cast<DomNode>());
            }
            else if (e.SubObject.Is<DomNode>())
            {
                CircuitUtil.GetDomNodeName(e.SubObject.Cast<DomNode>());
            }
            else if (hoverPart.Is<GroupPin>())
            {
                sb.Append(hoverPart.Cast<GroupPin>().Name);
                CircuitUtil.GetDomNodeName(hoverPart.Cast<DomNode>());
            }
            else if (hoverItem.Is<DomNode>())
            {
                CircuitUtil.GetDomNodeName(hoverItem.Cast<DomNode>());
            }

            HoverBase result = null;
            if (sb.Length > 0) // remove trailing '\n'
            {
                //sb.Length = sb.Length - 1;
                result = new HoverLabel(sb.ToString());
            }

            return result;
        }
Beispiel #3
0
        // create hover form for primitive state or transition
        private static HoverBase CreateHoverForm(object hoverTarget)
        {
            // handle states and transitions
            StringBuilder sb = new StringBuilder();
            ICustomTypeDescriptor customTypeDescriptor = hoverTarget.As<ICustomTypeDescriptor>();
            if (customTypeDescriptor != null)
            {
                // Get properties interface
                foreach (System.ComponentModel.PropertyDescriptor property in customTypeDescriptor.GetProperties())
                {
                    object value = property.GetValue(hoverTarget);
                    if (value != null)
                    {
                        sb.Append(property.Name);
                        sb.Append(": ");
                        sb.Append(value.ToString());
                        sb.Append("\n");
                    }
                }
            }

            HoverBase result = null;
            if (sb.Length > 0) // remove trailing '\n'
            {
                sb.Length = sb.Length - 1;
                result = new HoverLabel(sb.ToString());
            }

            return result;
        }
        private void HoverTimerTick(object sender, EventArgs e)
        {
            EndHover();

            if (m_hoverLabel == null && m_hoverThumbnail != null)
            {
                m_hoverLabel =
                    new HoverLabel(m_hoverThumbnail.Description)
                    {
                        Location = new Point(MousePosition.X - 8, MousePosition.Y + 8)
                    };
                m_hoverLabel.ShowWithoutFocus();
            }
        }
Beispiel #5
0
 private void EndHover()
 {
     if (m_hoverLabel != null)
     {
         m_hoverLabel.Hide();
         m_hoverLabel.Dispose();
         m_hoverLabel = null;
         m_hoverThumbnail = null;
     }
     m_hoverTimer.Stop();
 }
Beispiel #6
0
        // create hover form for module or connection
        private HoverBase CreateHoverForm(HoverEventArgs<object, object> e)
        {
            StringBuilder sb = new StringBuilder();

            var hoverItem = e.Object;
            var hoverPart = e.Part;

            string itemName= string.Empty;
            string partName= string.Empty;

            if (e.SubPart.Is<GroupPin>())
            {
                sb.Append(e.SubPart.Cast<GroupPin>().Name);
                partName = CircuitUtil.GetDomNodeName(e.SubPart.Cast<DomNode>());
            }
            else if (e.SubObject.Is<DomNode>())
            {
                itemName = CircuitUtil.GetDomNodeName(e.SubObject.Cast<DomNode>());
            }
            else if (hoverPart.Is<GroupPin>())
            {
                sb.Append(hoverPart.Cast<GroupPin>().Name);
                partName = CircuitUtil.GetDomNodeName(hoverPart.Cast<DomNode>());
            }
            else if (hoverItem.Is<DomNode>())
            {
                itemName = CircuitUtil.GetDomNodeName(hoverItem.Cast<DomNode>());
            }
           

            //Trace.TraceInformation("hoverItem {0} hoverPart  {1}", itemName, partName);

            //StringBuilder sb = new StringBuilder();
            //ICustomTypeDescriptor customTypeDescriptor = Adapters.As<ICustomTypeDescriptor>(hoverItem);
            //if (customTypeDescriptor != null)
            //{
            //    // Get properties interface
            //    foreach (System.ComponentModel.PropertyDescriptor property in customTypeDescriptor.GetProperties())
            //    {
            //        object value = property.GetValue(hoverItem);
            //        if (value != null)
            //        {
            //            sb.Append(property.Name);
            //            sb.Append(": ");
            //            sb.Append(value.ToString());
            //            sb.Append("\n");
            //        }
            //    }
            //}

            HoverBase result = null;
            if (sb.Length > 0) // remove trailing '\n'
            {
                //sb.Length = sb.Length - 1;
                result = new HoverLabel(sb.ToString());
            }

            return result;
        }
Beispiel #7
0
        public void SetContext(DiagramDocument context)
        {
            var existingContext = context as ISelectionContext;
            if (existingContext != null)
                existingContext.SelectionChanged -= Context_SelectionChanged;

            var graphAdapter = new HyperGraphAdapter();
            graphAdapter.HighlightCompatible = true;
            graphAdapter.LargeGridStep = 160F;
            graphAdapter.SmallGridStep = 20F;
            graphAdapter.LargeStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(90)))), ((int)(((byte)(90)))));
            graphAdapter.SmallStepGridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
            graphAdapter.ShowLabels = false;
            graphAdapter.Model = context.Model;
            graphAdapter.Selection = context.DiagramSelection; 
            graphAdapter.Context = context.UnderlyingDocument;
            graphAdapter.ModelConversion = _modelConversion;
            graphAdapter.NodeFactory = _nodeFactory;
            graphAdapter.Document = context.UnderlyingDocument;

            // calling Adapt will unbind previous adapters
            var hoverAdapter = new HoverAdapter();
            hoverAdapter.HoverStarted += (object sender, HoverEventArgs<object, object> args) =>
                {
                    if (_hover != null) return;

                    var n = args.Object as HyperGraph.Node;
                    if (n == null)
                    {
                        var i = args.Object as HyperGraph.NodeItem;
                        if (i != null) n = i.Node;
                    }
                    if (n != null)
                    {
                        _hover = new HoverLabel(n.Title)
                        {
                            Location = new Point(MousePosition.X - 8, MousePosition.Y + 8)
                        };
                        _hover.ShowWithoutFocus();
                    }
                };
            hoverAdapter.HoverStopped += EndHover;
            MouseLeave += EndHover;
            Adapt(
                new IControlAdapter[] {
                    graphAdapter,
                    new PickingAdapter { Context = context },
                    new CanvasAdapter(),
                    new ViewingAdapter(graphAdapter),
                    hoverAdapter
                });
            context.SelectionChanged += Context_SelectionChanged;

            // Our context is actually a collection of 2 separate context objects
            // - What represents the model itself
            // - Another is the "ViewingContext", which is how we're looking at the model
            // Curiously, there seems to be a bit of an overlap between control adapters
            // and the viewing context. For example, ViewingContext, PickingAdapter and ViewingAdapter
            // duplicate some of the same functionality.
            // However, all of these are needed to use the standard ATF commands for framing and aligning
            _contextSet = new AdaptableSet(new object[]{ context, new ViewingContext { Control = this } });
            Context = _contextSet;
        }