Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of ObjectManager.
        /// </summary>
        /// <param name="socket">The socket used to communicate with Flash.</param>
        public ObjectManager(FlashSocket socket, System.Windows.Forms.Control controlForThread)
        {
            m_requests = new Hashtable();
            m_flatcache = new FlashObjectCollection();

            m_rootnode = new FlashObject("_root", FlashObject.ObjectType.MovieClip);
            m_globalnode = new FlashObject("_global", FlashObject.ObjectType.Object);

            m_flatcache.Add(m_rootnode);
            m_flatcache.Add(m_globalnode);

            m_threadcontrol = controlForThread;

            m_socket = socket;
            m_socket.DataRecieved += new FlashSocket.DataRecievedHandler(socket_DataRecieved);
        }
Ejemplo n.º 2
0
        public PropertyInspectorForm(FlashSocket socket)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_objmanager = new ObjectManager(socket, this);

            m_selectedObject = null;

            //
            // Add root tree nodes
            //
            treeObjects.Nodes.Add(m_objmanager.Root.TreeNode);
            treeObjects.Nodes.Add(m_objmanager.Global.TreeNode);

            //
            // Layout stuff
            //
            m_grid_delta_x = this.Width - gridProperties.Width;
            m_grid_delta_y = this.Height - gridProperties.Height;
            m_list_delta_y = this.Height - treeObjects.Height;

            SetupGrid();
        }
