Beispiel #1
0
        // create hover form for sub-circuit instance
        private HoverBase CreateHoverForm(SubCircuitInstance subCircuitInstance)
        {
            const float MAX_SIZE      = 420;
            const int   CircuitMargin = 8;

            TransformAdapter xformAdapter = m_d2dHoverControl.As <TransformAdapter>();

            xformAdapter.Transform.Reset();
            m_d2dHoverControl.D2dGraphics.Transform = Matrix3x2F.Identity;

            m_d2dHoverControl.Context = subCircuitInstance.SubCircuit;

            RectangleF bounds = m_circuitRenderer.GetBounds(subCircuitInstance.SubCircuit.Elements.AsIEnumerable <Module>()
                                                            , m_d2dHoverControl.D2dGraphics);

            float boundRatio = bounds.Width / bounds.Height;

            Size size = (boundRatio > 1) ? new Size((int)MAX_SIZE, (int)(MAX_SIZE / boundRatio))
                : new Size((int)(MAX_SIZE * boundRatio), (int)MAX_SIZE);

            float scale = (float)size.Width / (float)bounds.Width;

            xformAdapter.Transform.Translate(CircuitMargin, CircuitMargin);
            xformAdapter.Transform.Scale(scale, scale);
            xformAdapter.Transform.Translate(-bounds.X, -bounds.Y);

            HoverBase result = new HoverBase();

            result.Size = new Size(size.Width + 2 * CircuitMargin, size.Height + 2 * CircuitMargin);
            result.Controls.Add(m_d2dHoverControl);
            return(result);
        }
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);
            }
            else if (hoverPart.Is <GroupPin>())
            {
                sb.Append(hoverPart.Cast <GroupPin>().Name);
            }
            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 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 #4
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);
        }
Beispiel #5
0
        private HoverBase GetHoverForm(HoverEventArgs <object, object> e)
        {
            HoverBase result = CreateHoverForm(e);

            if (result != null)
            {
                Point p = Control.MousePosition;
                result.Location = new Point(p.X - (result.Width + 12), p.Y + 12);
                result.ShowWithoutFocus();
            }
            return(result);
        }
Beispiel #6
0
        private HoverBase GetHoverForm(HoverEventArgs <object, object> e)
        {
            HoverBase result = null;

            // handle sub-circuit instance
            SubCircuitInstance subCircuitInstance = Adapters.As <SubCircuitInstance>(e.Object);

            if (subCircuitInstance != null)
            {
                result = CreateHoverForm(subCircuitInstance);
            }
            else
            {
                result = CreateHoverForm(e);
            }

            if (result != null)
            {
                Point p = Control.MousePosition;
                result.Location = new Point(p.X - (result.Width + 12), p.Y + 12);
                result.ShowWithoutFocus();
            }
            return(result);
        }
Beispiel #7
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 <ScriptGroupSocket>())
            {
                sb.Append(e.SubPart.Cast <ScriptGroupSocket>().Name);
                CircuitUtil.GetDomNodeName(e.SubPart.Cast <DomNode>());
            }
            else if (e.SubObject.Is <DomNode>())
            {
                CircuitUtil.GetDomNodeName(e.SubObject.Cast <DomNode>());
            }
            else if (hoverPart.Is <ScriptGroupSocket>())
            {
                sb.Append(hoverPart.Cast <ScriptGroupSocket>().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);
        }