Example #1
0
        public static string Generate_OS_CPC_contentfile(oscpc OSCPC)
        {
            // This allow to create OS.CPC content file with informations

            return
                (@"// ** OS.CPC file generated by OSMaker **" + "\r\n" +
                 @"" + "\r\n" +
                 @"// Load default gui profile (obligatory)" + "\r\n" +
                 @"exe/ & %CPC.REP.KRNL%/CONFIG/ENV_GUI/env_gui.cpc" + "\r\n" +

                 @"" + "\r\n" +
                 @"// Screen informations" + "\r\n" +
                 @"set/ SCR_Auto = " + OSCPC.Resolution_auto.ToString().ToLower() + "\r\n" +
                 "if/ \"%SCR_Auto%\" == \"true\" then:" + "\r\n" +
                 "\t// set/ SCR_RES = /f:cpc.check_best_resolution()" + "\r\n" +
                 "\t// set/ SCR_BIT = /f:cpc.check_best_resolution_color()" + "\r\n" +
                 @"else:" + "\r\n" +
                 "\tset/ SCR_RES = " + OSCPC.Resolution + "\r\n" +
                 "\tset/ SCR_BIT = " + OSCPC.Resolution_bit + "\r\n" +
                 @"end/ if" + "\r\n" +
                 @"" + "\r\n" +
                 @"// Default background color" + "\r\n" +
                 @"SET/ SCR_COLOR = " + OSCPC.Background_Color_R.ToString("D3") + "," + OSCPC.Background_Color_G.ToString("D3") + "," + OSCPC.Background_Color_B.ToString("D3") + "\r\n" +
                 @"" + "\r\n" +
                 @"// Default background screen" + "\r\n" +
                 @"SET/ SCR_IMG = " + OSCPC.Background_image + "\r\n" +
                 @"" + "\r\n" +
                 @"ccp/ /set.level = 4" + "\r\n" +
                 @"" + "\r\n" +
                 @"" + "\r\n" +

                 @"// **************************************************" + "\r\n" +
                 @"// ** [EN] Operating system informations           **" + "\r\n" +
                 @"// ** [FR] Informations du systeme d'exploitation  **" + "\r\n" +
                 @"// **************************************************" + "\r\n" +
                 @"" + "\r\n" +
                 @"set/ OS_NAME = " + OSCPC.os_name + "" + "\r\n" +
                 @"set/ OS_Author = " + OSCPC.AutorsNames + "\r\n" +
                 @"set/ OS_Compagny = " + OSCPC.CompagnyName + "\r\n" +
                 @"set/ OS_Created = " + OSCPC.CreationDate + "\r\n" +
                 @"set/ OS_Updated = " + OSCPC.CreationDate + "\r\n" +
                 @"" + "\r\n" +
                 @"" + "\r\n" +
                 @"// ***************************************************" + "\r\n" +
                 @"// ** [EN] Operating system configuration           **" + "\r\n" +
                 @"// ** [FR] Configuration du systeme d'exploitation  **" + "\r\n" +
                 @"// ***************************************************" + "\r\n" +
                 @"" + "\r\n" +
                 @"set/ HOST_OS = OS/" + OSCPC.os_SystemName + "\r\n" +
                 @"set/ GUI_OS = " + OSCPC.MediaPath + "\r\n" +
                 @"" + "\r\n" +
                 @"// Background image" + "\r\n" +
                 @"set/ SCR_IMG = " + OSCPC.Background_image + "\r\n" +
                 @"" + "\r\n" +
                 @"// Screenshot folder" + "\r\n" +
                 @"set/ SCR_SAVE = %CPC_TEMP%/SCR" + "\r\n" +
                 @"" + "\r\n" +
                 @"// ******************************************************" + "\r\n" +
                 @"// ** [EN] Starting Graphic User Interface             **" + "\r\n" +
                 @"// ** [FR] Demarrer l'interface utilisateur graphique  **" + "\r\n" +
                 @"// ******************************************************" + "\r\n" +
                 @"gui/ " + "\r\n" +
                 @"" + "\r\n" +
                 @"// Load icon on GUI" + "\r\n" +
                 @"sys/ /fileformat-gui-load" + "\r\n" +
                 @"" + "\r\n" +
                 @"// Desktop icons" + "\r\n" +
                 @"set/ Desktop_Icons = " + OSCPC.DesktopIcons + "\r\n" +
                 @"" + "\r\n" +
                 "if/ \"%desktop_Icons%\" == \"true\" then:" + "\r\n" +
                 "\tset/ pos_x = 0" + "\r\n" +
                 "\tset/ pos_y = 30" + "\r\n" +
                 "\tset/ size_x = %CPC.SCR.X%" + "\r\n" +
                 "\tset/ size_y = %CPC.SCR.Y%" + "\r\n" +
                 "\t" + "\r\n" +
                 "\t// Execute desktop function" + "\r\n" +
                 "\tset/ handle_desktop = /F:Init_Desktop(MyDesktop, ./, %pos_x%, %pos_y%, %size_X%, %size_Y%)" + "\r\n" +
                 @"end/ if" + "\r\n" +
                 @"" + "\r\n" +
                 @"" + "\r\n" +
                 @"" + "\r\n" +
                 @"" + "\r\n");
        }
