Exemplo n.º 1
0
        private PropertyForm createPropWindow(string filename, string tag)
        {
            if (panelCodeEditor.Controls.Count > 0)
            {
                foreach (PropertyForm p in panelCodeEditor.Controls)
                {
                    if (p.Tag.ToString() == tag)
                    {
                        p.BringToFront();
                        return(p);
                    }
                }
            }

            PropertyForm f = new PropertyForm();

            f.TopLevel      = false;
            f.Tag           = tag;
            f.StartPosition = FormStartPosition.Manual;
            //f.Dock = DockStyle.Fill;
            panelCodeEditor.Controls.Add(f);
            f.BringToFront();
            if (filename != "")
            {
                f.richXML.LoadFile(filename, RichTextBoxStreamType.PlainText);
                HighlightColors.HighlightRTF(f.richXML);
            }

            int pos = ((panelCodeEditor.Controls.Count - 1) * 30) % (panelCodeEditor.Width - f.Width) + 1;

            f.Location = new Point(pos, pos);
            f.Text     = tag;
            f.Show();

            return(f);
        }
Exemplo n.º 2
0
        private void findUnusedByType(string searchType)
        {
            usedObjects.Clear();

            List <string> allObjects = new List <string>();

            btnUnusedAll.Enabled = false;

            PropertyForm p       = createPropWindow("", "unused" + searchType);
            RichTextBox  richXML = p.richXML;

            richXML.Clear();
            p.Text = "Unused " + searchType;

            try
            {
                TreeNode to = treeViewGMX.Nodes.Find(searchType, true).First();
                allObjects = findChildItems(to);

                // first find in rooms - it's easier
                // since there is creation code for rooms... it's not best way :(

                /*TreeNode t = treeViewGMX.Nodes.Find("Rooms", true).First();
                 * foreach (TreeNode node in t.Nodes)
                 * {
                 *      if (node.Nodes.Count == 0)
                 *      {
                 *              findAllObjectsInRoom(getTreeViewGMXSelectedNodePath(node.Tag.ToString()));
                 *      }
                 * }*/

                int cnt = 0;

                string[] nodesToSearch = new string[] { "Scripts", "Objects", "Rooms" };

                progressTotal.Maximum = nodesToSearch.Count();
                progressTotal.Value   = 0;
                progressTotal.Visible = true;
                this.Refresh();

                foreach (string nodeName in nodesToSearch)
                {
                    // now search in scripts, obj, rooms
                    try
                    {
                        TreeNode sc = treeViewGMX.Nodes.Find(nodeName, true).First();
                        findObjectInObjects(sc, allObjects);

                        // remove those found
                        foreach (string obj in usedObjects)
                        {
                            allObjects.Remove(obj);
                        }
                    }
                    catch (Exception error)
                    {
                        richXML.AppendText("Nothing found under " + nodeName + " (Error: " + error.Message + ")\n");
                        cnt++;
                    }

                    progressTotal.Value++;
                    this.Refresh();
                }

                // reports

                richXML.AppendText("Those " + searchType + " are found inside rooms & objects & scripts:\r\n");
                cnt++;

                foreach (string obj in usedObjects)
                {
                    richXML.AppendText(obj + "\r\n");
                    richXML.Select(richXML.GetFirstCharIndexFromLine(cnt), richXML.Lines[cnt].Length);
                    richXML.SelectionColor = Color.Green;
                    cnt++;
                }

                if (allObjects.Count > 0)
                {
                    richXML.AppendText("Those " + searchType + " are NOT found inside rooms & objects:\r\n");

                    cnt++;

                    foreach (string obj in allObjects)
                    {
                        richXML.AppendText(obj + "\r\n");
                        richXML.Select(richXML.GetFirstCharIndexFromLine(cnt), richXML.Lines[cnt].Length);
                        richXML.SelectionColor = Color.Red;
                        cnt++;
                    }
                }

                progressTotal.Visible = false;
            }
            catch (Exception ex)
            {
                richXML.AppendText("Error: " + ex.Message);
            }

            btnUnusedAll.Enabled = true;
        }