Пример #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            basefont    = Content.Load <SpriteFont>("basefont");
            Button_Map  = Content.Load <Texture2D>("UI\\Project Spritemap");
            pixel       = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Bgra32);
            Color[] colors = new Color[1];
            colors[0] = Color.White;
            pixel.SetData(colors);

            // Load Config 1
            string[] configlines = File.ReadAllLines("config.txt");
            string   GCC_PATH    = Array.Find(configlines, x => x.StartsWith("GCC_Compiler_PATH"));

            Config.GCC_Compiler_PATH = GCC_PATH.Split('=')[1];
            string SAVE_PATH = Array.Find(configlines, x => x.StartsWith("Save_Folder_PATH"));

            Config.SAVE_PATH = SAVE_PATH.Split('=')[1];

            // Load Config 2
            configlines = File.ReadAllLines("config_2.txt");

            for (int i = 0; i < 7; ++i)
            {
                string curstr = Array.Find(configlines, x => x.StartsWith("WIRECOL_LAYER" + (i + 1).ToString()));
                string data   = curstr.Split('=')[1];
                int    R      = int.Parse(data.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                int    G      = int.Parse(data.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                int    B      = int.Parse(data.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                Config.WIRE_COLORS[i] = new Color(R, G, B);
            }

            // Check for write permissions for the simulation files
            bool WriteAccessToMainFolder = Extensions.HasWritePermissions(Directory.GetCurrentDirectory());

            if (!WriteAccessToMainFolder)
            {
                Console.WriteLine("Could not write important simulation files. Run the application in adminstrator mode or check the permissions of the application folder to fix this.");
                System.Windows.Forms.MessageBox.Show("Could not write important simulation files. Run the application in adminstrator mode or check the permissions of the application folder to fix this.", null, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                ExitApplication();
            }

            UI_handler = new UI_Handler(Content);
            UI_handler.Initialize(spriteBatch);

            simulator = new Simulator();
            GraphicsChanged(null, EventArgs.Empty);
            string pathtoexe = Directory.GetCurrentDirectory();

            IntPtr consolewindowhandle = GetConsoleWindow();

            ShowWindow(consolewindowhandle, SW_HIDE);
        }
Пример #2
0
        public static bool LoadLibrarys(params string[] paths)
        {
            List <string> missinglibraries = new List <string>();

            for (int i = 0; i < paths.Length; ++i)
            {
                if (!File.Exists(paths[i]))
                {
                    missinglibraries.Add(paths[i]);
                }
            }
            if (missinglibraries.Count > 0)
            {
                string message = "Following Libraries not found:\n";
                for (int i = 0; i < missinglibraries.Count; ++i)
                {
                    message += missinglibraries[i] + "\n";
                }
                System.Windows.Forms.MessageBox.Show(message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            Sim_Component.Components_Data.Clear();
            CompLibrary.AllUsedLibraries.Clear();

            for (int i = 0; i < paths.Length; ++i)
            {
                //if(File.Exists(paths[i]))
                //{
                CompLibrary newlibrary = new CompLibrary(null, paths[i]);
                newlibrary.LoadFromPath();
                //}
                //else
                //{
                //    System.Windows.Forms.MessageBox.Show("Library not found: \n" + paths[i], null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    Sim_Component.Components_Data.Clear();
                //    CompLibrary.AllUsedLibraries.Clear();
                //    UI_Handler.InitComponents();
                //    return -2;
                //}
            }
            UI_Handler.InitComponents();
            GenerateDllCodeAndCompile();
            return(true);
        }