Example #2
0
        private void btn_create_Click(object sender, EventArgs e)
        {
            if ((txtb_osPath.Text.Length > 1) && (txtb_osSystemName.Text.Length > 1) && (txtb_mediaFolder.Text.Length > 1))
            {
                /****************************************************************************************/



                // Create OS folder
                Directory.CreateDirectory(txtb_osPath.Text + "\\" + txtb_osSystemName.Text);

                // Create Media folder
                Directory.CreateDirectory(txtb_osPath.Text + "\\" + txtb_mediaFolder.Text);

                // Create boot folder
                Directory.CreateDirectory(txtb_osPath.Text + "\\" + txtb_osSystemName.Text + "\\boot");



                /****************************************************************************************/



                { /**** Generate os.cpc file for operating system ****/
                    oscpc OSCPC = new oscpc();

                    // OS informations
                    OSCPC.os_name       = txtb_osName.Text;
                    OSCPC.os_SystemName = txtb_osSystemName.Text;
                    OSCPC.MediaPath     = txtb_mediaFolder.Text;
                    OSCPC.AutorsNames   = txtb_authors.Text;
                    OSCPC.CompagnyName  = txtb_compagny.Text;
                    OSCPC.CreationDate  = DateTime_creation.Value.ToString("yyyy-MM-dd", DateTimeFormatInfo.InvariantInfo);

                    // Screen desktop
                    OSCPC.Resolution_auto = chk_SCREEN_autosize.Checked;
                    OSCPC.Resolution      = txtb_SCREEN_manualresolution.Text;
                    if (rad_screen_16bits.Checked == true)
                    {
                        OSCPC.Resolution_bit = "16";
                    }
                    else if (rad_screen_24bits.Checked == true)
                    {
                        OSCPC.Resolution_bit = "24";
                    }
                    else if (rad_screen_32bits.Checked == true)
                    {
                        OSCPC.Resolution_bit = "32";
                    }

                    OSCPC.Background_image   = txtb_background_image.Text;
                    OSCPC.Background_Color_R = Background_color.R;
                    OSCPC.Background_Color_G = Background_color.G;
                    OSCPC.Background_Color_B = Background_color.B;

                    OSCPC.DesktopIcons = chk_desktop.Checked;

                    // Generate code
                    string OSCPC_content = standbox.Generate_OS_CPC_contentfile(OSCPC);

                    // Create OS.CPC file
                    using (StreamWriter sw = File.CreateText(txtb_osPath.Text + "\\" + txtb_osSystemName.Text + "\\os.cpc"))
                    {
                        sw.WriteLine(OSCPC_content);
                    }
                }


                /****************************************************************************************/



                { /**** Open folder project into OSmaker window ****/
                    new_os_path = txtb_osPath.Text + "\\" + txtb_osSystemName.Text;

                    // Copy media dir to your OS
                    try
                    {
                        standbox.DirectoryCopy(txtb_osPath.Text + "\\media", new_os_path + "\\media", true);
                    }
                    catch
                    {
                        MessageBox.Show(this, "Unable to copy original media dir to your OS. Please check if your OS dir is in CPCDOS dir", "Error during OS generation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                /****************************************************************************************/


                // Close this form
                this.Close();
            }
            else
            {
                MessageBox.Show(this, "Please enter the information correctly.", "Unable to create OS folders", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }