Beispiel #1
0
        public static string[][] GetCategory(ObjectCacheItemVersions version, Data.ObjFunctionSubSort subsort, Data.ObjectTypes type, ObjectClass cl)
        {
            uint ofss = (uint)subsort;

            string[][] ret = null;

            if (version == ObjectCacheItemVersions.ClassicOW)
            {
                System.Collections.ArrayList list = new System.Collections.ArrayList();
                Data.ObjFunctionSortBits[]   ss   = (Data.ObjFunctionSortBits[])System.Enum.GetValues(typeof(Data.ObjFunctionSortBits));
                foreach (Data.ObjFunctionSortBits s in ss)
                {
                    if ((ofss & (uint)Math.Pow(2, (byte)s)) != 0)
                    {
                        list.Add(s.ToString());
                    }
                }

                ret = new string[list.Count][];
                for (int i = 0; i < list.Count; i++)
                {
                    ret[i] = new string[] { list[i].ToString() }
                }
                ;
            }
            else if (version == ObjectCacheItemVersions.DockableOW)
            {
                if (cl == ObjectClass.XObject)
                {
                    Data.XObjFunctionSubSort fss = (Data.XObjFunctionSubSort)subsort;
                    ret = new string[1][];
                    string[] ps = SimPe.Localization.GetString("SimPe.Data.XObjFunctionSubSort." + fss.ToString()).Replace(" / ", "_").Split("_".ToCharArray(), 2);
                    if (ps.Length >= 2)
                    {
                        ret[0] = new string[] { SimPe.Localization.GetString("XObject"), ps[0], ps[1] };
                    }
                    else if (ps.Length == 1)
                    {
                        ret[0] = new string[] { SimPe.Localization.GetString("XObject"), ps[0] };
                    }
                }
                else
                {
                    Data.ObjFunctionSubSort fss = subsort;
                    uint upper = (uint)((ofss >> 8) & 0xfff);
                    uint lower = (uint)(ofss & 0xff);

                    System.Collections.ArrayList list = new System.Collections.ArrayList();
                    Data.ObjFunctionSortBits[]   ss   = (Data.ObjFunctionSortBits[])System.Enum.GetValues(typeof(Data.ObjFunctionSortBits));

                    foreach (Data.ObjFunctionSortBits s in ss)
                    {
                        int vu = (int)Math.Pow(2, (byte)s);
                        if ((upper & vu) != 0)
                        {
                            bool added = false;
                            for (int i = 0; i < 8; i++)
                            {
                                int v = (int)Math.Pow(2, i);
                                if ((lower & v) != 0)
                                {
                                    Data.ObjFunctionSubSort mss = (Data.ObjFunctionSubSort)(((vu & 0xfff) << 8) | (v & 0xff));
                                    string[] ps = SimPe.Localization.GetString("SimPe.Data.ObjFunctionSubSort." + mss.ToString()).Replace(" / ", "_").Split("_".ToCharArray(), 2);
                                    if (ps.Length >= 2)
                                    {
                                        list.Add(new string[] { ps[0], ps[1] });       added = true;
                                    }
                                    else if (ps.Length == 1)
                                    {
                                        list.Add(new string[] { SimPe.Localization.GetString("SimPe.Data.ObjFunctionSortBits." + s.ToString()) }); added = true;
                                    }
                                }
                            }

                            if (!added)
                            {
                                list.Add(new string[] { SimPe.Localization.GetString("SimPe.Data.ObjFunctionSortBits." + s.ToString()) });
                            }
                        }
                    }

                    ret = new string[list.Count][];
                    for (int i = 0; i < list.Count; i++)
                    {
                        string[] ct = (string[])list[i];
                        ret[i] = ct;
                    }
                }
            }

            if (type != Data.ObjectTypes.Normal)
            {
                System.Collections.ArrayList list = new System.Collections.ArrayList();
                if (ret != null)
                {
                    foreach (string[] s in ret)
                    {
                        list.Add(s);
                    }
                }
                list.Add(new string[] { SimPe.Localization.GetString("Other"), SimPe.Localization.GetString("SimPe.Data.ObjectTypes." + type.ToString()) });

                ret = new string[list.Count][];
                for (int i = 0; i < list.Count; i++)
                {
                    string[] ct = (string[])list[i];
                    ret[i] = ct;
                }
            }


            if (ret == null)
            {
                ret = new string[][] { new string[] { SimPe.Localization.GetString("Unknown") } }
            }
            ;

            if (ret.Length == 0)
            {
                ret = new string[][] { new string[] { SimPe.Localization.GetString("Unknown") } }
            }
            ;

            return(ret);
        }
Beispiel #2
0
 public static string[][] GetCategory(ObjectCacheItemVersions version, Data.ObjFunctionSubSort subsort, Data.ObjectTypes type)
 {
     return(GetCategory(version, subsort, type, ObjectClass.Object));
 }