Пример #1
0
        /// <summary>
        /// Begins dragging any selected items managed by the adapter. May be called
        /// by another adapter when it begins dragging.</summary>
        /// <param name="initiator">Control adapter that is initiating the drag</param>
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            // drag all selected nodes, and any edges impinging on them
            var draggingNodes = new ActiveCollection <Element>();

            foreach (var node in m_selectionContext.GetSelection <Element>())
            {
                draggingNodes.Add(node);
            }

            m_draggingNodes.AddRange(draggingNodes.GetSnapshot());

            var draggingGrpPins = new ActiveCollection <GroupPin>();

            // add the selected floating pins
            foreach (var grpin in m_selectionContext.GetSelection <GroupPin>())
            {
                draggingGrpPins.Add(grpin);
            }
            m_draggingGroupPins.AddRange(draggingGrpPins.GetSnapshot());

            if (m_draggingGroupPins.Any())
            {
                m_originalPinY = new int[m_draggingGroupPins.Count];
                for (int i = 0; i < m_originalPinY.Length; i++)
                {
                    m_originalPinY[i] = m_draggingGroupPins[i].Bounds.Location.Y;
                }
            }
        }
Пример #2
0
        protected override ControlAdapter ResolveAdapter()
        {
            Debug.WriteLine("ResolveAdapter");
            ControlAdapter controlAdapter = null;

            try
            {
                controlAdapter = base.ResolveAdapter();
            }
            catch (Exception ex)
            {
                ErrorMessage += ex.Message;
            }
            return(controlAdapter);
        }
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            m_isDragging = true;

            // drag all selected nodes, and any edges impinging on them
            ActiveCollection <TNode> draggingNodes = new ActiveCollection <TNode>();
            List <TEdge>             draggingEdges = new List <TEdge>();
            HashSet <TNode>          nodes         = new HashSet <TNode>();

            foreach (TNode node in m_selectionContext.GetSelection <TNode>())
            {
                AddDragNode(node, draggingNodes, nodes);
            }

            // render all edges connected to the dragging nodes
            foreach (TEdge edge in m_graph.Edges)
            {
                if (nodes.Contains(edge.FromNode) ||
                    nodes.Contains(edge.ToNode))
                {
                    draggingEdges.Add(edge);

                    m_graphAdapter.SetStyle(edge, DiagramDrawingStyle.Ghosted);
                }
            }

            m_draggingNodes = draggingNodes.GetSnapshot <TNode>();
            m_newPositions  = new Point[m_draggingNodes.Length];
            m_oldPositions  = new Point[m_draggingNodes.Length];
            for (int i = 0; i < m_draggingNodes.Length; i++)
            {
                // Initialize m_newPositions in case the mouse up event occurs before
                //  a paint event, which can happen during rapid clicking.
                Point currentLocation = m_draggingNodes[i].Bounds.Location;
                m_newPositions[i] = currentLocation;
                m_oldPositions[i] = currentLocation;
            }

            m_draggingEdges = draggingEdges.ToArray();
        }
Пример #4
0
        public void FrameAdvance(bool render, bool rendersound)
        {
            _frame++;

            if (Controller.IsPressed("Power"))
            {
                // it seems that theMachine.Reset() doesn't clear ram, etc
                // this should leave hsram intact but clear most other things
                HardReset();
            }

            ControlAdapter.Convert(Controller, theMachine.InputState);
            theMachine.ComputeNextFrame(avProvider.framebuffer);

            _islag = theMachine.InputState.Lagged;

            if (_islag)
            {
                _lagcount++;
            }

            avProvider.FillFrameBuffer();
        }
Пример #5
0
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
            // drag all selected nodes, and any edges impinging on them
            ActiveCollection <TNode> draggingNodes = new ActiveCollection <TNode>();
            HashSet <TNode>          nodes         = new HashSet <TNode>();

            foreach (TNode node in m_selectionContext.GetSelection <TNode>())
            {
                AddDragNode(node, draggingNodes, nodes);
            }
            m_draggingNodes = draggingNodes.GetSnapshot <TNode>();

            m_newPositions = new Point[m_draggingNodes.Length];
            m_oldPositions = new Point[m_draggingNodes.Length];
            for (int i = 0; i < m_draggingNodes.Length; i++)
            {
                // Initialize m_newPositions in case the mouse up event occurs before
                //  a paint event, which can happen during rapid clicking.
                Point currentLocation = m_draggingNodes[i].Bounds.Location;
                m_newPositions[i] = currentLocation;
                m_oldPositions[i] = currentLocation;
            }
        }
