Пример #1
0
        // Helper function to show a palette

        internal static PaletteSet ShowPalette(
            PaletteSet ps, Guid guid, string cmd, string title, Uri uri,
            bool reload = false
            )
        {
            // If the reload flag is true we'll force an unload/reload
            // (this isn't strictly needed - given our refresh function -
            // but I've left it in for possible future use)

            if (reload && ps != null)
            {
                // Close the palette and make sure we process windows
                // messages, otherwise sizing is a problem

                ps.Close();
                System.Windows.Forms.Application.DoEvents();
                ps.Dispose();
                ps = null;
            }

            if (ps == null)
            {
                ps = new PaletteSet(cmd, guid);
            }
            else
            {
                if (ps.Visible)
                {
                    return(ps);
                }
            }

            if (ps.Count != 0)
            {
                ps.Remove(0);
            }

            ps.Add(title, uri);
            ps.Visible = true;

            return(ps);
        }