Ejemplo n.º 1
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        lcdDrawingarea.SetSizeRequest(178, 128);
        //Set stubs
        lcdStub               = new LcdStub(lcdDrawingarea);
        brickStub             = new BrickStub();
        brickStub.OnShutDown += OnShutDown;
        Lcd.Instance          = lcdStub;

        Buttons.Instance          = buttonsStub;
        ProgramManager.Instance   = programManagerStub;
        FirmwareSettings.Instance = firmwareSettings;
        WiFiDevice.Instance       = wiFiStub;
        UpdateHelper.Instance     = updateHelperStub;
        Brick.Instance            = brickStub;

        //Load and apply simulator settings
        simulatorSettings = new SimulatorSettings();
        simulatorSettings.Load();
        simulatorSettings.Save();
        ApplySettings();

        //Setup settings changed handler
        watcher.Path                = Directory.GetCurrentDirectory();
        watcher.NotifyFilter        = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.CreationTime;
        watcher.Filter              = simulatorSettings.SettingsFileName;
        watcher.Changed            += OnSettingsFileChanged;
        watcher.EnableRaisingEvents = true;

        lcdDrawingarea.ExposeEvent += LcdExposed;
    }
Ejemplo n.º 2
0
        public override bool UpdateBootFile()
        {
            /* Not yet used need some building
             * XmlDocument doc = new XmlDocument();
             * doc.Load("EV3MonoBrickSimulator.exe.config");
             * XmlNode node = doc.SelectSingleNode ("configuration/runtime").FirstChild.FirstChild;
             * node.Attributes [0].Value = GetAvailableFirmware ();
             * doc.Save ("EV3MonoBrickSimulator.exe.config");
             */

            string            newDir   = Path.Combine(Directory.GetCurrentDirectory(), GetAvailableFirmware());
            SimulatorSettings settings = new SimulatorSettings();

            if (settings.Load())
            {
                settings.BootSettings.StartUpDir = newDir;
                return(settings.Save());
            }
            return(false);
        }
Ejemplo n.º 3
0
    private static void StartupAppExecution()
    {
        firmwareRunning = true;
        Thread.Sleep(simulatorSettings.BootSettings.ExecutionDelay);
        string startUpAppPath = System.IO.Path.Combine(simulatorSettings.BootSettings.StartUpDir, "StartupApp.exe");

        if (!Directory.Exists(simulatorSettings.BootSettings.StartUpDir))
        {
            startUpAppPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "StartupApp.exe");
            simulatorSettings.BootSettings.StartUpDir = Directory.GetCurrentDirectory();
            simulatorSettings.Save();
        }

        var    startUppApp = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(startUpAppPath, "StartupApp.MainClass");
        string arg         = null;

        var methods = startUppApp.GetType().GetMethods();
        var field   = startUppApp.GetType().GetField("SuspendFile");

        field.SetValue(null, System.IO.Path.Combine(Directory.GetCurrentDirectory(), "suspendFirmware.txt"));
        MethodInfo mainMethod = null;

        foreach (var method in methods)
        {
            if (method.Name == "Main")
            {
                mainMethod = method;
            }
            if (method.Name == "Kill")
            {
                killMethod = method;
            }
        }
        mainMethod.Invoke(null, new object[] { arg });
        firmwareRunning = false;
    }