示例#1
0
        /// <summary>
        /// Displays a Save Dialog for the S2CP Files
        /// </summary>
        /// <param name="packages">The packages that should be added to the S2CP Files (the user can add more!)</param>
        /// <param name="extension">true if you want to add the Community Extension, otherwise
        /// a normal Sims2Pack File will be generated</param>
        /// <returns>true if the File was saved</returns>
        public static bool ShowSaveDialog(SimPe.Packages.GeneratableFile[] packages, bool extension)
        {
            SaveSims2CommunityPack form = new SaveSims2CommunityPack();

            S2CPDescriptor[] desc = form.Execute(packages, ref extension);

            if (desc != null)
            {
                MemoryStream ms = Create(desc, extension);

                System.IO.FileStream fs = new FileStream(form.tbflname.Text, FileMode.Create);
                try
                {
                    fs.Write(ms.ToArray(), 0, (int)ms.Length);
                }
                finally
                {
                    fs.Close();
                    fs.Dispose();
                    fs = null;
                }
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Show the Package Selector Dialog for a S2CP File
        /// </summary>
        /// <param name="filename">The Filename of the S2CP File</param>
        /// <param name="selmode">Selection Mode for the Listview</param>
        /// <returns>All Packages that were selected in the Dialog by the User or null
        /// if the User Cancled the Dialog</returns>
        public static S2CPDescriptor[] ShowOpenDialog(string filename, System.Windows.Forms.SelectionMode selmode)
        {
            SaveSims2CommunityPack form = new SaveSims2CommunityPack();

            return(form.Execute(Open(filename), selmode));
        }