Ejemplo n.º 3
0
 public void Add(FlashObject obj)
 {
     Dictionary.Add(obj.Path, obj);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of FlashObject.
        /// </summary>
        /// <param name="node">
        /// The client response data.
        /// </param>
        public FlashObject(XmlNode node)
            : this(node.Attributes["path"].Value,
			(ObjectType) g_typemappings[node.Attributes["objecttype"].Value])
        {
            //
            // Set the value
            //
            m_value = node.Attributes["value"].Value;

            //
            // Add the children.
            //
            FlashObject childobj;

            foreach (XmlNode child in node.ChildNodes)
            {
                //
                // Make sure it's a property node.
                //
                if (child.Name != "property")
                    continue;

                childobj = new FlashObject(child, this);
                m_properties.Add(childobj);

                if (childobj.m_type == ObjectType.MovieClip || childobj.m_type == ObjectType.Object)
                    m_treenode.Nodes.Add(childobj.m_treenode);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the FlashObject with a newer version of itself.
        /// </summary>
        /// <param name="newVer"></param>
        public void Update(FlashObject newVer)
        {
            //
            // If not yet filled, remove the Loading... node.
            //
            if (!IsFilled && m_treenode.Nodes.Count > 0)
            {
                m_treenode.Nodes.RemoveAt(0);
            }

            //
            // Update the value.
            //
            this.m_value = newVer.m_value;

            if (this.m_parent == null && newVer.m_parent != null)
            {
                this.m_parent = newVer.m_parent;
                this.m_parent.m_treenode.Nodes.Add(this.m_treenode);
            }

            IDictionaryEnumerator itr;

            //
            // Remove the properties that don't exist in the new one.
            //
            itr = m_properties.GetEnumerator();
            ArrayList toRemove = new ArrayList();

            while (itr.MoveNext()) // Find 'em
            {
                if (!newVer.m_properties.Contains(itr.Key as ObjectPath))
                {
                    toRemove.Add(itr.Key);
                }
            }

            foreach (object key in toRemove) // Remove 'em
            {
                try
                {
                    m_properties.Remove(key as ObjectPath);
                }
                catch
                {
                }
            }

            //
            // Update the properties
            //
            itr = newVer.m_properties.GetEnumerator();
            FlashObject current;

            while (itr.MoveNext())
            {
                current = itr.Value as FlashObject;

                //
                // If the object already exists, update it.
                //
                if (m_properties.Contains(current.Path))
                {
                    ((FlashObject) m_properties[current.Path]).Update(current);
                    continue;
                }

                //
                // If the object doesn't exist, then add it.
                //

                //
                // Set parent (as it was previously referencing the update object)
                //
                current.m_parent = this;

                m_properties.Add(current);

                if (current.m_type != ObjectType.MovieClip && current.m_type != ObjectType.Object)
                    continue;

                m_treenode.Nodes.Add(current.m_treenode);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of FlashObject.
 /// </summary>
 private FlashObject()
 {
     m_properties = new FlashObjectCollection();
     m_parent = null;
     m_treenode = new TreeNode();
     m_treenode.Tag = this;
     m_treenode.Nodes.Add(new TreeNode("Loading..."));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new instance of FlashObject, fills it, and sets its parent.
 /// </summary>
 /// <param name="node">
 /// The client response data.
 /// </param>
 /// <param name="parent">
 /// The object's parent.
 /// </param>
 public FlashObject(XmlNode node, FlashObject parent)
     : this(node)
 {
     m_parent = parent;
 }
Ejemplo n.º 8
0
        private void treeObjects_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            FlashObject obj = e.Node.Tag as FlashObject;

            if (obj != null && obj != m_selectedObject)
            {
                m_selectedObject = obj;
                DisplayObjectProperties(obj);
            }
        }
Ejemplo n.º 9
0
        private void treeObjects_AfterExpand(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            FlashObject obj = e.Node.Tag as FlashObject;

            if (obj != m_selectedObject || !obj.IsFilled)
            {
                m_selectedObject = obj;
                treeObjects.SelectedNode = obj.TreeNode;
                m_objmanager.RequestObjectProperties(obj.Path,
                    new ObjectManager.ObjectRecievedHandler(objManager_ObjectRecieved));
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Fired when a previously requested object has been recieved.
 /// </summary>
 /// <param name="obj"></param>
 private void objManager_ObjectRecieved(FlashObject obj)
 {
     treeObjects.Invoke(new ObjectEventHandler(objManager_ObjectRecieved_CT),
         new object[1] {obj});
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Fired when a "View" cell in the property grid is clicked.
        /// 
        /// This will request object data from the client.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void gridProperties_ViewCellClick(object sender, SourceGrid2.PositionEventArgs args)
        {
            FlashObject obj = gridProperties.Rows[args.Position.Row].Tag as FlashObject;

            //
            // Set the selected object (so that treeObjects_AfterSelect and
            // treeObjects_AfterExpand don't trigger manager calls.
            //
            m_selectedObject = obj;

            //
            // Select and expand the node.
            //
            m_selectedObject.TreeNode.Expand();

            //
            // Set the wait cursor (to block input).
            //
            Cursor.Current = Cursors.WaitCursor;

            //
            // Request the object's properties from the client.
            //
            m_objmanager.RequestObjectProperties(obj.Path,
                new ObjectManager.ObjectRecievedHandler(objManager_ObjectRecieved));

            string path = obj.Path.ToString();

            //
            // Add it to the recent objects list if it isn't already there.
            //
            if (!lstRecentObjects.Items.Contains(path))
                lstRecentObjects.Items.Add(path);

            treeObjects.SelectedNode = obj.TreeNode;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Displays the object's properties in the grid, as well as information
        /// about the object itself.
        /// </summary>
        /// <param name="props"></param>
        private void DisplayObjectProperties(FlashObject obj)
        {
            lblCurrentObjectValue.Text = obj.Path.ToString();
            treeObjects.SelectedNode = obj.TreeNode;

            //
            // Display properties in the grid.
            //
            ClearGridContents(); // clear grid

            FlashObjectCollection props = obj.Properties;

            //
            // Do nothing if no props.
            //
            if (props.Count == 0)
                return;

            SourceGrid2.Grid g = gridProperties;
            g.Rows.InsertRange(1, props.Count);

            //
            // Insert the rows.
            //
            SourceGrid2.Cells.Real.Cell c;
            FlashObject current;
            System.Collections.IDictionaryEnumerator itr = props.GetEnumerator();
            int counter = 1;

            while (itr.MoveNext())
            {
                current = itr.Value as FlashObject;

                //
                // Associate the FlashObject with the row.
                //
                g.Rows[counter].Tag = current;

                //
                // Add the cells.
                //
                c = new SourceGrid2.Cells.Real.Cell(current.InstanceName);
                g[counter, 0] = c;

                c = new SourceGrid2.Cells.Real.Cell(current.Type);
                g[counter, 1] = c;

                //
                // If the FlashObject is of type Object, then display a view button.
                //
                switch (current.Type)
                {
                    case FlashObject.ObjectType.Object:
                    case FlashObject.ObjectType.MovieClip:
                        //
                        // Add view link
                        //
                        c = new SourceGrid2.Cells.Real.Link("View",
                            new SourceGrid2.PositionEventHandler(gridProperties_ViewCellClick));

                        break;

                    case FlashObject.ObjectType.Function:

                        //
                        // Add view link
                        //
                        c = new SourceGrid2.Cells.Real.Link("Execute...",
                            new SourceGrid2.PositionEventHandler(gridProperties_ExecuteCellClick));

                        break;

                    default:
                        //
                        // Add standard cell.
                        //
                        c = new SourceGrid2.Cells.Real.Cell(current.Value);

                        break;

                }

                g[counter, 2] = c;

                counter++;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Parses the recieved data from the socket.
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="node"></param>
        private void socket_DataRecieved(System.Net.Sockets.Socket socket, XmlNode node)
        {
            if (node.Attributes["type"].Value != "objectproperties")
                return;

            FlashObject obj = new FlashObject(node);

            //
            // Add object to cache, hashing on the entire path.
            //
            if (m_flatcache.Contains(obj.Path))
            {
                FlashObject updateObj = obj;

                //
                // Set obj as the object already in the cache.
                //
                obj = m_flatcache[obj.Path] as FlashObject;

                try
                {
                    m_threadcontrol.Invoke(new ObjectEventHandler(
                        obj.Update), new object[1] {updateObj});
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debugger.Log(0, "1", e.ToString());
                }
            }
            else
            {
                m_flatcache.Add(obj);
            }

            //
            // Add all the property objects to the cache.
            //
            IDictionaryEnumerator itr = obj.Properties.GetEnumerator();
            FlashObject prop;

            while (itr.MoveNext())
            {
                prop = itr.Value as FlashObject;

                //
                // Add the object if it doesn't exist.
                //
                if (!m_flatcache.Contains(prop.Path))
                {
                    m_flatcache.Add(prop);
                }
            }

            //
            // Inform object specific handlers.
            //
            ArrayList handlers = m_requests[obj.Path.ToString()] as ArrayList;

            foreach (ObjectRecievedHandler hndlr in handlers)
                hndlr(obj);

            //
            // Remove the handler array.
            //
            m_requests.Remove(obj.Path.ToString());

            //
            // Dispatch ObjectRecieved event.
            //
            if (ObjectRecieved != null)
                ObjectRecieved(obj);
        }