/// <summary>
 /// 显示指定的page,并使之成为当前page
 /// </summary>
 /// <param name="container"></param>
 /// <param name="page"></param>
 public static void ShowPage(TabControl container,TabPage page)
 {
     if (!container.Contains(page))
     {
         container.TabPages.Add(page);
     }
     page.Show();
     container.SelectTab(page);
 }
示例#2
0
 private void ShowTab(TabControl tabControl, TabPage page)
 {
     if (!tabControl.Contains(page))
     {
         tabControl.TabPages.Add(page);
     }
     tabControl.SelectedTab = page;
 }
示例#3
0
        /// <summary>
        /// List available resources of a given type, allowing the user to select one.
        /// </summary>
        /// <param name="resourceType">Type of resource to list</param>
        /// <param name="group">Group number of "this" group</param>
        /// <param name="form">Parent form</param>
        /// <param name="skip_pages">A flag per page (this package, private, semi, global, prim) to suppress pages</param>
        /// <param name="canDoEA">Whether to differentiate overriding resources</param>
        /// <returns>The chosen resource entry</returns>
        public pjse.FileTable.Entry Execute(uint resourceType, uint group, Control form, bool canDoEA, Boolset skip_pages)
        {
            CanDoEA = canDoEA;

            form.Cursor = Cursors.WaitCursor;
            this.Cursor = Cursors.WaitCursor;

            List <TabPage> ltp = new List <TabPage>(new TabPage[] { tpPackage, tpGroup, tpSemiGroup, tpGlobalGroup, tpBuiltIn });

            btnViewBHAV.Visible = resourceType == SimPe.Data.MetaData.BHAV_FILE;

            this.tcResources.TabPages.Clear();

            // There doesn't appear to be a way to compare two paths and have the OS decide if they refer to the same object
            if (!skip_pages[0] &&
                pjse.FileTable.GFT.CurrentPackage != null &&
                pjse.FileTable.GFT.CurrentPackage.FileName != null &&
                !pjse.FileTable.GFT.CurrentPackage.FileName.ToLower().EndsWith("objects.package"))
            {
                FillPackage(resourceType, this.lvPackage, this.tpPackage);
            }

            if (!skip_pages[1])
            {
                FillGroup(resourceType, group, this.lvGroup, this.tpGroup);
            }

            if (!skip_pages[2])
            {
                Glob g = pjse.BhavWiz.GlobByGroup(group);
                if (g != null)
                {
                    FillGroup(resourceType, g.SemiGlobalGroup, this.lvSemi, this.tpSemiGroup);
                    this.tpSemiGroup.Text = g.SemiGlobalName;
                }
            }

            if (!skip_pages[3] && group != (uint)Group.Global)
            {
                FillGroup(resourceType, (uint)Group.Global, this.lvGlobal, this.tpGlobalGroup);
            }

            if (!skip_pages[4] && resourceType == SimPe.Data.MetaData.BHAV_FILE)
            {
                FillBuiltIn(resourceType, this.lvPrim, this.tpBuiltIn);
            }

            if (this.tcResources.TabCount > 0)
            {
                if (tcResources.Contains(ltp[PersistentTab]))
                {
                    tcResources.SelectTab(ltp[PersistentTab]);
                }
                else
                {
                    this.tcResources.SelectedIndex = 0;
                }
            }

            form.Cursor = Cursors.Default;
            this.Cursor = Cursors.Default;
            this.Size   = ChooserSize;

            DialogResult dr = ShowDialog();

            while (dr == DialogResult.Retry)
            {
                dr = ShowDialog();
            }

            ChooserSize   = this.Size;
            PersistentTab = ltp.IndexOf(this.tcResources.SelectedTab);
            Close();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                ListView lv = getListView();

                if (lv != null)
                {
                    if (lv != lvPrim)
                    {
                        return((pjse.FileTable.Entry)lv.SelectedItems[0].Tag);
                    }
                    else
                    {
                        IPackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor();
                        pfd.Instance = (uint)lvPrim.SelectedItems[0].Tag;
                        return(new pjse.FileTable.Entry(null, pfd, true, true));
                    }
                }
            }
            return(null);
        }