Пример #6
0
        /// <summary>
        /// Begins dragging any selected items managed by the adapter. May be called
        /// by another adapter when it begins dragging.</summary>
        /// <param name="initiator">Control adapter that is initiating the drag</param>
        void IItemDragAdapter.BeginDrag(ControlAdapter initiator)
        {
           
            // drag all selected nodes, and any edges impinging on them
            var draggingNodes = new ActiveCollection<Element>();
         
            foreach (var node in m_selectionContext.GetSelection<Element>())
                draggingNodes.Add(node);
                 
            m_draggingNodes.AddRange(draggingNodes.GetSnapshot());

            var draggingGrpPins= new ActiveCollection<GroupPin>();
            // add the selected floating pins
            foreach (var grpin in m_selectionContext.GetSelection<GroupPin>())         
                draggingGrpPins.Add(grpin);
            m_draggingGroupPins.AddRange(draggingGrpPins.GetSnapshot());

            if (m_draggingGroupPins.Any())
            {
                m_originalPinY = new int[m_draggingGroupPins.Count];
                for (int i = 0; i < m_originalPinY.Length; i++)
                    m_originalPinY[i] = m_draggingGroupPins[i].Bounds.Location.Y;
            }
        }
Пример #7
0
 protected void RenderControl(HtmlTextWriter writer, ControlAdapter adapter);
 /// <summary>
 /// Sets the given target Control as the Control whose performance is monitored by
 /// listening to its Paint event</summary>
 /// <param name="target">Target Control, or null to remove existing binding</param>
 /// <param name="name">The readable name of the Control, to indicate to the user
 /// which Control has the focus</param>
 public void Bind(Control target, string name)
 {
     var binding = new ControlAdapter(target);
     Bind(binding, name);
 }
Пример #9
0
        /// <summary>
        /// Sets the given target Control as the Control whose performance is monitored by
        /// listening to its Paint event</summary>
        /// <param name="target">Target Control, or null to remove existing binding</param>
        /// <param name="name">The readable name of the Control, to indicate to the user
        /// which Control has the focus</param>
        public void Bind(Control target, string name)
        {
            var binding = new ControlAdapter(target);

            Bind(binding, name);
        }
Пример #10
0
        public void GetNextControl_NestedControls()
        {
            // - Form
            //   - Button 1
            //   - Panel 1  (Panels are not selectable and are not IContainerControl
            //     - Button 2
            //   - UserControl 1  (UserControls are selectable and is IContainerControl)
            //     - Button 3
            //   - Button 4

            var form = new Form();
            var f    = new ControlAdapter(form);

            var b1 = new Button {
                Text = "Button 1"
            };
            var b2 = new Button {
                Text = "Button 2"
            };
            var b3 = new Button {
                Text = "Button 3"
            };
            var b4 = new Button {
                Text = "Button 4", Top = 90
            };

            f.Controls.Add(b1);

            var p1 = new Panel {
                Text = "Panel 1", Top = 30, Height = 30
            };

            p1.Controls.Add(b2);
            f.Controls.Add(p1);

            var uc1 = new UserControl {
                Text = "UserControl 1", Top = 60, Height = 30
            };

            uc1.Controls.Add(b3);
            f.Controls.Add(uc1);

            f.Controls.Add(b4);

            // Button 1 as "this"
            Assert.Null(b1.GetNextControl(f, true));
            Assert.Null(b1.GetNextControl(b1, true));
            Assert.Null(b1.GetNextControl(p1, true));
            Assert.Null(b1.GetNextControl(b2, true));
            Assert.Null(b1.GetNextControl(uc1, true));
            Assert.Null(b1.GetNextControl(b3, true));
            Assert.Null(b1.GetNextControl(b4, true));

            // Panel 1 as "this"
            Assert.Equal("Button 2", p1.GetNextControl(f, true).Text);
            Assert.Equal("Button 2", p1.GetNextControl(b1, true).Text);
            Assert.Equal("Button 2", p1.GetNextControl(p1, true).Text);
            Assert.Null(p1.GetNextControl(b2, true));
            Assert.Equal("Button 2", p1.GetNextControl(uc1, true).Text);
            Assert.Equal("Button 2", p1.GetNextControl(b3, true).Text);
            Assert.Equal("Button 2", p1.GetNextControl(b4, true).Text);

            // Form as "this"
            Assert.Equal("Button 1", f.GetNextControl(f, true).Text);
            Assert.Equal("Panel 1", f.GetNextControl(b1, true).Text);
            Assert.Equal("Button 2", f.GetNextControl(p1, true).Text);
            Assert.Equal("UserControl 1", f.GetNextControl(b2, true).Text);
            //Assert.Equal ("Button 4", f.GetNextControl (uc1, true).Text);
            Assert.Equal("Button 4", f.GetNextControl(b3, true).Text);
            Assert.Null(f.GetNextControl(b4, true));
        }
 protected void RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
 {
     Contract.Requires(writer != null);
 }