Example #1
0
        /// <summary>
        /// Adds all Orphants to the Tree
        /// </summary>
        /// <param name="pkg"></param>
        public void FindUnused(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            int top  = 0;
            int left = 0;

            foreach (int t in coords.Keys)
            {
                if (t > top)
                {
                    top = t;
                }
            }

            top += 128;
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
            {
                if ((pfd.Type == Data.MetaData.MMAT) || (Data.MetaData.RcolList.Contains(pfd.Type)))
                {
                    GraphItem gi = new GraphItem(new Ambertation.Collections.PropertyItems());
                    gi.Text = Hashes.StripHashFromName(pfd.Filename);

                    //gi.BeginUpdate();
                    gi.SetBounds(left, top, 200, 64);
                    //gi.Location = new Point(left, top);
                    gi.GotFocus += new EventHandler(gi_GotFocus);

                    gi.Tag  = Hashes.StripHashFromName(pfd.Filename);
                    gi.Fade = 0.7f;
                    //gi.LinkColor = Color.FromArgb(35, Color.Black);

                    //gi.SelectedLinkColor = Color.FromArgb(0xff, Color.DarkBlue);

                    SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(pfd.Type);
                    gi.Properties["Type"].Value      = ta.shortname;
                    gi.Properties["Available"].Value = "true (orphan)";
                    if (colors.ContainsKey(ta.shortname))
                    {
                        gi.PanelColor = (Color)colors[ta.shortname];
                    }

                    SimPe.Interfaces.Scenegraph.IScenegraphItem item = null;
                    if (Data.MetaData.RcolList.Contains(pfd.Type))
                    {
                        item = BuildRcol(pfd, pkg, gi);
                    }
                    else if (pfd.Type == Data.MetaData.MMAT)
                    {
                        item = BuildMmat(pfd, pkg, gi);
                    }
                    //gi.Parent = gc;
                    if (item != null)
                    {
                        string name = gi.Text.Trim().ToLower();
                        if (!names.ContainsKey(name))
                        {
                            //gc.Add(gi);
                            gi.Parent = gc;
                            left     += gi.Size.Width + 8;
                            //gi.EndUpdate();
                        }
                    }
                }
            }

            gc.Update();
        }
Example #2
0
        void AddItem(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg, GraphItem parent, SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex)
        {
            #region Default Setup
            int top  = -128;
            int left = 0;

            if (parent != null)
            {
                top = parent.Location.Y;
            }
            do
            {
                top += 128;
                if (coords.ContainsKey(top))
                {
                    left = (int)coords[top];
                }
                //if (parent!=null) if (left<parent.Location.X) left = parent.Location.X;
            } while (left > gc.Parent.Width && false);

            GraphItem gi = new GraphItem(new Ambertation.Collections.PropertyItems());
            gi.Text = Hashes.StripHashFromName(pfd.Filename);
            //gi.BeginUpdate();
            //gi.Location = new Point(left, top);
            gi.SetBounds(left, top, 200, 64);
            gi.GotFocus += new EventHandler(gi_GotFocus);
            gi.Tag       = Hashes.StripHashFromName(pfd.Filename);
            gi.Fade      = 0.7f;
            //gi.LinkColor = Color.FromArgb(35, Color.Black);
            //gi.SelectedLinkColor = Color.FromArgb(0xff, Color.DarkBlue);

            SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(pfd.Type);
            gi.Properties["Type"].Value      = ta.shortname;
            gi.Properties["Available"].Value = "false";
            //gi.Parent = gc;
            #endregion

            //check if we already have a reource of that kind
            string name = gi.Text.Trim().ToLower();
            if (names.ContainsKey(name))
            {
                //gi.EndUpdate();
                gi = (GraphItem)names[name];

                if (parent != null)
                {
                    parent.ChildItems.Add(gi);
                }
            }
            else
            {
                #region find File
                SimPe.Interfaces.Scenegraph.IScenegraphItem  item   = null;
                SimPe.Interfaces.Files.IPackedFileDescriptor pkgpfd = pkg.FindFile(pfd);

                //not found in the passed package, look for a global File with that Name
                if (pkgpfd == null)
                {
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem items = FileTable.FileIndex.FindFileByName(pfd.Filename, pfd.Type, pfd.Group, true);
                    if (items != null)
                    {
                        gi.Properties["Available"].Value = "extern";
                        gi.Properties["File"].Value      = items.Package.FileName;
                        gi.Size       = new Size(gi.Size.Width, 70);
                        gi.PanelColor = Color.Black;
                    }
                }
                #endregion

                //the file is available, so add it
                if (pkgpfd != null)
                {
                    gi.Properties["Available"].Value = "true";
                    if (colors.ContainsKey(ta.shortname))
                    {
                        gi.PanelColor = (Color)colors[ta.shortname];
                    }

                    if (Data.MetaData.RcolList.Contains(pfd.Type))
                    {
                        item = BuildRcol(pkgpfd, pkg, gi);
                    }
                    else if (pfd.Type == Data.MetaData.MMAT)
                    {
                        item = BuildMmat(pkgpfd, pkg, gi);
                    }

                    /*}
                     * else
                     * {
                     *      if (Data.MetaData.RcolList.Contains(pfd.Type)) item = BuildRcol(pkgpfd, altpkg, gi);
                     *      else if (pfd.Type==Data.MetaData.MMAT) item = BuildMmat(pkgpfd, altpkg, gi);
                     * }*/

                    //check again if we still don't have that file
                    name = gi.Text.Trim().ToLower();
                    if (names.ContainsKey(name))
                    {
                        //gi.EndUpdate();
                        gi = (GraphItem)names[name];
                    }
                    else
                    {
                        //now process the Reference Files
                        if (item != null)
                        {
                            Hashtable ht = item.ReferenceChains;
                            foreach (ArrayList list in ht.Values)
                            {
                                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor spfd in list)
                                {
                                    AddItem(spfd, pkg, gi, fileindex);
                                }
                            }
                        }
                    }
                }

                gi.Invalidate();

                if (!names.ContainsKey(name))
                {
                    names.Add(name, gi);
                    gi.Parent   = gc;
                    coords[top] = left + 8 + gi.Size.Width;

                    if (pkgpfd == null)
                    {
                        gi.PanelColor  = Color.DarkRed;
                        gi.ForeColor   = Color.White;
                        gi.BorderColor = gi.ForeColor;

                        if ((string)gi.Properties["Available"].Value == "extern")
                        {
                            gi.PanelColor = Color.Black;
                        }
                    }
                }


                if (parent != null)
                {
                    parent.ChildItems.Add(gi);
                }
            }

            //gi.EndUpdate();
        }