Exemple #1
0
        public string createTreeViewNodes(System.Windows.Forms.TreeView tv,
                                          System.Windows.Forms.TreeNodeMouseClickEventHandler tNmouseClickEH)
        {
            try
            {
                //Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                string dNameHeader   = "\tDisplayName";
                string includeHeader = "\tInclude";
                //this.CostumeTV_lable.Text = fileName;
                StreamReader sr = new StreamReader(filePath);
                String       line, displayName = "";
                tv.BeginUpdate();

                // Clear the TreeView each time the method is called.
                tv.Nodes.Clear();
                tv.NodeMouseDoubleClick += tNmouseClickEH;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith(dNameHeader))
                    {
                        int startIndex = line.IndexOf('\"');
                        int endIndex   = line.IndexOf('\"', startIndex + 1);
                        int nameLen    = endIndex - startIndex;
                        displayName = line.Substring(startIndex + 1, nameLen - 1);
                        tv.Nodes.Add(new System.Windows.Forms.TreeNode(displayName));
                    }
                    if (line.StartsWith(includeHeader))
                    {
                        int    startIndex       = includeHeader.Length;
                        int    nameLen          = line.Length - startIndex;
                        string includeStatement = line.Substring(1, line.Length - 1);
                        string includeName      = line.Substring(startIndex + 1, nameLen - 1);
                        string ctmFileName      = Path.GetFileName(includeName);
                        string fullPath         = pathRoot + includeName;

                        bool exists = File.Exists(fullPath);
                        System.Windows.Forms.TreeNode chTNode = new System.Windows.Forms.TreeNode(ctmFileName);
                        chTNode.ToolTipText = includeName;
                        chTNode.Tag         = fullPath;
                        if (!exists)
                        {
                            chTNode.ForeColor = System.Drawing.Color.Red;
                        }
                        tv.Nodes[tv.Nodes.Count - 1].Nodes.Add(chTNode);
                    }
                }
                sr.Close();
                //Cursor.Current = Cursors.Default;

                // Begin repainting the TreeView.
                tv.EndUpdate();
                return("built treeview \r\n");
            }
            catch (Exception e)
            {
                return(e.Message + "\r\n");
            }
        }
Exemple #2
0
        public string createTreeViewNodes(Regions regionsObject,
                                          System.Windows.Forms.TreeView tv,
                                          System.Windows.Forms.TreeNodeMouseClickEventHandler tNmouseClickEH)
        {
            try
            {
                //Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                //this.CostumeTV_lable.Text = regionsObject.filePath;
                tv.BeginUpdate();

                // Clear the TreeView each time the method is called.
                tv.Nodes.Clear();

                tv.NodeMouseDoubleClick += tNmouseClickEH;

                // Add a root TreeNode for each Customer object in the ArrayList.
                foreach (Region r in regionsObject.regionSections)
                {
                    tv.Nodes.Add(new System.Windows.Forms.TreeNode(r.displayName));
                    foreach (auras.auraCostume ctm in r.includeCostumes)
                    {
                        System.Windows.Forms.TreeNode chTNode = new System.Windows.Forms.TreeNode(ctm.fileName);
                        chTNode.ToolTipText = ctm.includeStatement;
                        chTNode.Tag         = ctm.fullPath;
                        if (!ctm.exists)
                        {
                            chTNode.ForeColor = System.Drawing.Color.Red;
                        }
                        tv.Nodes[tv.Nodes.Count - 1].Nodes.Add(chTNode);
                    }
                }
                //Cursor.Current = Cursors.Default;

                // Begin repainting the TreeView.
                tv.EndUpdate();

                return("built treeview\r\n");
            }
            catch (Exception e)
            {
                return(e.Message + "\r\n");
            }
        }
        public string buildTree(System.Windows.Forms.TreeView tv, System.Windows.Forms.TreeNodeMouseClickEventHandler tNmouseClickEH)
        {
            if (isCostumeFile())
            {
                cleanUpTv(tv, tNmouseClickEH);

                tv.BeginUpdate();

                tv.Nodes.Clear();

                tv.NodeMouseDoubleClick += tNmouseClickEH;

                // Add a root TreeNode for each Customer object in the ArrayList.
                for (int i = 0; i < fileContent.Count; i++)
                {
                    string str = (string)fileContent[i];
                    if (str.StartsWith("//"))
                    {
                        continue;
                    }
                    else if (common.COH_IO.stripWS_Tabs_newLine_Qts(str, false).ToLower().StartsWith("boneset"))
                    {
                        i = buildBoneSet(i, tv);
                    }
                    else if (common.COH_IO.stripWS_Tabs_newLine_Qts(str, false).ToLower().StartsWith("geoset"))
                    {
                        i = buildGeoSet(i, tv);
                    }

                    else if (str.Contains("Info"))
                    {
                        i = buildGeoPiece(i, tv);
                    }
                    else if (str.Contains("End") || str.Replace("\t", "").StartsWith("//"))
                    {
                    }
                    else
                    {
                        if (str.Length > 2)
                        {
                            System.Windows.Forms.TreeNode tn = new System.Windows.Forms.TreeNode(str);
                            tNodeTag tnTag = new tNodeTag(i, str);
                            tn.Tag  = tnTag;
                            tn.Name = "tN_" + i;
                            common.COH_IO.setImageIndex(ref tn, str);
                            tv.Nodes.Add(tn);
                        }
                    }
                }

                tv.EndUpdate();

                return("\"" + fileName + "\" treeview created.\r\n");
            }
            else
            {
                fileContent.Clear();
            }

            return("ERROR: \"" + fileName + " IS NOT A COSTUME FILE!!!\"\r\n");
        }