Beispiel #1
0
        IEnumerator Start()
        {
            /* Create a window container */
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = Context.GetApplicationContext().GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup.prefab");

            window.Create();
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());


            //ApplicationContext context = ApplicationContext.GetApplicationContext();
            //ISession session = context.GetService<ISession>();
            //session.Send(10001, -1, new Login() { DriveId = "default" });

            //ApplicationContext context = Context.GetApplicationContext();
            //ISession session = context.GetService<ISession>();
            //session.Connect("127.0.0.1", 10001);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            System.Console.SetOut(new DatedConsole());
            Console.WriteLine("Initialized output.");
            try
            {
                if (string.IsNullOrWhiteSpace(AppImagePath))
                {
                    Console.WriteLine("iCode is running outside of an AppImage.");
                }

                Directory.CreateDirectory(ConfigPath);
                Directory.CreateDirectory(SDKPath);
                Directory.CreateDirectory(DeveloperPath);
                Directory.CreateDirectory(UserDefinedTemplatesPath);
                Directory.CreateDirectory(ConfigPath);

                Gtk.Application.Init();

                GLib.Log.SetDefaultHandler(new GLib.LogFunc((domain, level, message) =>
                {
                    if (level != GLib.LogLevelFlags.Error && level != GLib.LogLevelFlags.FlagFatal)
                    {
                        return;
                    }

                    Console.WriteLine($"Gtk error: {message} ({domain})");
                }));

                Console.WriteLine("Initialized GTK and GDL.");

                if (!File.Exists(SettingsPath))
                {
                    var startup = StartupWindow.Create();
                    if ((ResponseType)startup.Run() != ResponseType.Ok)
                    {
                        return;
                    }

                    var jobj = new JObject();
                    jobj.Add("updateConsent", startup.Accepted);
                    File.WriteAllText(SettingsPath, jobj.ToString());
                    Console.WriteLine("Initialized settings file.");
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(AppImagePath))
                    {
                        var settings = JObject.Parse(File.ReadAllText(SettingsPath));
                        if ((bool)settings["updateConsent"])
                        {
                            var outp = Extensions.LaunchProcess(
                                Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                             "Updater"), $"--check-for-update \"{AppImagePath}\"", out int ret);
                            // TODO Updater
                            if (ret == 1)
                            {
                                Console.WriteLine("Update available.");
                                UpdateAvailable = true;
                            }
                        }
                    }
                }

                NativeLibraries.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/libs/"));
                Console.WriteLine("Initialized libimobiledevice.");
                Program.WinInstance = MainWindow.Create();
                Program.WinInstance.ShowAll();
                Console.WriteLine("Initialized window.");
                Gtk.Application.Run();
            }
            catch (Exception e)
            {
                ExceptionWindow.Create(e, null).ShowAll();
            }
        }