Exemple #1
0
        private void newCodeWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCode frm = new frmCode();
            frm.globalState = globalCodeState;
            frm.argWeb = null;
            frm.Text = "Script Window #" + (++counter).ToString();

            frm.Show();
        }
Exemple #2
0
        public override void ExecuteCommand(string cmdKey, TreeNode myNode)
        {
            if (cmdKey == "REF")
            {
                refresh(myNode);
            }
            else if (cmdKey == "ADD")
            {
                //pass to first child
                if (requiresRefresh(myNode)) refresh(myNode, true);

                foreach (TreeNode tn in myNode.Nodes)
                {
                    if (tn.Tag is BlocksNode)
                    {
                        (tn.Tag as BlocksNode).ExecuteCommand("ADD", myNode.Nodes[0]);
                        break;
                    }
                }
            }
            else if (cmdKey == "UNLOAD")
            {
                //maybe unload is called more than once
                if (myWeb == null) return;

                //when web is disposed, it disposes all of its blocks and they dispose their
                //related innerweb so this command will be propagated
                myWeb.Dispose();
                myWeb = null;

                if (myNodes.Count > 0)
                {
                    TreeView tv = myNodes[0].TreeView;

                    tv.Invoke(new MethodInvoker(delegate()
                        {
                            foreach (TreeNode node in myNodes)
                            {
                                //maybe parent treeview is disposed
                                if (node != null && node.TreeView != null && !node.TreeView.IsDisposed && node.TreeView.Nodes != null)
                                {
                                    //this will remove all my children too
                                    node.Remove();
                                }
                            }
                        }));
                }

                myNodes.Clear();
                children.Clear();
            }
            else if (cmdKey == "CODE")
            {
                frmCode frm = new frmCode();

                Control container = myNode.TreeView.Parent;

                while (container.Parent != null)
                {
                    container = container.Parent;
                }

                frm.globalState = (container as frmMain).globalCodeState;
                frm.argWeb = myWeb;
                frm.Text = "Script Window - " + myWeb.Id + " @ " + myWeb.Address;

                frm.Show();
            }
            else if (cmdKey == "RELOAD")
            {
                if (MessageBox.Show("Are you sure you want to re-load all Blocks in this BlockWeb?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    myWeb.ReloadBlocks();
                    myNode.Collapse();
                    myNode.Nodes.Clear();
                    refresh(myNode, true);
                }
            }
            else if (cmdKey == "RELOADWEB")
            {
                myNode.Collapse();

                myWeb.Dispose();
                myWeb = null;
                children.Clear();

                foreach (TreeNode node in myNodes)
                {
                    //maybe parent treeview is disposed
                    if (node != null && node.TreeView != null && !node.TreeView.IsDisposed && node.TreeView.Nodes != null)
                    {
                        //this will remove all my children too
                        node.Nodes.Clear();
                        node.Collapse();
                    }
                }

                Control container = myNode.TreeView.Parent;

                while (!(container is ctlWebTree))
                {
                    container = container.Parent;
                }

                ctlWebTree parentCtl = container as ctlWebTree;
                parentCtl.loadBlockWeb(id, host, port, myNodes);
            }
        }