public static void OnUndoRedo()
        {
            try
            {
                CASClothingCategory ths = CASClothingCategory.gSingleton;
                if (ths == null)
                {
                    return;
                }

                if (ths.mClothingTypesGrid == null)
                {
                    return;
                }

                ths.mClothingTypesGrid.SelectedItem = -1;
                List <ItemGridCellItem> items = ths.mClothingTypesGrid.Items;
                int num = 0x0;
                if (ths.mCurrentFocusedRow != null)
                {
                    ths.mCurrentFocusedRow.SetArrowGlow(false);
                }

                ths.mCurrentFocusedRow = null;
                int sAccessoriesSelection = CASClothingCategory.sAccessoriesSelection;
                foreach (ItemGridCellItem item in items)
                {
                    CASClothingRow mWin = item.mWin as CASClothingRow;
                    if (mWin != null)
                    {
                        if (mWin.SelectedItem != -1)
                        {
                            // Custom
                            bool compactCAS = false;
                            if (ths.mCurrentPart == BodyTypes.Accessories)
                            {
                                compactCAS = MasterController.Settings.mCompactAccessoryCAS;
                            }
                            else
                            {
                                compactCAS = MasterController.Settings.mCompactClothingCAS;
                            }

                            if (!compactCAS)
                            {
                                mWin.CreateGridItems(true);
                                mWin.PopulateGrid(true);
                            }

                            if ((ths.mCurrentFocusedRow == null) || (((BodyTypes)sAccessoriesSelection) == mWin.CASPart.BodyType))
                            {
                                if (ths.mCurrentFocusedRow != null)
                                {
                                    ths.mCurrentFocusedRow.SetArrowGlow(false);
                                }
                                ths.mClothingTypesGrid.SelectedItem = num;
                                ths.mCurrentFocusedRow = mWin;
                                ths.mCurrentFocusedRow.SetArrowGlow(true);
                                ths.UpdateButtons(mWin.SelectedType);
                                if (ths.IsAccessoryType(mWin.CASPart.BodyType))
                                {
                                    CASClothingCategory.sAccessoriesSelection = (int)mWin.CASPart.BodyType;
                                }
                                ths.mCurrentPreset = mWin.Selection as CASPartPreset;
                            }
                        }
                        num++;
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnUndoRedo", e);
            }
        }
        public static bool AddGridItem(ItemGrid grid, object current, ResourceKey layoutKey, object context)
        {
            try
            {
                CASClothingCategory ths = CASClothingCategory.gSingleton;
                if (ths == null)
                {
                    return(false);
                }

                bool flag = false;
                if (current != null)
                {
                    if (current is List <CASParts.PartPreset> )
                    {
                        List <CASParts.PartPreset> parts = current as List <CASParts.PartPreset>;
                        if (parts.Count > 0)
                        {
                            CASClothingRow row = UIManager.LoadLayout(layoutKey).GetWindowByExportID(0x1) as CASClothingRow;
                            if (row == null)
                            {
                                return(false);
                            }

                            row.UseEp5AsBaseContent = ths.mIsEp5Base;
                            row.CASPart             = parts[0].mPart;
                            row.RowController       = ths;

                            ArrayList list = CASClothingRowEx.CreateGridItems(row, parts, true);

                            ths.mSortButton.Tag = ((bool)ths.mSortButton.Tag) | row.HasFilterableContent;

                            if (list.Count > 0x0)
                            {
                                sRows.Add(row);

                                grid.AddItem(new ItemGridCellItem(row, null));

                                flag = true;
                                if (row.SelectedItem == -1)
                                {
                                    return(flag);
                                }

                                if (ths.IsAccessoryType(row.CASPart.BodyType))
                                {
                                    if (CASClothingRowEx.IsWorn(row.CASPart))
                                    {
                                        if (row.CASPart.BodyType == ((BodyTypes)CASClothingCategory.sAccessoriesSelection))
                                        {
                                            grid.SelectedItem = grid.Count - 0x1;
                                            ths.mSelectedType = row.SelectedType;
                                            CASClothingCategory.sAccessoriesSelection = (int)row.CASPart.BodyType;
                                            ths.mCurrentPreset = row.Selection as CASPartPreset;
                                        }
                                    }
                                    else
                                    {
                                        grid.SelectedItem = grid.Count - 0x1;
                                        ths.mSelectedType = row.SelectedType;
                                        CASClothingCategory.sAccessoriesSelection = (int)row.CASPart.BodyType;
                                        ths.mCurrentPreset = row.Selection as CASPartPreset;
                                    }

                                    return(flag);
                                }

                                grid.SelectedItem  = grid.Count - 0x1;
                                ths.mSelectedType  = row.SelectedType;
                                ths.mCurrentPreset = row.Selection as CASPartPreset;
                            }
                        }

                        return(flag);
                    }
                    else
                    {
                        List <object> featured = current as List <object>;
                        if (featured == null)
                        {
                            return(flag);
                        }

                        CASClothingRow row = UIManager.LoadLayout(layoutKey).GetWindowByExportID(1) as CASClothingRow;
                        row.ObjectOfInterest = featured;
                        row.RowController    = ths;

                        ArrayList items = row.CreateGridItems(true);
                        ths.mSortButton.Tag = ((bool)ths.mSortButton.Tag) | row.HasFilterableContent;
                        if (items.Count > 0)
                        {
                            grid.AddItem(new ItemGridCellItem(row, null));
                        }
                        return(true);
                    }
                }

                ths.mContentTypeFilter.UpdateFilterButtonState();

                ths.UpdateButtons(ths.mSelectedType);
                if (CASClothingCategory.OnClothingGridFinishedPopulating != null)
                {
                    CASClothingCategory.OnClothingGridFinishedPopulating();
                }

                return(flag);
            }
            catch (Exception e)
            {
                Common.Exception("AddGridItem", e);
                return(false);
            }
        }